1*7163Ssam /* if_en.c 4.65 82/06/13 */ 24686Swnj 34686Swnj #include "en.h" 45105Swnj 54686Swnj /* 65105Swnj * Xerox prototype (3 Mb) Ethernet interface driver. 74686Swnj */ 84686Swnj 94686Swnj #include "../h/param.h" 104686Swnj #include "../h/systm.h" 114686Swnj #include "../h/mbuf.h" 124686Swnj #include "../h/pte.h" 134686Swnj #include "../h/buf.h" 145083Swnj #include "../h/protosw.h" 155083Swnj #include "../h/socket.h" 164686Swnj #include "../h/ubareg.h" 174686Swnj #include "../h/ubavar.h" 184686Swnj #include "../h/enreg.h" 195083Swnj #include "../h/cpu.h" 204686Swnj #include "../h/mtpr.h" 215083Swnj #include "../h/vmmac.h" 225083Swnj #include "../net/in.h" 235083Swnj #include "../net/in_systm.h" 245083Swnj #include "../net/if.h" 255083Swnj #include "../net/if_en.h" 265083Swnj #include "../net/if_uba.h" 275083Swnj #include "../net/ip.h" 285083Swnj #include "../net/ip_var.h" 296027Ssam #include "../net/pup.h" 306364Ssam #include "../net/route.h" 316503Ssam #include <errno.h> 324686Swnj 335213Swnj #define ENMTU (1024+512) 346925Swnj #define ENMRU (1024+512+16) /* 16 is enough to receive trailer */ 355083Swnj 364686Swnj int enprobe(), enattach(), enrint(), enxint(), encollide(); 374686Swnj struct uba_device *eninfo[NEN]; 384686Swnj u_short enstd[] = { 0 }; 394686Swnj struct uba_driver endriver = 405171Swnj { enprobe, 0, enattach, 0, enstd, "en", eninfo }; 414686Swnj #define ENUNIT(x) minor(x) 424686Swnj 435105Swnj int eninit(),enoutput(),enreset(); 445105Swnj 455105Swnj /* 465105Swnj * Ethernet software status per interface. 475105Swnj * 485105Swnj * Each interface is referenced by a network interface structure, 495105Swnj * es_if, which the routing code uses to locate the interface. 505105Swnj * This structure contains the output queue for the interface, its address, ... 515105Swnj * We also have, for each interface, a UBA interface structure, which 525105Swnj * contains information about the UNIBUS resources held by the interface: 535105Swnj * map registers, buffered data paths, etc. Information is cached in this 545105Swnj * structure for use by the if_uba.c routines in running the interface 555105Swnj * efficiently. 565105Swnj */ 575083Swnj struct en_softc { 585105Swnj struct ifnet es_if; /* network-visible interface */ 595105Swnj struct ifuba es_ifuba; /* UNIBUS resources */ 605105Swnj short es_delay; /* current output delay */ 615105Swnj short es_mask; /* mask for current output delay */ 626471Sroot short es_lastx; /* host last transmitted to */ 635105Swnj short es_oactive; /* is output active? */ 645105Swnj short es_olen; /* length of last output */ 655083Swnj } en_softc[NEN]; 664686Swnj 675105Swnj /* 685105Swnj * Do output DMA to determine interface presence and 695105Swnj * interrupt vector. DMA is too short to disturb other hosts. 705105Swnj */ 714686Swnj enprobe(reg) 724686Swnj caddr_t reg; 734686Swnj { 745171Swnj register int br, cvec; /* r11, r10 value-result */ 754686Swnj register struct endevice *addr = (struct endevice *)reg; 764686Swnj 775083Swnj COUNT(ENPROBE); 784686Swnj #ifdef lint 794686Swnj br = 0; cvec = br; br = cvec; 804922Swnj enrint(0); enxint(0); encollide(0); 814686Swnj #endif 824686Swnj addr->en_istat = 0; 834686Swnj addr->en_owc = -1; 844686Swnj addr->en_oba = 0; 854771Swnj addr->en_ostat = EN_IEN|EN_GO; 864686Swnj DELAY(100000); 874686Swnj addr->en_ostat = 0; 886575Ssam #ifdef ECHACK 896575Ssam br = 0x16; 906575Ssam #endif 914686Swnj return (1); 924686Swnj } 934686Swnj 945105Swnj /* 955105Swnj * Interface exists: make available by filling in network interface 965105Swnj * record. System will initialize the interface when it is ready 975105Swnj * to accept packets. 985105Swnj */ 994686Swnj enattach(ui) 1004686Swnj struct uba_device *ui; 1014686Swnj { 1025105Swnj register struct en_softc *es = &en_softc[ui->ui_unit]; 1036335Ssam register struct sockaddr_in *sin; 1045105Swnj COUNT(ENATTACH); 1054688Swnj 1065105Swnj es->es_if.if_unit = ui->ui_unit; 1075171Swnj es->es_if.if_name = "en"; 1085105Swnj es->es_if.if_mtu = ENMTU; 109*7163Ssam es->es_if.if_net = ui->ui_flags; 1105105Swnj es->es_if.if_host[0] = 1116335Ssam (~(((struct endevice *)eninfo[ui->ui_unit]->ui_addr)->en_addr)) & 0xff; 1126335Ssam sin = (struct sockaddr_in *)&es->es_if.if_addr; 1136335Ssam sin->sin_family = AF_INET; 1146335Ssam sin->sin_addr = if_makeaddr(es->es_if.if_net, es->es_if.if_host[0]); 1156335Ssam sin = (struct sockaddr_in *)&es->es_if.if_broadaddr; 1166335Ssam sin->sin_family = AF_INET; 1176335Ssam sin->sin_addr = if_makeaddr(es->es_if.if_net, 0); 1186335Ssam es->es_if.if_flags = IFF_BROADCAST; 1195171Swnj es->es_if.if_init = eninit; 1205105Swnj es->es_if.if_output = enoutput; 1215105Swnj es->es_if.if_ubareset = enreset; 1226554Ssam es->es_ifuba.ifu_flags = UBA_NEEDBDP | UBA_NEED16 | UBA_CANTWAIT; 1235160Swnj if_attach(&es->es_if); 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, 1566925Swnj sizeof (struct en_header), (int)btoc(ENMRU)) == 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; 1706925Swnj addr->en_iwc = -(sizeof (struct en_header) + ENMRU) >> 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); 1767151Swnj if_rtinit(&es->es_if, RTF_UP); 1774686Swnj } 1784686Swnj 1796471Sroot int enalldelay = 0; 1806951Swnj int enlastdel = 50; 1816471Sroot 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 2206471Sroot * buffering in interface. To help avoid overrunning 2216471Sroot * receivers, enforce a small delay (about 1ms) in interface: 2226471Sroot * * between all packets when enalldelay 2236471Sroot * * whenever last packet was broadcast 2246471Sroot * * whenever this packet is to same host as last packet 2255105Swnj */ 2266471Sroot if (enalldelay || es->es_lastx == 0 || es->es_lastx == dest) { 2275083Swnj es->es_delay = enlastdel; 2286471Sroot es->es_mask = enlastmask; 2296471Sroot } 2306471Sroot 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) { 2776471Sroot 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; 3436471Sroot 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 /* 3636471Sroot * 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 */ 3696471Sroot resid = addr->en_iwc; 3706471Sroot if (resid) 3716471Sroot resid |= 0176000; 3726925Swnj len = (((sizeof (struct en_header) + ENMRU) >> 1) + resid) << 1; 3736471Sroot len -= sizeof (struct en_header); 3746925Swnj if (len > ENMRU) 3756471Sroot 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; 3816925Swnj if (off > ENMTU) 3825171Swnj goto setup; /* sanity */ 3835083Swnj en->en_type = *endataaddr(en, off, u_short *); 3846471Sroot resid = *(endataaddr(en, off+2, u_short *)); 3856471Sroot if (off + resid > len) 3866471Sroot goto setup; /* sanity */ 3876471Sroot 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 3966471Sroot * 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) { 4026471Sroot m->m_off += 2 * sizeof (u_short); 4036471Sroot 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; 4206526Ssam raw_input(m, &pupproto, (struct sockaddr *)&pupsrc, 4216526Ssam (struct sockaddr *)&pupdst); 4226027Ssam goto setup; 4236027Ssam } 4246335Ssam #endif 4256476Swnj default: 4266476Swnj m_freem(m); 4276476Swnj goto setup; 4286335Ssam } 4296335Ssam 4306207Swnj if (IF_QFULL(inq)) { 4316207Swnj IF_DROP(inq); 4326335Ssam m_freem(m); 4336207Swnj } else 4346207Swnj IF_ENQUEUE(inq, m); 4355105Swnj 4364688Swnj setup: 4375105Swnj /* 4385105Swnj * Reset for next packet. 4395105Swnj */ 4405105Swnj addr->en_iba = es->es_ifuba.ifu_r.ifrw_info; 4416925Swnj addr->en_iwc = -(sizeof (struct en_header) + ENMRU) >> 1; 4424771Swnj addr->en_istat = EN_IEN|EN_GO; 4434688Swnj } 4444686Swnj 4455083Swnj /* 4465083Swnj * Ethernet output routine. 4475083Swnj * Encapsulate a packet of type family for the local net. 4485105Swnj * Use trailer local net encapsulation if enough data in first 4495105Swnj * packet leaves a multiple of 512 bytes of data in remainder. 4505083Swnj */ 4516335Ssam enoutput(ifp, m0, dst) 4525083Swnj struct ifnet *ifp; 4535083Swnj struct mbuf *m0; 4546335Ssam struct sockaddr *dst; 4554686Swnj { 4566503Ssam int type, dest, s, error; 4575105Swnj register struct mbuf *m = m0; 4585083Swnj register struct en_header *en; 4596335Ssam register int off; 4604686Swnj 4615927Sroot COUNT(ENOUTPUT); 4626335Ssam switch (dst->sa_family) { 4635083Swnj 4645083Swnj #ifdef INET 4656335Ssam case AF_INET: 4666484Swnj dest = ((struct sockaddr_in *)dst)->sin_addr.s_addr; 4676503Ssam if (dest & 0x00ffff00) { 4686503Ssam error = EPERM; /* ??? */ 4696486Swnj goto bad; 4706503Ssam } 4716484Swnj dest = (dest >> 24) & 0xff; 4726335Ssam off = ntohs((u_short)mtod(m, struct ip *)->ip_len) - m->m_len; 4736335Ssam if (off > 0 && (off & 0x1ff) == 0 && 4746471Sroot m->m_off >= MMINOFF + 2 * sizeof (u_short)) { 4755083Swnj type = ENPUP_TRAIL + (off>>9); 4766471Sroot m->m_off -= 2 * sizeof (u_short); 4776471Sroot m->m_len += 2 * sizeof (u_short); 4785105Swnj *mtod(m, u_short *) = ENPUP_IPTYPE; 4796471Sroot *(mtod(m, u_short *) + 1) = m->m_len; 4805105Swnj goto gottrailertype; 4815083Swnj } 4825105Swnj type = ENPUP_IPTYPE; 4835105Swnj off = 0; 4845105Swnj goto gottype; 4855083Swnj #endif 4866027Ssam #ifdef PUP 4876335Ssam case AF_PUP: 4886335Ssam dest = ((struct sockaddr_pup *)dst)->spup_addr.pp_host; 4896027Ssam type = ENPUP_PUPTYPE; 4906027Ssam off = 0; 4916027Ssam goto gottype; 4926027Ssam #endif 4936027Ssam 4945083Swnj default: 4956335Ssam printf("en%d: can't handle af%d\n", ifp->if_unit, 4966335Ssam dst->sa_family); 4976503Ssam error = EAFNOSUPPORT; 4986503Ssam goto bad; 4994686Swnj } 5005105Swnj 5015171Swnj gottrailertype: 5025105Swnj /* 5035105Swnj * Packet to be sent as trailer: move first packet 5045105Swnj * (control information) to end of chain. 5055105Swnj */ 5065105Swnj while (m->m_next) 5075105Swnj m = m->m_next; 5085105Swnj m->m_next = m0; 5095105Swnj m = m0->m_next; 5105105Swnj m0->m_next = 0; 5115171Swnj m0 = m; 5125105Swnj 5135171Swnj gottype: 5145105Swnj /* 5155105Swnj * Add local net header. If no space in first mbuf, 5165105Swnj * allocate another. 5175105Swnj */ 5185213Swnj if (m->m_off > MMAXOFF || 5195213Swnj MMINOFF + sizeof (struct en_header) > m->m_off) { 5205584Sroot m = m_get(M_DONTWAIT); 5215083Swnj if (m == 0) { 5226503Ssam error = ENOBUFS; 5236503Ssam goto bad; 5245083Swnj } 5255083Swnj m->m_next = m0; 5265083Swnj m->m_off = MMINOFF; 5275083Swnj m->m_len = sizeof (struct en_header); 5285083Swnj } else { 5295083Swnj m->m_off -= sizeof (struct en_header); 5305083Swnj m->m_len += sizeof (struct en_header); 5315083Swnj } 5325083Swnj en = mtod(m, struct en_header *); 5335083Swnj en->en_shost = ifp->if_host[0]; 5345083Swnj en->en_dhost = dest; 5355083Swnj en->en_type = type; 5365105Swnj 5375105Swnj /* 5385105Swnj * Queue message on interface, and start output if interface 5395105Swnj * not yet active. 5405105Swnj */ 5415083Swnj s = splimp(); 5426207Swnj if (IF_QFULL(&ifp->if_snd)) { 5436207Swnj IF_DROP(&ifp->if_snd); 5446503Ssam error = ENOBUFS; 5456503Ssam goto qfull; 5466207Swnj } 5475083Swnj IF_ENQUEUE(&ifp->if_snd, m); 5485083Swnj if (en_softc[ifp->if_unit].es_oactive == 0) 5495083Swnj enstart(ifp->if_unit); 5505275Swnj splx(s); 5516503Ssam return (0); 5526503Ssam qfull: 5536503Ssam m0 = m; 5546503Ssam splx(s); 5556484Swnj bad: 5566503Ssam m_freem(m0); 5576503Ssam return (error); 5584686Swnj } 559