Lines Matching +full:spin +full:- +full:up
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 1997 Poul-Henning Kamp
41 * IF_LINK0 - Tim Wilkinson.
49 * +----------------------------------------+
50 * |A-name A-End B-End Descr. Port/Bit |
51 * +----------------------------------------+
53 * |-ERROR 15 2 1/0x08 |
54 * +----------------------------------------+
57 * +----------------------------------------+
60 * +----------------------------------------+
62 * |-ACK 10 5 1/0x40 |
63 * +----------------------------------------+
66 * +----------------------------------------+
67 * |GND 18-25 18-25 GND - |
68 * +----------------------------------------+
70 * Expect transfer-rates up to 75 kbyte/sec.
76 * Poul-Henning Kamp <phk@freebsd.org>
80 * Update for ppbus, PLIP support only - Nicolas Souchu
217 dev = device_find_child(parent, "plip", -1);
238 lp->sc_dev = dev;
244 lp->res_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
246 if (lp->res_irq == NULL) {
251 ifp = lp->sc_ifp = if_alloc(IFT_PARA);
267 error = bus_setup_intr(dev, lp->res_irq, INTR_TYPE_NET | INTR_MPSAFE,
268 NULL, lp_intr, lp, &lp->sc_intr_cookie);
272 bus_release_resource(dev, SYS_RES_IRQ, 0, lp->res_irq);
289 bpfdetach(sc->sc_ifp);
290 if_detach(sc->sc_ifp);
291 bus_teardown_intr(dev, sc->res_irq, sc->sc_intr_cookie);
292 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->res_irq);
344 device_t ppbus = device_get_parent(sc->sc_dev);
348 if_setdrvflagbits(sc->sc_ifp, 0, (IFF_DRV_RUNNING | IFF_DRV_OACTIVE));
349 free(sc->sc_ifbuf, M_DEVBUF);
350 sc->sc_ifbuf = NULL;
353 ppb_release_bus(ppbus, sc->sc_dev);
360 device_t dev = sc->sc_dev;
377 sc->sc_ifbuf = malloc(if_getmtu(sc->sc_ifp) + MLPIPHDRLEN,
379 if (sc->sc_ifbuf == NULL) {
398 device_t dev = sc->sc_dev;
408 if (ifa->ifa_addr->sa_family != AF_INET)
428 ptr = malloc(ifr->ifr_mtu + MLPIPHDRLEN, M_DEVBUF,
434 if (sc->sc_ifbuf)
435 free(sc->sc_ifbuf, M_DEVBUF);
436 sc->sc_ifbuf = ptr;
438 if_setmtu(ifp, ifr->ifr_mtu);
443 ifr->ifr_mtu = if_getmtu(sc->sc_ifp);
451 switch (ifr->ifr_addr.sa_family) {
474 clpoutbyte(u_char byte, int spin, device_t ppbus)
479 if (--spin == 0) {
484 if (--spin == 0) {
491 clpinbyte(int spin, device_t ppbus)
496 if (!--spin) {
497 return (-1);
503 if (!--spin) {
504 return (-1);
524 device_t ppbus = device_get_parent(sc->sc_dev);
531 if (if_getflags(sc->sc_ifp) & IFF_LINK0) {
537 if (j == -1)
541 if (j == -1)
544 if (len > if_getmtu(sc->sc_ifp) + MLPIPHDRLEN)
547 bp = sc->sc_ifbuf;
549 while (len--) {
551 if (j == -1) {
559 if (j == -1) {
563 len = bp - sc->sc_ifbuf;
567 sc->sc_iferrs = 0;
569 len -= CLPIPHDRLEN;
570 if_inc_counter(sc->sc_ifp, IFCOUNTER_IPACKETS, 1);
571 if_inc_counter(sc->sc_ifp, IFCOUNTER_IBYTES, len);
572 top = m_devget(sc->sc_ifbuf + CLPIPHDRLEN, len, 0, sc->sc_ifp,
576 lptap(sc->sc_ifp, top);
578 M_SETFIB(top, if_getfib(sc->sc_ifp));
587 len = if_getmtu(sc->sc_ifp) + LPIPHDRLEN;
588 bp = sc->sc_ifbuf;
589 while (len--) {
595 if (!--j)
609 if (!--j)
615 len = bp - sc->sc_ifbuf;
619 sc->sc_iferrs = 0;
621 len -= LPIPHDRLEN;
622 if_inc_counter(sc->sc_ifp, IFCOUNTER_IPACKETS, 1);
623 if_inc_counter(sc->sc_ifp, IFCOUNTER_IBYTES, len);
624 top = m_devget(sc->sc_ifbuf + LPIPHDRLEN, len, 0, sc->sc_ifp,
628 lptap(sc->sc_ifp, top);
630 M_SETFIB(top, if_getfib(sc->sc_ifp));
642 if_inc_counter(sc->sc_ifp, IFCOUNTER_IERRORS, 1);
643 sc->sc_iferrs++;
649 if (sc->sc_iferrs > LPMAXERRS) {
650 if_printf(sc->sc_ifp, "Too many errors, Going off-line.\n");
652 if_setdrvflagbits(sc->sc_ifp, 0, IFF_DRV_RUNNING);
653 sc->sc_iferrs = 0;
658 lpoutbyte(u_char byte, int spin, device_t ppbus)
663 if (--spin == 0)
667 if (--spin == 0)
677 device_t dev = sc->sc_dev;
684 int i, len, spin;
693 /* Suspend (on laptops) or receive-errors might have taken us offline */
703 spin = LPMAXSPIN1;
706 if (--spin == 0) {
715 for (mm = m; mm; mm = mm->m_next) {
716 count += mm->m_len;
739 len = mm->m_len;
740 while (len--) {
745 } while ((mm = mm->m_next));
763 if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len);
790 len = mm->m_len;
791 while (len--)
794 } while ((mm = mm->m_next));
799 --cp;
808 if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len);