| plan 9 kernel history: overview | file list | diff list |
1991/0108/port/devnonet.c (diff list | history)
| 1991/0102/sys/src/9/port/devnonet.c:16,22 – 1991/0108/sys/src/9/port/devnonet.c:16,22 (short | long | prev | next) | ||
| 1990/1210 | /* * tuning parameters */ | |
| 1990/1229 |
| |
| 1991/0108 | MSrexmit = 250, /* retranmission interval in ms */ | |
| 1990/1210 | MSack = 50, /* ms to sit on an ack */ /* | |
| 1991/0102/sys/src/9/port/devnonet.c:37,43 – 1991/0108/sys/src/9/port/devnonet.c:37,43 | ||
| 1990/1210 | static void sendmsg(Noconv*, Nomsg*); static void startconv(Noconv*, int, char*, int); static void queueack(Noconv*, int); | |
| 1991/0108 | static void nonetkproc(void*); | |
| 1990/1210 | static void nonetiput(Queue*, Block*); static void nonetoput(Queue*, Block*); static void nonetstclose(Queue*); | |
| 1991/0102/sys/src/9/port/devnonet.c:89,94 – 1991/0108/sys/src/9/port/devnonet.c:89,100 | ||
| 1990/1210 | }; /* | |
| 1991/0108 | * nonet kproc */ static int kstarted; static Rendez nonetkr; /* | |
| 1990/1210 | * nonet file system. most of the calls use dev.c to access the nonet * directory and stream.c to access the nonet devices. * create the nonet directory. the files are `clone' and stream | |
| 1991/0102/sys/src/9/port/devnonet.c:164,169 – 1991/0108/sys/src/9/port/devnonet.c:170,176 | ||
| 1990/1210 | error(Enoifc); c = devattach('n', spec); c->dev = ifc - noifc; | |
| 1991/0108 | ||
| 1990/1210 | return c; } | |
| 1991/0102/sys/src/9/port/devnonet.c:240,245 – 1991/0108/sys/src/9/port/devnonet.c:247,257 | ||
| 1990/1210 | Noifc *ifc; int line; | |
| 1991/0108 | if(!kstarted){ kproc("nonetack", nonetkproc, 0); kstarted = 1; } | |
| 1990/1210 | if(c->qid.path & CHDIR){ /* * directories are read only | |
| 1991/0102/sys/src/9/port/devnonet.c:466,473 – 1991/0108/sys/src/9/port/devnonet.c:478,487 | ||
| 1990/1210 | } } | |
| 1991/0108 | qlock(cp); | |
| 1990/1210 | cp->rcvcircuit = -1; cp->state = Cclosed; | |
| 1991/0108 | qunlock(cp); | |
| 1990/1210 | poperror(); } | |
| 1991/0102/sys/src/9/port/devnonet.c:511,516 – 1991/0108/sys/src/9/port/devnonet.c:525,531 | ||
| 1990/1210 | Noconv *cp; int next; Nomsg *mp; | |
| 1991/0108 | int retries; | |
| 1990/1210 | cp = (Noconv *)(q->ptr); | |
| 1991/0102/sys/src/9/port/devnonet.c:573,581 – 1991/0108/sys/src/9/port/devnonet.c:588,599 | ||
| 1990/1210 | /* * wait for acknowledgement */ | |
| 1991/0108 | retries = 0; | |
| 1990/1210 | while(!mp->acked && cp->state!=Chungup){ sendmsg(cp, mp); tsleep(&mp->r, acked, mp, MSrexmit); | |
| 1991/0108 | if(retries++ > 100) errors("to many nonet rexmits"); | |
| 1990/1210 | } /* | |
| 1991/0102/sys/src/9/port/devnonet.c:704,712 – 1991/0108/sys/src/9/port/devnonet.c:722,730 | ||
| 1990/1210 | cp->hdr->flag |= NO_SERVICE; sprint(buf, "%s %s", service, u->p->pgrp->user); c->qid.path = STREAMQID(STREAMID(c->qid.path), Sdataqid); | |
| 1990/1231 |
| |
| 1991/0108 | DPRINT("sending request\n"); | |
| 1990/1210 | streamwrite(c, buf, strlen(buf), 1); | |
| 1990/1231 |
| |
| 1991/0108 | DPRINT("request sent\n"); | |
| 1990/1210 | c->qid.path = STREAMQID(STREAMID(c->qid.path), Sctlqid); } } | |
| 1991/0102/sys/src/9/port/devnonet.c:783,791 – 1991/0108/sys/src/9/port/devnonet.c:801,809 | ||
| 1990/1210 | * stuff the connect message into it */ f = ((Nohdr *)(call.msg->rptr))->flag; | |
| 1990/1231 |
| |
| 1991/0108 | DPRINT("call from %d %s\n", call.circuit, call.raddr); | |
| 1990/1210 | startconv(cp, call.circuit, call.raddr, Cconnecting); | |
| 1991/0108 | DPRINT("rcving %d byte message\n", call.msg->wptr - call.msg->rptr); | |
| 1990/1210 | nonetrcvmsg(cp, call.msg); call.msg = 0; | |
| 1991/0102/sys/src/9/port/devnonet.c:794,808 – 1991/0108/sys/src/9/port/devnonet.c:812,824 | ||
| 1990/1210 | * grab them */ if(f & NO_SERVICE){ | |
| 1991/0108 | DPRINT("reading service\n"); | |
| 1990/1210 | c->qid.path = STREAMQID(cp - ifc->conv, Sdataqid); n = streamread(c, buf, sizeof(buf)); c->qid.path = STREAMQID(cp - ifc->conv, Sctlqid); | |
| 1991/0102/sys/src/9/port/devnonet.c:1056,1062 – 1991/0108/sys/src/9/port/devnonet.c:1072,1078 | ||
| 1990/1210 | * ignore old messages and process the acknowledgement */ if(h->mid != mp->mid){ | |
| 1991/0108 | DPRINT("old msg %d instead of %d r==%d\n", h->mid, mp->mid, r); | |
| 1990/1210 | if(r == 0){ rcvack(cp, h->ack); if(f & NO_HANGUP) | |
| 1991/0102/sys/src/9/port/devnonet.c:1063,1070 – 1991/0108/sys/src/9/port/devnonet.c:1079,1086 | ||
| 1990/1210 | hangup(cp); } else { | |
| 1991/0102 | if(r>0){ | |
| 1991/0108 | rcvack(cp, h->ack); | |
| 1991/0102 | queueack(cp, h->mid); | |
| 1990/1210 | cp->bad++; } | |
| 1991/0102/sys/src/9/port/devnonet.c:1238,1244 – 1991/0108/sys/src/9/port/devnonet.c:1254,1300 | ||
| 1990/1210 | return s & 0xffff; | |
| 1990/1229 | } | |
| 1991/0108 | /* * send acknowledges that need to be sent. this happens at 1/2 * the retransmission interval. */ static void nonetkproc(void *arg) { Noifc *ifc; Noconv *cp, *ep; cp = 0; ifc = 0; if(waserror()){ if(ifc) unlock(ifc); if(cp) qunlock(cp); } loop: for(ifc = noifc; ifc < &noifc[conf.nnoifc]; ifc++){ if(ifc->wq==0 || !canlock(ifc)) continue; ep = ifc->conv + conf.nnoconv; for(cp = ifc->conv; cp < ep; cp++){ if(cp->state==Cclosed || !canqlock(cp)) continue; if(cp->afirst != cp->anext){ DPRINT("sending ack %d\n", cp->ack[cp->afirst]); sendctlmsg(cp, 0, 0); } qunlock(cp); } unlock(ifc); } tsleep(&nonetkr, return0, 0, MSrexmit/2); goto loop; } | |
| 1990/1229 | nonettoggle() { pnonet ^= 1; | |
| 1990/1210 | } | |
| 1991/0108 | ||