plan 9 kernel history: overview | file list | diff list

1990/0911/port/devlance.c (diff list | history)

1990/0826/sys/src/9/port/devlance.c:11,171990/0911/sys/src/9/port/devlance.c:11,17 (short | long | prev | next)
1990/0227    
 */ 
enum { 
	Ntypes=		8,		/* max number of ethernet packet types */ 
1990/03042    
	Ndir=		Ntypes+1,	/* entries in top level directory */ 
1990/0911    
	Ndir=		Ntypes+2,	/* entries in top level directory */ 
1990/0227    
	LogNrrb=	7,		/* log of number of receive buffers */ 
	Nrrb=		(1<<LogNrrb),	/* number of recieve buffers */ 
	LogNtrb=	7,		/* log of number of transmit buffers */ 
1990/0826/sys/src/9/port/devlance.c:24,291990/0911/sys/src/9/port/devlance.c:24,40
1990/0707    
#define NOW (MACHP(0)->ticks*MS2HZ) 
1990/03042    
 
1990/0227    
/* 
1990/0911    
 *  Ethernet packet buffers.  These must also be in lance addressible RAM. 
 */ 
typedef struct { 
	uchar d[6]; 
	uchar s[6]; 
	uchar type[2]; 
	uchar data[1500]; 
	uchar crc[4]; 
} Pkt; 
 
/* 
1990/0227    
 *  Communication with the lance is via a transmit and receive ring of 
 *  message descriptors.  The Initblock contains pointers to and sizes of 
 *  these rings.  The rings must be in RAM addressible by the lance 
1990/0826/sys/src/9/port/devlance.c:36,901990/0911/sys/src/9/port/devlance.c:47,90
1990/0227    
} Msg; 
 
/* 
 *  Ethernet packet buffers.  These must also be in lance addressible RAM. 
 */ 
typedef struct { 
	uchar d[6]; 
	uchar s[6]; 
	uchar type[2]; 
	uchar data[1500]; 
	uchar crc[4]; 
} Pkt; 
                 
/* 
 *  lance memory map 
 */ 
typedef 
struct 
1990/0911    
typedef struct Lancemem 
1990/0227    
{ 
	/* 
	 *  initialization block 
	 */ 
	struct initblock {	 
		ushort	mode;		/* chip control (see below) */ 
		ushort	etheraddr[3];	/* the ethernet physical address */ 
		ushort	multi[4];	/* multicast addresses, 1 bit for each of 64 */ 
		ushort	rdralow;	/* receive buffer ring */ 
		ushort	rdrahigh;	/* (top three bits define size of ring) */ 
		ushort	tdralow;	/* transmit buffer ring */ 
		ushort	tdrahigh;	/* (top three bits define size of ring) */ 
	}; 
1990/0911    
	ushort	mode;		/* chip control (see below) */ 
	ushort	etheraddr[3];	/* the ethernet physical address */ 
	ushort	multi[4];	/* multicast addresses, 1 bit for each of 64 */ 
	ushort	rdralow;	/* receive buffer ring */ 
	ushort	rdrahigh;	/* (top three bits define size of ring) */ 
	ushort	tdralow;	/* transmit buffer ring */ 
	ushort	tdrahigh;	/* (top three bits define size of ring) */ 
1990/0227    
	 
	/* 
	 * ring buffers 
	 * first receive, then transmit 
1990/0911    
	 *  ring buffers 
	 *  first receive, then transmit 
1990/0227    
	 */ 
	Msg	rmr[Nrrb];		/* recieve message ring */ 
	Msg	tmr[Ntrb];		/* transmit message ring */ 
 
	/* 
	 * actual packets 
1990/0911    
	 *  packet buffers (for IO2 version) 
1990/0227    
	 */ 
	Pkt	p[1]; 
1990/0911    
	Pkt	rp[Nrrb]; 
	Pkt	tp[Ntrb]; 
1990/0227    
} Lancemem; 
#define LANCEMEM ((Lancemem *)LANCERAM) 
1990/0911    
#define LANCEMEM ((Lancemem*)0) 
1990/0227    
 
/* 
 *  Some macros for dealing with lance memory addresses.  The lance splits 
 *  its 24 bit addresses across two 16 bit registers. 
 */ 
#define HADDR(a) ((((ulong)(a))>>16)&0xF) 
1990/0911    
#define HADDR(a) ((((ulong)(a))>>16)&0xFF) 
1990/0227    
#define LADDR(a) (((ulong)a)&0xFFFF) 
1990/0911    
#define MPs(a) (*(short *)(l.lanceram + l.sep*((ushort*)&a - (ushort*)0))) 
#define MPus(a) (*(ushort *)(l.lanceram + l.sep*((ushort*)&a - (ushort*)0))) 
1990/0227    
 
/* 
 *  one per ethernet packet type 
1990/0826/sys/src/9/port/devlance.c:127,1501990/0911/sys/src/9/port/devlance.c:127,166
1990/0227    
	uchar	*lmp;		/* location of parity test */ 
	ushort	*rap;		/* lance address register */ 
	ushort	*rdp;		/* lance data register */ 
1990/0911    
	int	sep;		/* separaqtion between shorts in lance ram 
				    as seen by host */ 
	ushort	*lanceram;	/* start of lance ram as seen by host */ 
	ushort	*lanceend;	/* end of lance ram as seen by host */ 
	Lancemem *lm;		/* start of lance memory as seen by lance */ 
1990/0227    
 
