Deleted Added
full compact
if_fwe.c (148887) if_fwe.c (150789)
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 148887 2005-08-09 10:20:02Z rwatson $
34 * $FreeBSD: head/sys/dev/firewire/if_fwe.c 150789 2005-10-01 18:56:19Z glebius $
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>

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

95SYSCTL_INT(_hw_firewire_fwe, OID_AUTO, rx_queue_len, CTLFLAG_RW, &rx_queue_len,
96 0, "Length of the receive queue");
97
98TUNABLE_INT("hw.firewire.fwe.stream_ch", &stream_ch);
99TUNABLE_INT("hw.firewire.fwe.tx_speed", &tx_speed);
100TUNABLE_INT("hw.firewire.fwe.rx_queue_len", &rx_queue_len);
101
102#ifdef DEVICE_POLLING
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>

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

95SYSCTL_INT(_hw_firewire_fwe, OID_AUTO, rx_queue_len, CTLFLAG_RW, &rx_queue_len,
96 0, "Length of the receive queue");
97
98TUNABLE_INT("hw.firewire.fwe.stream_ch", &stream_ch);
99TUNABLE_INT("hw.firewire.fwe.tx_speed", &tx_speed);
100TUNABLE_INT("hw.firewire.fwe.rx_queue_len", &rx_queue_len);
101
102#ifdef DEVICE_POLLING
103#define FWE_POLL_REGISTER(func, fwe, ifp) \
104 if (ether_poll_register(func, ifp)) { \
105 struct firewire_comm *fc = (fwe)->fd.fc; \
106 fc->set_intr(fc, 0); \
107 }
108
109#define FWE_POLL_DEREGISTER(fwe, ifp) \
110 do { \
111 struct firewire_comm *fc = (fwe)->fd.fc; \
112 ether_poll_deregister(ifp); \
113 fc->set_intr(fc, 1); \
114 } while(0) \
115
116static poll_handler_t fwe_poll;
117
118static void
119fwe_poll(struct ifnet *ifp, enum poll_cmd cmd, int count)
120{
121 struct fwe_softc *fwe;
122 struct firewire_comm *fc;
123
103static poll_handler_t fwe_poll;
104
105static void
106fwe_poll(struct ifnet *ifp, enum poll_cmd cmd, int count)
107{
108 struct fwe_softc *fwe;
109 struct firewire_comm *fc;
110
111 if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
112 return;
113
124 fwe = ((struct fwe_eth_softc *)ifp->if_softc)->fwe;
125 fc = fwe->fd.fc;
114 fwe = ((struct fwe_eth_softc *)ifp->if_softc)->fwe;
115 fc = fwe->fd.fc;
126 if (cmd == POLL_DEREGISTER) {
127 /* enable interrupts */
128 fc->set_intr(fc, 1);
129 return;
130 }
131 fc->poll(fc, (cmd == POLL_AND_CHECK_STATUS)?0:1, count);
132}
116 fc->poll(fc, (cmd == POLL_AND_CHECK_STATUS)?0:1, count);
117}
133#else
134#define FWE_POLL_REGISTER(func, fwe, ifp)
135#define FWE_POLL_DEREGISTER(fwe, ifp)
136#endif
118#endif /* DEVICE_POLLING */
119
137static void
138fwe_identify(driver_t *driver, device_t parent)
139{
140 BUS_ADD_CHILD(parent, 0, "fwe", device_get_unit(parent));
141}
142
143static int
144fwe_probe(device_t dev)

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

237#else
238 ether_ifattach(ifp, eaddr);
239#endif
240 splx(s);
241
242 /* Tell the upper layer(s) we support long frames. */
243 ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header);
244#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
120static void
121fwe_identify(driver_t *driver, device_t parent)
122{
123 BUS_ADD_CHILD(parent, 0, "fwe", device_get_unit(parent));
124}
125
126static int
127fwe_probe(device_t dev)

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

