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