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 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 242 static void 243 fwe_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 283 static int 284 fwe_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 303 static void 304 fwe_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; 329 found: 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 403 static int 404 fwe_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 459 static void 460 fwe_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 485 static void 486 fwe_start(struct ifnet *ifp) 487 { 488 struct fwe_softc *fwe = ((struct fwe_eth_softc *)ifp->if_softc)->fwe; 489 int s; 490 491 FWEDEBUG(ifp, "starting\n"); 492 493 if (fwe->dma_ch < 0) { 494 struct mbuf *m = NULL; 495 496 FWEDEBUG(ifp, "not ready\n"); 497 498 s = splimp(); 499 do { 500 IF_DEQUEUE(&ifp->if_snd, m); 501 if (m != NULL) 502 m_freem(m); 503 ifp->if_oerrors ++; 504 } while (m != NULL); 505 splx(s); 506 507 return; 508 } 509 510 s = splimp(); 511 ifp->if_flags |= IFF_OACTIVE; 512 513 if (ifp->if_snd.ifq_len != 0) 514 fwe_as_output(fwe, ifp); 515 516 ifp->if_flags &= ~IFF_OACTIVE; 517 splx(s); 518 } 519 520 #define HDR_LEN 4 521 #ifndef ETHER_ALIGN 522 #define ETHER_ALIGN 2 523 #endif 524 /* Async. stream output */ 525 static void 526 fwe_as_output(struct fwe_softc *fwe, struct ifnet *ifp) 527 { 528 struct mbuf *m; 529 struct fw_xfer *xfer; 530 struct fw_xferq *xferq; 531 struct fw_pkt *fp; 532 int i = 0; 533 534 xfer = NULL; 535 xferq = fwe->fd.fc->atq; 536 while (xferq->queued < xferq->maxq - 1) { 537 xfer = STAILQ_FIRST(&fwe->xferlist); 538 if (xfer == NULL) { 539 printf("if_fwe: lack of xfer\n"); 540 return; 541 } 542 IF_DEQUEUE(&ifp->if_snd, m); 543 if (m == NULL) 544 break; 545 STAILQ_REMOVE_HEAD(&fwe->xferlist, link); 546 #if defined(__DragonFly__) || __FreeBSD_version < 500000 547 if (ifp->if_bpf != NULL) 548 bpf_mtap(ifp, m); 549 #else 550 BPF_MTAP(ifp, m); 551 #endif 552 553 /* keep ip packet alignment for alpha */ 554 M_PREPEND(m, ETHER_ALIGN, M_DONTWAIT); 555 fp = &xfer->send.hdr; 556 *(uint32_t *)&xfer->send.hdr = *(int32_t *)&fwe->pkt_hdr; 557 fp->mode.stream.len = m->m_pkthdr.len; 558 xfer->mbuf = m; 559 xfer->send.pay_len = m->m_pkthdr.len; 560 561 if (fw_asyreq(fwe->fd.fc, -1, xfer) != 0) { 562 /* error */ 563 ifp->if_oerrors ++; 564 /* XXX set error code */ 565 fwe_output_callback(xfer); 566 } else { 567 ifp->if_opackets ++; 568 i++; 569 } 570 } 571 #if 0 572 if (i > 1) 573 printf("%d queued\n", i); 574 #endif 575 if (i > 0) 576 xferq->start(fwe->fd.fc); 577 } 578 579 /* Async. stream output */ 580 static void 581 fwe_as_input(struct fw_xferq *xferq) 582 { 583 struct mbuf *m, *m0; 584 struct ifnet *ifp; 585 struct fwe_softc *fwe; 586 struct fw_bulkxfer *sxfer; 587 struct fw_pkt *fp; 588 u_char *c; 589 #if defined(__DragonFly__) || __FreeBSD_version < 500000 590 struct ether_header *eh; 591 #endif 592 593 fwe = (struct fwe_softc *)xferq->sc; 594 ifp = &fwe->fwe_if; 595 #if 0 596 FWE_POLL_REGISTER(fwe_poll, fwe, ifp); 597 #endif 598 while ((sxfer = STAILQ_FIRST(&xferq->stvalid)) != NULL) { 599 STAILQ_REMOVE_HEAD(&xferq->stvalid, link); 600 fp = mtod(sxfer->mbuf, struct fw_pkt *); 601 if (fwe->fd.fc->irx_post != NULL) 602 fwe->fd.fc->irx_post(fwe->fd.fc, fp->mode.ld); 603 m = sxfer->mbuf; 604 605 /* insert new rbuf */ 606 sxfer->mbuf = m0 = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); 607 if (m0 != NULL) { 608 m0->m_len = m0->m_pkthdr.len = m0->m_ext.ext_size; 609 STAILQ_INSERT_TAIL(&xferq->stfree, sxfer, link); 610 } else 611 printf("fwe_as_input: m_getcl failed\n"); 612 613 if (sxfer->resp != 0 || fp->mode.stream.len < 614 ETHER_ALIGN + sizeof(struct ether_header)) { 615 m_freem(m); 616 ifp->if_ierrors ++; 617 continue; 618 } 619 620 m->m_data += HDR_LEN + ETHER_ALIGN; 621 c = mtod(m, char *); 622 #if defined(__DragonFly__) || __FreeBSD_version < 500000 623 eh = (struct ether_header *)c; 624 m->m_data += sizeof(struct ether_header); 625 m->m_len = m->m_pkthdr.len = fp->mode.stream.len - ETHER_ALIGN 626 - sizeof(struct ether_header); 627 #else 628 m->m_len = m->m_pkthdr.len = fp->mode.stream.len - ETHER_ALIGN; 629 #endif 630 m->m_pkthdr.rcvif = ifp; 631 #if 0 632 FWEDEBUG(ifp, "%02x %02x %02x %02x %02x %02x\n" 633 "%02x %02x %02x %02x %02x %02x\n" 634 "%02x %02x %02x %02x\n" 635 "%02x %02x %02x %02x\n" 636 "%02x %02x %02x %02x\n" 637 "%02x %02x %02x %02x\n", 638 c[0], c[1], c[2], c[3], c[4], c[5], 639 c[6], c[7], c[8], c[9], c[10], c[11], 640 c[12], c[13], c[14], c[15], 641 c[16], c[17], c[18], c[19], 642 c[20], c[21], c[22], c[23], 643 c[20], c[21], c[22], c[23] 644 ); 645 #endif 646 #if defined(__DragonFly__) || __FreeBSD_version < 500000 647 ether_input(ifp, eh, m); 648 #else 649 (*ifp->if_input)(ifp, m); 650 #endif 651 ifp->if_ipackets ++; 652 } 653 if (STAILQ_FIRST(&xferq->stfree) != NULL) 654 fwe->fd.fc->irx_enable(fwe->fd.fc, fwe->dma_ch); 655 } 656 657 658 static devclass_t fwe_devclass; 659 660 static device_method_t fwe_methods[] = { 661 /* device interface */ 662 DEVMETHOD(device_identify, fwe_identify), 663 DEVMETHOD(device_probe, fwe_probe), 664 DEVMETHOD(device_attach, fwe_attach), 665 DEVMETHOD(device_detach, fwe_detach), 666 { 0, 0 } 667 }; 668 669 static driver_t fwe_driver = { 670 "fwe", 671 fwe_methods, 672 sizeof(struct fwe_softc), 673 }; 674 675 676 #ifdef __DragonFly__ 677 DECLARE_DUMMY_MODULE(fwe); 678 #endif 679 DRIVER_MODULE(fwe, firewire, fwe_driver, fwe_devclass, 0, 0); 680 MODULE_VERSION(fwe, 1); 681 MODULE_DEPEND(fwe, firewire, 1, 1, 1); 682