220#else
221 ether_ifattach(ifp, eaddr);
222#endif
223 splx(s);
224
225 /* Tell the upper layer(s) we support long frames. */
226 ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header);
227#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
245 ifp->if_capabilities |= IFCAP_VLAN_MTU;
228 ifp->if_capabilities |= IFCAP_VLAN_MTU & IFCAP_POLLING;
246 ifp->if_capenable |= IFCAP_VLAN_MTU;
247#endif
248
249
250 FWEDEBUG(ifp, "interface created\n");
251 return 0;
252}
253
254static void
255fwe_stop(struct fwe_softc *fwe)
256{
257 struct firewire_comm *fc;
258 struct fw_xferq *xferq;
259 struct ifnet *ifp = fwe->eth_softc.ifp;
260 struct fw_xfer *xfer, *next;
261 int i;
262
263 fc = fwe->fd.fc;
264
229 ifp->if_capenable |= IFCAP_VLAN_MTU;
230#endif
231
232
233 FWEDEBUG(ifp, "interface created\n");
234 return 0;
235}
236
237static void
238fwe_stop(struct fwe_softc *fwe)
239{
240 struct firewire_comm *fc;
241 struct fw_xferq *xferq;
242 struct ifnet *ifp = fwe->eth_softc.ifp;
243 struct fw_xfer *xfer, *next;
244 int i;
245
246 fc = fwe->fd.fc;
247
265 FWE_POLL_DEREGISTER(fwe, ifp);
266
267 if (fwe->dma_ch >= 0) {
268 xferq = fc->ir[fwe->dma_ch];
269
270 if (xferq->flag & FWXFERQ_RUNNING)
271 fc->irx_disable(fc, fwe->dma_ch);
272 xferq->flag &=
273 ~(FWXFERQ_MODEMASK | FWXFERQ_OPEN | FWXFERQ_STREAM |
274 FWXFERQ_EXTBUF | FWXFERQ_HANDLER | FWXFERQ_CHTAGMASK);

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

300fwe_detach(device_t dev)
301{
302 struct fwe_softc *fwe;
303 struct ifnet *ifp;
304 int s;
305
306 fwe = device_get_softc(dev);
307 ifp = fwe->eth_softc.ifp;
248 if (fwe->dma_ch >= 0) {
249 xferq = fc->ir[fwe->dma_ch];
250
251 if (xferq->flag & FWXFERQ_RUNNING)
252 fc->irx_disable(fc, fwe->dma_ch);
253 xferq->flag &=
254 ~(FWXFERQ_MODEMASK | FWXFERQ_OPEN | FWXFERQ_STREAM |
255 FWXFERQ_EXTBUF | FWXFERQ_HANDLER | FWXFERQ_CHTAGMASK);

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

281fwe_detach(device_t dev)
282{
283 struct fwe_softc *fwe;
284 struct ifnet *ifp;
285 int s;
286
287 fwe = device_get_softc(dev);
288 ifp = fwe->eth_softc.ifp;
289
290#ifdef DEVICE_POLLING
291 if (ifp->if_capenable & IFCAP_POLLING)
292 ether_poll_deregister(ifp);
293#endif
308 s = splimp();
309
310 fwe_stop(fwe);
311#if defined(__DragonFly__) || __FreeBSD_version < 500000
312 ether_ifdetach(ifp, 1);
313#else
314 ether_ifdetach(ifp);
315 if_free(ifp);

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

411#if defined(__FreeBSD__)
412 ifp->if_drv_flags |= IFF_DRV_RUNNING;
413 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
414#else
415 ifp->if_flags |= IFF_RUNNING;
416 ifp->if_flags &= ~IFF_OACTIVE;
417#endif
418
294 s = splimp();
295
296 fwe_stop(fwe);
297#if defined(__DragonFly__) || __FreeBSD_version < 500000
298 ether_ifdetach(ifp, 1);
299#else
300 ether_ifdetach(ifp);
301 if_free(ifp);

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

397#if defined(__FreeBSD__)
398 ifp->if_drv_flags |= IFF_DRV_RUNNING;
399 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
400#else
401 ifp->if_flags |= IFF_RUNNING;
402 ifp->if_flags &= ~IFF_OACTIVE;
403#endif
404
419 FWE_POLL_REGISTER(fwe_poll, fwe, ifp);
420#if 0
421 /* attempt to start output */
422 fwe_start(ifp);
423#endif
424}
425
426
427static int

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

463 len = strlen(ifs->ascii);
464 if (len < sizeof(ifs->ascii))
465 snprintf(ifs->ascii + len,
466 sizeof(ifs->ascii) - len,
467 "\tch %d dma %d\n",
468 fwe->stream_ch, fwe->dma_ch);
469 splx(s);
470 break;
405#if 0
406 /* attempt to start output */
407 fwe_start(ifp);
408#endif
409}
410
411
412static int

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

448 len = strlen(ifs->ascii);
449 if (len < sizeof(ifs->ascii))
450 snprintf(ifs->ascii + len,
451 sizeof(ifs->ascii) - len,
452 "\tch %d dma %d\n",
453 fwe->stream_ch, fwe->dma_ch);
454 splx(s);
455 break;
456 case SIOCSIFCAP:
457#ifdef DEVICE_POLLING
458 {
459 struct ifreq *ifr = (struct ifreq *) data;
460 struct firewire_comm *fc = fc = fwe->fd.fc;
461
462 if (ifr->ifr_reqcap & IFCAP_POLLING &&
463 !(ifp->if_capenable & IFCAP_POLLING)) {
464 error = ether_poll_register(fwe_poll, ifp);
465 if (error)
466 return(error);
467 /* Disable interrupts */
468 fc->set_intr(fc, 0);
469 ifp->if_capenable |= IFCAP_POLLING;
470 return (error);
471
472 }
473 if (!(ifr->ifr_reqcap & IFCAP_POLLING) &&
474 ifp->if_capenable & IFCAP_POLLING) {
475 error = ether_poll_deregister(ifp);
476 /* Enable interrupts. */
477 fc->set_intr(fc, 1);
478 ifp->if_capenable &= ~IFCAP_POLLING;
479 return (error);
480 }
481 }
482#endif /* DEVICE_POLLING */
483 break;
471#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
472 default:
473#else
474 case SIOCSIFADDR:
475 case SIOCGIFADDR:
476 case SIOCSIFMTU:
477#endif
478 s = splimp();

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

629 struct fw_pkt *fp;
630 u_char *c;
631#if defined(__DragonFly__) || __FreeBSD_version < 500000
632 struct ether_header *eh;
633#endif
634
635 fwe = (struct fwe_softc *)xferq->sc;
636 ifp = fwe->eth_softc.ifp;
484#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
485 default:
486#else
487 case SIOCSIFADDR:
488 case SIOCGIFADDR:
489 case SIOCSIFMTU:
490#endif
491 s = splimp();

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

642 struct fw_pkt *fp;
643 u_char *c;
644#if defined(__DragonFly__) || __FreeBSD_version < 500000
645 struct ether_header *eh;
646#endif
647
648 fwe = (struct fwe_softc *)xferq->sc;
649 ifp = fwe->eth_softc.ifp;
637#if 0
638 FWE_POLL_REGISTER(fwe_poll, fwe, ifp);
639#endif
650
640 while ((sxfer = STAILQ_FIRST(&xferq->stvalid)) != NULL) {
641 STAILQ_REMOVE_HEAD(&xferq->stvalid, link);
642 fp = mtod(sxfer->mbuf, struct fw_pkt *);
643 if (fwe->fd.fc->irx_post != NULL)
644 fwe->fd.fc->irx_post(fwe->fd.fc, fp->mode.ld);
645 m = sxfer->mbuf;
646
647 /* insert new rbuf */

--- 76 unchanged lines hidden ---
651 while ((sxfer = STAILQ_FIRST(&xferq->stvalid)) != NULL) {
652 STAILQ_REMOVE_HEAD(&xferq->stvalid, link);
653 fp = mtod(sxfer->mbuf, struct fw_pkt *);
654 if (fwe->fd.fc->irx_post != NULL)
655 fwe->fd.fc->irx_post(fwe->fd.fc, fp->mode.ld);
656 m = sxfer->mbuf;
657
658 /* insert new rbuf */

--- 76 unchanged lines hidden ---