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