| plan 9 kernel history: overview | file list | diff list |
1999/0608/mpc/devether.c (diff list | history)
| 1999/0508/sys/src/9/mpc/devether.c:12,19 – 1999/0608/sys/src/9/mpc/devether.c:12,17 (short | long | prev | next) | ||
| 1999/0121 | static Ether *etherxx[MaxEther]; | |
| 1999/0508/sys/src/9/mpc/devether.c:37,55 – 1999/0608/sys/src/9/mpc/devether.c:35,40 | ||
| 1999/0121 | return chan; } | |
| 1999/0508/sys/src/9/mpc/devether.c:76,93 – 1999/0608/sys/src/9/mpc/devether.c:61,74 | ||
| 1999/0121 | static void etherclose(Chan* chan) { | |
| 1999/0608 | netifclose(etherxx[chan->dev], chan); | |
| 1999/0121 | } static long | |
| 1999/0608 | etherread(Chan* chan, void* buf, long n, vlong off) | |
| 1999/0121 | { Ether *ether; | |
| 1999/0608 | ulong offset = off; | |
| 1999/0121 | ether = etherxx[chan->dev]; if((chan->qid.path & CHDIR) == 0 && ether->ifstat){ | |
| 1999/0508/sys/src/9/mpc/devether.c:153,159 – 1999/0608/sys/src/9/mpc/devether.c:134,140 | ||
| 1999/0121 | { Etherpkt *pkt; ushort type; | |
| 1999/0608 | int len, multi, forme; | |
| 1999/0121 | Netfile **ep, *f, **fp, *fx; Block *xbp; | |
| 1999/0508/sys/src/9/mpc/devether.c:165,172 – 1999/0608/sys/src/9/mpc/devether.c:146,154 | ||
| 1999/0121 | fx = 0; ep = ðer->f[Ntypes]; | |
| 1999/0608 | multi = pkt->d[0] & 1; | |
| 1999/0121 | /* check for valid multcast addresses */ | |
| 1999/0608 | if(multi && memcmp(pkt->d, ether->bcast, sizeof(pkt->d)) && ether->prom == 0){ | |
| 1999/0121 | if(!activemulti(ether, pkt->d, sizeof(pkt->d))){ if(freebp){ freeb(bp); | |
| 1999/0508/sys/src/9/mpc/devether.c:176,181 – 1999/0608/sys/src/9/mpc/devether.c:158,166 | ||
| 1999/0121 | } } | |
| 1999/0608 | // is it for me? forme = memcmp(pkt->d, ether->ea, sizeof(pkt->d)) == 0; | |
| 1999/0121 | /* * Multiplex the packet to all the connections which want it. * If the packet is not to be used subsequently (freebp != 0), | |
| 1999/0508/sys/src/9/mpc/devether.c:183,189 – 1999/0608/sys/src/9/mpc/devether.c:168,174 | ||
| 1999/0121 | * saving a copy of the data (usual case hopefully). */ for(fp = ether->f; fp < ep; fp++){ | |
| 1999/0608 | if((f = *fp) && (f->type == type || f->type < 0) && (forme || multi || f->prom)){ | |
| 1999/0121 | if(f->type > -2){ if(freebp && fx == 0) fx = f; | |
| 1999/0508/sys/src/9/mpc/devether.c:201,207 – 1999/0608/sys/src/9/mpc/devether.c:186,193 | ||
| 1999/0121 | } if(fx){ | |
| 1999/0608 | if(qpass(fx->in, bp) < 0) ether->soverflows++; | |
| 1999/0121 | return 0; } if(freebp){ | |
| 1999/0508/sys/src/9/mpc/devether.c:215,221 – 1999/0608/sys/src/9/mpc/devether.c:201,207 | ||
| 1999/0121 | static int etheroq(Ether* ether, Block* bp) { | |
| 1999/0608 | int len, loopback, s, mine; | |
| 1999/0121 | Etherpkt *pkt; ether->outpackets++; | |
| 1999/0508/sys/src/9/mpc/devether.c:226,235 – 1999/0608/sys/src/9/mpc/devether.c:212,225 | ||
| 1999/0121 | * in promiscuous mode. * If it's a loopback packet indicate to etheriq that the data isn't * needed and return, etheriq will pass-on or free the block. | |
| 1999/0608 | * To enable bridging to work, only packets that were originated * by this interface are fed back. | |
| 1999/0121 | */ pkt = (Etherpkt*)bp->rp; len = BLEN(bp); loopback = (memcmp(pkt->d, ether->ea, sizeof(pkt->d)) == 0); | |
| 1999/0608 | mine = memcmp(pkt->s, ether->ea, sizeof(pkt->s)) == 0; if(mine) | |
| 1999/0121 | if(loopback || memcmp(pkt->d, ether->bcast, sizeof(pkt->d)) == 0 || ether->prom){ s = splhi(); etheriq(ether, bp, loopback); | |
| 1999/0508/sys/src/9/mpc/devether.c:256,263 – 1999/0608/sys/src/9/mpc/devether.c:246,253 | ||
| 1999/0121 | if(n > ETHERMAXTU) error(Etoobig); | |
| 1999/0608 | if(n < ETHERMINTU) error(Etoosmall); | |
| 1999/0121 | bp = allocb(n); if(waserror()){ | |
| 1999/0508/sys/src/9/mpc/devether.c:279,285 – 1999/0608/sys/src/9/mpc/devether.c:269,274 | ||
| 1999/0121 | long n; n = BLEN(bp); | |
| 1999/0508/sys/src/9/mpc/devether.c:291,296 – 1999/0608/sys/src/9/mpc/devether.c:280,289 | ||
| 1999/0121 | freeb(bp); error(Ebadarg); } | |
| 1999/0608 | if(n < ETHERMINTU){ freeb(bp); error(Etoosmall); } | |
| 1999/0121 | return etheroq(ether, bp); } | |
| 1999/0508/sys/src/9/mpc/devether.c:304,310 – 1999/0608/sys/src/9/mpc/devether.c:297,303 | ||
| 1999/0121 | addethercard(char* t, int (*r)(Ether*)) { static int ncard; | |
| 1999/0508 |
| |
| 1999/0608 | ||
| 1999/0121 | if(ncard == MaxEther) panic("too many ether cards"); cards[ncard].type = t; | |
| 1999/0508/sys/src/9/mpc/devether.c:342,349 – 1999/0608/sys/src/9/mpc/devether.c:335,340 | ||
| 1999/0121 | int i, n, ctlrno; char name[NAMELEN], buf[128]; | |
| 1999/0508 |
| |
| 1999/0121 |
| |
| 1999/0508/sys/src/9/mpc/devether.c:353,361 – 1999/0608/sys/src/9/mpc/devether.c:344,350 | ||
| 1999/0121 | ether->mbps = 10; if(isaconfig("ether", ctlrno, ether) == 0) continue; | |
| 1999/0508 |
| |
| 1999/0121 | for(n = 0; cards[n].type; n++){ | |
| 1999/0508 |
| |
| 1999/0121 | if(cistrcmp(cards[n].type, ether->type)) continue; for(i = 0; i < ether->nopt; i++){ | |
| 1999/0508/sys/src/9/mpc/devether.c:367,375 – 1999/0608/sys/src/9/mpc/devether.c:356,371 | ||
| 1999/0121 | if(cards[n].reset(ether)) break; | |
| 1999/0608 | /* * IRQ2 doesn't really exist, it's used to gang the interrupt * controllers together. A device set to IRQ2 will appear on * the second interrupt controller as IRQ9. */ if(ether->irq == 2) ether->irq = 9; | |
| 1999/0121 | intrenable(ether->irq, ether->interrupt, ether, ether->tbdf); | |
| 1999/0608 | i = sprint(buf, "#l%d: %s: %dMbps port 0x%luX irq %lud", | |
| 1999/0121 | ctlrno, ether->type, ether->mbps, ether->port, ether->irq); if(ether->mem) i += sprint(buf+i, " addr 0x%luX", PADDR(ether->mem)); | |
| 1999/0508/sys/src/9/mpc/devether.c:388,396 – 1999/0608/sys/src/9/mpc/devether.c:384,392 | ||
| 1999/0121 | ether->oq = qopen(256*1024, 1, 0, 0); } else{ | |
| 1999/0608 | netifinit(ether, name, Ntypes, 65*1024); | |
| 1999/0121 | if(ether->oq == 0) | |
| 1999/0608 | ether->oq = qopen(65*1024, 1, 0, 0); | |
| 1999/0121 | } if(ether->oq == 0) panic("etherreset %s", name); | |
| 1999/0508/sys/src/9/mpc/devether.c:434,440 – 1999/0608/sys/src/9/mpc/devether.c:430,435 | ||
| 1999/0121 | etherreset, devinit, etherattach, | |