	Rendez	rr;		/* rendezvous for an input buffer */ 
	ushort	rl;		/* first rcv Message belonging to Lance */	 
	ushort	rc;		/* first rcv Message belonging to CPU */ 
	Pkt	*rp[Nrrb];	/* receive buffers */ 
	int	inpackets; 
 
	Rendez	tr;		/* rendezvous for an output buffer */ 
	QLock	tlock;		/* semaphore on tc */ 
	ushort	tl;		/* first xmt Message belonging to Lance */	 
	ushort	tc;		/* first xmt Message belonging to CPU */	 
	Pkt	*tp[Ntrb];	/* transmit buffers */ 
	int	outpackets; 
 
	Ethertype e[Ntypes]; 
	int	debug; 
	int	kstarted; 
	Debqueue dq; 
1990/0911    
 
	Pkt	*rp;		/* receive buffers */ 
	Pkt	*tp;		/* transmit buffers */ 
	uchar	*rpa[Nrrb];	/* receive buffer address in lance space */ 
	uchar	*tpa[Ntrb];	/* transmit buffer address in lance space */ 
 
	/* sadistics */ 
 
	int	inpackets; 
	int	outpackets; 
	int	crcs;		/* input crc errors */ 
	int	oerrs;		/* output erros */ 
	int	frames;		/* framing errors */ 
	int	overflows;	/* packet overflows */ 
	int	buffs;		/* buffering errors */ 
1990/0227    
} Lance; 
static Lance l; 
 
1990/0826/sys/src/9/port/devlance.c:231,2371990/0911/sys/src/9/port/devlance.c:247,253
1990/0409    
		p->d[0], p->d[1], p->d[2], p->d[3], p->d[4], p->d[5], 
		p->s[0], p->s[1], p->s[2], p->s[3], p->s[4], p->s[5], 
		p->type[0], p->type[1]); 
	for(i=0; i<41; i++) 
1990/0911    
	for(i=0; i<16; i++) 
1990/0409    
		sprint(buf+strlen(buf), "%.2ux", p->data[i]); 
	sprint(buf+strlen(buf), ")\n"); 
1990/0227    
} 
1990/0826/sys/src/9/port/devlance.c:262,2801990/0911/sys/src/9/port/devlance.c:278,283
1990/0227    
} 
 
/* 
 *  copy to/from lance memory till we get it right 
 */ 
void 
slowcpy(uchar *to, uchar *from, int n) 
{ 
	memcpy(to, from, n); 
	while(memcmp(to, from, n)!=0){ 
		print("lance compare error\n"); 
		memcpy(to, from, n); 
	} 
} 
                 
/* 
 *  lance stream module definition 
 */ 
static void lanceoput(Queue*, Block*); 
1990/0826/sys/src/9/port/devlance.c:365,3711990/0911/sys/src/9/port/devlance.c:368,374
1990/0227    
		sleep(&l.tr, isobuf, (void *)0); 
		print("done"); 
	} 
	p = l.tp[l.tc]; 
1990/0911    
	p = &l.tp[l.tc]; 
