Deleted Added
full compact
if_plip.c (257176) if_plip.c (271849)
1/*-
2 * Copyright (c) 1997 Poul-Henning Kamp
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * From Id: lpt.c,v 1.55.2.1 1996/11/12 09:08:38 phk Exp
27 */
28
29#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1997 Poul-Henning Kamp
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * From Id: lpt.c,v 1.55.2.1 1996/11/12 09:08:38 phk Exp
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/dev/ppbus/if_plip.c 257176 2013-10-26 17:58:36Z glebius $");
30__FBSDID("$FreeBSD: head/sys/dev/ppbus/if_plip.c 271849 2014-09-19 03:51:26Z glebius $");
31
32/*
33 * Parallel port TCP/IP interfaces added. I looked at the driver from
34 * MACH but this is a complete rewrite, and btw. incompatible, and it
35 * should perform better too. I have never run the MACH driver though.
36 *
37 * This driver sends two bytes (0x08, 0x00) in front of each packet,
38 * to allow us to distinguish another format later.

--- 532 unchanged lines hidden (view full) ---

571
572 len = bp - sc->sc_ifbuf;
573 if (len <= CLPIPHDRLEN)
574 goto err;
575
576 sc->sc_iferrs = 0;
577
578 len -= CLPIPHDRLEN;
31
32/*
33 * Parallel port TCP/IP interfaces added. I looked at the driver from
34 * MACH but this is a complete rewrite, and btw. incompatible, and it
35 * should perform better too. I have never run the MACH driver though.
36 *
37 * This driver sends two bytes (0x08, 0x00) in front of each packet,
38 * to allow us to distinguish another format later.

--- 532 unchanged lines hidden (view full) ---

571
572 len = bp - sc->sc_ifbuf;
573 if (len <= CLPIPHDRLEN)
574 goto err;
575
576 sc->sc_iferrs = 0;
577
578 len -= CLPIPHDRLEN;
579 sc->sc_ifp->if_ipackets++;
580 sc->sc_ifp->if_ibytes += len;
579 if_inc_counter(sc->sc_ifp, IFCOUNTER_IPACKETS, 1);
580 if_inc_counter(sc->sc_ifp, IFCOUNTER_IBYTES, len);
581 top = m_devget(sc->sc_ifbuf + CLPIPHDRLEN, len, 0, sc->sc_ifp,
582 0);
583 if (top) {
584 ppb_unlock(ppbus);
585 if (bpf_peers_present(sc->sc_ifp->if_bpf))
586 lptap(sc->sc_ifp, top);
587
588 M_SETFIB(top, sc->sc_ifp->if_fib);

--- 36 unchanged lines hidden (view full) ---

625 end:
626 len = bp - sc->sc_ifbuf;
627 if (len <= LPIPHDRLEN)
628 goto err;
629
630 sc->sc_iferrs = 0;
631
632 len -= LPIPHDRLEN;
581 top = m_devget(sc->sc_ifbuf + CLPIPHDRLEN, len, 0, sc->sc_ifp,
582 0);
583 if (top) {
584 ppb_unlock(ppbus);
585 if (bpf_peers_present(sc->sc_ifp->if_bpf))
586 lptap(sc->sc_ifp, top);
587
588 M_SETFIB(top, sc->sc_ifp->if_fib);

--- 36 unchanged lines hidden (view full) ---

625 end:
626 len = bp - sc->sc_ifbuf;
627 if (len <= LPIPHDRLEN)
628 goto err;
629
630 sc->sc_iferrs = 0;
631
632 len -= LPIPHDRLEN;
633 sc->sc_ifp->if_ipackets++;
634 sc->sc_ifp->if_ibytes += len;
633 if_inc_counter(sc->sc_ifp, IFCOUNTER_IPACKETS, 1);
634 if_inc_counter(sc->sc_ifp, IFCOUNTER_IBYTES, len);
635 top = m_devget(sc->sc_ifbuf + LPIPHDRLEN, len, 0, sc->sc_ifp,
636 0);
637 if (top) {
638 ppb_unlock(ppbus);
639 if (bpf_peers_present(sc->sc_ifp->if_bpf))
640 lptap(sc->sc_ifp, top);
641
642 M_SETFIB(top, sc->sc_ifp->if_fib);
643
644 /* mbuf is free'd on failure. */
645 netisr_queue(NETISR_IP, top);
646 ppb_lock(ppbus);
647 }
648 }
649 return;
650
651err:
652 ppb_wdtr(ppbus, 0);
653 lprintf("R");
635 top = m_devget(sc->sc_ifbuf + LPIPHDRLEN, len, 0, sc->sc_ifp,
636 0);
637 if (top) {
638 ppb_unlock(ppbus);
639 if (bpf_peers_present(sc->sc_ifp->if_bpf))
640 lptap(sc->sc_ifp, top);
641
642 M_SETFIB(top, sc->sc_ifp->if_fib);
643
644 /* mbuf is free'd on failure. */
645 netisr_queue(NETISR_IP, top);
646 ppb_lock(ppbus);
647 }
648 }
649 return;
650
651err:
652 ppb_wdtr(ppbus, 0);
653 lprintf("R");
654 sc->sc_ifp->if_ierrors++;
654 if_inc_counter(sc->sc_ifp, IFCOUNTER_IERRORS, 1);
655 sc->sc_iferrs++;
656
657 /*
658 * We are not able to send receive anything for now,
659 * so stop wasting our time
660 */
661 if (sc->sc_iferrs > LPMAXERRS) {
662 if_printf(sc->sc_ifp, "Too many errors, Going off-line.\n");

--- 100 unchanged lines hidden (view full) ---

763 /* Go quiescent */
764 ppb_wdtr(ppbus, 0);
765
766 err = 0; /* No errors */
767
768 nend:
769 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
770 if (err) { /* if we didn't timeout... */
655 sc->sc_iferrs++;
656
657 /*
658 * We are not able to send receive anything for now,
659 * so stop wasting our time
660 */
661 if (sc->sc_iferrs > LPMAXERRS) {
662 if_printf(sc->sc_ifp, "Too many errors, Going off-line.\n");

--- 100 unchanged lines hidden (view full) ---

763 /* Go quiescent */
764 ppb_wdtr(ppbus, 0);
765
766 err = 0; /* No errors */
767
768 nend:
769 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
770 if (err) { /* if we didn't timeout... */
771 ifp->if_oerrors++;
771 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
772 lprintf("X");
773 } else {
772 lprintf("X");
773 } else {
774 ifp->if_opackets++;
775 ifp->if_obytes += m->m_pkthdr.len;
774 if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
775 if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len);
776 if (bpf_peers_present(ifp->if_bpf))
777 lptap(ifp, m);
778 }
779
780 m_freem(m);
781
782 if (!(ppb_rstr(ppbus) & CLPIP_SHAKE)) {
783 lprintf("^");

--- 25 unchanged lines hidden (view full) ---

809 err = 0; /* no errors were encountered */
810
811end:
812 --cp;
813 ppb_wdtr(ppbus, txmitl[*cp] ^ 0x17);
814
815 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
816 if (err) { /* if we didn't timeout... */
776 if (bpf_peers_present(ifp->if_bpf))
777 lptap(ifp, m);
778 }
779
780 m_freem(m);
781
782 if (!(ppb_rstr(ppbus) & CLPIP_SHAKE)) {
783 lprintf("^");

--- 25 unchanged lines hidden (view full) ---

809 err = 0; /* no errors were encountered */
810
811end:
812 --cp;
813 ppb_wdtr(ppbus, txmitl[*cp] ^ 0x17);
814
815 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
816 if (err) { /* if we didn't timeout... */
817 ifp->if_oerrors++;
817 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
818 lprintf("X");
819 } else {
818 lprintf("X");
819 } else {
820 ifp->if_opackets++;
821 ifp->if_obytes += m->m_pkthdr.len;
820 if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
821 if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len);
822 if (bpf_peers_present(ifp->if_bpf))
823 lptap(ifp, m);
824 }
825
826 m_freem(m);
827
828 if (ppb_rstr(ppbus) & LPIP_SHAKE) {
829 lprintf("^");

--- 25 unchanged lines hidden ---
822 if (bpf_peers_present(ifp->if_bpf))
823 lptap(ifp, m);
824 }
825
826 m_freem(m);
827
828 if (ppb_rstr(ppbus) & LPIP_SHAKE) {
829 lprintf("^");

--- 25 unchanged lines hidden ---