Browse Source

Plan 9 from Bell Labs 2009-03-17

David du Colombier 15 years ago
parent
commit
532bd3c823
4 changed files with 40 additions and 28 deletions
  1. 9 4
      sys/src/9/port/devaoe.c
  2. 12 8
      sys/src/9/port/sdaoe.c
  3. 2 1
      sys/src/boot/pc/ether82563.c
  4. 17 15
      sys/src/boot/pc/sdaoe.c

+ 9 - 4
sys/src/9/port/devaoe.c

@@ -70,10 +70,15 @@ enum {
 	Tfree		= -1,
 	Tmgmt,
 
-	/* round trip bounds, timeouts, in ticks */
+	/*
+	 * round trip bounds, timeouts, in ticks.
+	 * timeouts should be long enough that rebooting
+	 * the coraid (which takes under two minutes)
+	 * doesn't trigger a timeout.
+	 */
 	Rtmax		= Ms2tk(320),
 	Rtmin		= Ms2tk(20),
-	Srbtimeout	= 45*HZ,
+	Srbtimeout	= 3*60*HZ,		/* was 45*HZ */
 
 	Dbcnt		= 1024,
 
@@ -583,7 +588,7 @@ aoesweepproc(void*)
 {
 	ulong i, tx, timeout, nbc;
 	vlong starttick;
-	enum { Nms = 100, Nbcms = 30*1000, };
+	enum { Nms = 100, Nbcms = 30*1000, };		/* magic */
 	uchar *ea;
 	Aoeata *a;
 	Aoedev *d;
@@ -641,7 +646,7 @@ loop:
 			}
 		}
 		if(d->nout == d->maxout && d->maxout < d->nframes &&
-		   TK2MS(MACHP(0)->ticks - d->lastwadj) > 10*1000){
+		   TK2MS(MACHP(0)->ticks - d->lastwadj) > 10*1000){ /* more magic */
 			d->maxout++;
 			d->lastwadj = MACHP(0)->ticks;
 		}

+ 12 - 8
sys/src/9/port/sdaoe.c

