Deleted Added
sdiff udiff text old ( 124251 ) new ( 127468 )
full compact
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 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>
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 */
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
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_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();
220#if defined(__DragonFly__) || __FreeBSD_version < 500000
221 ether_ifattach(ifp, 1);
222#else
223 ether_ifattach(ifp, eaddr);
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);
229#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
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);
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
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 =
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");

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

--- 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);
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 *(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;
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

--- 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 *);
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"

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

--- 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
673DRIVER_MODULE(fwe, firewire, fwe_driver, fwe_devclass, 0, 0);
674MODULE_VERSION(fwe, 1);
675MODULE_DEPEND(fwe, firewire, 1, 1, 1);