1990/0227    
 
	/* 
	 *  copy message into lance RAM 
1990/0826/sys/src/9/port/devlance.c:395,4101990/0911/sys/src/9/port/devlance.c:398,414
1990/0227    
	if(len < 60) 
		len = 60; 
 
1990/03042    
	lancedebq('o', p, len); 
1990/0911    
	lancedebq('o', p, len);/**/ 
1990/0227    
 
	/* 
	 *  set up the ring descriptor and hand to lance 
	 */ 
1990/0911    
	l.outpackets++; 
1990/0227    
	m = &(LANCEMEM->tmr[l.tc]); 
	m->size = -len; 
	m->cntflags = 0; 
	m->laddr = LADDR(l.tp[l.tc]); 
	m->flags = OWN|STP|ENP|HADDR(l.tp[l.tc]); 
1990/0911    
	MPs(m->size) = -len; 
	MPus(m->cntflags) = 0; 
	MPus(m->laddr) = LADDR(l.tpa[l.tc]); 
	MPus(m->flags) = OWN|STP|ENP|HADDR(l.tpa[l.tc]); 
1990/0227    
	l.tc = TSUCC(l.tc); 
	*l.rdp = INEA|TDMD; /**/ 
	qunlock(&l.tlock); 
1990/0826/sys/src/9/port/devlance.c:416,4251990/0911/sys/src/9/port/devlance.c:420,429
1990/0227    
enum { 
1990/03042    
	Lchanqid = 1, 
	Ltraceqid = 2, 
1990/0911    
	Lstatsqid = 3, 
1990/0227    
}; 
1990/03042    
Dirtab lancedir[Ndir]; 
1990/0227    
 
                 
/* 
 *  stop the lance, disable all ring buffers, and free all staged rcv buffers 
 */ 
1990/0826/sys/src/9/port/devlance.c:426,4551990/0911/sys/src/9/port/devlance.c:430,512
1990/0227    
void 
lancereset(void) 
{ 
	Lancemem *lm=LANCEMEM; 
	int i; 
1990/0911    
	ushort *sp; 
	ulong x; 
	int index; 
	static int already; 
1990/0227    
 
	/* 
	 *  toggle lance's reset line 
1990/0911    
	 *  so that we don't have to indirect through constants 
1990/0227    
	 */ 
	MODEREG->promenet &= ~1; 
	MODEREG->promenet |= 1; 
1990/0911    
	l.rap = LANCERAP; 
	l.rdp = LANCERDP; 
1990/0227    
 
	/* 
	 *  disable all ring entries 
1990/0911    
	 *  allocate the send and receive buffers and map them into 
	 *  the lance's address space. 
1990/0227    
	 */ 
	l.tl = l.tc = 0; 
	for(i = 0; i < Ntrb; i++) 
		lm->tmr[i].flags = 0; 
	l.rl = l.rc = 0; 
	for(i = 0; i < Ntrb; i++) 
		lm->rmr[i].flags = 0; 
1990/0911    
	if(already == 0){ 
		already = 1; 
		if(ioid < IO3R1){ 
			/* 
			 *  toggle lance's reset line 
			 */ 
			MODEREG->promenet &= ~1; 
			MODEREG->promenet |= 1; 
1990/0227    
 
1990/0911    
			l.lanceram = LANCERAM; 
			l.lanceend = LANCEEND; 
			l.lm = (Lancemem *)0; 
			l.sep = 1; 
 
			/* 
			 *  allocate packet buffers in lance memory 
			 */ 
			for(i = 0; i < Nrrb; i++) 
				l.rpa[i] = (uchar *)&l.lm->rp[i]; 
			for(i = 0; i < Ntrb; i++) 
				l.tpa[i] = (uchar *)&l.lm->tp[i]; 
		} else { 
			/* 
			 *  toggle lance's reset line 
			 */ 
			MODEREG->promenet |= 1; 
			MODEREG->promenet &= ~1; 
 
			l.lanceram = LANCE3RAM; 
			l.lanceend = LANCE3END; 
			l.lm = (Lancemem *)0x800000; 
			l.sep = 4; 
 
			/* 
			 *  allocate packet buffers in MP bus memory 
			 *  and map it into lance space 
			 */ 
			l.rp = (Pkt *)ialloc((Nrrb + Ntrb)*sizeof(Pkt), 1); 
			l.tp = l.rp + Nrrb; 
			index = 0x1E00; 
			for(i = 0; i < Nrrb; i++){ 
				x = (ulong)&l.rp[i]; 
				*WRITEMAP = (index<<16) | (x>>12)&0xFFFF; 
				l.rpa[i] = (uchar *)((i<<12) | (x & 0xFFF)); 
				index++; 
			} 
			for(i = 0; i < Ntrb; i++){ 
				x = (ulong)&l.tp[i]; 
				*WRITEMAP = (index<<16) | (x>>12)&0xFFFF; 
				l.tpa[i] = (uchar *)(((i+Nrrb)<<12) | (x & 0xFFF)); 
				index++; 
			} 
		} 
	} 
 
1990/0227    
	/* 
	 *  run through all lance memory to set parity 
	 */ 
	for(l.lmp=LANCERAM; l.lmp<=LANCEEND; l.lmp++) 
		*l.lmp = 55; 
1990/0911    
	for(sp = l.lanceram; sp < l.lanceend; sp += l.sep) 
		*sp = 0; 
 
1990/0227    
} 
 
