Plan 9 from Bell Labs’s /usr/web/sources/extra/9hist/pc/ether.h

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


## diffname pc/ether.h 1992/1222
## diff -e /dev/null /n/bootesdump/1992/1222/sys/src/9/pc/ether.h
0a
/*
 * All the goo for PC ethernet cards.
 */
typedef struct Board Board;
typedef struct RingBuf RingBuf;
typedef struct Type Type;
typedef struct Ctlr Ctlr;

/*
 * Hardware interface.
 */
struct Board {
	int	(*reset)(Ctlr*);
	void	(*init)(Ctlr*);
	void	(*attach)(Ctlr*);
	void	(*mode)(Ctlr*, int);

	void	(*receive)(Ctlr*);
	void	(*transmit)(Ctlr*);
	void	(*intr)(Ctlr*);
	void	(*watch)(Ctlr*);

	ulong	io;			/* interface I/O base address */
	uchar	irq;			/* interrupt level */
	uchar	bit16;			/* true if a 16 bit interface */

	uchar	ram;			/* true if interface has shared memory */
	ulong	ramstart;		/* interface shared memory address start */
	ulong	ramstop;		/* interface shared memory address end */

	ulong	dp8390;			/* I/O address of 8390 (if any) */
	ulong	data;			/* I/O data port if no shared memory */
	uchar	tstart;			/* 8390 ring addresses */
	uchar	pstart;
	uchar	pstop;
};

/*
 * Software ring buffer.
 */
struct RingBuf {
	uchar	owner;
	uchar	busy;
	ushort	len;
	uchar	pkt[sizeof(Etherpkt)];
};

enum {
	Host		= 0,	/* buffer owned by host */
	Interface	= 1,	/* buffer owned by interface */

	Nrb		= 16,	/* default number of receive buffers */
	Ntb		= 4,	/* default number of transmit buffers */
};

/*
 * One per ethernet packet type.
 */
struct Type {
	QLock;
	Netprot;		/* stat info */
	int	type;		/* ethernet type */
	int	prom;		/* promiscuous mode */
	Queue	*q;
	int	inuse;
	Ctlr	*ctlr;

	Rendez	cr;		/* rendezvous for close */
	Type	*clist;		/* close list */
};

enum {
	NType		= 9,	/* types/interface */
};

/*
 * Software controller.
 */
struct Ctlr {
	QLock;

	Board	*board;
	int	present;

	ushort	nrb;		/* number of software receive buffers */
	ushort	ntb;		/* number of software transmit buffers */
	RingBuf *rb;		/* software receive buffers */
	RingBuf *tb;		/* software transmit buffers */

	uchar	ea[6];		/* ethernet address */
	uchar	ba[6];		/* broadcast address */

	Rendez	rr;		/* rendezvous for a receive buffer */
	ushort	rh;		/* first receive buffer belonging to host */
	ushort	ri;		/* first receive buffer belonging to interface */	

	Rendez	tr;		/* rendezvous for a transmit buffer */
	QLock	tlock;		/* semaphore on th */
	ushort	th;		/* first transmit buffer belonging to host */	
	ushort	ti;		/* first transmit buffer belonging to interface */	

	Type	type[NType];
	int	all;		/* number of channels listening to all packets */
	Type	*clist;		/* channels waiting to close */
	Lock	clock;		/* lock for clist */
	int	prom;		/* number of promiscuous channels */
	int	kproc;		/* true if kproc started */
	char	name[NAMELEN];	/* name of kproc */
	Network	net;

	Queue	lbq;		/* software loopback packet queue */

	int	inpackets;
	int	outpackets;
	int	crcs;		/* input crc errors */
	int	oerrs;		/* output errors */
	int	frames;		/* framing errors */
	int	overflows;	/* packet overflows */
	int	buffs;		/* buffering errors */
};

#define NEXT(x, l)	(((x)+1)%(l))
#define	HOWMANY(x, y)	(((x)+((y)-1))/(y))
#define ROUNDUP(x, y)	(HOWMANY((x), (y))*(y))

/*
 * The Western Digital 8003 and 8013 series, the NE2000
 * and the 3Com 503 all use the DP8390 Network Interface
 * Chip.
 */
extern void dp8390reset(Ctlr*);
extern void dp8390attach(Ctlr*);
extern void dp8390mode(Ctlr*, int);
extern void dp8390setea(Ctlr*);
extern void *dp8390read(Ctlr*, void*, ulong, ulong);
extern void dp8390receive(Ctlr*);
extern void dp8390transmit(Ctlr*);
extern void dp8390intr(Ctlr*);

