| plan 9 kernel history: overview | file list | diff list |
1991/1106/port/devlance.c (diff list | history)
| 1991/1031/sys/src/9/port/devlance.c:109,114 – 1991/1106/sys/src/9/port/devlance.c:109,116 (short | long | prev | next) | ||
| 1990/0227 | int debug; int kstarted; | |
| 1990/0911 | ||
| 1991/1106 | Queue self; /* packets turned around at the interface */ | |
| 1990/0911 | /* sadistics */ int inpackets; | |
| 1991/1031/sys/src/9/port/devlance.c:185,190 – 1991/1106/sys/src/9/port/devlance.c:187,193 | ||
| 1991/0621 | static void lancekproc(void *); | |
| 1991/0828 | static void lancestart(int, int); static void lancedump(void); | |
| 1991/1106 | static void lanceup(Etherpkt*, int); | |
| 1991/0828 | ||
| 1990/0227 | /* * lance stream module definition | |
| 1991/1031/sys/src/9/port/devlance.c:241,246 – 1991/1106/sys/src/9/port/devlance.c:244,288 | ||
| 1990/0227 | } /* | |
| 1991/1106 | * expand a block list to be one byte, len bytes long */ static Block* expandb(Block *bp, int len) { Block *nbp, *new; int i; new = allocb(len); if(new == 0){ freeb(bp); return 0; } /* * copy bytes into new block */ for(nbp = bp; len>0 && nbp; nbp = nbp->next){ i = BLEN(bp); if(i > len) { memmove(new->wptr, nbp->rptr, len); new->wptr += len; break; } else { memmove(new->wptr, nbp->rptr, i); new->wptr += i; len -= i; } } if(len){ memset(new->wptr, 0, len); new->wptr += len; } freeb(bp); return new; } /* | |
| 1990/0227 | * the ``connect'' control message specifyies the type */ Proc *lanceout; | |
| 1991/1031/sys/src/9/port/devlance.c:275,280 – 1991/1106/sys/src/9/port/devlance.c:317,343 | ||
| 1990/0227 | } /* | |
| 1991/1106 | * give packet a local address, return upstream if destined for * this machine. */ if(BLEN(bp) < ETHERHDRSIZE){ bp = pullup(bp, ETHERHDRSIZE); if(bp == 0) return; } p = (Etherpkt *)bp->rptr; memmove(p->s, l.ea, sizeof(l.ea)); if(memcmp(l.ea, p->d, sizeof(l.ea)) == 0){ len = blen(bp); bp = expandb(bp, len >= 60 ? len : 60); if(bp){ putq(&l.self, bp); wakeup(&l.rr); } return; } /* | |
| 1990/0227 | * only one transmitter at a time */ qlock(&l.tlock); | |
| 1991/1031/sys/src/9/port/devlance.c:305,315 – 1991/1106/sys/src/9/port/devlance.c:368,373 | ||
| 1990/0227 | } /* | |
| 1991/0318 |
| |
| 1990/0227 |
| |
| 1991/0118 | * pad the packet (zero the pad) | |
| 1990/0227 | */ | |
| 1991/0118 | if(len < 60){ | |
| 1991/1031/sys/src/9/port/devlance.c:671,697 – 1991/1106/sys/src/9/port/devlance.c:729,775 | ||
| 1990/0227 | /* | |
| 1991/0621 | * send a packet upstream */ | |
| 1991/1106 | static void lanceup(Etherpkt *p, int len) | |
| 1991/0621 | { Block *bp; | |
| 1991/1106 | Ethertype *e; int t; | |
| 1991/0621 |
| |
| 1991/1026 |
| |
| 1991/1106 | t = (p->type[0]<<8) | p->type[1]; for(e = &l.e[0]; e < &l.e[Ntypes]; e++){ /* * check before locking just to save a lock */ if(e->q==0 || (t!=e->type && e->type!=-1)) continue; | |
| 1991/1026 |
| |
| 1991/0621 |
| |
| 1991/1106 | /* * only a trace channel gets packets destined for other machines */ if(e->type!=-1 && p->d[0]!=0xff && memcmp(p->d, l.ea, sizeof(p->d))!=0) continue; /* * check after locking to make sure things didn't * change under foot */ if(!canqlock(e)) continue; if(e->q==0 || e->q->next->len>Streamhi || (t!=e->type && e->type!=-1)){ qunlock(e); continue; } if(!waserror()){ bp = allocb(len); memmove(bp->rptr, (uchar *)p, len); bp->wptr += len; bp->flags |= S_DELIM; PUTNEXT(e->q, bp); } poperror(); qunlock(e); | |
| 1991/0621 | } | |
| 1991/1026 |
| |
| 1991/0621 | } /* | |
| 1991/1031/sys/src/9/port/devlance.c:701,707 – 1991/1106/sys/src/9/port/devlance.c:779,785 | ||
| 1990/0227 | isinput(void *arg) { | |
| 1990/0911 | Lancemem *lm = LANCEMEM; | |
| 1991/1106 | return l.self.first || (l.rl!=l.rc && (MPus(lm->rmr[l.rl].flags) & OWN)==0); | |
| 1990/0227 | } | |
| 1991/1027 | ||
| 1991/0621 | static void | |
| 1991/1031/sys/src/9/port/devlance.c:713,721 – 1991/1106/sys/src/9/port/devlance.c:791,804 | ||
| 1991/0621 | int t; | |
| 1990/0911 | Lancemem *lm = LANCEMEM; Msg *m; | |
| 1991/1106 | Block *bp; | |
| 1990/0227 | for(;;){ | |
| 1991/0621 | qlock(&l.rlock); | |
| 1991/1106 | while(bp = getq(&l.self)){ lanceup((Etherpkt*)bp->rptr, BLEN(bp)); freeb(bp); } | |
| 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]); | |
| 1991/1031/sys/src/9/port/devlance.c:736,750 – 1991/1106/sys/src/9/port/devlance.c:819,826 | ||
| 1991/0621 | * stuff packet up each queue that wants it | |
| 1990/0227 | */ | |
| 1990/0911 | p = &l.rp[l.rl]; | |
| 1990/03011 |
| |
| 1990/0911 | len = MPus(m->cntflags) - 4; | |
| 1990/0227 |
| |
| 1991/0621 |
| |
| 1990/0227 |
| |
| 1991/1106 | lanceup(p, len); | |
| 1991/0621 | ||
| 1990/0227 | stage: /* | |