~kris/9p

9hist

242b2764aa705313569eec9091c2c73c4cc9b21a — David du Colombier 28 years ago 23f0453
Plan 9 from Bell Labs 1997-12-03
5 files changed, 53 insertions(+), 44 deletions(-)

M pc/etherelnk3.c
M port/devproc.c
M port/pgrp.c
M port/sysfile.c
M port/sysproc.c
M pc/etherelnk3.c => pc/etherelnk3.c +20 -8
@@ 413,6 413,8 @@ typedef struct {
	long	stats[BytesRcvdOk+3];

	int	upqmax;
	long	upinterrupts;
	long	upqueued;
	int	upstalls;
	int	dnqmax;
	long	dninterrupts;


@@ 816,6 818,7 @@ receive905(Ether* ether)
	}
	ctlr->uphead = pd;

	ctlr->upqueued += q;
	if(q > ctlr->upqmax)
		ctlr->upqmax = q;
}


@@ 982,9 985,10 @@ interrupt(Ureg*, void* arg)
		}

		if(status & (upComplete)){
			receive905(ether);
			COMMAND(port, AcknowledgeInterrupt, upComplete);
			receive905(ether);
			status &= ~upComplete;
			ctlr->upinterrupts++;
		}

		if(status & txComplete){


@@ 1041,8 1045,8 @@ interrupt(Ureg*, void* arg)
		}

		if(status & dnComplete){
			txstart905(ether);
			COMMAND(port, AcknowledgeInterrupt, dnComplete);
			txstart905(ether);
			status &= ~dnComplete;
			ctlr->dninterrupts++;
		}


@@ 1103,12 1107,18 @@ ifstat(Ether* ether, void* a, long n, ulong offset)
	len += snprint(p+len, READSTR-len, "framesdeferred: %lud\n", ctlr->stats[FramesDeferred]);
	len += snprint(p+len, READSTR-len, "bytesrcvdok: %lud\n", ctlr->stats[BytesRcvdOk]);
	len += snprint(p+len, READSTR-len, "bytesxmittedok: %lud\n", ctlr->stats[BytesRcvdOk+1]);
len += snprint(p+len, READSTR-len, "up: q %lud s %lud\n",
    ctlr->upqmax, ctlr->upstalls);
ctlr->upqmax = 0;
len += snprint(p+len, READSTR-len, "dn: q %lud i %lud m %d\n",
    ctlr->dnqueued, ctlr->dninterrupts, ctlr->dnqmax);
ctlr->dnqmax = 0;

	if(ctlr->upenabled){
		len += snprint(p+len, READSTR-len, "up: q %lud i %lud m %d s %lud\n",
			ctlr->upqueued, ctlr->upinterrupts, ctlr->dnqmax, ctlr->upstalls);
		ctlr->upqmax = 0;
	}
	if(ctlr->dnenabled){
		len += snprint(p+len, READSTR-len, "dn: q %lud i %lud m %d\n",
			ctlr->dnqueued, ctlr->dninterrupts, ctlr->dnqmax);
		ctlr->dnqmax = 0;
	}

	snprint(p+len, READSTR-len, "badssd: %lud\n", ctlr->stats[BytesRcvdOk+2]);

	n = readstr(offset, a, n, p);


@@ 1730,6 1740,8 @@ etherelnk3reset(Ether* ether)
	COMMAND(port, SetTxStartThresh, ctlr->txthreshold>>ctlr->ts);
	COMMAND(port, SetRxEarlyThresh, rxearly>>ctlr->ts);

