xref: /freebsd/sys/dev/firewire/if_fwe.c (revision 5e7c89e4883d582e7cdec92157a506c1ba534172)
1 /*
2  * Copyright (c) 2002-2003
3  * 	Hidetoshi Shimokawa. 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
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *
16  *	This product includes software developed by Hidetoshi Shimokawa.
17  *
18  * 4. Neither the name of the author nor the names of its contributors
19  *    may be used to endorse or promote products derived from this software
20  *    without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  *
34  * $FreeBSD$
35  */
36 
37 #include "opt_inet.h"
38 
39 #include <sys/param.h>
40 #include <sys/kernel.h>
41 #include <sys/malloc.h>
42 #include <sys/mbuf.h>
43 #include <sys/socket.h>
44 #include <sys/sockio.h>
45 #include <sys/sysctl.h>
46 #include <sys/systm.h>
47 #include <sys/module.h>
48 #include <sys/bus.h>
49 #include <machine/bus.h>
50 
51 #include <net/bpf.h>
52 #include <net/ethernet.h>
53 #include <net/if.h>
54 #include <net/if_arp.h>
55 #include <net/if_vlan_var.h>
56 
57 #include <dev/firewire/firewire.h>
58 #include <dev/firewire/firewirereg.h>
59 #include <dev/firewire/if_fwevar.h>
60 
61 #define FWEDEBUG	if (fwedebug) printf
62 #define TX_MAX_QUEUE	(FWMAXQUEUE - 1)
63 #define RX_MAX_QUEUE	FWMAXQUEUE
64 
65 /* network interface */
66 static void fwe_start __P((struct ifnet *));
67 static int fwe_ioctl __P((struct ifnet *, u_long, caddr_t));
68 static void fwe_init __P((void *));
69 
70 static void fwe_output_callback __P((struct fw_xfer *));
71 static void fwe_as_output __P((struct fwe_softc *, struct ifnet *));
72 static void fwe_as_input __P((struct fw_xferq *));
73 
74 static int fwedebug = 0;
75 static int stream_ch = 1;
76 static int tx_speed = 2;
77 
78 MALLOC_DEFINE(M_FWE, "if_fwe", "Ethernet over FireWire interface");
79 SYSCTL_INT(_debug, OID_AUTO, if_fwe_debug, CTLFLAG_RW, &fwedebug, 0, "");
80 SYSCTL_DECL(_hw_firewire);
81 SYSCTL_NODE(_hw_firewire, OID_AUTO, fwe, CTLFLAG_RD, 0,
82 	"Ethernet Emulation Subsystem");
83 SYSCTL_INT(_hw_firewire_fwe, OID_AUTO, stream_ch, CTLFLAG_RW, &stream_ch, 0,
84 	"Stream channel to use");
85 SYSCTL_INT(_hw_firewire_fwe, OID_AUTO, tx_speed, CTLFLAG_RW, &tx_speed, 0,
86 	"Transmission Speed");
87 
88 #ifdef DEVICE_POLLING
89 #define FWE_POLL_REGISTER(func, fwe, ifp)			\
90 	if (ether_poll_register(func, ifp)) {			\
91 		struct firewire_comm *fc = (fwe)->fd.fc;	\
92 		fc->set_intr(fc, 0);				\
93 	}
94 
95 #define FWE_POLL_DEREGISTER(fwe, ifp)				\
96 	do {							\
97 		struct firewire_comm *fc = (fwe)->fd.fc;	\
98 		ether_poll_deregister(ifp);			\
99 		fc->set_intr(fc, 1);				\
100 	} while(0)						\
101 
102 static poll_handler_t fwe_poll;
103 
104 static void
105 fwe_poll(struct ifnet *ifp, enum poll_cmd cmd, int count)
106 {
107 	struct fwe_softc *fwe;
108 	struct firewire_comm *fc;
109 
110 	fwe = ((struct fwe_eth_softc *)ifp->if_softc)->fwe;
111 	fc = fwe->fd.fc;
112 	if (cmd == POLL_DEREGISTER) {
113 		/* enable interrupts */
114 		fc->set_intr(fc, 1);
115 		return;
116 	}
117 	fc->poll(fc, (cmd == POLL_AND_CHECK_STATUS)?0:1, count);
118 }
119 #else
120 #define FWE_POLL_REGISTER(func, fwe, ifp)
121 #define FWE_POLL_DEREGISTER(fwe, ifp)
122 #endif
123 static void
124 fwe_identify(driver_t *driver, device_t parent)
125 {
126 	BUS_ADD_CHILD(parent, 0, "fwe", device_get_unit(parent));
127 }
128 
129 static int
130 fwe_probe(device_t dev)
131 {
132 	device_t pa;
133 
134 	pa = device_get_parent(dev);
135 	if(device_get_unit(dev) != device_get_unit(pa)){
136 		return(ENXIO);
137 	}
138 
139 	device_set_desc(dev, "Ethernet over FireWire");
140 	return (0);
141 }
142 
143 static int
144 fwe_attach(device_t dev)
145 {
146 	struct fwe_softc *fwe;
147 	struct ifnet *ifp;
148 	int unit, s;
149 	u_char *eaddr;
150 	struct fw_eui64 *eui;
151 
152 	fwe = ((struct fwe_softc *)device_get_softc(dev));
153 	unit = device_get_unit(dev);
154 
155 	bzero(fwe, sizeof(struct fwe_softc));
156 	/* XXX */
157 	fwe->stream_ch = stream_ch;
158 	fwe->dma_ch = -1;
159 
160 	fwe->fd.fc = device_get_ivars(dev);
161 	fwe->fd.dev = dev;
162 	fwe->fd.post_explore = NULL;
163 	fwe->eth_softc.fwe = fwe;
164 
165 	fwe->pkt_hdr.mode.stream.tcode = FWTCODE_STREAM;
166 	fwe->pkt_hdr.mode.stream.sy = 0;
167 	fwe->pkt_hdr.mode.stream.chtag = fwe->stream_ch;
168 
169 	/* generate fake MAC address: first and last 3bytes from eui64 */
170 #define LOCAL (0x02)
171 #define GROUP (0x01)
172 	eaddr = &fwe->eth_softc.arpcom.ac_enaddr[0];
173 
174 	eui = &fwe->fd.fc->eui;
175 	eaddr[0] = (FW_EUI64_BYTE(eui, 0) | LOCAL) & ~GROUP;
176 	eaddr[1] = FW_EUI64_BYTE(eui, 1);
177 	eaddr[2] = FW_EUI64_BYTE(eui, 2);
178 	eaddr[3] = FW_EUI64_BYTE(eui, 5);
179 	eaddr[4] = FW_EUI64_BYTE(eui, 6);
180 	eaddr[5] = FW_EUI64_BYTE(eui, 7);
181 	printf("if_fwe%d: Fake Ethernet address: "
182 		"%02x:%02x:%02x:%02x:%02x:%02x\n", unit,
183 		eaddr[0], eaddr[1], eaddr[2], eaddr[3], eaddr[4], eaddr[5]);
184 
185 	/* fill the rest and attach interface */
186 	ifp = &fwe->fwe_if;
187 	ifp->if_softc = &fwe->eth_softc;
188 
189 	if_initname(ifp, device_get_name(dev), unit);
190 	ifp->if_init = fwe_init;
191 	ifp->if_output = ether_output;
192 	ifp->if_start = fwe_start;
193 	ifp->if_ioctl = fwe_ioctl;
194 	ifp->if_mtu = ETHERMTU;
195 	ifp->if_flags = (IFF_BROADCAST|IFF_SIMPLEX|IFF_MULTICAST);
196 	ifp->if_snd.ifq_maxlen = TX_MAX_QUEUE;
197 
198 	s = splimp();
199 #if __FreeBSD_version >= 500000
200 	ether_ifattach(ifp, eaddr);
201 #else
202 	ether_ifattach(ifp, 1);
203 #endif
204 	splx(s);
205 
206         /* Tell the upper layer(s) we support long frames. */
207 	ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header);
208 #if __FreeBSD_version >= 500000
209 	ifp->if_capabilities |= IFCAP_VLAN_MTU;
210 #endif
211 
212 
213 	FWEDEBUG("interface %s created.\n", ifp->if_xname);
214 	return 0;
215 }
216 
217 static void
218 fwe_stop(struct fwe_softc *fwe)
219 {
220 	struct firewire_comm *fc;
221 	struct fw_xferq *xferq;
222 	struct ifnet *ifp = &fwe->fwe_if;
223 	struct fw_xfer *xfer, *next;
224 	int i;
225 
226 	fc = fwe->fd.fc;
227 
228 	FWE_POLL_DEREGISTER(fwe, ifp);
229 
230 	if (fwe->dma_ch >= 0) {
231 		xferq = fc->ir[fwe->dma_ch];
232 
233 		if (xferq->flag & FWXFERQ_RUNNING)
234 			fc->irx_disable(fc, fwe->dma_ch);
235 		xferq->flag &=
236 			~(FWXFERQ_MODEMASK | FWXFERQ_OPEN | FWXFERQ_STREAM |
237 			FWXFERQ_EXTBUF | FWXFERQ_HANDLER | FWXFERQ_CHTAGMASK);
238 		xferq->hand =  NULL;
239 
240 		for (i = 0; i < xferq->bnchunk; i ++)
241 			m_freem(xferq->bulkxfer[i].mbuf);
242 		free(xferq->bulkxfer, M_FWE);
243 
244 		for (xfer = STAILQ_FIRST(&fwe->xferlist); xfer != NULL;
245 					xfer = next) {
246 			next = STAILQ_NEXT(xfer, link);
247 			fw_xfer_free(xfer);
248 		}
249 		STAILQ_INIT(&fwe->xferlist);
250 
251 		xferq->bulkxfer =  NULL;
252 		fwe->dma_ch = -1;
253 	}
254 
255 	ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
256 }
257 
258 static int
259 fwe_detach(device_t dev)
260 {
261 	struct fwe_softc *fwe;
262 	int s;
263 
264 	fwe = (struct fwe_softc *)device_get_softc(dev);
265 	s = splimp();
266 
267 	fwe_stop(fwe);
268 #if __FreeBSD_version >= 500000
269 	ether_ifdetach(&fwe->fwe_if);
270 #else
271 	ether_ifdetach(&fwe->fwe_if, 1);
272 #endif
273 
274 	splx(s);
275 	return 0;
276 }
277 
278 static void
279 fwe_init(void *arg)
280 {
281 	struct fwe_softc *fwe = ((struct fwe_eth_softc *)arg)->fwe;
282 	struct firewire_comm *fc;
283 	struct ifnet *ifp = &fwe->fwe_if;
284 	struct fw_xferq *xferq;
285 	struct fw_xfer *xfer;
286 	struct mbuf *m;
287 	int i;
288 
289 	FWEDEBUG("initializing %s\n", ifp->if_xname);
290 
291 	/* XXX keep promiscoud mode */
292 	ifp->if_flags |= IFF_PROMISC;
293 
294 	fc = fwe->fd.fc;
295 #define START 0
296 	if (fwe->dma_ch < 0) {
297 		for (i = START; i < fc->nisodma; i ++) {
298 			xferq = fc->ir[i];
299 			if ((xferq->flag & FWXFERQ_OPEN) == 0)
300 				goto found;
301 		}
302 		printf("no free dma channel\n");
303 		return;
304 found:
305 		fwe->dma_ch = i;
306 		fwe->stream_ch = stream_ch;
307 		fwe->pkt_hdr.mode.stream.chtag = fwe->stream_ch;
308 		/* allocate DMA channel and init packet mode */
309 		xferq->flag |= FWXFERQ_OPEN | FWXFERQ_EXTBUF |
310 				FWXFERQ_HANDLER | FWXFERQ_STREAM;
311 		xferq->flag &= ~0xff;
312 		xferq->flag |= fwe->stream_ch & 0xff;
313 		/* register fwe_input handler */
314 		xferq->sc = (caddr_t) fwe;
315 		xferq->hand = fwe_as_input;
316 		xferq->bnchunk = RX_MAX_QUEUE;
317 		xferq->bnpacket = 1;
318 		xferq->psize = MCLBYTES;
319 		xferq->queued = 0;
320 		xferq->buf = NULL;
321 		xferq->bulkxfer = (struct fw_bulkxfer *) malloc(
322 			sizeof(struct fw_bulkxfer) * xferq->bnchunk,
323 							M_FWE, M_WAITOK);
324 		if (xferq->bulkxfer == NULL) {
325 			printf("if_fwe: malloc failed\n");
326 			return;
327 		}
328 		STAILQ_INIT(&xferq->stvalid);
329 		STAILQ_INIT(&xferq->stfree);
330 		STAILQ_INIT(&xferq->stdma);
331 		xferq->stproc = NULL;
332 		for (i = 0; i < xferq->bnchunk; i ++) {
333 			m =
334 #if __FreeBSD_version >= 500000
335 				m_getcl(M_TRYWAIT, MT_DATA, M_PKTHDR);
336 #else
337 				m_getcl(M_WAIT, MT_DATA, M_PKTHDR);
338 #endif
339 			xferq->bulkxfer[i].mbuf = m;
340 			if (m != NULL) {
341 				m->m_len = m->m_pkthdr.len = m->m_ext.ext_size;
342 				STAILQ_INSERT_TAIL(&xferq->stfree,
343 						&xferq->bulkxfer[i], link);
344 			} else
345 				printf("fwe_as_input: m_getcl failed\n");
346 		}
347 		STAILQ_INIT(&fwe->xferlist);
348 		for (i = 0; i < TX_MAX_QUEUE; i++) {
349 			xfer = fw_xfer_alloc(M_FWE);
350 			if (xfer == NULL)
351 				break;
352 			xfer->send.spd = tx_speed;
353 			xfer->fc = fwe->fd.fc;
354 			xfer->retry_req = fw_asybusy;
355 			xfer->sc = (caddr_t)fwe;
356 			xfer->act.hand = fwe_output_callback;
357 			STAILQ_INSERT_TAIL(&fwe->xferlist, xfer, link);
358 		}
359 	} else
360 		xferq = fc->ir[fwe->dma_ch];
361 
362 
363 	/* start dma */
364 	if ((xferq->flag & FWXFERQ_RUNNING) == 0)
365 		fc->irx_enable(fc, fwe->dma_ch);
366 
367 	ifp->if_flags |= IFF_RUNNING;
368 	ifp->if_flags &= ~IFF_OACTIVE;
369 
370 	FWE_POLL_REGISTER(fwe_poll, fwe, ifp);
371 #if 0
372 	/* attempt to start output */
373 	fwe_start(ifp);
374 #endif
375 }
376 
377 
378 static int
379 fwe_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
380 {
381 	struct fwe_softc *fwe = ((struct fwe_eth_softc *)ifp->if_softc)->fwe;
382 	struct ifstat *ifs = NULL;
383 	int s, error, len;
384 
385 	switch (cmd) {
386 		case SIOCSIFFLAGS:
387 			s = splimp();
388 			if (ifp->if_flags & IFF_UP) {
389 				if (!(ifp->if_flags & IFF_RUNNING))
390 					fwe_init(&fwe->eth_softc);
391 			} else {
392 				if (ifp->if_flags & IFF_RUNNING)
393 					fwe_stop(fwe);
394 			}
395 			/* XXX keep promiscoud mode */
396 			ifp->if_flags |= IFF_PROMISC;
397 			splx(s);
398 			break;
399 		case SIOCADDMULTI:
400 		case SIOCDELMULTI:
401 			break;
402 
403 		case SIOCGIFSTATUS:
404 			s = splimp();
405 			ifs = (struct ifstat *)data;
406 			len = strlen(ifs->ascii);
407 			if (len < sizeof(ifs->ascii))
408 				snprintf(ifs->ascii + len,
409 					sizeof(ifs->ascii) - len,
410 					"\tch %d dma %d\n",
411 						fwe->stream_ch, fwe->dma_ch);
412 			splx(s);
413 			break;
414 #if __FreeBSD_version >= 500000
415 		default:
416 #else
417 		case SIOCSIFADDR:
418 		case SIOCGIFADDR:
419 		case SIOCSIFMTU:
420 #endif
421 			s = splimp();
422 			error = ether_ioctl(ifp, cmd, data);
423 			splx(s);
424 			return (error);
425 #if __FreeBSD_version < 500000
426 		default:
427 			return (EINVAL);
428 #endif
429 	}
430 
431 	return (0);
432 }
433 
434 static void
435 fwe_output_callback(struct fw_xfer *xfer)
436 {
437 	struct fwe_softc *fwe;
438 	struct ifnet *ifp;
439 	int s;
440 
441 	fwe = (struct fwe_softc *)xfer->sc;
442 	ifp = &fwe->fwe_if;
443 	/* XXX error check */
444 	FWEDEBUG("resp = %d\n", xfer->resp);
445 	if (xfer->resp != 0)
446 		ifp->if_oerrors ++;
447 
448 	m_freem(xfer->mbuf);
449 	fw_xfer_unload(xfer);
450 
451 	s = splimp();
452 	STAILQ_INSERT_TAIL(&fwe->xferlist, xfer, link);
453 	splx(s);
454 
455 	/* for queue full */
456 	if (ifp->if_snd.ifq_head != NULL)
457 		fwe_start(ifp);
458 }
459 
460 static void
461 fwe_start(struct ifnet *ifp)
462 {
463 	struct fwe_softc *fwe = ((struct fwe_eth_softc *)ifp->if_softc)->fwe;
464 	int s;
465 
466 	FWEDEBUG("%s starting\n", ifp->if_xname);
467 
468 	if (fwe->dma_ch < 0) {
469 		struct mbuf	*m = NULL;
470 
471 		FWEDEBUG("%s not ready.\n", ifp->if_xname);
472 
473 		s = splimp();
474 		do {
475 			IF_DEQUEUE(&ifp->if_snd, m);
476 			if (m != NULL)
477 				m_freem(m);
478 			ifp->if_oerrors ++;
479 		} while (m != NULL);
480 		splx(s);
481 
482 		return;
483 	}
484 
485 	s = splimp();
486 	ifp->if_flags |= IFF_OACTIVE;
487 
488 	if (ifp->if_snd.ifq_len != 0)
489 		fwe_as_output(fwe, ifp);
490 
491 	ifp->if_flags &= ~IFF_OACTIVE;
492 	splx(s);
493 }
494 
495 #define HDR_LEN 4
496 #ifndef ETHER_ALIGN
497 #define ETHER_ALIGN 2
498 #endif
499 /* Async. stream output */
500 static void
501 fwe_as_output(struct fwe_softc *fwe, struct ifnet *ifp)
502 {
503 	struct mbuf *m;
504 	struct fw_xfer *xfer;
505 	struct fw_xferq *xferq;
506 	struct fw_pkt *fp;
507 	int i = 0;
508 
509 	xfer = NULL;
510 	xferq = fwe->fd.fc->atq;
511 	while (xferq->queued < xferq->maxq - 1) {
512 		xfer = STAILQ_FIRST(&fwe->xferlist);
513 		if (xfer == NULL) {
514 			printf("if_fwe: lack of xfer\n");
515 			return;
516 		}
517 		IF_DEQUEUE(&ifp->if_snd, m);
518 		if (m == NULL)
519 			break;
520 		STAILQ_REMOVE_HEAD(&fwe->xferlist, link);
521 #if __FreeBSD_version >= 500000
522 		BPF_MTAP(ifp, m);
523 #else
524 		if (ifp->if_bpf != NULL)
525 			bpf_mtap(ifp, m);
526 #endif
527 
528 		/* keep ip packet alignment for alpha */
529 		M_PREPEND(m, ETHER_ALIGN, M_DONTWAIT);
530 		fp = &xfer->send.hdr;
531 		*(u_int32_t *)&xfer->send.hdr = *(int32_t *)&fwe->pkt_hdr;
532 		fp->mode.stream.len = m->m_pkthdr.len;
533 		xfer->mbuf = m;
534 		xfer->send.pay_len = m->m_pkthdr.len;
535 
536 		if (fw_asyreq(fwe->fd.fc, -1, xfer) != 0) {
537 			/* error */
538 			ifp->if_oerrors ++;
539 			/* XXX set error code */
540 			fwe_output_callback(xfer);
541 		} else {
542 			ifp->if_opackets ++;
543 			i++;
544 		}
545 	}
546 #if 0
547 	if (i > 1)
548 		printf("%d queued\n", i);
549 #endif
550 	if (i > 0)
551 		xferq->start(fwe->fd.fc);
552 }
553 
554 /* Async. stream output */
555 static void
556 fwe_as_input(struct fw_xferq *xferq)
557 {
558 	struct mbuf *m, *m0;
559 	struct ifnet *ifp;
560 	struct fwe_softc *fwe;
561 	struct fw_bulkxfer *sxfer;
562 	struct fw_pkt *fp;
563 	u_char *c;
564 #if __FreeBSD_version < 500000
565 	struct ether_header *eh;
566 #endif
567 
568 	fwe = (struct fwe_softc *)xferq->sc;
569 	ifp = &fwe->fwe_if;
570 #if 0
571 	FWE_POLL_REGISTER(fwe_poll, fwe, ifp);
572 #endif
573 	while ((sxfer = STAILQ_FIRST(&xferq->stvalid)) != NULL) {
574 		STAILQ_REMOVE_HEAD(&xferq->stvalid, link);
575 		fp = mtod(sxfer->mbuf, struct fw_pkt *);
576 		if (fwe->fd.fc->irx_post != NULL)
577 			fwe->fd.fc->irx_post(fwe->fd.fc, fp->mode.ld);
578 		m = sxfer->mbuf;
579 
580 		/* insert new rbuf */
581 		sxfer->mbuf = m0 = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
582 		if (m0 != NULL) {
583 			m0->m_len = m0->m_pkthdr.len = m0->m_ext.ext_size;
584 			STAILQ_INSERT_TAIL(&xferq->stfree, sxfer, link);
585 		} else
586 			printf("fwe_as_input: m_getcl failed\n");
587 
588 		if (sxfer->resp != 0 || fp->mode.stream.len <
589 		    ETHER_ALIGN + sizeof(struct ether_header)) {
590 			m_freem(m);
591 			ifp->if_ierrors ++;
592 			continue;
593 		}
594 
595 		m->m_data += HDR_LEN + ETHER_ALIGN;
596 		c = mtod(m, char *);
597 #if __FreeBSD_version < 500000
598 		eh = (struct ether_header *)c;
599 		m->m_data += sizeof(struct ether_header);
600 #endif
601 		m->m_len = m->m_pkthdr.len =
602 				fp->mode.stream.len - ETHER_ALIGN;
603 		m->m_pkthdr.rcvif = ifp;
604 #if 0
605 		FWEDEBUG("%02x %02x %02x %02x %02x %02x\n"
606 			 "%02x %02x %02x %02x %02x %02x\n"
607 			 "%02x %02x %02x %02x\n"
608 			 "%02x %02x %02x %02x\n"
609 			 "%02x %02x %02x %02x\n"
610 			 "%02x %02x %02x %02x\n",
611 			 c[0], c[1], c[2], c[3], c[4], c[5],
612 			 c[6], c[7], c[8], c[9], c[10], c[11],
613 			 c[12], c[13], c[14], c[15],
614 			 c[16], c[17], c[18], c[19],
615 			 c[20], c[21], c[22], c[23],
616 			 c[20], c[21], c[22], c[23]
617 		 );
618 #endif
619 #if __FreeBSD_version >= 500000
620 		(*ifp->if_input)(ifp, m);
621 #else
622 		ether_input(ifp, eh, m);
623 #endif
624 		ifp->if_ipackets ++;
625 	}
626 	if (STAILQ_FIRST(&xferq->stfree) != NULL)
627 		fwe->fd.fc->irx_enable(fwe->fd.fc, fwe->dma_ch);
628 }
629 
630 
631 static devclass_t fwe_devclass;
632 
633 static device_method_t fwe_methods[] = {
634 	/* device interface */
635 	DEVMETHOD(device_identify,	fwe_identify),
636 	DEVMETHOD(device_probe,		fwe_probe),
637 	DEVMETHOD(device_attach,	fwe_attach),
638 	DEVMETHOD(device_detach,	fwe_detach),
639 	{ 0, 0 }
640 };
641 
642 static driver_t fwe_driver = {
643         "fwe",
644 	fwe_methods,
645 	sizeof(struct fwe_softc),
646 };
647 
648 
649 DRIVER_MODULE(fwe, firewire, fwe_driver, fwe_devclass, 0, 0);
650 MODULE_VERSION(fwe, 1);
651 MODULE_DEPEND(fwe, firewire, 1, 1, 1);
652