@@ -21,6 +21,9 @@ extern	char	Enotup[];
 enum {
 	Nctlr	= 32,
 	Maxpath	= 128,
+
+	Probeintvl	= 100,		/* ms. between probes */
+	Probemax	= 8000,		/* max ms. to wait */
 };
 
 enum {
@@ -288,10 +291,10 @@ aoeprobe(char *path, SDev *s)
 	poperror();
 	cclose(c);
 
-	for(i = 0;; i += 200){
-		if(i > 8000 || waserror())
+	for(i = 0; ; i += Probeintvl){
+		if(i > Probemax || waserror())
 			error(Etimedout);
-		tsleep(&up->sleep, return0, 0, 200);
+		tsleep(&up->sleep, return0, 0, Probeintvl);
 		poperror();
 
 		uprint("%s/ident", path);
@@ -376,20 +379,21 @@ pnpprobe(SDev *sd)
 	if(p[1] == '!')
 		p += 2;
 
-	for(j = 0;; j += 200){
-		if(j > 8000){
-			print("#æ: pnpprobe: %s: %s\n", probef[i-1], up->errstr);
+	for(j = 0; ; j += Probeintvl){
+		if(j > Probemax){
+			print("#æ: pnpprobe failed in %d ms: %s: %s\n",
+				j, probef[i-1], up->errstr);
 			return 0;
 		}
 		if(waserror()){
-			tsleep(&up->sleep, return0, 0, 200);
+			tsleep(&up->sleep, return0, 0, Probeintvl);
 			continue;
 		}
 		sd = aoeprobe(p, sd);
 		poperror();
 		break;
 	}
-	print("#æ: pnpprobe establishes %s in %dms\n", probef[i-1], j);
+	print("#æ: pnpprobe established %s in %d ms\n", probef[i-1], j);
 	return sd->ctlr;
 }
 

+ 2 - 1
sys/src/boot/pc/ether82563.c

@@ -674,7 +674,7 @@ i82563interrupt(Ureg*, void* arg)
 						bp->rp+6, rdesc->length);
 				ctlr->rb[rdh] = nil;
 				bp->wp += rdesc->length;
-//				if (interesting(bp))
+				if (interesting(bp))
 					toringbuf(edev, bp);
 				freeb(bp);
 			} else if (rdesc->status & Reop && rdesc->errors)
@@ -729,6 +729,7 @@ i82563init(Ether* edev)
 	ctlr->rb = malloc(sizeof(Block*)*Nrdesc);
 	i82563replenish(ctlr);
 	csr32w(ctlr, Rdtr, 0);
+	csr32w(ctlr, Radv, 0);
 
 	if(ctlr->type == i82573)
 		csr32w(ctlr, Ert, 1024/8);

+ 17 - 15
sys/src/boot/pc/sdaoe.c

@@ -13,7 +13,11 @@
 
 enum {
 	NCtlr	= 4,
-	Ctlrlet = 'e',		/* first sd controller letter */
+	Ctlrlet = 'e',			/* first sd controller letter */
+
+	Probeintvl	= 100,		/* ms. between probes */
+	Probemax	= 8000,		/* max ms. to wait */
+	Probetries	= Probemax / Probeintvl, /* max tries */
 };
 
 enum {
@@ -232,7 +236,7 @@ chktag(int *out, int nout, int tag)
 	for(j = 0; j <= nout; j++)
 		if(out[j] == tag)
 			return 0;
-print("wrong tag\n");
+	print("wrong aoe tag\n");
 	for(j = 0; j <= nout; j++)
 		print("%.8ux != %.8ux\n", out[j], tag);
 	return -1;
@@ -277,7 +281,7 @@ identify(Ctlr *c)
 	a = (Aoeata*)&p;
 	i = 0;
 	do {
-		if(i == 5){
+		if(i == Probetries){
 			print("aoe: identify timeout\n");
 			return -1;
 		}
@@ -285,7 +289,7 @@ identify(Ctlr *c)
 		ethertxany(&p, sizeof *a);
 		memset(&p, 0, sizeof p);
 next:
-		n = etherrxany(&p, 125);
+		n = etherrxany(&p, Probeintvl);
 		if(n == 0){
 			i++;
 			continue;
@@ -386,18 +390,17 @@ aoeprobe(int major, int minor, SDev *s)
 	Etherpkt p;
 	int n, i;
 
-	for(i = 0;; i += 200){
-		if(i > 8000)
+	for(i = 0; ; i += Probeintvl){
+		if(i > Probemax)
 			return -1;
 		discover(major, minor);
 again:
-		n = etherrxany(&p, 100);
-		if(n > 0 && (ctlr = newctlr(&p)))
+		n = etherrxany(&p, Probeintvl);
+		if(n > 0 && (ctlr = newctlr(&p)) != nil)
 			break;
 		if(n > 0)
 			goto again;
 	}
-
 	s->ctlr = ctlr;
 	s->ifc = &sdaoeifc;
 	s->nunit = 1;
@@ -434,8 +437,8 @@ aoepnp0(void)
 
 	if((p = getconf("aoeif")) == nil)
 		return 0;
-//	print("aoepnp0: aoeif=%s\n", p);
 	nprobe = tokenize(p, probef, nelem(probef));
+
 	for(i = 0; i < nprobe; i++){
 		if(strncmp(probef[i], "ether", 5) != 0)
 			continue;
@@ -447,8 +450,7 @@ aoepnp0(void)
 
 	if((p = getconf("aoedev")) == nil)
 		return 0;
-	nprobe = tokenize(p, probef, nelem(probef));
-	return nprobe;
+	return tokenize(p, probef, nelem(probef));
 }
 
 static int
@@ -578,13 +580,13 @@ rio(Ctlr *c, Aoeata *a, int n, int scnt)
 {
 	int i, tag, cmd;
 
-	for(i = 0; i < 5; i++){
+	for(i = 0; i < Probetries; i++){
 		tag = hset(c, a, ACata);
 		cmd = a->cmdstat;
 		ethertxany((Etherpkt*)a, n);
 		memset(a, 0, sizeof *a);
 again:
-		n = etherrxany((Etherpkt*)a, 125);
+		n = etherrxany((Etherpkt*)a, Probeintvl);
 		if(n == 0)
 			continue;
 		if(nhgets(a->type) != Aoetype || nhgetl(a->tag) != tag ||
@@ -607,7 +609,7 @@ again:
 		case Cwrext:
 			return scnt * 512;
 		default:
-print("unknown cmd %ux\n", cmd);
+			print("unknown aoe cmd %ux\n", cmd);
 			break;
 		}
 	}