COMMAND(port, AcknowledgeInterrupt, interruptLatch);

	iunlock(&ctlr->wlock);

	/*

M port/devproc.c => port/devproc.c +1 -1
@@ 467,7 467,7 @@ procread(Chan *c, void *va, long n, ulong offset)
			return 0;
		if(n < NAMELEN+11)
			error(Etoosmall);
		i = sprint(a, "%s %d ", mw->cm->spec, mw->cm->flag);
		i = sprint(a, "%.*s %d ", NAMELEN, mw->cm->spec, mw->cm->flag);
		n -= i;
		a += i;
		i = ptpath(mw->mh->from->path, a, n);

M port/pgrp.c => port/pgrp.c +5 -5
@@ 122,7 122,7 @@ pgrpcpy(Pgrp *to, Pgrp *from)
	Mount *n, *m, **link, *order;
	Mhead *f, **tom, **l, *mh;

	rlock(&from->ns);
	wlock(&from->ns);
	order = 0;
	tom = to->mnthash;
	for(i = 0; i < MNTHASH; i++) {


@@ 140,8 140,8 @@ pgrpcpy(Pgrp *to, Pgrp *from)
				incref(n->to);
				n->head = mh;
				n->flag = m->flag;
				if(m->spec != 0)
					strcpy(n->spec, m->spec);
				if(m->spec[0] != 0)
					strncpy(n->spec, m->spec, NAMELEN);
				m->copy = n;
				pgrpinsert(&order, m);
				*link = n;


@@ 156,7 156,7 @@ pgrpcpy(Pgrp *to, Pgrp *from)
	for(m = order; m; m = m->order)
		m->copy->mountid = mountid.ref++;
	unlock(&mountid);
	runlock(&from->ns);
	wunlock(&from->ns);
}

Fgrp*


@@ 231,7 231,7 @@ newmount(Mhead *mh, Chan *to, int flag, char *spec)
	m->mountid = incref(&mountid);
	m->flag = flag;
	if(spec != 0)
		strcpy(m->spec, spec);
		strncpy(m->spec, spec, NAMELEN);

	return m;
}

M port/sysfile.c => port/sysfile.c +2 -1
@@ 177,11 177,12 @@ sysdup(ulong *arg)
	c = fdtochan(arg[0], -1, 0, 1);
	fd = arg[1];
	if(fd != -1){
		lock(f);
		if(fd<0 || f->nfd<=fd) {
			unlock(f);
			cclose(c);
			error(Ebadfd);
		}
		lock(f);
		if(fd > f->maxfd)
			f->maxfd = fd;


M port/sysproc.c => port/sysproc.c +25 -29
@@ 21,25 21,45 @@ sysrfork(ulong *arg)
{
	Proc *p;
	int n, i;
	Fgrp *ofg;
	Pgrp *opg;
	Rgrp *org;
	Egrp *oeg;
	Fgrp *ofg;
	ulong pid, flag;

	flag = arg[0];
	/* Check flags before we commit */
	if((flag & (RFFDG|RFCFDG)) == (RFFDG|RFCFDG))
		error(Ebadarg);
	if((flag & (RFNAMEG|RFCNAMEG)) == (RFNAMEG|RFCNAMEG))
		error(Ebadarg);
	if((flag & (RFENVG|RFCENVG)) == (RFENVG|RFCENVG))
		error(Ebadarg);

	if((flag&RFPROC) == 0) {
		if(flag & (RFMEM|RFNOWAIT))
			error(Ebadarg);
		if(flag & (RFFDG|RFCFDG)) {
			ofg = up->fgrp;
			if(flag & RFFDG)
				up->fgrp = dupfgrp(ofg);
			else
				up->fgrp = dupfgrp(nil);
			closefgrp(ofg);
		}
		if(flag & (RFNAMEG|RFCNAMEG)) {
			if((flag & (RFNAMEG|RFCNAMEG)) == (RFNAMEG|RFCNAMEG))
				error(Ebadarg);
			opg = up->pgrp;
			up->pgrp = newpgrp();
			if(flag & RFNAMEG)
				pgrpcpy(up->pgrp, opg);
			closepgrp(opg);
		}
		if(flag & RFREND) {
			org = up->rgrp;
			up->rgrp = newrgrp();
			closergrp(org);
		}
		if(flag & (RFENVG|RFCENVG)) {
			if((flag & (RFENVG|RFCENVG)) == (RFENVG|RFCENVG))
				error(Ebadarg);
			oeg = up->egrp;
			up->egrp = smalloc(sizeof(Egrp));
			up->egrp->ref = 1;


@@ 47,34 67,10 @@ sysrfork(ulong *arg)
				envcpy(up->egrp, oeg);
			closeegrp(oeg);
		}
		if(flag & RFFDG) {
			ofg = up->fgrp;
			up->fgrp = dupfgrp(ofg);
			closefgrp(ofg);
		}
		else
		if(flag & RFCFDG) {
			ofg = up->fgrp;
			up->fgrp = dupfgrp(nil);
			closefgrp(ofg);
		}
		if(flag & RFNOTEG)
			up->noteid = incref(&noteidalloc);
		if(flag & (RFMEM|RFNOWAIT))
			error(Ebadarg);
		if(flag & RFREND) {
			closergrp(up->rgrp);
			up->rgrp = newrgrp();
		}
		return 0;
	}
	/* Check flags before we commit */
	if((flag & (RFFDG|RFCFDG)) == (RFFDG|RFCFDG))
		error(Ebadarg);
	if((flag & (RFNAMEG|RFCNAMEG)) == (RFNAMEG|RFCNAMEG))
		error(Ebadarg);
	if((flag & (RFENVG|RFCENVG)) == (RFENVG|RFCENVG))
		error(Ebadarg);

	p = newproc();