Deleted Added
full compact
if_fwe.c (124251) if_fwe.c (127468)
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

--- 17 unchanged lines hidden (view full) ---

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 *
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

--- 17 unchanged lines hidden (view full) ---

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: head/sys/dev/firewire/if_fwe.c 124251 2004-01-08 14:58:09Z simokawa $
34 * $FreeBSD: head/sys/dev/firewire/if_fwe.c 127468 2004-03-26 23:17:10Z simokawa $
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>

--- 4 unchanged lines hidden (view full) ---

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>
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>

--- 4 unchanged lines hidden (view full) ---

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
55#include <net/if_vlan_var.h>
56
57#include <dev/firewire/firewire.h>
58#include <dev/firewire/firewirereg.h>
59#include <dev/firewire/if_fwevar.h>
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
60
61#define FWEDEBUG if (fwedebug) if_printf
62#define TX_MAX_QUEUE (FWMAXQUEUE - 1)
63
64/* network interface */
65static void fwe_start (struct ifnet *);
66static int fwe_ioctl (struct ifnet *, u_long, caddr_t);
67static void fwe_init (void *);

--- 122 unchanged lines hidden (view full) ---

190 printf("if_fwe%d: Fake Ethernet address: "
191 "%02x:%02x:%02x:%02x:%02x:%02x\n", unit,
192 eaddr[0], eaddr[1], eaddr[2], eaddr[3], eaddr[4], eaddr[5]);
193
194 /* fill the rest and attach interface */
195 ifp = &fwe->fwe_if;
196 ifp->if_softc = &fwe->eth_softc;
197
67
68#define FWEDEBUG if (fwedebug) if_printf
69#define TX_MAX_QUEUE (FWMAXQUEUE - 1)
70
71/* network interface */
72static void fwe_start (struct ifnet *);
73static int fwe_ioctl (struct ifnet *, u_long, caddr_t);
74static void fwe_init (void *);

--- 122 unchanged lines hidden (view full) ---

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
198#if __FreeBSD_version >= 501113
205#if __FreeBSD_version >= 501113 || defined(__DragonFly__)
199 if_initname(ifp, device_get_name(dev), unit);
200#else
201 ifp->if_unit = unit;
202 ifp->if_name = "fwe";
203#endif
204 ifp->if_init = fwe_init;
205 ifp->if_output = ether_output;
206 ifp->if_start = fwe_start;
207 ifp->if_ioctl = fwe_ioctl;
208 ifp->if_mtu = ETHERMTU;
209 ifp->if_flags = (IFF_BROADCAST|IFF_SIMPLEX|IFF_MULTICAST);
210 ifp->if_snd.ifq_maxlen = TX_MAX_QUEUE;
211
212 s = splimp();
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_output = ether_output;
213 ifp->if_start = fwe_start;
214 ifp->if_ioctl = fwe_ioctl;
215 ifp->if_mtu = ETHERMTU;
216 ifp->if_flags = (IFF_BROADCAST|IFF_SIMPLEX|IFF_MULTICAST);
217 ifp->if_snd.ifq_maxlen = TX_MAX_QUEUE;
218
219 s = splimp();
213#if __FreeBSD_version >= 500000
214 ether_ifattach(ifp, eaddr);
215#else
220#if defined(__DragonFly__) || __FreeBSD_version < 500000
216 ether_ifattach(ifp, 1);
221 ether_ifattach(ifp, 1);
222#else
223 ether_ifattach(ifp, eaddr);
217#endif
218 splx(s);
219
220 /* Tell the upper layer(s) we support long frames. */
221 ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header);
224#endif
225 splx(s);
226
227 /* Tell the upper layer(s) we support long frames. */
228 ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header);
222#if __FreeBSD_version >= 500000
229#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
223 ifp->if_capabilities |= IFCAP_VLAN_MTU;
224#endif
225
226
227 FWEDEBUG(ifp, "interface created\n");
228 return 0;
229}
230

--- 43 unchanged lines hidden (view full) ---

274{
275 struct fwe_softc *fwe;
276 int s;
277
278 fwe = (struct fwe_softc *)device_get_softc(dev);
279 s = splimp();
280
281 fwe_stop(fwe);
230 ifp->if_capabilities |= IFCAP_VLAN_MTU;
231#endif
232
233
234 FWEDEBUG(ifp, "interface created\n");
235 return 0;
236}
237