enum {
	Dp8390BufSz	= 256,		/* hardware ring buffer size */
};
.
## diffname pc/ether.h 1993/0212
## diff -e /n/bootesdump/1992/1222/sys/src/9/pc/ether.h /n/bootesdump/1993/0212/sys/src/9/pc/ether.h
138a
extern void dp8390watch(Ctlr*);
extern void dp8390overflow(Ctlr*);

extern void dp8390debug(Ctlr*);

/*
 * The DP8390 needs some time between successive 
 * chip selects, so we need special I/O routines.
 * See l.s.
 * These routines only need to be used for accessing
 * the chip registers. Data I/O, either through
 * remote DMA or shared memory, can use the normal
 * routines.
 */
extern int dp8390inb(ulong);
extern void dp8390outb(ulong, uchar);
.
135a
extern void *dp8390write(Ctlr*, ulong, void*, ulong);
.
115,119c
	int	crcs;			/* input crc errors */
	int	oerrs;			/* output errors */
	int	frames;			/* framing errors */
	int	overflows;		/* packet overflows */
	int	buffs;			/* buffering errors */
.
111c
	Queue	lbq;			/* software loopback packet queue */
.
103,108c
	int	all;			/* number of channels listening to all packets */
	Type	*clist;			/* channels waiting to close */
	Lock	clock;			/* lock for clist */
	int	prom;			/* number of promiscuous channels */
	int	kproc;			/* true if kproc started */
	char	name[NAMELEN];		/* name of kproc */
.
97,100c
	Rendez	tr;			/* rendezvous for a transmit buffer */
	QLock	tlock;			/* semaphore on th */
	ushort	th;			/* first transmit buffer belonging to host */	
	ushort	ti;			/* first transmit buffer belonging to card */
	int	tbusy;			/* transmitter is busy */	
.
93,95c
	Rendez	rr;			/* rendezvous for a receive buffer */
	ushort	rh;			/* first receive buffer belonging to host */
	ushort	ri;			/* first receive buffer belonging to card */	
.
90,91c
	uchar	ea[6];			/* ethernet address */
	uchar	ba[6];			/* broadcast address */
.
85,88c
	ushort	nrb;			/* number of software receive buffers */
	ushort	ntb;			/* number of software transmit buffers */
	RingBuf *rb;			/* software receive buffers */
	RingBuf *tb;			/* software transmit buffers */
.
83a
	int	debug;
.
82c
	Card	card;			/* hardware info */
.
73c
	NType		= 9,		/* types/card */
.
68,69c
	Rendez	cr;			/* rendezvous for close */
	Type	*clist;			/* close list */
.
61,63c
	Netprot;			/* stat info */
	int	type;			/* ethernet type */
	int	prom;			/* promiscuous mode */
.
52,53c
	Nrb		= 16,		/* default number of receive buffers */
	Ntb		= 4,		/* default number of transmit buffers */
.
49,50c
	Host		= 0,		/* buffer owned by host */
	Interface	= 1,		/* buffer owned by card */
.
43c
	uchar	busy;			/* unused */
.
32a
	uchar	nxtpkt;			/* software bndry */
.
27,29c
	uchar	ram;			/* true if card has shared memory */
	ulong	ramstart;		/* card shared memory address start */
	ulong	ramstop;		/* card shared memory address end */
.
23c
	ulong	io;			/* card I/O base address */
.
21a
	void	(*overflow)(Ctlr*);
.
17a
	void	*(*read)(Ctlr*, void*, ulong, ulong);
	void	*(*write)(Ctlr*, ulong, void*, ulong);

.
12c
struct Card {
	char	id[NAMELEN];		/* type of card */

.
4c
typedef struct Card Card;
.
## diffname pc/ether.h 1993/0915
## diff -e /n/bootesdump/1993/0212/sys/src/9/pc/ether.h /n/fornaxdump/1993/0915/sys/src/brazil/pc/ether.h
168a


extern void	addethercard(char*, int	(*)(Ctlr*));
.
142a
extern void dp8390getea(Ctlr*);
.
87a
	int	ctlrno;
	Ctlr	*next;
.
34,35d
32d
29,30d
13c
	ISAConf;
.
## diffname pc/ether.h 1993/1113 # deleted
## diff -e /n/fornaxdump/1993/0915/sys/src/brazil/pc/ether.h /n/fornaxdump/1993/1113/sys/src/brazil/pc/ether.h
1,169d

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.