if_fwe.c revision 139749
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 139749 2005-01-06 01:43:34Z imp $ 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#if defined(__DragonFly__) || __FreeBSD_version < 500000 213 ifp->if_output = ether_output; 214#endif 215 ifp->if_start = fwe_start; 216 ifp->if_ioctl = fwe_ioctl; 217 ifp->if_mtu = ETHERMTU; 218 ifp->if_flags = (IFF_BROADCAST|IFF_SIMPLEX|IFF_MULTICAST| 219 IFF_NEEDSGIANT); 220 ifp->if_snd.ifq_maxlen = TX_MAX_QUEUE; 221 222 s = splimp(); 223#if defined(__DragonFly__) || __FreeBSD_version < 500000 224 ether_ifattach(ifp, 1); 225#else 226 ether_ifattach(ifp, eaddr); 227#endif 228 splx(s); 229 230 /* Tell the upper layer(s) we support long frames. */ 231 ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header); 232#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 233 ifp->if_capabilities |= IFCAP_VLAN_MTU; 234 ifp->if_capenable |= IFCAP_VLAN_MTU; 235#endif 236 237 238 FWEDEBUG(ifp, "interface created\n"); 239 return 0; 240} 241 242static void 243fwe_stop(struct fwe_softc *fwe) 244{ 245 struct firewire_comm *fc; 246 struct fw_xferq *xferq; 247 struct ifnet *ifp = &fwe->fwe_if; 248 struct fw_xfer *xfer, *next; 249 int i; 250 251 fc = fwe->fd.fc; 252 253 FWE_POLL_DEREGISTER(fwe, ifp); 254 255 if (fwe->dma_ch >= 0) { 256 xferq = fc->ir[fwe->dma_ch]; 257 258 if (xferq->flag & FWXFERQ_RUNNING) 259 fc->irx_disable(fc, fwe->dma_ch); 260 xferq->flag &= 261 ~(FWXFERQ_MODEMASK | FWXFERQ_OPEN | FWXFERQ_STREAM | 262 FWXFERQ_EXTBUF | FWXFERQ_HANDLER | FWXFERQ_CHTAGMASK); 263 xferq->hand = NULL; 264 265 for (i = 0; i < xferq->bnchunk; i ++) 266 m_freem(xferq->bulkxfer[i].mbuf); 267 free(xferq->bulkxfer, M_FWE); 268 269 for (xfer = STAILQ_FIRST(&fwe->xferlist); xfer != NULL; 270 xfer = next) { 271 next = STAILQ_NEXT(xfer, link); 272 fw_xfer_free(xfer); 273 } 274 STAILQ_INIT(&fwe->xferlist); 275 276 xferq->bulkxfer = NULL; 277 fwe->dma_ch = -1; 278 } 279 280 ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); 281} 282 283static int 284fwe_detach(device_t dev) 285{ 286 struct fwe_softc *fwe; 287 int s; 288 289 fwe = (struct fwe_softc *)device_get_softc(dev); 290 s = splimp(); 291 292 fwe_stop(fwe); 293#if defined(__DragonFly__) || __FreeBSD_version < 500000 294 ether_ifdetach(&fwe->fwe_if, 1); 295#else 296 ether_ifdetach(&fwe->fwe_if); 297#endif 298 299 splx(s); 300 return 0; 301} 302 303static void 304fwe_init(void *arg) 305{ 306 struct fwe_softc *fwe = ((struct fwe_eth_softc *)arg)->fwe; 307 struct firewire_comm *fc; 308 struct ifnet *ifp = &fwe->fwe_if; 309 struct fw_xferq *xferq; 310 struct fw_xfer *xfer; 311 struct mbuf *m; 312 int i; 313 314 FWEDEBUG(ifp, "initializing\n"); 315 316 /* XXX keep promiscoud mode */ 317 ifp->if_flags |= IFF_PROMISC; 318 319 fc = fwe->fd.fc; 320#define START 0 321 if (fwe->dma_ch < 0) { 322 for (i = START; i < fc->nisodma; i ++) { 323 xferq = fc->ir[i]; 324 if ((xferq->flag & FWXFERQ_OPEN) == 0) 325 goto found; 326 } 327 printf("no free dma channel\n"); 328 return; 329found: 330 fwe->dma_ch = i; 331 fwe->stream_ch = stream_ch; 332 fwe->pkt_hdr.mode.stream.chtag = fwe->stream_ch; 333 /* allocate DMA channel and init packet mode */ 334 xferq->flag |= FWXFERQ_OPEN | FWXFERQ_EXTBUF | 335 FWXFERQ_HANDLER | FWXFERQ_STREAM; 336 xferq->flag &= ~0xff; 337 xferq->flag |= fwe->stream_ch & 0xff; 338 /* register fwe_input handler */ 339 xferq->sc = (caddr_t) fwe; 340 xferq->hand = fwe_as_input; 341 xferq->bnchunk = rx_queue_len; 342 xferq->bnpacket = 1; 343 xferq->psize = MCLBYTES; 344 xferq->queued = 0; 345 xferq->buf = NULL; 346 xferq->bulkxfer = (struct fw_bulkxfer *) malloc( 347 sizeof(struct fw_bulkxfer) * xferq->bnchunk, 348 M_FWE, M_WAITOK); 349 if (xferq->bulkxfer == NULL) { 350 printf("if_fwe: malloc failed\n"); 351 return; 352 } 353 STAILQ_INIT(&xferq->stvalid); 354 STAILQ_INIT(&xferq->stfree); 355 STAILQ_INIT(&xferq->stdma); 356 xferq->stproc = NULL; 357 for (i = 0; i < xferq->bnchunk; i ++) { 358 m = 359#if defined(__DragonFly__) || __FreeBSD_version < 500000 360 m_getcl(M_WAIT, MT_DATA, M_PKTHDR); 361#else 362 m_getcl(M_TRYWAIT, MT_DATA, M_PKTHDR); 363#endif 364 xferq->bulkxfer[i].mbuf = m; 365 if (m != NULL) { 366 m->m_len = m->m_pkthdr.len = m->m_ext.ext_size; 367 STAILQ_INSERT_TAIL(&xferq->stfree, 368 &xferq->bulkxfer[i], link); 369 } else 370 printf("fwe_as_input: m_getcl failed\n"); 371 } 372 STAILQ_INIT(&fwe->xferlist); 373 for (i = 0; i < TX_MAX_QUEUE; i++) { 374 xfer = fw_xfer_alloc(M_FWE); 375 if (xfer == NULL) 376 break; 377 xfer->send.spd = tx_speed; 378 xfer->fc = fwe->fd.fc; 379 xfer->retry_req = fw_asybusy; 380 xfer->sc = (caddr_t)fwe; 381 xfer->act.hand = fwe_output_callback; 382 STAILQ_INSERT_TAIL(&fwe->xferlist, xfer, link); 383 } 384 } else 385 xferq = fc->ir[fwe->dma_ch]; 386 387 388 /* start dma */ 389 if ((xferq->flag & FWXFERQ_RUNNING) == 0) 390 fc->irx_enable(fc, fwe->dma_ch); 391 392 ifp->if_flags |= IFF_RUNNING; 393 ifp->if_flags &= ~IFF_OACTIVE; 394 395 FWE_POLL_REGISTER(fwe_poll, fwe, ifp); 396#if 0 397 /* attempt to start output */ 398 fwe_start(ifp); 399#endif 400} 401 402 403static int 404fwe_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) 405{ 406 struct fwe_softc *fwe = ((struct fwe_eth_softc *)ifp->if_softc)->fwe; 407 struct ifstat *ifs = NULL; 408 int s, error, len; 409 410 switch (cmd) { 411 case SIOCSIFFLAGS: 412 s = splimp(); 413 if (ifp->if_flags & IFF_UP) { 414 if (!(ifp->if_flags & IFF_RUNNING)) 415 fwe_init(&fwe->eth_softc); 416 } else { 417 if (ifp->if_flags & IFF_RUNNING) 418 fwe_stop(fwe); 419 } 420 /* XXX keep promiscoud mode */ 421 ifp->if_flags |= IFF_PROMISC; 422 splx(s); 423 break; 424 case SIOCADDMULTI: 425 case SIOCDELMULTI: 426 break; 427 428 case SIOCGIFSTATUS: 429 s = splimp(); 430 ifs = (struct ifstat *)data; 431 len = strlen(ifs->ascii); 432 if (len < sizeof(ifs->ascii)) 433 snprintf(ifs->ascii + len, 434 sizeof(ifs->ascii) - len, 435 "\tch %d dma %d\n", 436 fwe->stream_ch, fwe->dma_ch); 437 splx(s); 438 break; 439#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 440 default: 441#else 442 case SIOCSIFADDR: 443 case SIOCGIFADDR: 444 case SIOCSIFMTU: 445#endif 446 s = splimp(); 447 error = ether_ioctl(ifp, cmd, data); 448 splx(s); 449 return (error); 450#if defined(__DragonFly__) || __FreeBSD_version < 500000 451 default: 452 return (EINVAL); 453#endif 454 } 455 456 return (0); 457} 458 459static void 460fwe_output_callback(struct fw_xfer *xfer) 461{ 462 struct fwe_softc *fwe; 463 struct ifnet *ifp; 464 int s; 465 466 fwe = (struct fwe_softc *)xfer->sc; 467 ifp = &fwe->fwe_if; 468 /* XXX error check */ 469 FWEDEBUG(ifp, "resp = %d\n", xfer->resp); 470 if (xfer->resp != 0) 471 ifp->if_oerrors ++; 472 473 m_freem(xfer->mbuf); 474 fw_xfer_unload(xfer); 475 476 s = splimp(); 477 STAILQ_INSERT_TAIL(&fwe->xferlist, xfer, link); 478 splx(s); 479 480 /* for queue full */ 481 if (ifp->if_snd.ifq_head != NULL) 482 fwe_start(ifp); 483} 484 485static void 486fwe_start(struct ifnet *ifp) 487{ 488 struct fwe_softc *fwe = ((struct fwe_eth_softc *)ifp->if_softc)->fwe; 489 int s; 490 491 GIANT_REQUIRED; 492 493 FWEDEBUG(ifp, "starting\n"); 494 495 if (fwe->dma_ch < 0) { 496 struct mbuf *m = NULL; 497 498 FWEDEBUG(ifp, "not ready\n"); 499 500 s = splimp(); 501 do { 502 IF_DEQUEUE(&ifp->if_snd, m); 503 if (m != NULL) 504 m_freem(m); 505 ifp->if_oerrors ++; 506 } while (m != NULL); 507 splx(s); 508 509 return; 510 } 511 512 s = splimp(); 513 ifp->if_flags |= IFF_OACTIVE; 514 515 if (ifp->if_snd.ifq_len != 0) 516 fwe_as_output(fwe, ifp); 517 518 ifp->if_flags &= ~IFF_OACTIVE; 519 splx(s); 520} 521 522#define HDR_LEN 4 523#ifndef ETHER_ALIGN 524#define ETHER_ALIGN 2 525#endif 526/* Async. stream output */ 527static void 528fwe_as_output(struct fwe_softc *fwe, struct ifnet *ifp) 529{ 530 struct mbuf *m; 531 struct fw_xfer *xfer; 532 struct fw_xferq *xferq; 533 struct fw_pkt *fp; 534 int i = 0; 535 536 xfer = NULL; 537 xferq = fwe->fd.fc->atq; 538 while (xferq->queued < xferq->maxq - 1) { 539 xfer = STAILQ_FIRST(&fwe->xferlist); 540 if (xfer == NULL) { 541 printf("if_fwe: lack of xfer\n"); 542 return; 543 } 544 IF_DEQUEUE(&ifp->if_snd, m); 545 if (m == NULL) 546 break; 547 STAILQ_REMOVE_HEAD(&fwe->xferlist, link); 548#if defined(__DragonFly__) || __FreeBSD_version < 500000 549 if (ifp->if_bpf != NULL) 550 bpf_mtap(ifp, m); 551#else 552 BPF_MTAP(ifp, m); 553#endif 554 555 /* keep ip packet alignment for alpha */ 556 M_PREPEND(m, ETHER_ALIGN, M_DONTWAIT); 557 fp = &xfer->send.hdr; 558 *(uint32_t *)&xfer->send.hdr = *(int32_t *)&fwe->pkt_hdr; 559 fp->mode.stream.len = m->m_pkthdr.len; 560 xfer->mbuf = m; 561 xfer->send.pay_len = m->m_pkthdr.len; 562 563 if (fw_asyreq(fwe->fd.fc, -1, xfer) != 0) { 564 /* error */ 565 ifp->if_oerrors ++; 566 /* XXX set error code */ 567 fwe_output_callback(xfer); 568 } else { 569 ifp->if_opackets ++; 570 i++; 571 } 572 } 573#if 0 574 if (i > 1) 575 printf("%d queued\n", i); 576#endif 577 if (i > 0) 578 xferq->start(fwe->fd.fc); 579} 580 581/* Async. stream output */ 582static void 583fwe_as_input(struct fw_xferq *xferq) 584{ 585 struct mbuf *m, *m0; 586 struct ifnet *ifp; 587 struct fwe_softc *fwe; 588 struct fw_bulkxfer *sxfer; 589 struct fw_pkt *fp; 590 u_char *c; 591#if defined(__DragonFly__) || __FreeBSD_version < 500000 592 struct ether_header *eh; 593#endif 594 595 fwe = (struct fwe_softc *)xferq->sc; 596 ifp = &fwe->fwe_if; 597#if 0 598 FWE_POLL_REGISTER(fwe_poll, fwe, ifp); 599#endif 600 while ((sxfer = STAILQ_FIRST(&xferq->stvalid)) != NULL) { 601 STAILQ_REMOVE_HEAD(&xferq->stvalid, link); 602 fp = mtod(sxfer->mbuf, struct fw_pkt *); 603 if (fwe->fd.fc->irx_post != NULL) 604 fwe->fd.fc->irx_post(fwe->fd.fc, fp->mode.ld); 605 m = sxfer->mbuf; 606 607 /* insert new rbuf */ 608 sxfer->mbuf = m0 = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); 609 if (m0 != NULL) { 610 m0->m_len = m0->m_pkthdr.len = m0->m_ext.ext_size; 611 STAILQ_INSERT_TAIL(&xferq->stfree, sxfer, link); 612 } else 613 printf("fwe_as_input: m_getcl failed\n"); 614 615 if (sxfer->resp != 0 || fp->mode.stream.len < 616 ETHER_ALIGN + sizeof(struct ether_header)) { 617 m_freem(m); 618 ifp->if_ierrors ++; 619 continue; 620 } 621 622 m->m_data += HDR_LEN + ETHER_ALIGN; 623 c = mtod(m, char *); 624#if defined(__DragonFly__) || __FreeBSD_version < 500000 625 eh = (struct ether_header *)c; 626 m->m_data += sizeof(struct ether_header); 627 m->m_len = m->m_pkthdr.len = fp->mode.stream.len - ETHER_ALIGN 628 - sizeof(struct ether_header); 629#else 630 m->m_len = m->m_pkthdr.len = fp->mode.stream.len - ETHER_ALIGN; 631#endif 632 m->m_pkthdr.rcvif = ifp; 633#if 0 634 FWEDEBUG(ifp, "%02x %02x %02x %02x %02x %02x\n" 635 "%02x %02x %02x %02x %02x %02x\n" 636 "%02x %02x %02x %02x\n" 637 "%02x %02x %02x %02x\n" 638 "%02x %02x %02x %02x\n" 639 "%02x %02x %02x %02x\n", 640 c[0], c[1], c[2], c[3], c[4], c[5], 641 c[6], c[7], c[8], c[9], c[10], c[11], 642 c[12], c[13], c[14], c[15], 643 c[16], c[17], c[18], c[19], 644 c[20], c[21], c[22], c[23], 645 c[20], c[21], c[22], c[23] 646 ); 647#endif 648#if defined(__DragonFly__) || __FreeBSD_version < 500000 649 ether_input(ifp, eh, m); 650#else 651 (*ifp->if_input)(ifp, m); 652#endif 653 ifp->if_ipackets ++; 654 } 655 if (STAILQ_FIRST(&xferq->stfree) != NULL) 656 fwe->fd.fc->irx_enable(fwe->fd.fc, fwe->dma_ch); 657} 658 659 660static devclass_t fwe_devclass; 661 662static device_method_t fwe_methods[] = { 663 /* device interface */ 664 DEVMETHOD(device_identify, fwe_identify), 665 DEVMETHOD(device_probe, fwe_probe), 666 DEVMETHOD(device_attach, fwe_attach), 667 DEVMETHOD(device_detach, fwe_detach), 668 { 0, 0 } 669}; 670 671static driver_t fwe_driver = { 672 "fwe", 673 fwe_methods, 674 sizeof(struct fwe_softc), 675}; 676 677 678#ifdef __DragonFly__ 679DECLARE_DUMMY_MODULE(fwe); 680#endif 681DRIVER_MODULE(fwe, firewire, fwe_driver, fwe_devclass, 0, 0); 682MODULE_VERSION(fwe, 1); 683MODULE_DEPEND(fwe, firewire, 1, 1, 1); 684