--- 43 unchanged lines hidden (view full) ---

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);
282#if __FreeBSD_version >= 500000
283 ether_ifdetach(&fwe->fwe_if);
284#else
289#if defined(__DragonFly__) || __FreeBSD_version < 500000
285 ether_ifdetach(&fwe->fwe_if, 1);
290 ether_ifdetach(&fwe->fwe_if, 1);
291#else
292 ether_ifdetach(&fwe->fwe_if);
286#endif
287
288 splx(s);
289 return 0;
290}
291
292static void
293fwe_init(void *arg)

--- 46 unchanged lines hidden (view full) ---

340 return;
341 }
342 STAILQ_INIT(&xferq->stvalid);
343 STAILQ_INIT(&xferq->stfree);
344 STAILQ_INIT(&xferq->stdma);
345 xferq->stproc = NULL;
346 for (i = 0; i < xferq->bnchunk; i ++) {
347 m =
293#endif
294
295 splx(s);
296 return 0;
297}
298
299static void
300fwe_init(void *arg)

--- 46 unchanged lines hidden (view full) ---

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 =
348#if __FreeBSD_version >= 500000
349 m_getcl(M_TRYWAIT, MT_DATA, M_PKTHDR);
350#else
355#if defined(__DragonFly__) || __FreeBSD_version < 500000
351 m_getcl(M_WAIT, MT_DATA, M_PKTHDR);
356 m_getcl(M_WAIT, MT_DATA, M_PKTHDR);
357#else
358 m_getcl(M_TRYWAIT, MT_DATA, M_PKTHDR);
352#endif
353 xferq->bulkxfer[i].mbuf = m;
354 if (m != NULL) {
355 m->m_len = m->m_pkthdr.len = m->m_ext.ext_size;
356 STAILQ_INSERT_TAIL(&xferq->stfree,
357 &xferq->bulkxfer[i], link);
358 } else
359 printf("fwe_as_input: m_getcl failed\n");

--- 60 unchanged lines hidden (view full) ---

420 len = strlen(ifs->ascii);
421 if (len < sizeof(ifs->ascii))
422 snprintf(ifs->ascii + len,
423 sizeof(ifs->ascii) - len,
424 "\tch %d dma %d\n",
425 fwe->stream_ch, fwe->dma_ch);
426 splx(s);
427 break;
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");

--- 60 unchanged lines hidden (view full) ---

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;
428#if __FreeBSD_version >= 500000
435#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
429 default:
430#else
431 case SIOCSIFADDR:
432 case SIOCGIFADDR:
433 case SIOCSIFMTU:
434#endif
435 s = splimp();
436 error = ether_ioctl(ifp, cmd, data);
437 splx(s);
438 return (error);
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);
439#if __FreeBSD_version < 500000
446#if defined(__DragonFly__) || __FreeBSD_version < 500000
440 default:
441 return (EINVAL);
442#endif
443 }
444
445 return (0);
446}
447

--- 79 unchanged lines hidden (view full) ---

527 if (xfer == NULL) {
528 printf("if_fwe: lack of xfer\n");
529 return;
530 }
531 IF_DEQUEUE(&ifp->if_snd, m);
532 if (m == NULL)
533 break;
534 STAILQ_REMOVE_HEAD(&fwe->xferlist, link);
447 default:
448 return (EINVAL);
449#endif
450 }
451
452 return (0);
453}
454

--- 79 unchanged lines hidden (view full) ---

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);
535#if __FreeBSD_version >= 500000
536 BPF_MTAP(ifp, m);
537#else
542#if defined(__DragonFly__) || __FreeBSD_version < 500000
538 if (ifp->if_bpf != NULL)
539 bpf_mtap(ifp, m);
543 if (ifp->if_bpf != NULL)
544 bpf_mtap(ifp, m);
545#else
546 BPF_MTAP(ifp, m);
540#endif
541
542 /* keep ip packet alignment for alpha */
543 M_PREPEND(m, ETHER_ALIGN, M_DONTWAIT);
544 fp = &xfer->send.hdr;
545 *(u_int32_t *)&xfer->send.hdr = *(int32_t *)&fwe->pkt_hdr;
546 fp->mode.stream.len = m->m_pkthdr.len;
547 xfer->mbuf = m;

