1 /* $NetBSD: if_plip.c,v 1.21 2008/04/18 14:56:40 cegger Exp $ */
4 * Copyright (c) 1997 Poul-Henning Kamp
5 * Copyright (c) 2003, 2004 Gary Thorpe <gathorpe@users.sourceforge.net>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * From Id: lpt.c,v 1.55.2.1 1996/11/12 09:08:38 phk Exp
30 * FreeBSD: src/sys/dev/ppbus/if_plip.c,v 1.19.2.1 2000/05/24 00:20:57 n_hibma Exp
33 #include <sys/cdefs.h>
34 __KERNEL_RCSID(0, "$NetBSD: if_plip.c,v 1.21 2008/04/18 14:56:40 cegger Exp $");
37 * Parallel port TCP/IP interfaces added. I looked at the driver from
38 * MACH but this is a complete rewrite, and btw. incompatible, and it
39 * should perform better too. I have never run the MACH driver though.
41 * This driver sends two bytes (0x08, 0x00) in front of each packet,
42 * to allow us to distinguish another format later.
44 * Now added an Linux/Crynwr compatibility mode which is enabled using
45 * IF_LINK0 - Tim Wilkinson.
48 * Make HDLC/PPP mode, use IF_LLC1 to enable.
50 * Connect the two computers using a Laplink parallel cable to use this
53 * +----------------------------------------+
54 * |A-name A-End B-End Descr. Port/Bit |
55 * +----------------------------------------+
56 * |DATA0 2 15 Data 0/0x01 |
57 * |-ERROR 15 2 1/0x08 |
58 * +----------------------------------------+
59 * |DATA1 3 13 Data 0/0x02 |
60 * |+SLCT 13 3 1/0x10 |
61 * +----------------------------------------+
62 * |DATA2 4 12 Data 0/0x04 |
64 * +----------------------------------------+
65 * |DATA3 5 10 Strobe 0/0x08 |
67 * +----------------------------------------+
68 * |DATA4 6 11 Data 0/0x10 |
69 * |BUSY 11 6 1/~0x80 |
70 * +----------------------------------------+
71 * |GND 18-25 18-25 GND - |
72 * +----------------------------------------+
74 * Expect transfer-rates up to 75 kbyte/sec.
76 * If GCC could correctly grok
77 * register int port __asm("edx")
78 * the code would be cleaner
80 * Poul-Henning Kamp <phk@freebsd.org>
84 * Update for ppbus, PLIP support only - Nicolas Souchu
91 #include <sys/systm.h>
92 #include <sys/param.h>
94 #include <sys/types.h>
95 #include <sys/device.h>
96 #include <sys/ioctl.h>
97 #include <sys/malloc.h>
101 #include <net/if_types.h>
102 #include <net/netisr.h>
105 #include <sys/time.h>
110 #include <netinet/in_var.h>
111 /* #include <netinet/in.h> */
113 #error Cannot config lp/plip without inet
116 #include <dev/ppbus/ppbus_base.h>
117 #include <dev/ppbus/ppbus_device.h>
118 #include <dev/ppbus/ppbus_io.h>
119 #include <dev/ppbus/ppbus_var.h>
121 #include <machine/types.h>
122 #include <sys/intr.h>
124 #ifndef LPMTU /* MTU for the lp# interfaces */
128 #ifndef LPMAXSPIN1 /* DELAY factor for the lp# interfaces */
129 #define LPMAXSPIN1 8000 /* Spinning for remote intr to happen */
132 #ifndef LPMAXSPIN2 /* DELAY factor for the lp# interfaces */
133 #define LPMAXSPIN2 500 /* Spinning for remote handshake to happen */
136 #ifndef LPMAXERRS /* Max errors before !RUNNING */
137 #define LPMAXERRS 100
141 #define LPMAXRTRY 100 /* If channel busy, retry LPMAXRTRY
145 #define CLPIPHDRLEN 14 /* We send dummy ethernet addresses (two) + packet type in front of packet */
146 #define CLPIP_SHAKE 0x80 /* This bit toggles between nibble reception */
147 #define MLPIPHDRLEN CLPIPHDRLEN
149 #define LPIPHDRLEN 2 /* We send 0x08, 0x00 in front of packet */
150 #define LPIP_SHAKE 0x40 /* This bit toggles between nibble reception */
151 #if !defined(MLPIPHDRLEN) || LPIPHDRLEN > MLPIPHDRLEN
152 #define MLPIPHDRLEN LPIPHDRLEN
155 #define LPIPTBLSIZE 256 /* Size of octet translation table */
157 #define LP_PRINTF if (lpflag) printf
160 static int volatile lpflag
= 1;
162 static int volatile lpflag
= 0;
165 /* Tx/Rsv tables for the lp interface */
166 static u_char
*txmith
;
167 #define txmitl (txmith+(1*LPIPTBLSIZE))
168 #define trecvh (txmith+(2*LPIPTBLSIZE))
169 #define trecvl (txmith+(3*LPIPTBLSIZE))
170 static u_char
*ctxmith
;
171 #define ctxmitl (ctxmith+(1*LPIPTBLSIZE))
172 #define ctrecvh (ctxmith+(2*LPIPTBLSIZE))
173 #define ctrecvl (ctxmith+(3*LPIPTBLSIZE))
174 static uint16_t lp_count
= 0;
176 /* Autoconf functions */
177 static int lp_probe(device_t
, cfdata_t
, void *);
178 static void lp_attach(device_t
, device_t
, void *);
179 static int lp_detach(device_t
, int);
181 /* Soft config data */
183 struct ppbus_device_softc ppbus_dev
;
186 unsigned short sc_iferrs
;
187 unsigned short sc_xmit_rtry
;
188 u_int8_t sc_dev_ok
; /* Zero means ok */
191 /* Autoconf structure */
192 CFATTACH_DECL_NEW(plip
, sizeof(struct lp_softc
), lp_probe
, lp_attach
, lp_detach
,
195 /* Functions for the lp interface */
196 static void lpinittables(void);
197 static void lpfreetables(void);
198 static int lpioctl(struct ifnet
*, u_long
, void *);
199 static int lpoutput(struct ifnet
*, struct mbuf
*, const struct sockaddr
*,
201 static void lpstart(struct ifnet
*);
202 static void lp_intr(void *);
206 lp_probe(device_t parent
, cfdata_t match
, void *aux
)
208 struct ppbus_attach_args
* args
= aux
;
210 /* Fail if ppbus is not interrupt capable */
211 if(args
->capabilities
& PPBUS_HAS_INTR
)
214 printf("%s(%s): not an interrupt-driven port.\n", __func__
,
215 device_xname(parent
));
220 lp_attach(device_t parent
, device_t self
, void *aux
)
222 struct lp_softc
* lp
= device_private(self
);
223 struct ifnet
* ifp
= &lp
->sc_if
;
225 lp
->ppbus_dev
.sc_dev
= self
;
229 lp
->sc_xmit_rtry
= 0;
232 strlcpy(ifp
->if_xname
, device_xname(self
), IFNAMSIZ
);
234 ifp
->if_flags
= IFF_SIMPLEX
| IFF_POINTOPOINT
| IFF_MULTICAST
;
235 ifp
->if_ioctl
= lpioctl
;
236 ifp
->if_output
= lpoutput
;
237 ifp
->if_start
= lpstart
;
238 ifp
->if_type
= IFT_PARA
;
241 ifp
->if_dlt
= DLT_NULL
;
242 IFQ_SET_MAXLEN(&ifp
->if_snd
, IFQ_MAXLEN
);
243 IFQ_SET_READY(&ifp
->if_snd
);
248 bpfattach(ifp
, DLT_NULL
, sizeof(u_int32_t
));
257 lp_detach(device_t self
, int flags
)
260 struct lp_softc
* lp
= device_private(self
);
261 device_t ppbus
= device_parent(self
);
264 if(!(flags
& DETACH_QUIET
))
265 LP_PRINTF("%s(%s): device not properly attached! "
266 "Skipping detach....\n", __func__
,
271 /* If interface is up, bring it down and release ppbus */
272 if(lp
->sc_if
.if_flags
& IFF_RUNNING
) {
273 ppbus_wctr(ppbus
, 0x00);
274 if_detach(&lp
->sc_if
);
275 error
= ppbus_remove_handler(ppbus
, lp_intr
);
277 if(!(flags
& DETACH_QUIET
))
278 LP_PRINTF("%s(%s): unable to remove interrupt "
279 "callback.\n", __func__
,
281 if(!(flags
& DETACH_FORCE
))
284 error
= ppbus_release_bus(ppbus
, self
, 0, 0);
286 if(!(flags
& DETACH_QUIET
))
287 LP_PRINTF("%s(%s): error releasing bus %s.\n",
288 __func__
, device_xname(self
),
289 device_xname(ppbus
));
290 if(!(flags
& DETACH_FORCE
))
296 free(lp
->sc_ifbuf
, M_DEVBUF
);
304 * Build the translation tables for the LPIP (BSD unix) protocol.
305 * We don't want to calculate these nasties in our tight loop, so we
306 * precalculate them when we initialize.
314 txmith
= malloc(4*LPIPTBLSIZE
, M_DEVBUF
, M_WAITOK
);
317 ctxmith
= malloc(4*LPIPTBLSIZE
, M_DEVBUF
, M_WAITOK
);
319 for(i
= 0; i
< LPIPTBLSIZE
; i
++) {
320 ctxmith
[i
] = (i
& 0xF0) >> 4;
321 ctxmitl
[i
] = 0x10 | (i
& 0x0F);
322 ctrecvh
[i
] = (i
& 0x78) << 1;
323 ctrecvl
[i
] = (i
& 0x78) >> 3;
326 for(i
= 0; i
< LPIPTBLSIZE
; i
++) {
327 txmith
[i
] = ((i
& 0x80) >> 3) | ((i
& 0x70) >> 4) | 0x08;
328 txmitl
[i
] = ((i
& 0x08) << 1) | (i
& 0x07);
329 trecvh
[i
] = ((~i
) & 0x80) | ((i
& 0x38) << 1);
330 trecvl
[i
] = (((~i
) & 0x80) >> 4) | ((i
& 0x38) >> 3);
334 /* Free translation tables */
339 free(txmith
, M_DEVBUF
);
341 free(ctxmith
, M_DEVBUF
);
342 txmith
= ctxmith
= NULL
;
346 /* Process an ioctl request. */
348 lpioctl(struct ifnet
*ifp
, u_long cmd
, void *data
)
350 struct lp_softc
* sc
= ifp
->if_softc
;
351 device_t dev
= sc
->ppbus_dev
.sc_dev
;
352 device_t ppbus
= device_parent(dev
);
353 struct ifaddr
* ifa
= (struct ifaddr
*)data
;
354 struct ifreq
* ifr
= (struct ifreq
*)data
;
362 LP_PRINTF("%s(%s): device not properly attached!", __func__
,
371 if (ifa
->ifa_addr
->sa_family
!= AF_INET
)
372 error
= EAFNOSUPPORT
;
376 if (ifa
->ifa_addr
->sa_family
!= AF_INET
) {
377 error
= EAFNOSUPPORT
;
380 ifp
->if_flags
|= IFF_UP
;
383 if ((error
= ifioctl_common(ifp
, cmd
, data
)) != 0)
385 if((ifp
->if_flags
& (IFF_UP
|IFF_RUNNING
)) == IFF_UP
) {
386 if((error
= ppbus_request_bus(ppbus
, dev
, 0, 0)))
388 error
= ppbus_set_mode(ppbus
, PPBUS_COMPATIBLE
, 0);
392 error
= ppbus_add_handler(ppbus
, lp_intr
, dev
);
394 LP_PRINTF("%s(%s): unable to register interrupt"
395 " callback.\n", __func__
,
397 ppbus_release_bus(ppbus
, dev
, 0, 0);
401 /* Allocate a buffer if necessary */
402 if(sc
->sc_ifbuf
== NULL
) {
403 sc
->sc_ifbuf
= malloc(sc
->sc_if
.if_mtu
+
404 MLPIPHDRLEN
, M_DEVBUF
, M_NOWAIT
);
407 ppbus_release_bus(ppbus
, dev
, 0, 0);
412 ppbus_wctr(ppbus
, IRQENABLE
);
413 ifp
->if_flags
|= IFF_RUNNING
;
415 if((ifp
->if_flags
& (IFF_UP
|IFF_RUNNING
)) == IFF_RUNNING
) {
416 ppbus_remove_handler(ppbus
, lp_intr
);
417 error
= ppbus_release_bus(ppbus
, dev
, 0, 0);
418 ifp
->if_flags
&= ~IFF_RUNNING
;
421 ppbus_wdtr(ppbus
, 0);
425 if(sc
->sc_if
.if_mtu
== ifr
->ifr_mtu
)
428 sc
->sc_ifbuf
= malloc(ifr
->ifr_mtu
+MLPIPHDRLEN
, M_DEVBUF
,
439 if ((error
= ifioctl_common(ifp
, cmd
, data
)) == ENETRESET
)
446 error
= EAFNOSUPPORT
; /* XXX */
449 switch (ifreq_getaddr(cmd
, ifr
)->sa_family
) {
459 * No ifmedia support at this stage; maybe use it
460 * in future for eg. protocol selection.
463 LP_PRINTF("LP:ioctl(0x%lx)\n", cmd
);
464 error
= ifioctl_common(ifp
, cmd
, data
);
473 clpoutbyte (u_char byte
, int spin
, device_t ppbus
)
476 ppbus_wdtr(ppbus
, ctxmitl
[byte
]);
477 while (ppbus_rstr(ppbus
) & CLPIP_SHAKE
) {
483 ppbus_wdtr(ppbus
, ctxmith
[byte
]);
484 while (!(ppbus_rstr(ppbus
) & CLPIP_SHAKE
)) {
493 clpinbyte (int spin
, device_t ppbus
)
498 while(ppbus_rstr(ppbus
) & CLPIP_SHAKE
) {
503 cl
= ppbus_rstr(ppbus
);
504 ppbus_wdtr(ppbus
, 0x10);
507 while(!(ppbus_rstr(ppbus
) & CLPIP_SHAKE
)) {
512 c
= ppbus_rstr(ppbus
);
513 ppbus_wdtr(ppbus
, 0x00);
515 return (ctrecvl
[cl
] | ctrecvh
[c
]);
520 lptap(struct ifnet
*ifp
, struct mbuf
*m
)
523 * Send a packet through bpf. We need to prepend the address family
524 * as a four byte field. Cons up a dummy header to pacify bpf. This
525 * is safe because bpf will only read from the mbuf (i.e., it won't
526 * try to free it or keep a pointer to it).
528 u_int32_t af
= AF_INET
;
532 m0
.m_len
= sizeof(u_int32_t
);
533 m0
.m_data
= (char *)&af
;
534 bpf_mtap(ifp
->if_bpf
, &m0
);
538 /* Soft interrupt handler called by hardware interrupt handler */
542 device_t dev
= (device_t
)arg
;
543 device_t ppbus
= device_parent(dev
);
544 struct lp_softc
* sc
= device_private(dev
);
545 struct ifnet
* ifp
= &sc
->sc_if
;
553 /* Do nothing if device not properly attached */
555 LP_PRINTF("%s(%s): device not properly attached!", __func__
,
560 /* Do nothing if interface is not up */
561 if((ifp
->if_flags
& (IFF_UP
|IFF_RUNNING
)) != (IFF_UP
|IFF_RUNNING
))
564 /* If other side is no longer transmitting, do nothing */
565 if(!(ppbus_rstr(ppbus
) & LPIP_SHAKE
))
568 /* Disable interrupts until we finish */
569 ppbus_wctr(ppbus
, ~IRQENABLE
);
573 /* Linux/crynwyr protocol receiving */
574 if(ifp
->if_flags
& IFF_LINK0
) {
575 /* Ack. the request */
576 ppbus_wdtr(ppbus
, 0x01);
578 /* Get the packet length */
579 j
= clpinbyte(LPMAXSPIN2
, ppbus
);
583 j
= clpinbyte(LPMAXSPIN2
, ppbus
);
586 len
= len
+ (j
<< 8);
587 if(len
> ifp
->if_mtu
+ MLPIPHDRLEN
)
591 j
= clpinbyte(LPMAXSPIN2
, ppbus
);
597 /* Get and ignore checksum */
598 j
= clpinbyte(LPMAXSPIN2
, ppbus
);
603 /* Return to idle state */
604 ppbus_wdtr(ppbus
, 0);
605 len
= bp
- sc
->sc_ifbuf
;
606 if (len
<= CLPIPHDRLEN
)
609 top
= m_devget(sc
->sc_ifbuf
+ CLPIPHDRLEN
, len
, 0, ifp
, NULL
);
611 /* FreeBSD protocol receiving */
613 len
= ifp
->if_mtu
+ LPIPHDRLEN
;
615 cl
= ppbus_rstr(ppbus
);
616 ppbus_wdtr(ppbus
, 0x08);
619 while((ppbus_rstr(ppbus
) & LPIP_SHAKE
)) {
623 c
= ppbus_rstr(ppbus
);
624 ppbus_wdtr(ppbus
, 0);
626 *bp
++= trecvh
[cl
] | trecvl
[c
];
629 while(!((cl
=ppbus_rstr(ppbus
)) & LPIP_SHAKE
)) {
631 (((cl
= ppbus_rstr(ppbus
)) ^ 0xb8) &
639 len
= bp
- sc
->sc_ifbuf
;
640 if(len
<= LPIPHDRLEN
)
643 top
= m_devget(sc
->sc_ifbuf
+ LPIPHDRLEN
, len
, 0, ifp
, NULL
);
646 /* Do nothing if mbuf was not created or the queue is full */
647 if((top
== NULL
) || (IF_QFULL(&ipintrq
))) {
657 IF_ENQUEUE(&ipintrq
, top
);
658 schednetisr(NETISR_IP
);
660 ifp
->if_ibytes
+= len
;
666 /* Return to idle state */
667 ppbus_wdtr(ppbus
, 0);
671 /* Disable interface if there are too many errors */
672 if(sc
->sc_iferrs
> LPMAXERRS
) {
673 aprint_error_dev(dev
, "Too many consecutive errors, going off-line.\n");
674 ppbus_wctr(ppbus
, ~IRQENABLE
);
680 /* Re-enable interrupts */
681 ppbus_wctr(ppbus
, IRQENABLE
);
682 /* If interface is not active, send some packets */
683 if((ifp
->if_flags
& IFF_OACTIVE
) == 0)
690 lpoutbyte(u_char byte
, int spin
, device_t ppbus
)
693 ppbus_wdtr(ppbus
, txmith
[byte
]);
694 while(!(ppbus_rstr(ppbus
) & LPIP_SHAKE
)) {
699 ppbus_wdtr(ppbus
, txmitl
[byte
]);
700 while(ppbus_rstr(ppbus
) & LPIP_SHAKE
) {
707 /* Queue a packet for delivery */
709 lpoutput(struct ifnet
*ifp
, struct mbuf
*m
, const struct sockaddr
*dst
,
712 struct lp_softc
* sc
= ifp
->if_softc
;
713 device_t dev
= sc
->ppbus_dev
.sc_dev
;
714 device_t ppbus
= device_parent(dev
);
715 ALTQ_DECL(struct altq_pktattr pktattr
;)
722 LP_PRINTF("%s(%s): device not properly attached!", __func__
,
728 if((ifp
->if_flags
& (IFF_UP
|IFF_RUNNING
)) != (IFF_UP
|IFF_RUNNING
)) {
733 /* Only support INET */
734 if(dst
->sa_family
!= AF_INET
) {
735 LP_PRINTF("%s: af%d not supported\n", ifp
->if_xname
,
742 IFQ_CLASSIFY(&ifp
->if_snd
, m
, dst
->sa_family
, &pktattr
);
743 IFQ_ENQUEUE(&ifp
->if_snd
, m
, NULL
, err
);
745 if((ifp
->if_flags
& IFF_OACTIVE
) == 0)
753 /* Disable interface if there are too many errors */
754 if(sc
->sc_iferrs
> LPMAXERRS
) {
755 aprint_error_dev(dev
, "Too many errors, going off-line.\n");
756 ppbus_wctr(ppbus
, ~IRQENABLE
);
763 if((err
!= 0) && (err
!= ENOBUFS
))
769 /* Send routine: send packets over PLIP cable. Call at splnet(). */
771 lpstart(struct ifnet
* ifp
)
773 struct lp_softc
* lp
= ifp
->if_softc
;
774 device_t dev
= lp
->ppbus_dev
.sc_dev
;
775 device_t ppbus
= device_parent(dev
);
779 int err
, i
, len
, spin
, count
;
783 LP_PRINTF("%s(%s): device not properly attached!", __func__
,
788 if((ifp
->if_flags
& (IFF_UP
|IFF_RUNNING
)) != (IFF_UP
|IFF_RUNNING
)) {
792 ifp
->if_flags
|= IFF_OACTIVE
;
795 ppbus_wdtr(ppbus
, 0);
799 /* Check if there are packets to send */
800 if(IFQ_IS_EMPTY(&ifp
->if_snd
)) {
803 /* Try to send a packet, dequeue it later if successful */
804 IFQ_POLL(&ifp
->if_snd
, m
);
808 str
= ppbus_rstr(ppbus
);
809 /* Wait until other side is not transmitting */
810 if((str
& LPIP_SHAKE
) ||
811 ((ifp
->if_flags
& IFF_LINK0
) && !(str
& CLPIP_SHAKE
))) {
813 if(++lp
->sc_xmit_rtry
> LPMAXRTRY
) {
814 aprint_error_dev(dev
, "Too many retries while channel "
815 "busy, going off-line.\n");
816 ppbus_wctr(ppbus
, ~IRQENABLE
);
818 lp
->sc_xmit_rtry
= 0;
822 lp
->sc_xmit_rtry
= 0;
824 /* Disable interrupt generation */
825 ppbus_wctr(ppbus
, ~IRQENABLE
);
829 /* Output packet for Linux/crynwyr compatible protocol */
830 if(ifp
->if_flags
& IFF_LINK0
) {
831 /* Calculate packet length */
832 count
= 14; /* Ethernet header len */
833 for(mm
= m
; mm
; mm
= mm
->m_next
) {
837 /* Alert other end to pending packet */
839 ppbus_wdtr(ppbus
, 0x08);
840 while((ppbus_rstr(ppbus
) & 0x08) == 0) {
846 if(clpoutbyte(count
& 0xFF, LPMAXSPIN1
, ppbus
))
848 if(clpoutbyte((count
>> 8) & 0xFF, LPMAXSPIN1
, ppbus
))
851 /* Send dummy ethernet header */
853 for(i
= 0; i
< 12; i
++) {
854 if(clpoutbyte(i
, LPMAXSPIN1
, ppbus
))
859 if(clpoutbyte(0x08, LPMAXSPIN1
, ppbus
))
861 if(clpoutbyte(0x00, LPMAXSPIN1
, ppbus
))
863 chksum
+= 0x08 + 0x00; /* Add into checksum */
867 cp
= mtod(mm
, u_char
*);
870 if(clpoutbyte(*cp
, LPMAXSPIN2
, ppbus
))
874 } while ((mm
= mm
->m_next
));
877 if(clpoutbyte(chksum
, LPMAXSPIN2
, ppbus
))
883 ppbus_wdtr(ppbus
, 0);
885 /* Output packet for FreeBSD compatible protocol */
887 /* We need a sensible value if we abort */
890 if(lpoutbyte(0x08, LPMAXSPIN1
, ppbus
))
892 if(lpoutbyte(0x00, LPMAXSPIN2
, ppbus
))
897 cp
= mtod(mm
,u_char
*);
900 if(lpoutbyte(*cp
++, LPMAXSPIN2
, ppbus
))
902 } while ((mm
= mm
->m_next
));
904 /* no errors were encountered */
909 ppbus_wdtr(ppbus
, txmitl
[*(--cp
)] ^ 0x17);
911 ppbus_wdtr(ppbus
, txmitl
['\0'] ^ 0x17);
915 /* Re-enable interrupt generation */
916 ppbus_wctr(ppbus
, IRQENABLE
);
920 ppbus_wdtr(ppbus
, 0);
926 /* Disable interface if there are too many errors */
927 if(lp
->sc_iferrs
> LPMAXERRS
) {
928 aprint_error_dev(dev
, "Too many errors, going off-line.\n");
929 ppbus_wctr(ppbus
, ~IRQENABLE
);
936 /* Dequeue packet on success */
937 IFQ_DEQUEUE(&ifp
->if_snd
, m
);
943 ifp
->if_obytes
+= m
->m_pkthdr
.len
;
949 ifp
->if_flags
&= ~IFF_OACTIVE
;