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