--- 22 unchanged lines hidden (view full) ---

570fwe_as_input(struct fw_xferq *xferq)
571{
572 struct mbuf *m, *m0;
573 struct ifnet *ifp;
574 struct fwe_softc *fwe;
575 struct fw_bulkxfer *sxfer;
576 struct fw_pkt *fp;
577 u_char *c;
547#endif
548
549 /* keep ip packet alignment for alpha */
550 M_PREPEND(m, ETHER_ALIGN, M_DONTWAIT);
551 fp = &xfer->send.hdr;
552 *(u_int32_t *)&xfer->send.hdr = *(int32_t *)&fwe->pkt_hdr;
553 fp->mode.stream.len = m->m_pkthdr.len;
554 xfer->mbuf = m;

--- 22 unchanged lines hidden (view full) ---

577fwe_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;
578#if __FreeBSD_version < 500000
585#if defined(__DragonFly__) || __FreeBSD_version < 500000
579 struct ether_header *eh;
580#endif
581
582 fwe = (struct fwe_softc *)xferq->sc;
583 ifp = &fwe->fwe_if;
584#if 0
585 FWE_POLL_REGISTER(fwe_poll, fwe, ifp);
586#endif

--- 16 unchanged lines hidden (view full) ---

603 ETHER_ALIGN + sizeof(struct ether_header)) {
604 m_freem(m);
605 ifp->if_ierrors ++;
606 continue;
607 }
608
609 m->m_data += HDR_LEN + ETHER_ALIGN;
610 c = mtod(m, char *);
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

--- 16 unchanged lines hidden (view full) ---

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 *);
611#if __FreeBSD_version < 500000
618#if defined(__DragonFly__) || __FreeBSD_version < 500000
612 eh = (struct ether_header *)c;
613 m->m_data += sizeof(struct ether_header);
614#endif
615 m->m_len = m->m_pkthdr.len =
616 fp->mode.stream.len - ETHER_ALIGN;
617 m->m_pkthdr.rcvif = ifp;
618#if 0
619 FWEDEBUG(ifp, "%02x %02x %02x %02x %02x %02x\n"

--- 5 unchanged lines hidden (view full) ---

625 c[0], c[1], c[2], c[3], c[4], c[5],
626 c[6], c[7], c[8], c[9], c[10], c[11],
627 c[12], c[13], c[14], c[15],
628 c[16], c[17], c[18], c[19],
629 c[20], c[21], c[22], c[23],
630 c[20], c[21], c[22], c[23]
631 );
632#endif
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"

--- 5 unchanged lines hidden (view full) ---

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
633#if __FreeBSD_version >= 500000
634 (*ifp->if_input)(ifp, m);
635#else
640#if defined(__DragonFly__) || __FreeBSD_version < 500000
636 ether_input(ifp, eh, m);
641 ether_input(ifp, eh, m);
642#else
643 (*ifp->if_input)(ifp, m);
637#endif
638 ifp->if_ipackets ++;
639 }
640 if (STAILQ_FIRST(&xferq->stfree) != NULL)
641 fwe->fd.fc->irx_enable(fwe->fd.fc, fwe->dma_ch);
642}
643
644

--- 10 unchanged lines hidden (view full) ---

655
656static driver_t fwe_driver = {
657 "fwe",
658 fwe_methods,
659 sizeof(struct fwe_softc),
660};
661
662
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

--- 10 unchanged lines hidden (view full) ---

662
663static driver_t fwe_driver = {
664 "fwe",
665 fwe_methods,
666 sizeof(struct fwe_softc),
667};
668
669
670#ifdef __DragonFly__
671DECLARE_DUMMY_MODULE(fwe);
672#endif
663DRIVER_MODULE(fwe, firewire, fwe_driver, fwe_devclass, 0, 0);
664MODULE_VERSION(fwe, 1);
665MODULE_DEPEND(fwe, firewire, 1, 1, 1);
673DRIVER_MODULE(fwe, firewire, fwe_driver, fwe_devclass, 0, 0);
674MODULE_VERSION(fwe, 1);
675MODULE_DEPEND(fwe, firewire, 1, 1, 1);