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