/* 
1990/0826/sys/src/9/port/devlance.c:459,4671990/0911/sys/src/9/port/devlance.c:516,525
1990/0227    
static void 
lancestart(void) 
{ 
	Lancemem *lm=LANCEMEM; 
	int i; 
	Pkt *p; 
1990/0911    
	Lancemem *lm = LANCEMEM; 
	Msg *m; 
1990/0227    
 
	lancereset(); 
 
1990/0826/sys/src/9/port/devlance.c:468,4741990/0911/sys/src/9/port/devlance.c:526,532
1990/0227    
	/* 
	 *  create the initialization block 
	 */ 
	lm->mode = 0; 
1990/0911    
	MPus(lm->mode) = 0; 
1990/0227    
 
	/* 
	 *  set ether addr from the value in the id prom. 
1990/0826/sys/src/9/port/devlance.c:475,4831990/0911/sys/src/9/port/devlance.c:533,541
1990/0227    
	 *  the id prom has them in reverse order, the init 
	 *  structure wants them in byte swapped order 
	 */ 
	lm->etheraddr[0] = (LANCEID[16]&0xff00)|((LANCEID[20]>>8)&0xff); 
	lm->etheraddr[1] = (LANCEID[8]&0xff00)|((LANCEID[12]>>8)&0xff); 
	lm->etheraddr[2] = (LANCEID[0]&0xff00)|((LANCEID[4]>>8)&0xff); 
1990/0911    
	MPus(lm->etheraddr[0]) = (LANCEID[16]&0xff00)|((LANCEID[20]>>8)&0xff); 
	MPus(lm->etheraddr[1]) = (LANCEID[8]&0xff00)|((LANCEID[12]>>8)&0xff); 
	MPus(lm->etheraddr[2]) = (LANCEID[0]&0xff00)|((LANCEID[4]>>8)&0xff); 
1990/0227    
	l.ea[0] = LANCEID[20]>>8; 
	l.ea[1] = LANCEID[16]>>8; 
	l.ea[2] = LANCEID[12]>>8; 
1990/0826/sys/src/9/port/devlance.c:484,5481990/0911/sys/src/9/port/devlance.c:542,599
1990/0227    
	l.ea[3] = LANCEID[8]>>8; 
	l.ea[4] = LANCEID[4]>>8; 
	l.ea[5] = LANCEID[0]>>8; 
1990/0419    
/* 
	print("lance addr = %.4ux %.4ux %.4ux\n", lm->etheraddr[0], lm->etheraddr[1], 
		lm->etheraddr[2]); 
/**/ 
1990/0227    
 
	/* 
	 *  ignore multicast addresses 
	 */ 
	for(i=0; i<4; i++) 
		lm->multi[i] = 0; 
1990/0911    
	MPus(lm->multi[0]) = 0; 
	MPus(lm->multi[1]) = 0; 
	MPus(lm->multi[2]) = 0; 
	MPus(lm->multi[3]) = 0; 
