if_fwe.c revision 118312
194575Sdes/* 294575Sdes * Copyright (c) 2002-2003 394575Sdes * Hidetoshi Shimokawa. All rights reserved. 494575Sdes * 594575Sdes * Redistribution and use in source and binary forms, with or without 694575Sdes * modification, are permitted provided that the following conditions 794575Sdes * are met: 894575Sdes * 1. Redistributions of source code must retain the above copyright 994575Sdes * notice, this list of conditions and the following disclaimer. 1094575Sdes * 2. Redistributions in binary form must reproduce the above copyright 1194575Sdes * notice, this list of conditions and the following disclaimer in the 1294575Sdes * documentation and/or other materials provided with the distribution. 1394575Sdes * 3. All advertising materials mentioning features or use of this software 1494575Sdes * must display the following acknowledgement: 1594575Sdes * 1694575Sdes * This product includes software developed by Hidetoshi Shimokawa. 1794575Sdes * 1894575Sdes * 4. Neither the name of the author nor the names of its contributors 1994575Sdes * may be used to endorse or promote products derived from this software 2094575Sdes * without specific prior written permission. 2194575Sdes * 2294575Sdes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2394575Sdes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2494575Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2594575Sdes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2694575Sdes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2794575Sdes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2894575Sdes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2994575Sdes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3094575Sdes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3194575Sdes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3294575Sdes * SUCH DAMAGE. 3394575Sdes * 3494575Sdes * $FreeBSD: head/sys/dev/firewire/if_fwe.c 118312 2003-08-01 17:19:12Z simokawa $ 3594575Sdes */ 3694575Sdes 3794575Sdes#include "opt_inet.h" 3894575Sdes 3994575Sdes#include <sys/param.h> 4094575Sdes#include <sys/kernel.h> 4194575Sdes#include <sys/malloc.h> 4294575Sdes#include <sys/mbuf.h> 4394575Sdes#include <sys/socket.h> 4494575Sdes#include <sys/sockio.h> 4594575Sdes#include <sys/sysctl.h> 4694575Sdes#include <sys/systm.h> 4794575Sdes#include <sys/module.h> 4894575Sdes#include <sys/bus.h> 4994575Sdes#include <machine/bus.h> 5094575Sdes 5194575Sdes#include <net/bpf.h> 5294575Sdes#include <net/ethernet.h> 5394575Sdes#include <net/if.h> 5494575Sdes#include <net/if_arp.h> 5594575Sdes#include <net/if_vlan_var.h> 5694575Sdes 5794575Sdes#include <dev/firewire/firewire.h> 5894575Sdes#include <dev/firewire/firewirereg.h> 5994575Sdes#include <dev/firewire/if_fwevar.h> 6094575Sdes 6194575Sdes#define FWEDEBUG if (fwedebug) printf 6294575Sdes#define TX_MAX_QUEUE (FWMAXQUEUE - 1) 63#define RX_MAX_QUEUE FWMAXQUEUE 64 65/* network interface */ 66static void fwe_start __P((struct ifnet *)); 67static int fwe_ioctl __P((struct ifnet *, u_long, caddr_t)); 68static void fwe_init __P((void *)); 69 70static void fwe_output_callback __P((struct fw_xfer *)); 71static void fwe_as_output __P((struct fwe_softc *, struct ifnet *)); 72static void fwe_as_input __P((struct fw_xferq *)); 73 74static int fwedebug = 0; 75static int stream_ch = 1; 76static int tx_speed = 2; 77 78MALLOC_DEFINE(M_FWE, "if_fwe", "Ethernet over FireWire interface"); 79SYSCTL_INT(_debug, OID_AUTO, if_fwe_debug, CTLFLAG_RW, &fwedebug, 0, ""); 80SYSCTL_DECL(_hw_firewire); 81SYSCTL_NODE(_hw_firewire, OID_AUTO, fwe, CTLFLAG_RD, 0, 82 "Ethernet Emulation Subsystem"); 83SYSCTL_INT(_hw_firewire_fwe, OID_AUTO, stream_ch, CTLFLAG_RW, &stream_ch, 0, 84 "Stream channel to use"); 85SYSCTL_INT(_hw_firewire_fwe, OID_AUTO, tx_speed, CTLFLAG_RW, &tx_speed, 0, 86 "Transmission Speed"); 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 102static poll_handler_t fwe_poll; 103 104static void 105fwe_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 123static void 124fwe_identify(driver_t *driver, device_t parent) 125{ 126 BUS_ADD_CHILD(parent, 0, "if_fwe", device_get_unit(parent)); 127} 128 129static int 130fwe_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 143static int 144fwe_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 218static void 219fwe_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 | FWXFERQ_STREAM | 238 FWXFERQ_EXTBUF | FWXFERQ_HANDLER | FWXFERQ_CHTAGMASK); 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 259static int 260fwe_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 279static void 280fwe_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 struct mbuf *m; 288 int i; 289 290 FWEDEBUG("initializing %s%d\n", ifp->if_name, ifp->if_unit); 291 292 /* XXX keep promiscoud mode */ 293 ifp->if_flags |= IFF_PROMISC; 294 295 fc = fwe->fd.fc; 296#define START 0 297 if (fwe->dma_ch < 0) { 298 for (i = START; i < fc->nisodma; i ++) { 299 xferq = fc->ir[i]; 300 if ((xferq->flag & FWXFERQ_OPEN) == 0) 301 goto found; 302 } 303 printf("no free dma channel\n"); 304 return; 305found: 306 fwe->dma_ch = i; 307 fwe->stream_ch = stream_ch; 308 fwe->pkt_hdr.mode.stream.chtag = fwe->stream_ch; 309 /* allocate DMA channel and init packet mode */ 310 xferq->flag |= FWXFERQ_OPEN | FWXFERQ_EXTBUF | 311 FWXFERQ_HANDLER | FWXFERQ_STREAM; 312 xferq->flag &= ~0xff; 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->bnchunk = RX_MAX_QUEUE; 318 xferq->bnpacket = 1; 319 xferq->psize = MCLBYTES; 320 xferq->queued = 0; 321 xferq->buf = NULL; 322 xferq->bulkxfer = (struct fw_bulkxfer *) malloc( 323 sizeof(struct fw_bulkxfer) * xferq->bnchunk, 324 M_FWE, M_WAITOK); 325 if (xferq->bulkxfer == NULL) { 326 printf("if_fwe: malloc failed\n"); 327 return; 328 } 329 STAILQ_INIT(&xferq->stvalid); 330 STAILQ_INIT(&xferq->stfree); 331 STAILQ_INIT(&xferq->stdma); 332 xferq->stproc = NULL; 333 for (i = 0; i < xferq->bnchunk; i ++) { 334 m = 335#if __FreeBSD_version >= 500000 336 m_getcl(M_TRYWAIT, MT_DATA, M_PKTHDR); 337#else 338 m_getcl(M_WAIT, MT_DATA, M_PKTHDR); 339#endif 340 xferq->bulkxfer[i].mbuf = m; 341 if (m != NULL) { 342 m->m_len = m->m_pkthdr.len = m->m_ext.ext_size; 343 STAILQ_INSERT_TAIL(&xferq->stfree, 344 &xferq->bulkxfer[i], link); 345 } else 346 printf("fwe_as_input: m_getcl failed\n"); 347 } 348 STAILQ_INIT(&fwe->xferlist); 349 for (i = 0; i < TX_MAX_QUEUE; i++) { 350 xfer = fw_xfer_alloc(M_FWE); 351 if (xfer == NULL) 352 break; 353 xfer->spd = tx_speed; 354 xfer->fc = fwe->fd.fc; 355 xfer->retry_req = fw_asybusy; 356 xfer->sc = (caddr_t)fwe; 357 xfer->act.hand = fwe_output_callback; 358 STAILQ_INSERT_TAIL(&fwe->xferlist, xfer, link); 359 } 360 } else 361 xferq = fc->ir[fwe->dma_ch]; 362 363 364 /* start dma */ 365 if ((xferq->flag & FWXFERQ_RUNNING) == 0) 366 fc->irx_enable(fc, fwe->dma_ch); 367 368 ifp->if_flags |= IFF_RUNNING; 369 ifp->if_flags &= ~IFF_OACTIVE; 370 371 FWE_POLL_REGISTER(fwe_poll, fwe, ifp); 372#if 0 373 /* attempt to start output */ 374 fwe_start(ifp); 375#endif 376} 377 378 379static int 380fwe_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) 381{ 382 struct fwe_softc *fwe = ((struct fwe_eth_softc *)ifp->if_softc)->fwe; 383 struct ifstat *ifs = NULL; 384 int s, error, len; 385 386 switch (cmd) { 387 case SIOCSIFFLAGS: 388 s = splimp(); 389 if (ifp->if_flags & IFF_UP) { 390 if (!(ifp->if_flags & IFF_RUNNING)) 391 fwe_init(&fwe->eth_softc); 392 } else { 393 if (ifp->if_flags & IFF_RUNNING) 394 fwe_stop(fwe); 395 } 396 /* XXX keep promiscoud mode */ 397 ifp->if_flags |= IFF_PROMISC; 398 splx(s); 399 break; 400 case SIOCADDMULTI: 401 case SIOCDELMULTI: 402 break; 403 404 case SIOCGIFSTATUS: 405 s = splimp(); 406 ifs = (struct ifstat *)data; 407 len = strlen(ifs->ascii); 408 if (len < sizeof(ifs->ascii)) 409 snprintf(ifs->ascii + len, 410 sizeof(ifs->ascii) - len, 411 "\tch %d dma %d\n", 412 fwe->stream_ch, fwe->dma_ch); 413 splx(s); 414 break; 415#if __FreeBSD_version >= 500000 416 default: 417#else 418 case SIOCSIFADDR: 419 case SIOCGIFADDR: 420 case SIOCSIFMTU: 421#endif 422 s = splimp(); 423 error = ether_ioctl(ifp, cmd, data); 424 splx(s); 425 return (error); 426#if __FreeBSD_version < 500000 427 default: 428 return (EINVAL); 429#endif 430 } 431 432 return (0); 433} 434 435static void 436fwe_output_callback(struct fw_xfer *xfer) 437{ 438 struct fwe_softc *fwe; 439 struct ifnet *ifp; 440 int s; 441 442 fwe = (struct fwe_softc *)xfer->sc; 443 ifp = &fwe->fwe_if; 444 /* XXX error check */ 445 FWEDEBUG("resp = %d\n", xfer->resp); 446 if (xfer->resp != 0) 447 ifp->if_oerrors ++; 448 449 m_freem(xfer->mbuf); 450 xfer->send.buf = NULL; 451 fw_xfer_unload(xfer); 452 453 s = splimp(); 454 STAILQ_INSERT_TAIL(&fwe->xferlist, xfer, link); 455 splx(s); 456 457 /* for queue full */ 458 if (ifp->if_snd.ifq_head != NULL) 459 fwe_start(ifp); 460} 461 462static void 463fwe_start(struct ifnet *ifp) 464{ 465 struct fwe_softc *fwe = ((struct fwe_eth_softc *)ifp->if_softc)->fwe; 466 int s; 467 468 FWEDEBUG("%s%d starting\n", ifp->if_name, ifp->if_unit); 469 470 if (fwe->dma_ch < 0) { 471 struct mbuf *m = NULL; 472 473 FWEDEBUG("%s%d not ready.\n", ifp->if_name, ifp->if_unit); 474 475 s = splimp(); 476 do { 477 IF_DEQUEUE(&ifp->if_snd, m); 478 if (m != NULL) 479 m_freem(m); 480 ifp->if_oerrors ++; 481 } while (m != NULL); 482 splx(s); 483 484 return; 485 } 486 487 s = splimp(); 488 ifp->if_flags |= IFF_OACTIVE; 489 490 if (ifp->if_snd.ifq_len != 0) 491 fwe_as_output(fwe, ifp); 492 493 ifp->if_flags &= ~IFF_OACTIVE; 494 splx(s); 495} 496 497#define HDR_LEN 4 498#ifndef ETHER_ALIGN 499#define ETHER_ALIGN 2 500#endif 501/* Async. stream output */ 502static void 503fwe_as_output(struct fwe_softc *fwe, struct ifnet *ifp) 504{ 505 struct mbuf *m; 506 struct fw_xfer *xfer; 507 struct fw_xferq *xferq; 508 struct fw_pkt *fp; 509 int i = 0; 510 511 xfer = NULL; 512 xferq = fwe->fd.fc->atq; 513 while (xferq->queued < xferq->maxq - 1) { 514 xfer = STAILQ_FIRST(&fwe->xferlist); 515 if (xfer == NULL) { 516 printf("if_fwe: lack of xfer\n"); 517 return; 518 } 519 IF_DEQUEUE(&ifp->if_snd, m); 520 if (m == NULL) 521 break; 522 STAILQ_REMOVE_HEAD(&fwe->xferlist, link); 523#if __FreeBSD_version >= 500000 524 BPF_MTAP(ifp, m); 525#else 526 if (ifp->if_bpf != NULL) 527 bpf_mtap(ifp, m); 528#endif 529 530 /* keep ip packet alignment for alpha */ 531 M_PREPEND(m, ETHER_ALIGN, M_DONTWAIT); 532 fp = (struct fw_pkt *)&xfer->dst; /* XXX */ 533 xfer->dst = *((int32_t *)&fwe->pkt_hdr); 534 fp->mode.stream.len = m->m_pkthdr.len; 535 xfer->send.buf = (caddr_t) fp; 536 xfer->mbuf = m; 537 xfer->send.len = m->m_pkthdr.len + HDR_LEN; 538 539 if (fw_asyreq(fwe->fd.fc, -1, xfer) != 0) { 540 /* error */ 541 ifp->if_oerrors ++; 542 /* XXX set error code */ 543 fwe_output_callback(xfer); 544 } else { 545 ifp->if_opackets ++; 546 i++; 547 } 548 } 549#if 0 550 if (i > 1) 551 printf("%d queued\n", i); 552#endif 553 if (i > 0) 554 xferq->start(fwe->fd.fc); 555} 556 557/* Async. stream output */ 558static void 559fwe_as_input(struct fw_xferq *xferq) 560{ 561 struct mbuf *m, *m0; 562 struct ifnet *ifp; 563 struct fwe_softc *fwe; 564 struct fw_bulkxfer *sxfer; 565 struct fw_pkt *fp; 566 u_char *c; 567#if __FreeBSD_version < 500000 568 struct ether_header *eh; 569#endif 570 571 fwe = (struct fwe_softc *)xferq->sc; 572 ifp = &fwe->fwe_if; 573#if 0 574 FWE_POLL_REGISTER(fwe_poll, fwe, ifp); 575#endif 576 while ((sxfer = STAILQ_FIRST(&xferq->stvalid)) != NULL) { 577 STAILQ_REMOVE_HEAD(&xferq->stvalid, link); 578 if (sxfer->resp != 0) 579 ifp->if_ierrors ++; 580 fp = mtod(sxfer->mbuf, struct fw_pkt *); 581 /* XXX */ 582 if (fwe->fd.fc->irx_post != NULL) 583 fwe->fd.fc->irx_post(fwe->fd.fc, fp->mode.ld); 584 m = sxfer->mbuf; 585 586 /* insert rbuf */ 587 sxfer->mbuf = m0 = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); 588 if (m0 != NULL) { 589 m0->m_len = m0->m_pkthdr.len = m0->m_ext.ext_size; 590 STAILQ_INSERT_TAIL(&xferq->stfree, sxfer, link); 591 } else 592 printf("fwe_as_input: m_getcl failed\n"); 593 594 m->m_data += HDR_LEN + ETHER_ALIGN; 595 c = mtod(m, char *); 596#if __FreeBSD_version < 500000 597 eh = (struct ether_header *)c; 598 m->m_data += sizeof(struct ether_header); 599#endif 600 m->m_len = m->m_pkthdr.len = 601 fp->mode.stream.len - ETHER_ALIGN; 602 m->m_pkthdr.rcvif = ifp; 603#if 0 604 FWEDEBUG("%02x %02x %02x %02x %02x %02x\n" 605 "%02x %02x %02x %02x %02x %02x\n" 606 "%02x %02x %02x %02x\n" 607 "%02x %02x %02x %02x\n" 608 "%02x %02x %02x %02x\n" 609 "%02x %02x %02x %02x\n", 610 c[0], c[1], c[2], c[3], c[4], c[5], 611 c[6], c[7], c[8], c[9], c[10], c[11], 612 c[12], c[13], c[14], c[15], 613 c[16], c[17], c[18], c[19], 614 c[20], c[21], c[22], c[23], 615 c[20], c[21], c[22], c[23] 616 ); 617#endif 618#if __FreeBSD_version >= 500000 619 (*ifp->if_input)(ifp, m); 620#else 621 ether_input(ifp, eh, m); 622#endif 623 ifp->if_ipackets ++; 624 } 625 if (STAILQ_FIRST(&xferq->stfree) != NULL) 626 fwe->fd.fc->irx_enable(fwe->fd.fc, fwe->dma_ch); 627} 628 629 630static devclass_t fwe_devclass; 631 632static device_method_t fwe_methods[] = { 633 /* device interface */ 634 DEVMETHOD(device_identify, fwe_identify), 635 DEVMETHOD(device_probe, fwe_probe), 636 DEVMETHOD(device_attach, fwe_attach), 637 DEVMETHOD(device_detach, fwe_detach), 638 { 0, 0 } 639}; 640 641static driver_t fwe_driver = { 642 "if_fwe", 643 fwe_methods, 644 sizeof(struct fwe_softc), 645}; 646 647 648DRIVER_MODULE(fwe, firewire, fwe_driver, fwe_devclass, 0, 0); 649MODULE_VERSION(fwe, 1); 650MODULE_DEPEND(fwe, firewire, 1, 1, 1); 651