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