1990/0227    
 
	/* 
	 *  set up rcv message ring 
	 */ 
	p = lm->p; 
	for(i = 0; i < Nrrb; i++){ 
		l.rp[i] = p++; 
		lm->rmr[i].size = -sizeof(Pkt); 
		lm->rmr[i].cntflags = 0; 
		lm->rmr[i].laddr = LADDR(l.rp[i]); 
		lm->rmr[i].flags = HADDR(l.rp[i]); 
1990/0911    
	m = lm->rmr; 
	for(i = 0; i < Nrrb; i++, m++){ 
		MPs(m->size) = -sizeof(Pkt); 
		MPus(m->cntflags) = 0; 
		MPus(m->laddr) = LADDR(l.rpa[i]); 
		MPus(m->flags) = HADDR(l.rpa[i]); 
1990/0227    
	} 
	lm->rdralow = LADDR(lm->rmr); 
	lm->rdrahigh = (LogNrrb<<13)|HADDR(lm->rmr); 
1990/0911    
	MPus(lm->rdralow) = LADDR(l.lm->rmr); 
	MPus(lm->rdrahigh) = (LogNrrb<<13)|HADDR(l.lm->rmr); 
1990/0227    
 
1990/0911    
 
1990/0227    
	/* 
	 *  give the lance all the rcv buffers except one (as a sentinel) 
	 */ 
	l.rc = Nrrb - 1; 
	for(i = 0; i < l.rc; i++) 
		lm->rmr[i].flags |= OWN; 
1990/0911    
	m = lm->rmr; 
	for(i = 0; i < l.rc; i++, m++) 
		MPus(m->flags) |= OWN; 
1990/0227    
 
	/* 
	 *  set up xmit message ring 
	 */ 
	for(i = 0; i < Ntrb; i++){ 
		l.tp[i] = p++; 
		lm->tmr[i].size = 0; 
		lm->tmr[i].cntflags = 0; 
		lm->tmr[i].laddr = LADDR(l.tp[i]); 
		lm->tmr[i].flags = HADDR(l.tp[i]); 
1990/0911    
	m = lm->tmr; 
	for(i = 0; i < Ntrb; i++, m++){ 
		MPs(m->size) = 0; 
		MPus(m->cntflags) = 0; 
		MPus(m->laddr) = LADDR(l.tpa[i]); 
		MPus(m->flags) = HADDR(l.tpa[i]); 
1990/0227    
	} 
	lm->tdralow = LADDR(lm->tmr); 
	lm->tdrahigh = (LogNtrb<<13)|HADDR(lm->tmr); 
1990/0911    
	MPus(lm->tdralow) = LADDR(l.lm->tmr); 
	MPus(lm->tdrahigh) = (LogNtrb<<13)|HADDR(l.lm->tmr); 
1990/0227    
 
	/* 
	 *  so that we don't have to indirect through constants 
	 */ 
	l.rap = LANCERAP; 
	l.rdp = LANCERDP; 
                 
	/* 
	 *  point lance to the initialization block 
	 */ 
	*l.rap = 1; 
	*l.rdp = LADDR(lm); 
1990/0911    
	*l.rdp = LADDR(l.lm); 
1990/0227    
	wbflush(); 
	*l.rap = 2; 
	*l.rdp = HADDR(lm); 
1990/0911    
	*l.rdp = HADDR(l.lm); 
1990/0227    
 
	/* 
	 *  The lance byte swaps the ethernet packet unless we tell it not to 
1990/0826/sys/src/9/port/devlance.c:580,5861990/0911/sys/src/9/port/devlance.c:631,640
1990/03042    
	lancedir[Ntypes].qid = Ltraceqid; 
	lancedir[Ntypes].length = 0; 
	lancedir[Ntypes].perm = 0600; 
1990/0707    
                 
1990/0911    
	strcpy(lancedir[Ntypes+1].name, "stats"); 
	lancedir[Ntypes+1].qid = Lstatsqid; 
	lancedir[Ntypes+1].length = 0; 
	lancedir[Ntypes+1].perm = 0600; 
1990/0227    
} 
 
Chan* 
1990/0826/sys/src/9/port/devlance.c:589,5951990/0911/sys/src/9/port/devlance.c:643,649
1990/0227    
	Chan *c; 
 
	if(l.kstarted == 0){ 
1990/0722    
		kproc("lancekproc", lancekproc, 0); 
1990/0911    
		kproc("lancekproc", lancekproc, 0);/**/ 
1990/0227    
		l.kstarted = 1; 
		lancestart(); 
	} 
1990/0826/sys/src/9/port/devlance.c:620,6261990/0911/sys/src/9/port/devlance.c:674,680
1990/0227    
void	  
lancestat(Chan *c, char *dp) 
{ 
1990/0319    
	if(c->qid==CHDIR || c->qid==Ltraceqid) 
1990/0911    
	if(c->qid==CHDIR || c->qid==Ltraceqid || c->qid==Lstatsqid) 
1990/03042    
		devstat(c, dp, lancedir, Ndir, devgen); 
1990/0227    
	else 
		devstat(c, dp, 0, 0, streamgen); 
1990/0826/sys/src/9/port/devlance.c:637,6421990/0911/sys/src/9/port/devlance.c:691,697
1990/03042    
	switch(c->qid){ 
	case CHDIR: 
	case Ltraceqid: 
1990/0911    
	case Lstatsqid: 
1990/0227    
		if(omode != OREAD) 
			error(0, Eperm); 
1990/03042    
		break; 
1990/0826/sys/src/9/port/devlance.c:663,6681990/0911/sys/src/9/port/devlance.c:718,724
1990/03042    
	switch(c->qid){ 
	case CHDIR: 
	case Ltraceqid: 
1990/0911    
	case Lstatsqid: 
1990/03042    
		break; 
	default: 
1990/0227    
		streamclose(c); 
1990/0826/sys/src/9/port/devlance.c:706,7141990/0911/sys/src/9/port/devlance.c:762,777
1990/0227    
long	  
lanceread(Chan *c, void *a, long n) 
{ 
1990/0911    
	char buf[256]; 
 
1990/03042    
	switch(c->qid){ 
	case CHDIR: 
		return devdirread(c, a, n, lancedir, Ndir, devgen); 
1990/0911    
	case Lstatsqid: 
		sprint(buf, "in: %d\nout: %d\ncrc errs %d\noverflows: %d\nframe errs %d\nbuff errs: %d\noerrs %d\n", 
			l.inpackets, l.outpackets, l.crcs, l.overflows, l.frames, 
			l.buffs, l.oerrs); 
		return stringread(c, a, n, buf); 
1990/03042    
	case Ltraceqid: 
		return lancetraceread(c, a, n); 
	default: 
1990/0826/sys/src/9/port/devlance.c:754,7641990/0911/sys/src/9/port/devlance.c:817,826
1990/0227    
void 
lanceintr(void) 
{ 
1990/0911    
	int i; 
1990/0227    
	ushort csr; 
	Lancemem *lm; 
1990/0911    
	Lancemem *lm = LANCEMEM; 
1990/0227    
 
	lm = LANCEMEM; 
                 
	csr = *l.rdp; 
 
	/* 
1990/0826/sys/src/9/port/devlance.c:778,7841990/0911/sys/src/9/port/devlance.c:840,846
1990/0227    
	/* 
	 *  look for rcv'd packets, just wakeup the input process 
	 */ 
	if(l.rl!=l.rc && (lm->rmr[l.rl].flags & OWN)==0) 
1990/0911    
	if(l.rl!=l.rc && (MPus(lm->rmr[l.rl].flags) & OWN)==0) 
1990/0227    
		wakeup(&l.rr); 
 
	/* 
1990/0826/sys/src/9/port/devlance.c:785,7941990/0911/sys/src/9/port/devlance.c:847,855
1990/0227    
	 *  look for xmitt'd packets, wake any process waiting for a 
	 *  transmit buffer 
	 */ 
	while(l.tl != l.tc && (lm->tmr[l.tl].flags & OWN) == 0){ 
		if(lm->tmr[l.tl].flags & ERR) 
			print("xmt error %ux %ux\n", lm->tmr[l.tl].flags, 
				lm->tmr[l.tl].cntflags); 
1990/0911    
	while(l.tl!=l.tc && (MPus(lm->tmr[l.tl].flags) & OWN)==0){ 
		if(MPus(lm->tmr[l.tl].flags) & ERR) 
			l.oerrs++; 
1990/0227    
		l.tl = TSUCC(l.tl); 
		wakeup(&l.tr); 
	} 
1990/0826/sys/src/9/port/devlance.c:800,8281990/0911/sys/src/9/port/devlance.c:861,895
1990/0227    
static int 
isinput(void *arg) 
{ 
	return l.rl!=l.rc && (LANCEMEM->rmr[l.rl].flags & OWN)==0; 
1990/0911    
	Lancemem *lm = LANCEMEM; 
	return l.rl!=l.rc && (MPus(lm->rmr[l.rl].flags) & OWN)==0; 
1990/0227    
} 
void 
lancekproc(void *arg) 
{ 
	Block *bp; 
	Lancemem *lm; 
	Pkt *p; 
	Ethertype *e; 
	int t; 
	Msg *m; 
	int len; 
	int i, last; 
1990/0911    
	Lancemem *lm = LANCEMEM; 
	Msg *m; 
1990/0227    
 
	lm = LANCEMEM; 
                 
	for(;;){ 
		for(; l.rl!=l.rc && (lm->rmr[l.rl].flags & OWN)==0 ; l.rl=RSUCC(l.rl)){ 
1990/0911    
		for(; l.rl!=l.rc && (MPus(lm->rmr[l.rl].flags) & OWN)==0 ; l.rl=RSUCC(l.rl)){ 
1990/0227    
			l.inpackets++; 
			m = &(lm->rmr[l.rl]); 
			if(m->flags & ERR){ 
				print("rcv error %ux\n", 
					m->flags&(FRAM|OFLO|CRC|BUFF)); 
1990/0911    
			if(MPus(m->flags) & ERR){ 
				t = MPus(m->flags); 
				if(t & FRAM) 
					l.frames++; 
				if(t & OFLO) 
					l.overflows++; 
				if(t & CRC) 
					l.crcs++; 
				if(t & BUFF) 
					l.buffs++; 
1990/0227    
				goto stage; 
			} 
	 
1990/0826/sys/src/9/port/devlance.c:829,8381990/0911/sys/src/9/port/devlance.c:896,905
1990/0227    
			/* 
			 *  See if a queue exists for this packet type. 
			 */ 
			p = l.rp[l.rl]; 
1990/0911    
			p = &l.rp[l.rl]; 
1990/03011    
			t = (p->type[0]<<8) | p->type[1]; 
1990/0227    
			len = m->cntflags - 4; 
1990/03042    
			lancedebq('i', p, len); 
1990/0911    
			len = MPus(m->cntflags) - 4; 
			lancedebq('i', p, len);/**/ 
1990/0227    
			for(e = &l.e[0]; e < &l.e[Ntypes]; e++){ 
				if(!canqlock(e)) 
					continue; 
1990/0826/sys/src/9/port/devlance.c:854,8601990/0911/sys/src/9/port/devlance.c:921,927
1990/0227    
					qunlock(e); 
				} 
			} 
			if(e != &l.e[Ntypes] && e->q->next->len <= Streamhi){ 
1990/0911    
			if(e!=&l.e[Ntypes] && e->q->next->len<=Streamhi){ 
1990/0227    
				/* 
				 *  The lock on e makes sure the queue is still there. 
				 */ 
1990/0826/sys/src/9/port/devlance.c:871,8801990/0911/sys/src/9/port/devlance.c:938,947
1990/0227    
			 *  stage the next input buffer 
			 */ 
			m = &(lm->rmr[l.rc]); 
			m->size = -sizeof(Pkt); 
			m->cntflags = 0; 
			m->laddr = LADDR(l.rp[l.rc]); 
			m->flags = OWN|HADDR(l.rp[l.rc]); 
1990/0911    
			MPs(m->size) = -sizeof(Pkt); 
			MPus(m->cntflags) = 0; 
			MPus(m->laddr) = LADDR(l.rpa[l.rc]); 
			MPus(m->flags) = OWN|HADDR(l.rpa[l.rc]); 
1990/0227    
			l.rc = RSUCC(l.rc); 
		} 
		sleep(&l.rr, isinput, 0); 
1990/0826/sys/src/9/port/devlance.c:887,8961990/0911/sys/src/9/port/devlance.c:954,957
1990/0227    
	print("lance DRAM parity error lmp=%ux\n", l.lmp); 
	MODEREG->promenet &= ~4; 
	MODEREG->promenet |= 4; 
} 
1990/0826    
                 
void 
lance3intr(void) 
{ 
	panic("lance3 interrupt\n"); 
} 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)