1*6471Sroot /* if_en.c 4.50 82/04/04 */ 24686Swnj 34686Swnj #include "en.h" 46410Ssam #include "imp.h" 55105Swnj 64686Swnj /* 75105Swnj * Xerox prototype (3 Mb) Ethernet interface driver. 84686Swnj */ 94686Swnj 104686Swnj #include "../h/param.h" 114686Swnj #include "../h/systm.h" 124686Swnj #include "../h/mbuf.h" 134686Swnj #include "../h/pte.h" 144686Swnj #include "../h/buf.h" 155083Swnj #include "../h/protosw.h" 165083Swnj #include "../h/socket.h" 174686Swnj #include "../h/ubareg.h" 184686Swnj #include "../h/ubavar.h" 194686Swnj #include "../h/enreg.h" 205083Swnj #include "../h/cpu.h" 214686Swnj #include "../h/mtpr.h" 225083Swnj #include "../h/vmmac.h" 235083Swnj #include "../net/in.h" 245083Swnj #include "../net/in_systm.h" 255083Swnj #include "../net/if.h" 265083Swnj #include "../net/if_en.h" 275083Swnj #include "../net/if_uba.h" 285083Swnj #include "../net/ip.h" 295083Swnj #include "../net/ip_var.h" 306027Ssam #include "../net/pup.h" 316364Ssam #include "../net/route.h" 324686Swnj 335213Swnj #define ENMTU (1024+512) 345083Swnj 354686Swnj int enprobe(), enattach(), enrint(), enxint(), encollide(); 364686Swnj struct uba_device *eninfo[NEN]; 374686Swnj u_short enstd[] = { 0 }; 384686Swnj struct uba_driver endriver = 395171Swnj { enprobe, 0, enattach, 0, enstd, "en", eninfo }; 404686Swnj #define ENUNIT(x) minor(x) 414686Swnj 425105Swnj int eninit(),enoutput(),enreset(); 435105Swnj 445105Swnj /* 455105Swnj * Ethernet software status per interface. 465105Swnj * 475105Swnj * Each interface is referenced by a network interface structure, 485105Swnj * es_if, which the routing code uses to locate the interface. 495105Swnj * This structure contains the output queue for the interface, its address, ... 505105Swnj * We also have, for each interface, a UBA interface structure, which 515105Swnj * contains information about the UNIBUS resources held by the interface: 525105Swnj * map registers, buffered data paths, etc. Information is cached in this 535105Swnj * structure for use by the if_uba.c routines in running the interface 545105Swnj * efficiently. 555105Swnj */ 565083Swnj struct en_softc { 575105Swnj struct ifnet es_if; /* network-visible interface */ 585105Swnj struct ifuba es_ifuba; /* UNIBUS resources */ 595105Swnj short es_delay; /* current output delay */ 605105Swnj short es_mask; /* mask for current output delay */ 61*6471Sroot short es_lastx; /* host last transmitted to */ 625105Swnj short es_oactive; /* is output active? */ 635105Swnj short es_olen; /* length of last output */ 645083Swnj } en_softc[NEN]; 654686Swnj 665105Swnj /* 675105Swnj * Do output DMA to determine interface presence and 685105Swnj * interrupt vector. DMA is too short to disturb other hosts. 695105Swnj */ 704686Swnj enprobe(reg) 714686Swnj caddr_t reg; 724686Swnj { 735171Swnj register int br, cvec; /* r11, r10 value-result */ 744686Swnj register struct endevice *addr = (struct endevice *)reg; 754686Swnj 765083Swnj COUNT(ENPROBE); 774686Swnj #ifdef lint 784686Swnj br = 0; cvec = br; br = cvec; 794922Swnj enrint(0); enxint(0); encollide(0); 804686Swnj #endif 814686Swnj addr->en_istat = 0; 824686Swnj addr->en_owc = -1; 834686Swnj addr->en_oba = 0; 844771Swnj addr->en_ostat = EN_IEN|EN_GO; 854686Swnj DELAY(100000); 864686Swnj addr->en_ostat = 0; 874686Swnj return (1); 884686Swnj } 894686Swnj 905105Swnj /* 915105Swnj * Interface exists: make available by filling in network interface 925105Swnj * record. System will initialize the interface when it is ready 935105Swnj * to accept packets. 945105Swnj */ 954686Swnj enattach(ui) 964686Swnj struct uba_device *ui; 974686Swnj { 985105Swnj register struct en_softc *es = &en_softc[ui->ui_unit]; 996335Ssam register struct sockaddr_in *sin; 1005105Swnj COUNT(ENATTACH); 1014688Swnj 1025105Swnj es->es_if.if_unit = ui->ui_unit; 1035171Swnj es->es_if.if_name = "en"; 1045105Swnj es->es_if.if_mtu = ENMTU; 1056433Ssam es->es_if.if_net = ui->ui_flags & 0xff; 1065105Swnj es->es_if.if_host[0] = 1076335Ssam (~(((struct endevice *)eninfo[ui->ui_unit]->ui_addr)->en_addr)) & 0xff; 1086335Ssam sin = (struct sockaddr_in *)&es->es_if.if_addr; 1096335Ssam sin->sin_family = AF_INET; 1106335Ssam sin->sin_addr = if_makeaddr(es->es_if.if_net, es->es_if.if_host[0]); 1116335Ssam sin = (struct sockaddr_in *)&es->es_if.if_broadaddr; 1126335Ssam sin->sin_family = AF_INET; 1136335Ssam sin->sin_addr = if_makeaddr(es->es_if.if_net, 0); 1146335Ssam es->es_if.if_flags = IFF_BROADCAST; 1155171Swnj es->es_if.if_init = eninit; 1165105Swnj es->es_if.if_output = enoutput; 1175105Swnj es->es_if.if_ubareset = enreset; 1185696Sroot es->es_ifuba.ifu_flags = UBA_NEEDBDP | UBA_NEED16; 1195160Swnj if_attach(&es->es_if); 1206410Ssam #if NIMP == 0 1216410Ssam /* here's one for you john baby.... */ 1226422Sroot enlhinit((ui->ui_flags &~ 0xff) | 0x0a); 1236410Ssam #endif 1244686Swnj } 1254686Swnj 1265105Swnj /* 1275105Swnj * Reset of interface after UNIBUS reset. 1285105Swnj * If interface is on specified uba, reset its state. 1295105Swnj */ 1305105Swnj enreset(unit, uban) 1315105Swnj int unit, uban; 1325105Swnj { 1335105Swnj register struct uba_device *ui; 1345105Swnj COUNT(ENRESET); 1355105Swnj 1365171Swnj if (unit >= NEN || (ui = eninfo[unit]) == 0 || ui->ui_alive == 0 || 1375171Swnj ui->ui_ubanum != uban) 1385105Swnj return; 1395171Swnj printf(" en%d", unit); 1405105Swnj eninit(unit); 1415105Swnj } 1425105Swnj 1435105Swnj /* 1445105Swnj * Initialization of interface; clear recorded pending 1455105Swnj * operations, and reinitialize UNIBUS usage. 1465105Swnj */ 1474688Swnj eninit(unit) 1484686Swnj int unit; 1495083Swnj { 1505171Swnj register struct en_softc *es = &en_softc[unit]; 1515171Swnj register struct uba_device *ui = eninfo[unit]; 1524686Swnj register struct endevice *addr; 1535105Swnj int s; 1544686Swnj 1555105Swnj if (if_ubainit(&es->es_ifuba, ui->ui_ubanum, 1565708Sroot sizeof (struct en_header), (int)btoc(ENMTU)) == 0) { 1575171Swnj printf("en%d: can't initialize\n", unit); 1586335Ssam es->es_if.if_flags &= ~IFF_UP; 1595083Swnj return; 1604686Swnj } 1614686Swnj addr = (struct endevice *)ui->ui_addr; 1625083Swnj addr->en_istat = addr->en_ostat = 0; 1634686Swnj 1645105Swnj /* 1655171Swnj * Hang a receive and start any 1665171Swnj * pending writes by faking a transmit complete. 1675105Swnj */ 1685105Swnj s = splimp(); 1695171Swnj addr->en_iba = es->es_ifuba.ifu_r.ifrw_info; 1705171Swnj addr->en_iwc = -(sizeof (struct en_header) + ENMTU) >> 1; 1715171Swnj addr->en_istat = EN_IEN|EN_GO; 1725171Swnj es->es_oactive = 1; 1736335Ssam es->es_if.if_flags |= IFF_UP; 1745105Swnj enxint(unit); 1755105Swnj splx(s); 1766364Ssam if_rtinit(&es->es_if, RTF_DIRECT|RTF_UP); 1774686Swnj } 1784686Swnj 179*6471Sroot int enalldelay = 0; 1804717Swnj int enlastdel = 25; 181*6471Sroot int enlastmask = (~0) << 5; 1825083Swnj 1835105Swnj /* 1845105Swnj * Start or restart output on interface. 1855105Swnj * If interface is already active, then this is a retransmit 1865105Swnj * after a collision, and just restuff registers and delay. 1875105Swnj * If interface is not already active, get another datagram 1885105Swnj * to send off of the interface queue, and map it to the interface 1895105Swnj * before starting the output. 1905105Swnj */ 1914688Swnj enstart(dev) 1924686Swnj dev_t dev; 1934686Swnj { 1945171Swnj int unit = ENUNIT(dev); 1955171Swnj struct uba_device *ui = eninfo[unit]; 1965171Swnj register struct en_softc *es = &en_softc[unit]; 1975083Swnj register struct endevice *addr; 1985083Swnj struct mbuf *m; 1995083Swnj int dest; 2004688Swnj COUNT(ENSTART); 2014686Swnj 2025083Swnj if (es->es_oactive) 2035083Swnj goto restart; 2045105Swnj 2055105Swnj /* 2065105Swnj * Not already active: dequeue another request 2075105Swnj * and map it to the UNIBUS. If no more requests, 2085105Swnj * just return. 2095105Swnj */ 2105105Swnj IF_DEQUEUE(&es->es_if.if_snd, m); 2115083Swnj if (m == 0) { 2125083Swnj es->es_oactive = 0; 2134686Swnj return; 2144686Swnj } 2155213Swnj dest = mtod(m, struct en_header *)->en_dhost; 2165105Swnj es->es_olen = if_wubaput(&es->es_ifuba, m); 2175105Swnj 2185105Swnj /* 2195105Swnj * Ethernet cannot take back-to-back packets (no 220*6471Sroot * buffering in interface. To help avoid overrunning 221*6471Sroot * receivers, enforce a small delay (about 1ms) in interface: 222*6471Sroot * * between all packets when enalldelay 223*6471Sroot * * whenever last packet was broadcast 224*6471Sroot * * whenever this packet is to same host as last packet 2255105Swnj */ 226*6471Sroot if (enalldelay || es->es_lastx == 0 || es->es_lastx == dest) { 2275083Swnj es->es_delay = enlastdel; 228*6471Sroot es->es_mask = enlastmask; 229*6471Sroot } 230*6471Sroot es->es_lastx = dest; 2315105Swnj 2325083Swnj restart: 2335105Swnj /* 2345105Swnj * Have request mapped to UNIBUS for transmission. 2355105Swnj * Purge any stale data from this BDP, and start the otput. 2365105Swnj */ 2376335Ssam if (es->es_ifuba.ifu_flags & UBA_NEEDBDP) 2386335Ssam UBAPURGE(es->es_ifuba.ifu_uba, es->es_ifuba.ifu_w.ifrw_bdp); 2394686Swnj addr = (struct endevice *)ui->ui_addr; 2405160Swnj addr->en_oba = (int)es->es_ifuba.ifu_w.ifrw_info; 2415083Swnj addr->en_odelay = es->es_delay; 2425083Swnj addr->en_owc = -((es->es_olen + 1) >> 1); 2434771Swnj addr->en_ostat = EN_IEN|EN_GO; 2445083Swnj es->es_oactive = 1; 2454686Swnj } 2464686Swnj 2475105Swnj /* 2485105Swnj * Ethernet interface transmitter interrupt. 2495105Swnj * Start another output if more data to send. 2505105Swnj */ 2514686Swnj enxint(unit) 2524686Swnj int unit; 2534686Swnj { 2545171Swnj register struct uba_device *ui = eninfo[unit]; 2555171Swnj register struct en_softc *es = &en_softc[unit]; 2566242Sroot register struct endevice *addr = (struct endevice *)ui->ui_addr; 2574686Swnj COUNT(ENXINT); 2584686Swnj 2595083Swnj if (es->es_oactive == 0) 2605083Swnj return; 2616242Sroot if (es->es_mask && (addr->en_ostat&EN_OERROR)) { 2626242Sroot es->es_if.if_oerrors++; 2636242Sroot if (es->es_if.if_oerrors % 100 == 0) 2646242Sroot printf("en%d: += 100 output errors\n", unit); 2656242Sroot endocoll(unit); 2666242Sroot return; 2676242Sroot } 2685171Swnj es->es_if.if_opackets++; 2695083Swnj es->es_oactive = 0; 2705083Swnj es->es_delay = 0; 2715083Swnj es->es_mask = ~0; 2725696Sroot if (es->es_ifuba.ifu_xtofree) { 2735696Sroot m_freem(es->es_ifuba.ifu_xtofree); 2745696Sroot es->es_ifuba.ifu_xtofree = 0; 2755696Sroot } 2765105Swnj if (es->es_if.if_snd.ifq_head == 0) { 277*6471Sroot es->es_lastx = 256; /* putatively illegal */ 2784686Swnj return; 2794686Swnj } 2805083Swnj enstart(unit); 2814686Swnj } 2824686Swnj 2835105Swnj /* 2845105Swnj * Collision on ethernet interface. Do exponential 2855105Swnj * backoff, and retransmit. If have backed off all 2866335Ssam * the way print warning diagnostic, and drop packet. 2875105Swnj */ 2884686Swnj encollide(unit) 2894686Swnj int unit; 2904686Swnj { 2916242Sroot struct en_softc *es = &en_softc[unit]; 2924686Swnj COUNT(ENCOLLIDE); 2934686Swnj 2945105Swnj es->es_if.if_collisions++; 2955083Swnj if (es->es_oactive == 0) 2964686Swnj return; 2976242Sroot endocoll(unit); 2986242Sroot } 2996242Sroot 3006242Sroot endocoll(unit) 3016242Sroot int unit; 3026242Sroot { 3036242Sroot register struct en_softc *es = &en_softc[unit]; 3046242Sroot 3055171Swnj /* 3065171Swnj * Es_mask is a 16 bit number with n low zero bits, with 3075171Swnj * n the number of backoffs. When es_mask is 0 we have 3085171Swnj * backed off 16 times, and give up. 3095171Swnj */ 3105083Swnj if (es->es_mask == 0) { 3115213Swnj printf("en%d: send error\n", unit); 3125083Swnj enxint(unit); 3135171Swnj return; 3144686Swnj } 3155171Swnj /* 3165171Swnj * Another backoff. Restart with delay based on n low bits 3175171Swnj * of the interval timer. 3185171Swnj */ 3195171Swnj es->es_mask <<= 1; 3205171Swnj es->es_delay = mfpr(ICR) &~ es->es_mask; 3215171Swnj enstart(unit); 3224686Swnj } 3234686Swnj 3246027Ssam struct sockaddr_pup pupsrc = { AF_PUP }; 3256027Ssam struct sockaddr_pup pupdst = { AF_PUP }; 3266027Ssam struct sockproto pupproto = { PF_PUP }; 3275105Swnj /* 3285105Swnj * Ethernet interface receiver interrupt. 3295105Swnj * If input error just drop packet. 3305105Swnj * Otherwise purge input buffered data path and examine 3315105Swnj * packet to determine type. If can't determine length 3325105Swnj * from type, then have to drop packet. Othewise decapsulate 3335105Swnj * packet based on type and pass to type specific higher-level 3345105Swnj * input routine. 3355105Swnj */ 3364686Swnj enrint(unit) 3374686Swnj int unit; 3384686Swnj { 3395171Swnj register struct en_softc *es = &en_softc[unit]; 3405171Swnj struct endevice *addr = (struct endevice *)eninfo[unit]->ui_addr; 3415171Swnj register struct en_header *en; 3425083Swnj struct mbuf *m; 343*6471Sroot int len, plen; short resid; 3445171Swnj register struct ifqueue *inq; 3455083Swnj int off; 3464686Swnj COUNT(ENRINT); 3474686Swnj 3485171Swnj es->es_if.if_ipackets++; 3495105Swnj 3505105Swnj /* 3515171Swnj * Purge BDP; drop if input error indicated. 3525105Swnj */ 3536335Ssam if (es->es_ifuba.ifu_flags & UBA_NEEDBDP) 3546335Ssam UBAPURGE(es->es_ifuba.ifu_uba, es->es_ifuba.ifu_r.ifrw_bdp); 3554771Swnj if (addr->en_istat&EN_IERROR) { 3565105Swnj es->es_if.if_ierrors++; 3576238Sroot if (es->es_if.if_ierrors % 100 == 0) 3586238Sroot printf("en%d: += 100 input errors\n", unit); 3595083Swnj goto setup; 3604686Swnj } 3615105Swnj 3625105Swnj /* 363*6471Sroot * Calculate input data length. 3645105Swnj * Get pointer to ethernet header (in input buffer). 3655105Swnj * Deal with trailer protocol: if type is PUP trailer 3665105Swnj * get true type from first 16-bit word past data. 3675105Swnj * Remember that type was trailer by setting off. 3685105Swnj */ 369*6471Sroot resid = addr->en_iwc; 370*6471Sroot if (resid) 371*6471Sroot resid |= 0176000; 372*6471Sroot len = (((sizeof (struct en_header) + ENMTU) >> 1) + resid) << 1; 373*6471Sroot len -= sizeof (struct en_header); 374*6471Sroot if (len >= ENMTU) 375*6471Sroot goto setup; /* sanity */ 3765105Swnj en = (struct en_header *)(es->es_ifuba.ifu_r.ifrw_addr); 3775083Swnj #define endataaddr(en, off, type) ((type)(((caddr_t)((en)+1)+(off)))) 3785083Swnj if (en->en_type >= ENPUP_TRAIL && 3795083Swnj en->en_type < ENPUP_TRAIL+ENPUP_NTRAILER) { 3805083Swnj off = (en->en_type - ENPUP_TRAIL) * 512; 3815171Swnj if (off >= ENMTU) 3825171Swnj goto setup; /* sanity */ 3835083Swnj en->en_type = *endataaddr(en, off, u_short *); 384*6471Sroot resid = *(endataaddr(en, off+2, u_short *)); 385*6471Sroot if (off + resid > len) 386*6471Sroot goto setup; /* sanity */ 387*6471Sroot len = off + resid; 3885083Swnj } else 3895083Swnj off = 0; 3905083Swnj if (len == 0) 3915083Swnj goto setup; 3925105Swnj /* 3935105Swnj * Pull packet off interface. Off is nonzero if packet 3945105Swnj * has trailing header; if_rubaget will then force this header 3955105Swnj * information to be at the front, but we still have to drop 396*6471Sroot * the type and length which are at the front of any trailer data. 3975105Swnj */ 3985105Swnj m = if_rubaget(&es->es_ifuba, len, off); 3995213Swnj if (m == 0) 4005213Swnj goto setup; 4015105Swnj if (off) { 402*6471Sroot m->m_off += 2 * sizeof (u_short); 403*6471Sroot m->m_len -= 2 * sizeof (u_short); 4045105Swnj } 4056027Ssam switch (en->en_type) { 4066027Ssam 4076027Ssam #ifdef INET 4086027Ssam case ENPUP_IPTYPE: 4096260Swnj schednetisr(NETISR_IP); 4106027Ssam inq = &ipintrq; 4116027Ssam break; 4126027Ssam #endif 4136335Ssam #ifdef PUP 4146027Ssam case ENPUP_PUPTYPE: { 4156027Ssam struct pup_header *pup = mtod(m, struct pup_header *); 4166027Ssam 4176027Ssam pupproto.sp_protocol = pup->pup_type; 4186027Ssam pupdst.spup_addr = pup->pup_dport; 4196027Ssam pupsrc.spup_addr = pup->pup_sport; 4206159Ssam raw_input(m, &pupproto, (struct sockaddr *)&pupdst, 4216335Ssam (struct sockaddr *)&pupsrc); 4226027Ssam goto setup; 4236027Ssam } 4246335Ssam #endif 4256335Ssam } 4266335Ssam 4276207Swnj if (IF_QFULL(inq)) { 4286207Swnj IF_DROP(inq); 4296335Ssam m_freem(m); 4306207Swnj } else 4316207Swnj IF_ENQUEUE(inq, m); 4325105Swnj 4334688Swnj setup: 4345105Swnj /* 4355105Swnj * Reset for next packet. 4365105Swnj */ 4375105Swnj addr->en_iba = es->es_ifuba.ifu_r.ifrw_info; 4385083Swnj addr->en_iwc = -(sizeof (struct en_header) + ENMTU) >> 1; 4394771Swnj addr->en_istat = EN_IEN|EN_GO; 4404688Swnj } 4414686Swnj 4425083Swnj /* 4435083Swnj * Ethernet output routine. 4445083Swnj * Encapsulate a packet of type family for the local net. 4455105Swnj * Use trailer local net encapsulation if enough data in first 4465105Swnj * packet leaves a multiple of 512 bytes of data in remainder. 4475083Swnj */ 4486335Ssam enoutput(ifp, m0, dst) 4495083Swnj struct ifnet *ifp; 4505083Swnj struct mbuf *m0; 4516335Ssam struct sockaddr *dst; 4524686Swnj { 4536335Ssam int type, dest, s; 4545105Swnj register struct mbuf *m = m0; 4555083Swnj register struct en_header *en; 4566335Ssam register int off; 4574686Swnj 4585927Sroot COUNT(ENOUTPUT); 4596335Ssam switch (dst->sa_family) { 4605083Swnj 4615083Swnj #ifdef INET 4626335Ssam case AF_INET: 4636335Ssam dest = ((struct sockaddr_in *)dst)->sin_addr.s_addr >> 24; 4646335Ssam off = ntohs((u_short)mtod(m, struct ip *)->ip_len) - m->m_len; 4656335Ssam if (off > 0 && (off & 0x1ff) == 0 && 466*6471Sroot m->m_off >= MMINOFF + 2 * sizeof (u_short)) { 4675083Swnj type = ENPUP_TRAIL + (off>>9); 468*6471Sroot m->m_off -= 2 * sizeof (u_short); 469*6471Sroot m->m_len += 2 * sizeof (u_short); 4705105Swnj *mtod(m, u_short *) = ENPUP_IPTYPE; 471*6471Sroot *(mtod(m, u_short *) + 1) = m->m_len; 4725105Swnj goto gottrailertype; 4735083Swnj } 4745105Swnj type = ENPUP_IPTYPE; 4755105Swnj off = 0; 4765105Swnj goto gottype; 4775083Swnj #endif 4786027Ssam #ifdef PUP 4796335Ssam case AF_PUP: 4806335Ssam dest = ((struct sockaddr_pup *)dst)->spup_addr.pp_host; 4816027Ssam type = ENPUP_PUPTYPE; 4826027Ssam off = 0; 4836027Ssam goto gottype; 4846027Ssam #endif 4856027Ssam 4865083Swnj default: 4876335Ssam printf("en%d: can't handle af%d\n", ifp->if_unit, 4886335Ssam dst->sa_family); 4895083Swnj m_freem(m0); 4905083Swnj return (0); 4914686Swnj } 4925105Swnj 4935171Swnj gottrailertype: 4945105Swnj /* 4955105Swnj * Packet to be sent as trailer: move first packet 4965105Swnj * (control information) to end of chain. 4975105Swnj */ 4985105Swnj while (m->m_next) 4995105Swnj m = m->m_next; 5005105Swnj m->m_next = m0; 5015105Swnj m = m0->m_next; 5025105Swnj m0->m_next = 0; 5035171Swnj m0 = m; 5045105Swnj 5055171Swnj gottype: 5065105Swnj /* 5075105Swnj * Add local net header. If no space in first mbuf, 5085105Swnj * allocate another. 5095105Swnj */ 5105213Swnj if (m->m_off > MMAXOFF || 5115213Swnj MMINOFF + sizeof (struct en_header) > m->m_off) { 5125584Sroot m = m_get(M_DONTWAIT); 5135083Swnj if (m == 0) { 5145083Swnj m_freem(m0); 5155083Swnj return (0); 5165083Swnj } 5175083Swnj m->m_next = m0; 5185083Swnj m->m_off = MMINOFF; 5195083Swnj m->m_len = sizeof (struct en_header); 5205083Swnj } else { 5215083Swnj m->m_off -= sizeof (struct en_header); 5225083Swnj m->m_len += sizeof (struct en_header); 5235083Swnj } 5245083Swnj en = mtod(m, struct en_header *); 5255083Swnj en->en_shost = ifp->if_host[0]; 5265083Swnj en->en_dhost = dest; 5275083Swnj en->en_type = type; 5285105Swnj 5295105Swnj /* 5305105Swnj * Queue message on interface, and start output if interface 5315105Swnj * not yet active. 5325105Swnj */ 5335083Swnj s = splimp(); 5346207Swnj if (IF_QFULL(&ifp->if_snd)) { 5356207Swnj IF_DROP(&ifp->if_snd); 5366207Swnj m_freem(m); 5376207Swnj splx(s); 5386207Swnj return (0); 5396207Swnj } 5405083Swnj IF_ENQUEUE(&ifp->if_snd, m); 5415083Swnj if (en_softc[ifp->if_unit].es_oactive == 0) 5425083Swnj enstart(ifp->if_unit); 5435275Swnj splx(s); 5445105Swnj return (1); 5454686Swnj } 5466410Ssam 5476410Ssam #if NIMP == 0 && NEN > 0 5486410Ssam /* 5496410Ssam * Logical host interface driver. 5506410Ssam * Allows host to appear as an ARPAnet 5516410Ssam * logical host. Must also have routing 5526410Ssam * table entry set up to forward packets 5536410Ssam * to appropriate gateway on localnet. 5546410Ssam */ 5556410Ssam 5566410Ssam struct ifnet enlhif; 5576410Ssam int enlhoutput(); 5586410Ssam 5596410Ssam /* 5606410Ssam * Called by localnet interface to allow logical 5616410Ssam * host interface to "attach". Nothing should ever 5626410Ssam * be sent locally to this interface, it's purpose 5636410Ssam * is simply to establish the host's arpanet address. 5646410Ssam */ 5656410Ssam enlhinit(addr) 5666410Ssam int addr; 5676410Ssam { 5686410Ssam register struct ifnet *ifp = &enlhif; 5696410Ssam register struct sockaddr_in *sin; 5706410Ssam 5716410Ssam COUNT(ENLHINIT); 5726410Ssam ifp->if_name = "lh"; 5736410Ssam ifp->if_mtu = ENMTU; 5746410Ssam sin = (struct sockaddr_in *)&ifp->if_addr; 5756410Ssam sin->sin_family = AF_INET; 5766410Ssam sin->sin_addr.s_addr = addr; 5776410Ssam ifp->if_net = sin->sin_addr.s_net; 5786410Ssam ifp->if_flags = IFF_UP; 5796410Ssam ifp->if_output = enlhoutput; /* should never be used */ 5806410Ssam if_attach(ifp); 5816410Ssam } 5826410Ssam 5836410Ssam enlhoutput(ifp, m0, dst) 5846410Ssam struct ifnet *ifp; 5856410Ssam struct mbuf *m0; 5866410Ssam struct sockaddr *dst; 5876410Ssam { 5886410Ssam COUNT(ENLHOUTPUT); 5896410Ssam ifp->if_oerrors++; 5906410Ssam m_freem(m0); 5916410Ssam return (0); 5926410Ssam } 5936410Ssam #endif 594