1*6599Ssam /* if_imp.c 4.29 82/04/28 */ 25640Sroot 35640Sroot #include "imp.h" 45640Sroot #if NIMP > 0 55640Sroot /* 66582Ssam * ARPANET IMP interface driver. 75640Sroot * 85640Sroot * The IMP-host protocol is handled here, leaving 95640Sroot * hardware specifics to the lower level interface driver. 105640Sroot */ 115640Sroot #include "../h/param.h" 125640Sroot #include "../h/systm.h" 135640Sroot #include "../h/mbuf.h" 145640Sroot #include "../h/pte.h" 155640Sroot #include "../h/buf.h" 165640Sroot #include "../h/protosw.h" 175640Sroot #include "../h/socket.h" 185640Sroot #include "../h/ubareg.h" 195640Sroot #include "../h/ubavar.h" 205640Sroot #include "../h/cpu.h" 215640Sroot #include "../h/mtpr.h" 225640Sroot #include "../h/vmmac.h" 235640Sroot #include "../net/in.h" 245640Sroot #include "../net/in_systm.h" 255640Sroot #include "../net/if.h" 265640Sroot #include "../net/if_imp.h" 275859Sroot #include "../net/if_imphost.h" 285640Sroot #include "../net/ip.h" 295640Sroot #include "../net/ip_var.h" 306365Ssam #include "../net/route.h" 316504Ssam #include <errno.h> 325640Sroot 335640Sroot /* 345640Sroot * IMP software status per interface. 355640Sroot * (partially shared with the hardware specific module) 365640Sroot * 375640Sroot * Each interface is referenced by a network interface structure, 385640Sroot * imp_if, which the routing code uses to locate the interface. 395640Sroot * This structure contains the output queue for the interface, its 405640Sroot * address, ... IMP specific structures used in connecting the 415640Sroot * IMP software modules to the hardware specific interface routines 425771Swnj * are stored here. The common structures are made visible to the 435771Swnj * interface driver by passing a pointer to the hardware routine 445771Swnj * at "attach" time. 455640Sroot * 465640Sroot * NOTE: imp_if and imp_cb are assumed adjacent in hardware code. 475640Sroot */ 485640Sroot struct imp_softc { 495640Sroot struct ifnet imp_if; /* network visible interface */ 505640Sroot struct impcb imp_cb; /* hooks to hardware module */ 515640Sroot u_char imp_state; /* current state of IMP */ 525640Sroot char imp_dropcnt; /* used during initialization */ 535640Sroot } imp_softc[NIMP]; 545640Sroot 555640Sroot /* 565640Sroot * Messages from IMP regarding why 575640Sroot * it's going down. 585640Sroot */ 595924Sroot static char *impmessage[] = { 605640Sroot "in 30 seconds", 615640Sroot "for hardware PM", 625640Sroot "to reload software", 635640Sroot "for emergency reset" 645640Sroot }; 655640Sroot 665771Swnj int impdown(), impinit(), impoutput(); 675771Swnj 685640Sroot /* 695640Sroot * IMP attach routine. Called from hardware device attach routine 705640Sroot * at configuration time with a pointer to the UNIBUS device structure. 715640Sroot * Sets up local state and returns pointer to base of ifnet+impcb 725640Sroot * structures. This is then used by the device's attach routine 735640Sroot * set up its back pointers. 745640Sroot */ 755640Sroot impattach(ui) 765640Sroot struct uba_device *ui; 775640Sroot { 785640Sroot struct imp_softc *sc = &imp_softc[ui->ui_unit]; 795640Sroot register struct ifnet *ifp = &sc->imp_if; 806336Ssam struct sockaddr_in *sin; 815640Sroot 825640Sroot COUNT(IMPATTACH); 835640Sroot /* UNIT COULD BE AMBIGUOUS */ 845640Sroot ifp->if_unit = ui->ui_unit; 855640Sroot ifp->if_name = "imp"; 866271Sroot ifp->if_mtu = IMPMTU - sizeof(struct imp_leader); 875640Sroot ifp->if_net = ui->ui_flags; 885989Sroot /* the host and imp fields will be filled in by the imp */ 896336Ssam sin = (struct sockaddr_in *)&ifp->if_addr; 906336Ssam sin->sin_family = AF_INET; 916336Ssam sin->sin_addr = if_makeaddr(ifp->if_net, 0); 925771Swnj ifp->if_init = impinit; 935771Swnj ifp->if_output = impoutput; 945771Swnj /* reset is handled at the hardware level */ 955640Sroot if_attach(ifp); 965640Sroot return ((int)&sc->imp_if); 975640Sroot } 985640Sroot 995640Sroot /* 1005640Sroot * IMP initialization routine: call hardware module to 1015640Sroot * setup UNIBUS resources, init state and get ready for 1025640Sroot * NOOPs the IMP should send us, and that we want to drop. 1035640Sroot */ 1045640Sroot impinit(unit) 1055640Sroot int unit; 1065640Sroot { 1076500Ssam int s = splimp(); 1085640Sroot register struct imp_softc *sc = &imp_softc[unit]; 1095640Sroot 1106500Ssam COUNT(IMPINIT); 1115771Swnj if ((*sc->imp_cb.ic_init)(unit) == 0) { 1125771Swnj sc->imp_state = IMPS_DOWN; 1136336Ssam sc->imp_if.if_flags &= ~IFF_UP; 1146500Ssam splx(s); 1155771Swnj return; 1165771Swnj } 1175640Sroot sc->imp_state = IMPS_INIT; 1185771Swnj impnoops(sc); 1196365Ssam if_rtinit(&sc->imp_if, RTF_DIRECT|RTF_UP); 1206500Ssam splx(s); 1215640Sroot } 1225640Sroot 1235640Sroot struct sockproto impproto = { PF_IMPLINK }; 1245645Ssam struct sockaddr_in impdst = { AF_IMPLINK }; 1255645Ssam struct sockaddr_in impsrc = { AF_IMPLINK }; 1265640Sroot 1275640Sroot /* 1285640Sroot * ARPAnet 1822 input routine. 1295640Sroot * Called from hardware input interrupt routine to handle 1822 1305640Sroot * IMP-host messages. Type 0 messages (non-control) are 1315640Sroot * passed to higher level protocol processors on the basis 1325640Sroot * of link number. Other type messages (control) are handled here. 1335640Sroot */ 1345771Swnj impinput(unit, m) 1355640Sroot int unit; 1365771Swnj register struct mbuf *m; 1375640Sroot { 1385640Sroot register struct imp_leader *ip; 1395640Sroot register struct imp_softc *sc = &imp_softc[unit]; 1405640Sroot register struct host *hp; 1415640Sroot register struct ifqueue *inq; 1425771Swnj struct control_leader *cp; 1435640Sroot struct in_addr addr; 1445924Sroot struct mbuf *next; 1456336Ssam struct sockaddr_in *sin; 1465640Sroot 1475932Sroot COUNT(IMPINPUT); 1486257Sroot /* verify leader length. */ 1495771Swnj if (m->m_len < sizeof(struct control_leader) && 1505771Swnj (m = m_pullup(m, sizeof(struct control_leader))) == 0) 1515771Swnj return; 1525771Swnj cp = mtod(m, struct control_leader *); 1535771Swnj if (cp->dl_mtype == IMPTYPE_DATA) 1545771Swnj if (m->m_len < sizeof(struct imp_leader) && 1555771Swnj (m = m_pullup(m, sizeof(struct imp_leader))) == 0) 1565771Swnj return; 1575640Sroot ip = mtod(m, struct imp_leader *); 1585640Sroot 1596257Sroot /* check leader type */ 1605771Swnj if (ip->il_format != IMP_NFF) { 1615771Swnj sc->imp_if.if_collisions++; /* XXX */ 1625640Sroot goto drop; 1635771Swnj } 1645640Sroot 1656588Ssam if (ip->il_mtype != IMPTYPE_DATA) { 1665859Sroot #ifdef notdef 1675771Swnj addr.s_net = ip->il_network; 1685859Sroot #else 1696588Ssam addr.s_net = sc->imp_if.if_net; 1705859Sroot #endif 1715771Swnj addr.s_imp = ip->il_imp; 1725771Swnj addr.s_host = ip->il_host; 1735640Sroot } 1745640Sroot switch (ip->il_mtype) { 1755640Sroot 1765640Sroot case IMPTYPE_DATA: 1775640Sroot break; 1785640Sroot 1795640Sroot /* 1805640Sroot * IMP leader error. Reset the IMP and discard the packet. 1815640Sroot */ 1825640Sroot case IMPTYPE_BADLEADER: 1835647Ssam /* 1845647Ssam * According to 1822 document, this message 1855647Ssam * will be generated in response to the 1865647Ssam * first noop sent to the IMP after 1875647Ssam * the host resets the IMP interface. 1885647Ssam */ 1895771Swnj if (sc->imp_state != IMPS_INIT) { 1905924Sroot impmsg(sc, "leader error"); 1916582Ssam hostreset(sc->imp_if.if_net); 1925647Ssam impnoops(sc); 1935647Ssam } 1946582Ssam goto drop; 1955640Sroot 1965640Sroot /* 1975640Sroot * IMP going down. Print message, and if not immediate, 1985640Sroot * set off a timer to insure things will be reset at the 1995640Sroot * appropriate time. 2005640Sroot */ 2015640Sroot case IMPTYPE_DOWN: 202*6599Ssam if (sc->imp_state < IMPS_INIT) 2036598Ssam goto drop; 2045640Sroot if ((ip->il_link & IMP_DMASK) == 0) { 2055640Sroot sc->imp_state = IMPS_GOINGDOWN; 2066160Ssam timeout(impdown, (caddr_t)sc, 30 * hz); 2075640Sroot } 2086160Ssam impmsg(sc, "going down %s", 2096160Ssam (u_int)impmessage[ip->il_link&IMP_DMASK]); 2106582Ssam goto drop; 2115640Sroot 2125640Sroot /* 2135640Sroot * A NOP usually seen during the initialization sequence. 2145640Sroot * Compare the local address with that in the message. 2155640Sroot * Reset the local address notion if it doesn't match. 2165640Sroot */ 2176336Ssam case IMPTYPE_NOOP: 2185647Ssam if (sc->imp_state == IMPS_DOWN) { 2195647Ssam sc->imp_state = IMPS_INIT; 2205647Ssam sc->imp_dropcnt = IMP_DROPCNT; 2215647Ssam } 2226500Ssam if (sc->imp_state == IMPS_INIT && --sc->imp_dropcnt > 0) 2236271Sroot goto drop; 2246500Ssam sin = (struct sockaddr_in *)&sc->imp_if.if_addr; 2256500Ssam if (sin->sin_addr.s_host != ip->il_host || 2266500Ssam sin->sin_addr.s_imp != ip->il_imp) { 2276500Ssam sc->imp_if.if_host[0] = 2286500Ssam sin->sin_addr.s_host = ip->il_host; 2296500Ssam sin->sin_addr.s_imp = ip->il_imp; 2306500Ssam impmsg(sc, "reset (host %d/imp %d)", (u_int)ip->il_host, 2316500Ssam ntohs(ip->il_imp)); 2326500Ssam } 2335771Swnj sc->imp_state = IMPS_UP; 2346336Ssam sc->imp_if.if_flags |= IFF_UP; 2355771Swnj /* restart output in case something was q'd */ 2365771Swnj (*sc->imp_cb.ic_start)(sc->imp_if.if_unit); 2376271Sroot goto drop; 2385640Sroot 2395640Sroot /* 2406582Ssam * RFNM or INCOMPLETE message, send next 2416582Ssam * message on the q. We could pass incomplete's 2426582Ssam * up to the next level, but this currently isn't 2436582Ssam * needed. 2445640Sroot */ 2455640Sroot case IMPTYPE_RFNM: 2465640Sroot case IMPTYPE_INCOMPLETE: 2476588Ssam if (hp = hostlookup(addr)) { 2486588Ssam if (hp->h_rfnm == 0) 2496588Ssam hp->h_flags &= ~HF_INUSE; 2506588Ssam else if (next = hostdeque(hp)) 2516588Ssam (void) impsnd(&sc->imp_if, next); 2526588Ssam } 2536271Sroot goto drop; 2545640Sroot 2555640Sroot /* 2565640Sroot * Host or IMP can't be reached. Flush any packets 2575640Sroot * awaiting transmission and release the host structure. 2585640Sroot */ 2595640Sroot case IMPTYPE_HOSTDEAD: 2606588Ssam case IMPTYPE_HOSTUNREACH: { 2616588Ssam int s = splnet(); 2626588Ssam impnotify(ip->il_mtype, ip, hostlookup(addr)); 2636588Ssam splx(s); 2645859Sroot goto rawlinkin; 2656588Ssam } 2665640Sroot 2675640Sroot /* 2685640Sroot * Error in data. Clear RFNM status for this host and send 2695640Sroot * noops to the IMP to clear the interface. 2705640Sroot */ 2716588Ssam case IMPTYPE_BADDATA: { 2726588Ssam int s; 2736588Ssam 2745924Sroot impmsg(sc, "data error"); 2756588Ssam s = splnet(); 2766588Ssam if (hp = hostlookup(addr)) 2775640Sroot hp->h_rfnm = 0; 2786588Ssam splx(s); 2795640Sroot impnoops(sc); 2806582Ssam goto drop; 2816588Ssam } 2825640Sroot 2835640Sroot /* 2845647Ssam * Interface reset. 2855640Sroot */ 2865640Sroot case IMPTYPE_RESET: 2875924Sroot impmsg(sc, "interface reset"); 2885647Ssam impnoops(sc); 2896582Ssam goto drop; 2905640Sroot 2915640Sroot default: 2925640Sroot sc->imp_if.if_collisions++; /* XXX */ 2936582Ssam goto drop; 2945640Sroot } 2955640Sroot 2965640Sroot /* 2976257Sroot * Data for a protocol. Dispatch to the appropriate 2986257Sroot * protocol routine (running at software interrupt). 2996257Sroot * If this isn't a raw interface, advance pointer 3006257Sroot * into mbuf past leader. 3015640Sroot */ 3025640Sroot switch (ip->il_link) { 3035640Sroot 3045640Sroot #ifdef INET 3055640Sroot case IMPLINK_IP: 3065640Sroot m->m_len -= sizeof(struct imp_leader); 3075640Sroot m->m_off += sizeof(struct imp_leader); 3086261Swnj schednetisr(NETISR_IP); 3095640Sroot inq = &ipintrq; 3105640Sroot break; 3115640Sroot #endif 3125640Sroot 3135640Sroot default: 3145868Sroot rawlinkin: 3155640Sroot impproto.sp_protocol = ip->il_link; 3166336Ssam sin = (struct sockaddr_in *)&sc->imp_if.if_addr; 3176336Ssam impdst.sin_addr = sin->sin_addr;; 3185645Ssam impsrc.sin_addr.s_net = ip->il_network; 3195645Ssam impsrc.sin_addr.s_host = ip->il_host; 3205645Ssam impsrc.sin_addr.s_imp = ip->il_imp; 3216527Ssam raw_input(m, &impproto, (struct sockaddr *)&impsrc, 3226527Ssam (struct sockaddr *)&impdst); 3235640Sroot return; 3245640Sroot } 3256208Swnj if (IF_QFULL(inq)) { 3266208Swnj IF_DROP(inq); 3276208Swnj goto drop; 3286208Swnj } 3295640Sroot IF_ENQUEUE(inq, m); 3305640Sroot return; 3315640Sroot 3325640Sroot drop: 3335640Sroot m_freem(m); 3345640Sroot } 3355640Sroot 3365647Ssam /* 3375647Ssam * Bring the IMP down after notification. 3385647Ssam */ 3395647Ssam impdown(sc) 3405647Ssam struct imp_softc *sc; 3415647Ssam { 3426208Swnj 3436588Ssam COUNT(IMPDOWN); 3445647Ssam sc->imp_state = IMPS_DOWN; 3455924Sroot impmsg(sc, "marked down"); 3466588Ssam hostreset(sc->imp_if.if_net); 3476582Ssam if_down(&sc->imp_if); 3485647Ssam } 3495647Ssam 3505640Sroot /*VARARGS*/ 3515924Sroot impmsg(sc, fmt, a1, a2) 3525640Sroot struct imp_softc *sc; 3535640Sroot char *fmt; 3546160Ssam u_int a1; 3555640Sroot { 3566208Swnj 3576588Ssam COUNT(IMPMSG); 3585640Sroot printf("imp%d: ", sc->imp_if.if_unit); 3595640Sroot printf(fmt, a1, a2); 3605640Sroot printf("\n"); 3615640Sroot } 3625640Sroot 3635640Sroot /* 3646582Ssam * Process an IMP "error" message, passing this 3656582Ssam * up to the higher level protocol. 3666582Ssam */ 3676582Ssam impnotify(what, cp, hp) 3686582Ssam int what; 3696582Ssam struct control_leader *cp; 3706582Ssam struct host *hp; 3716582Ssam { 3726582Ssam struct in_addr in; 3736582Ssam 3746588Ssam COUNT(IMPNOTIFY); 3756582Ssam #ifdef notdef 3766582Ssam in.s_net = cp->dl_network; 3776582Ssam #else 3786588Ssam in.s_net = 10; /* XXX */ 3796582Ssam #endif 3806582Ssam in.s_host = cp->dl_host; 3816582Ssam in.s_imp = cp->dl_imp; 3826582Ssam if (cp->dl_link != IMPLINK_IP) 3836582Ssam raw_ctlinput(what, (caddr_t)&in); 3846582Ssam else 3856582Ssam ip_ctlinput(what, (caddr_t)&in); 3866588Ssam if (hp) { 3876588Ssam hp->h_flags |= (1 << what); 3886582Ssam hostfree(hp); 3896588Ssam } 3906582Ssam } 3916582Ssam 3926582Ssam /* 3935640Sroot * ARPAnet 1822 output routine. 3945640Sroot * Called from higher level protocol routines to set up messages for 3955640Sroot * transmission to the imp. Sets up the header and calls impsnd to 3965640Sroot * enqueue the message for this IMP's hardware driver. 3975640Sroot */ 3986336Ssam impoutput(ifp, m0, dst) 3995640Sroot register struct ifnet *ifp; 4005640Sroot struct mbuf *m0; 4016336Ssam struct sockaddr *dst; 4025640Sroot { 4035640Sroot register struct imp_leader *imp; 4045640Sroot register struct mbuf *m = m0; 4056244Sroot int x, dhost, dimp, dlink, len, dnet; 4066504Ssam int error = 0; 4075640Sroot 4085771Swnj COUNT(IMPOUTPUT); 4095640Sroot /* 4105640Sroot * Don't even try if the IMP is unavailable. 4115640Sroot */ 4126504Ssam if (imp_softc[ifp->if_unit].imp_state != IMPS_UP) { 4136504Ssam error = ENETDOWN; 4145647Ssam goto drop; 4156504Ssam } 4165640Sroot 4176336Ssam switch (dst->sa_family) { 4185640Sroot 4195640Sroot #ifdef INET 4206336Ssam case AF_INET: { 4216336Ssam struct ip *ip = mtod(m0, struct ip *); 4226336Ssam struct sockaddr_in *sin = (struct sockaddr_in *)dst; 4235640Sroot 4246336Ssam dhost = sin->sin_addr.s_host; 4256336Ssam dimp = sin->sin_addr.s_impno; 4265640Sroot dlink = IMPLINK_IP; 4276244Sroot dnet = 0; 4286160Ssam len = ntohs((u_short)ip->ip_len); 4295640Sroot break; 4305640Sroot } 4315640Sroot #endif 4326336Ssam case AF_IMPLINK: 4335640Sroot goto leaderexists; 4345640Sroot 4355640Sroot default: 4366336Ssam printf("imp%d: can't handle af%d\n", ifp->if_unit, 4376336Ssam dst->sa_family); 4386504Ssam error = EAFNOSUPPORT; 4395647Ssam goto drop; 4405640Sroot } 4415640Sroot 4425640Sroot /* 4435640Sroot * Add IMP leader. If there's not enough space in the 4445640Sroot * first mbuf, allocate another. If that should fail, we 4455640Sroot * drop this sucker. 4465640Sroot */ 4475640Sroot if (m->m_off > MMAXOFF || 4485640Sroot MMINOFF + sizeof(struct imp_leader) > m->m_off) { 4495640Sroot m = m_get(M_DONTWAIT); 4506504Ssam if (m == 0) { 4516504Ssam error = ENOBUFS; 4525647Ssam goto drop; 4536504Ssam } 4545640Sroot m->m_next = m0; 4555640Sroot m->m_off = MMINOFF; 4565640Sroot m->m_len = sizeof(struct imp_leader); 4575640Sroot } else { 4585640Sroot m->m_off -= sizeof(struct imp_leader); 4595640Sroot m->m_len += sizeof(struct imp_leader); 4605640Sroot } 4615640Sroot imp = mtod(m, struct imp_leader *); 4625640Sroot imp->il_format = IMP_NFF; 4635859Sroot imp->il_mtype = IMPTYPE_DATA; 4646244Sroot imp->il_network = dnet; 4655640Sroot imp->il_host = dhost; 4666244Sroot imp->il_imp = htons((u_short)dimp); 4676160Ssam imp->il_length = 4686160Ssam htons((u_short)(len + sizeof(struct imp_leader)) << 3); 4695640Sroot imp->il_link = dlink; 4705859Sroot imp->il_flags = imp->il_htype = imp->il_subtype = 0; 4715640Sroot 4725640Sroot leaderexists: 4735640Sroot return (impsnd(ifp, m)); 4745647Ssam drop: 4755647Ssam m_freem(m0); 4766504Ssam return (error); 4775640Sroot } 4785640Sroot 4795640Sroot /* 4805640Sroot * Put a message on an interface's output queue. 4815640Sroot * Perform RFNM counting: no more than 8 message may be 4825640Sroot * in flight to any one host. 4835640Sroot */ 4845640Sroot impsnd(ifp, m) 4855640Sroot struct ifnet *ifp; 4865640Sroot struct mbuf *m; 4875640Sroot { 4885640Sroot register struct imp_leader *ip; 4895640Sroot register struct host *hp; 4905640Sroot struct impcb *icp; 4916588Ssam int s, error; 4925640Sroot 4935771Swnj COUNT(IMPSND); 4945640Sroot ip = mtod(m, struct imp_leader *); 4955640Sroot 4965640Sroot /* 4975640Sroot * Do RFNM counting for data messages 4985640Sroot * (no more than 8 outstanding to any host) 4995640Sroot */ 5006588Ssam s = splimp(); 5015640Sroot if (ip->il_mtype == IMPTYPE_DATA) { 5025640Sroot struct in_addr addr; 5035640Sroot 5045859Sroot #ifdef notdef 5055771Swnj addr.s_net = ip->il_network; 5065859Sroot #else 5076588Ssam addr.s_net = ifp->if_net; /* XXX */ 5085859Sroot #endif 5095640Sroot addr.s_host = ip->il_host; 5105640Sroot addr.s_imp = ip->il_imp; 5115771Swnj if ((hp = hostlookup(addr)) == 0) 5125771Swnj hp = hostenter(addr); 5136588Ssam if (hp && (hp->h_flags & (HF_DEAD|HF_UNREACH))) { 5146588Ssam #ifdef notdef 5156588Ssam error = hp->h_flags & HF_DEAD ? 5166588Ssam EHOSTDEAD : EHOSTUNREACH; 5176588Ssam #else 5186588Ssam error = ENETUNREACH; 5196588Ssam hp->h_timer = HOSTTIMER; 5206588Ssam hp->h_flags &= ~HF_INUSE; 5216588Ssam goto bad; 5226588Ssam #endif 5236588Ssam } 5245640Sroot 5255640Sroot /* 5265647Ssam * If IMP would block, queue until RFNM 5275640Sroot */ 5285640Sroot if (hp) { 5295640Sroot if (hp->h_rfnm < 8) { 5305640Sroot hp->h_rfnm++; 5315640Sroot goto enque; 5325640Sroot } 5336095Swnj if (hp->h_qcnt < 8) { /* high water mark */ 5346095Swnj HOST_ENQUE(hp, m); 5356095Swnj goto start; 5366095Swnj } 5375640Sroot } 5386588Ssam error = ENOBUFS; 5396588Ssam goto bad; 5405640Sroot } 5415640Sroot enque: 5426208Swnj if (IF_QFULL(&ifp->if_snd)) { 5436208Swnj IF_DROP(&ifp->if_snd); 5446588Ssam error = ENOBUFS; 5456588Ssam bad: 5466208Swnj m_freem(m); 5476588Ssam splx(s); 5486588Ssam return (error); 5496208Swnj } 5505640Sroot IF_ENQUEUE(&ifp->if_snd, m); 5516095Swnj start: 5526588Ssam splx(s); 5535640Sroot icp = &imp_softc[ifp->if_unit].imp_cb; 5545640Sroot if (icp->ic_oactive == 0) 5555640Sroot (*icp->ic_start)(ifp->if_unit); 5566504Ssam return (0); 5575640Sroot } 5585640Sroot 5595640Sroot /* 5605640Sroot * Put three 1822 NOOPs at the head of the output queue. 5615640Sroot * Part of host-IMP initialization procedure. 5625640Sroot * (Should return success/failure, but noone knows 5635640Sroot * what to do with this, so why bother?) 5645640Sroot */ 5655640Sroot impnoops(sc) 5665640Sroot register struct imp_softc *sc; 5675640Sroot { 5685640Sroot register i; 5695640Sroot register struct mbuf *m; 5705771Swnj register struct control_leader *cp; 5715640Sroot int x; 5725640Sroot 5735771Swnj COUNT(IMPNOOPS); 5745640Sroot sc->imp_dropcnt = IMP_DROPCNT; 5755771Swnj for (i = 0; i < IMP_DROPCNT + 1; i++ ) { 5765640Sroot if ((m = m_getclr(M_DONTWAIT)) == 0) 5775640Sroot return; 5785640Sroot m->m_off = MMINOFF; 5795771Swnj m->m_len = sizeof(struct control_leader); 5805771Swnj cp = mtod(m, struct control_leader *); 5815771Swnj cp->dl_format = IMP_NFF; 5825771Swnj cp->dl_link = i; 5835771Swnj cp->dl_mtype = IMPTYPE_NOOP; 5845640Sroot x = splimp(); 5855640Sroot IF_PREPEND(&sc->imp_if.if_snd, m); 5865640Sroot splx(x); 5875640Sroot } 5885640Sroot if (sc->imp_cb.ic_oactive == 0) 5895640Sroot (*sc->imp_cb.ic_start)(sc->imp_if.if_unit); 5905640Sroot } 5915640Sroot #endif 592