1*6588Ssam /* if_imp.c 4.27 82/04/25 */ 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 165*6588Ssam if (ip->il_mtype != IMPTYPE_DATA) { 1665859Sroot #ifdef notdef 1675771Swnj addr.s_net = ip->il_network; 1685859Sroot #else 169*6588Ssam 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: 2025640Sroot if ((ip->il_link & IMP_DMASK) == 0) { 2035640Sroot sc->imp_state = IMPS_GOINGDOWN; 2046160Ssam timeout(impdown, (caddr_t)sc, 30 * hz); 2055640Sroot } 2066160Ssam impmsg(sc, "going down %s", 2076160Ssam (u_int)impmessage[ip->il_link&IMP_DMASK]); 2086582Ssam goto drop; 2095640Sroot 2105640Sroot /* 2115640Sroot * A NOP usually seen during the initialization sequence. 2125640Sroot * Compare the local address with that in the message. 2135640Sroot * Reset the local address notion if it doesn't match. 2145640Sroot */ 2156336Ssam case IMPTYPE_NOOP: 2165647Ssam if (sc->imp_state == IMPS_DOWN) { 2175647Ssam sc->imp_state = IMPS_INIT; 2185647Ssam sc->imp_dropcnt = IMP_DROPCNT; 2195647Ssam } 2206500Ssam if (sc->imp_state == IMPS_INIT && --sc->imp_dropcnt > 0) 2216271Sroot goto drop; 2226500Ssam sin = (struct sockaddr_in *)&sc->imp_if.if_addr; 2236500Ssam if (sin->sin_addr.s_host != ip->il_host || 2246500Ssam sin->sin_addr.s_imp != ip->il_imp) { 2256500Ssam sc->imp_if.if_host[0] = 2266500Ssam sin->sin_addr.s_host = ip->il_host; 2276500Ssam sin->sin_addr.s_imp = ip->il_imp; 2286500Ssam impmsg(sc, "reset (host %d/imp %d)", (u_int)ip->il_host, 2296500Ssam ntohs(ip->il_imp)); 2306500Ssam } 2315771Swnj sc->imp_state = IMPS_UP; 2326336Ssam sc->imp_if.if_flags |= IFF_UP; 2335771Swnj /* restart output in case something was q'd */ 2345771Swnj (*sc->imp_cb.ic_start)(sc->imp_if.if_unit); 2356271Sroot goto drop; 2365640Sroot 2375640Sroot /* 2386582Ssam * RFNM or INCOMPLETE message, send next 2396582Ssam * message on the q. We could pass incomplete's 2406582Ssam * up to the next level, but this currently isn't 2416582Ssam * needed. 2425640Sroot */ 2435640Sroot case IMPTYPE_RFNM: 2445640Sroot case IMPTYPE_INCOMPLETE: 245*6588Ssam if (hp = hostlookup(addr)) { 246*6588Ssam if (hp->h_rfnm == 0) 247*6588Ssam hp->h_flags &= ~HF_INUSE; 248*6588Ssam else if (next = hostdeque(hp)) 249*6588Ssam (void) impsnd(&sc->imp_if, next); 250*6588Ssam } 2516271Sroot goto drop; 2525640Sroot 2535640Sroot /* 2545640Sroot * Host or IMP can't be reached. Flush any packets 2555640Sroot * awaiting transmission and release the host structure. 2565640Sroot */ 2575640Sroot case IMPTYPE_HOSTDEAD: 258*6588Ssam case IMPTYPE_HOSTUNREACH: { 259*6588Ssam int s = splnet(); 260*6588Ssam impnotify(ip->il_mtype, ip, hostlookup(addr)); 261*6588Ssam splx(s); 2625859Sroot goto rawlinkin; 263*6588Ssam } 2645640Sroot 2655640Sroot /* 2665640Sroot * Error in data. Clear RFNM status for this host and send 2675640Sroot * noops to the IMP to clear the interface. 2685640Sroot */ 269*6588Ssam case IMPTYPE_BADDATA: { 270*6588Ssam int s; 271*6588Ssam 2725924Sroot impmsg(sc, "data error"); 273*6588Ssam s = splnet(); 274*6588Ssam if (hp = hostlookup(addr)) 2755640Sroot hp->h_rfnm = 0; 276*6588Ssam splx(s); 2775640Sroot impnoops(sc); 2786582Ssam goto drop; 279*6588Ssam } 2805640Sroot 2815640Sroot /* 2825647Ssam * Interface reset. 2835640Sroot */ 2845640Sroot case IMPTYPE_RESET: 2855924Sroot impmsg(sc, "interface reset"); 2865647Ssam impnoops(sc); 2876582Ssam goto drop; 2885640Sroot 2895640Sroot default: 2905640Sroot sc->imp_if.if_collisions++; /* XXX */ 2916582Ssam goto drop; 2925640Sroot } 2935640Sroot 2945640Sroot /* 2956257Sroot * Data for a protocol. Dispatch to the appropriate 2966257Sroot * protocol routine (running at software interrupt). 2976257Sroot * If this isn't a raw interface, advance pointer 2986257Sroot * into mbuf past leader. 2995640Sroot */ 3005640Sroot switch (ip->il_link) { 3015640Sroot 3025640Sroot #ifdef INET 3035640Sroot case IMPLINK_IP: 3045640Sroot m->m_len -= sizeof(struct imp_leader); 3055640Sroot m->m_off += sizeof(struct imp_leader); 3066261Swnj schednetisr(NETISR_IP); 3075640Sroot inq = &ipintrq; 3085640Sroot break; 3095640Sroot #endif 3105640Sroot 3115640Sroot default: 3125868Sroot rawlinkin: 3135640Sroot impproto.sp_protocol = ip->il_link; 3146336Ssam sin = (struct sockaddr_in *)&sc->imp_if.if_addr; 3156336Ssam impdst.sin_addr = sin->sin_addr;; 3165645Ssam impsrc.sin_addr.s_net = ip->il_network; 3175645Ssam impsrc.sin_addr.s_host = ip->il_host; 3185645Ssam impsrc.sin_addr.s_imp = ip->il_imp; 3196527Ssam raw_input(m, &impproto, (struct sockaddr *)&impsrc, 3206527Ssam (struct sockaddr *)&impdst); 3215640Sroot return; 3225640Sroot } 3236208Swnj if (IF_QFULL(inq)) { 3246208Swnj IF_DROP(inq); 3256208Swnj goto drop; 3266208Swnj } 3275640Sroot IF_ENQUEUE(inq, m); 3285640Sroot return; 3295640Sroot 3305640Sroot drop: 3315640Sroot m_freem(m); 3325640Sroot } 3335640Sroot 3345647Ssam /* 3355647Ssam * Bring the IMP down after notification. 3365647Ssam */ 3375647Ssam impdown(sc) 3385647Ssam struct imp_softc *sc; 3395647Ssam { 3406208Swnj 341*6588Ssam COUNT(IMPDOWN); 3425647Ssam sc->imp_state = IMPS_DOWN; 3435924Sroot impmsg(sc, "marked down"); 344*6588Ssam hostreset(sc->imp_if.if_net); 3456582Ssam if_down(&sc->imp_if); 3465647Ssam } 3475647Ssam 3485640Sroot /*VARARGS*/ 3495924Sroot impmsg(sc, fmt, a1, a2) 3505640Sroot struct imp_softc *sc; 3515640Sroot char *fmt; 3526160Ssam u_int a1; 3535640Sroot { 3546208Swnj 355*6588Ssam COUNT(IMPMSG); 3565640Sroot printf("imp%d: ", sc->imp_if.if_unit); 3575640Sroot printf(fmt, a1, a2); 3585640Sroot printf("\n"); 3595640Sroot } 3605640Sroot 3615640Sroot /* 3626582Ssam * Process an IMP "error" message, passing this 3636582Ssam * up to the higher level protocol. 3646582Ssam */ 3656582Ssam impnotify(what, cp, hp) 3666582Ssam int what; 3676582Ssam struct control_leader *cp; 3686582Ssam struct host *hp; 3696582Ssam { 3706582Ssam struct in_addr in; 3716582Ssam 372*6588Ssam COUNT(IMPNOTIFY); 3736582Ssam #ifdef notdef 3746582Ssam in.s_net = cp->dl_network; 3756582Ssam #else 376*6588Ssam in.s_net = 10; /* XXX */ 3776582Ssam #endif 3786582Ssam in.s_host = cp->dl_host; 3796582Ssam in.s_imp = cp->dl_imp; 3806582Ssam if (cp->dl_link != IMPLINK_IP) 3816582Ssam raw_ctlinput(what, (caddr_t)&in); 3826582Ssam else 3836582Ssam ip_ctlinput(what, (caddr_t)&in); 384*6588Ssam if (hp) { 385*6588Ssam hp->h_flags |= (1 << what); 3866582Ssam hostfree(hp); 387*6588Ssam } 3886582Ssam } 3896582Ssam 3906582Ssam /* 3915640Sroot * ARPAnet 1822 output routine. 3925640Sroot * Called from higher level protocol routines to set up messages for 3935640Sroot * transmission to the imp. Sets up the header and calls impsnd to 3945640Sroot * enqueue the message for this IMP's hardware driver. 3955640Sroot */ 3966336Ssam impoutput(ifp, m0, dst) 3975640Sroot register struct ifnet *ifp; 3985640Sroot struct mbuf *m0; 3996336Ssam struct sockaddr *dst; 4005640Sroot { 4015640Sroot register struct imp_leader *imp; 4025640Sroot register struct mbuf *m = m0; 4036244Sroot int x, dhost, dimp, dlink, len, dnet; 4046504Ssam int error = 0; 4055640Sroot 4065771Swnj COUNT(IMPOUTPUT); 4075640Sroot /* 4085640Sroot * Don't even try if the IMP is unavailable. 4095640Sroot */ 4106504Ssam if (imp_softc[ifp->if_unit].imp_state != IMPS_UP) { 4116504Ssam error = ENETDOWN; 4125647Ssam goto drop; 4136504Ssam } 4145640Sroot 4156336Ssam switch (dst->sa_family) { 4165640Sroot 4175640Sroot #ifdef INET 4186336Ssam case AF_INET: { 4196336Ssam struct ip *ip = mtod(m0, struct ip *); 4206336Ssam struct sockaddr_in *sin = (struct sockaddr_in *)dst; 4215640Sroot 4226336Ssam dhost = sin->sin_addr.s_host; 4236336Ssam dimp = sin->sin_addr.s_impno; 4245640Sroot dlink = IMPLINK_IP; 4256244Sroot dnet = 0; 4266160Ssam len = ntohs((u_short)ip->ip_len); 4275640Sroot break; 4285640Sroot } 4295640Sroot #endif 4306336Ssam case AF_IMPLINK: 4315640Sroot goto leaderexists; 4325640Sroot 4335640Sroot default: 4346336Ssam printf("imp%d: can't handle af%d\n", ifp->if_unit, 4356336Ssam dst->sa_family); 4366504Ssam error = EAFNOSUPPORT; 4375647Ssam goto drop; 4385640Sroot } 4395640Sroot 4405640Sroot /* 4415640Sroot * Add IMP leader. If there's not enough space in the 4425640Sroot * first mbuf, allocate another. If that should fail, we 4435640Sroot * drop this sucker. 4445640Sroot */ 4455640Sroot if (m->m_off > MMAXOFF || 4465640Sroot MMINOFF + sizeof(struct imp_leader) > m->m_off) { 4475640Sroot m = m_get(M_DONTWAIT); 4486504Ssam if (m == 0) { 4496504Ssam error = ENOBUFS; 4505647Ssam goto drop; 4516504Ssam } 4525640Sroot m->m_next = m0; 4535640Sroot m->m_off = MMINOFF; 4545640Sroot m->m_len = sizeof(struct imp_leader); 4555640Sroot } else { 4565640Sroot m->m_off -= sizeof(struct imp_leader); 4575640Sroot m->m_len += sizeof(struct imp_leader); 4585640Sroot } 4595640Sroot imp = mtod(m, struct imp_leader *); 4605640Sroot imp->il_format = IMP_NFF; 4615859Sroot imp->il_mtype = IMPTYPE_DATA; 4626244Sroot imp->il_network = dnet; 4635640Sroot imp->il_host = dhost; 4646244Sroot imp->il_imp = htons((u_short)dimp); 4656160Ssam imp->il_length = 4666160Ssam htons((u_short)(len + sizeof(struct imp_leader)) << 3); 4675640Sroot imp->il_link = dlink; 4685859Sroot imp->il_flags = imp->il_htype = imp->il_subtype = 0; 4695640Sroot 4705640Sroot leaderexists: 4715640Sroot return (impsnd(ifp, m)); 4725647Ssam drop: 4735647Ssam m_freem(m0); 4746504Ssam return (error); 4755640Sroot } 4765640Sroot 4775640Sroot /* 4785640Sroot * Put a message on an interface's output queue. 4795640Sroot * Perform RFNM counting: no more than 8 message may be 4805640Sroot * in flight to any one host. 4815640Sroot */ 4825640Sroot impsnd(ifp, m) 4835640Sroot struct ifnet *ifp; 4845640Sroot struct mbuf *m; 4855640Sroot { 4865640Sroot register struct imp_leader *ip; 4875640Sroot register struct host *hp; 4885640Sroot struct impcb *icp; 489*6588Ssam int s, error; 4905640Sroot 4915771Swnj COUNT(IMPSND); 4925640Sroot ip = mtod(m, struct imp_leader *); 4935640Sroot 4945640Sroot /* 4955640Sroot * Do RFNM counting for data messages 4965640Sroot * (no more than 8 outstanding to any host) 4975640Sroot */ 498*6588Ssam s = splimp(); 4995640Sroot if (ip->il_mtype == IMPTYPE_DATA) { 5005640Sroot struct in_addr addr; 5015640Sroot 5025859Sroot #ifdef notdef 5035771Swnj addr.s_net = ip->il_network; 5045859Sroot #else 505*6588Ssam addr.s_net = ifp->if_net; /* XXX */ 5065859Sroot #endif 5075640Sroot addr.s_host = ip->il_host; 5085640Sroot addr.s_imp = ip->il_imp; 5095771Swnj if ((hp = hostlookup(addr)) == 0) 5105771Swnj hp = hostenter(addr); 511*6588Ssam if (hp && (hp->h_flags & (HF_DEAD|HF_UNREACH))) { 512*6588Ssam #ifdef notdef 513*6588Ssam error = hp->h_flags & HF_DEAD ? 514*6588Ssam EHOSTDEAD : EHOSTUNREACH; 515*6588Ssam #else 516*6588Ssam error = ENETUNREACH; 517*6588Ssam hp->h_timer = HOSTTIMER; 518*6588Ssam hp->h_flags &= ~HF_INUSE; 519*6588Ssam goto bad; 520*6588Ssam #endif 521*6588Ssam } 5225640Sroot 5235640Sroot /* 5245647Ssam * If IMP would block, queue until RFNM 5255640Sroot */ 5265640Sroot if (hp) { 5275640Sroot if (hp->h_rfnm < 8) { 5285640Sroot hp->h_rfnm++; 5295640Sroot goto enque; 5305640Sroot } 5316095Swnj if (hp->h_qcnt < 8) { /* high water mark */ 5326095Swnj HOST_ENQUE(hp, m); 5336095Swnj goto start; 5346095Swnj } 5355640Sroot } 536*6588Ssam error = ENOBUFS; 537*6588Ssam goto bad; 5385640Sroot } 5395640Sroot enque: 5406208Swnj if (IF_QFULL(&ifp->if_snd)) { 5416208Swnj IF_DROP(&ifp->if_snd); 542*6588Ssam error = ENOBUFS; 543*6588Ssam bad: 5446208Swnj m_freem(m); 545*6588Ssam splx(s); 546*6588Ssam return (error); 5476208Swnj } 5485640Sroot IF_ENQUEUE(&ifp->if_snd, m); 5496095Swnj start: 550*6588Ssam splx(s); 5515640Sroot icp = &imp_softc[ifp->if_unit].imp_cb; 5525640Sroot if (icp->ic_oactive == 0) 5535640Sroot (*icp->ic_start)(ifp->if_unit); 5546504Ssam return (0); 5555640Sroot } 5565640Sroot 5575640Sroot /* 5585640Sroot * Put three 1822 NOOPs at the head of the output queue. 5595640Sroot * Part of host-IMP initialization procedure. 5605640Sroot * (Should return success/failure, but noone knows 5615640Sroot * what to do with this, so why bother?) 5625640Sroot */ 5635640Sroot impnoops(sc) 5645640Sroot register struct imp_softc *sc; 5655640Sroot { 5665640Sroot register i; 5675640Sroot register struct mbuf *m; 5685771Swnj register struct control_leader *cp; 5695640Sroot int x; 5705640Sroot 5715771Swnj COUNT(IMPNOOPS); 5725640Sroot sc->imp_dropcnt = IMP_DROPCNT; 5735771Swnj for (i = 0; i < IMP_DROPCNT + 1; i++ ) { 5745640Sroot if ((m = m_getclr(M_DONTWAIT)) == 0) 5755640Sroot return; 5765640Sroot m->m_off = MMINOFF; 5775771Swnj m->m_len = sizeof(struct control_leader); 5785771Swnj cp = mtod(m, struct control_leader *); 5795771Swnj cp->dl_format = IMP_NFF; 5805771Swnj cp->dl_link = i; 5815771Swnj cp->dl_mtype = IMPTYPE_NOOP; 5825640Sroot x = splimp(); 5835640Sroot IF_PREPEND(&sc->imp_if.if_snd, m); 5845640Sroot splx(x); 5855640Sroot } 5865640Sroot if (sc->imp_cb.ic_oactive == 0) 5875640Sroot (*sc->imp_cb.ic_start)(sc->imp_if.if_unit); 5885640Sroot } 5895640Sroot #endif 590