Deleted Added
full compact
firewire.c (277508) firewire.c (277509)
1/*-
2 * Copyright (c) 2003 Hidetoshi Shimokawa
3 * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
30 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 */
34
35#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2003 Hidetoshi Shimokawa
3 * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
30 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 */
34
35#include <sys/cdefs.h>
36__FBSDID("$FreeBSD: head/sys/dev/firewire/firewire.c 277508 2015-01-21 20:03:46Z will $");
36__FBSDID("$FreeBSD: head/sys/dev/firewire/firewire.c 277509 2015-01-21 20:05:10Z will $");
37
38#include <sys/param.h>
39#include <sys/systm.h>
40#include <sys/types.h>
41
42#include <sys/jail.h>
43#include <sys/kernel.h>
44#include <sys/module.h>

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

141
142/*
143 * Lookup fwdev by node id.
144 */
145struct fw_device *
146fw_noderesolve_nodeid(struct firewire_comm *fc, int dst)
147{
148 struct fw_device *fwdev;
37
38#include <sys/param.h>
39#include <sys/systm.h>
40#include <sys/types.h>
41
42#include <sys/jail.h>
43#include <sys/kernel.h>
44#include <sys/module.h>

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

141
142/*
143 * Lookup fwdev by node id.
144 */
145struct fw_device *
146fw_noderesolve_nodeid(struct firewire_comm *fc, int dst)
147{
148 struct fw_device *fwdev;
149 int s;
150
149
151 s = splfw();
150 FW_GLOCK(fc);
152 STAILQ_FOREACH(fwdev, &fc->devices, link)
153 if (fwdev->dst == dst && fwdev->status != FWDEVINVAL)
154 break;
151 STAILQ_FOREACH(fwdev, &fc->devices, link)
152 if (fwdev->dst == dst && fwdev->status != FWDEVINVAL)
153 break;
155 splx(s);
154 FW_GUNLOCK(fc);
156
157 return fwdev;
158}
159
160/*
161 * Lookup fwdev by EUI64.
162 */
163struct fw_device *
164fw_noderesolve_eui64(struct firewire_comm *fc, struct fw_eui64 *eui)
165{
166 struct fw_device *fwdev;
155
156 return fwdev;
157}
158
159/*
160 * Lookup fwdev by EUI64.
161 */
162struct fw_device *
163fw_noderesolve_eui64(struct firewire_comm *fc, struct fw_eui64 *eui)
164{
165 struct fw_device *fwdev;
167 int s;
168
166
169 s = splfw();
170 FW_GLOCK(fc);
171 STAILQ_FOREACH(fwdev, &fc->devices, link)
172 if (FW_EUI64_EQUAL(fwdev->eui, *eui))
173 break;
174 FW_GUNLOCK(fc);
167 FW_GLOCK(fc);
168 STAILQ_FOREACH(fwdev, &fc->devices, link)
169 if (FW_EUI64_EQUAL(fwdev->eui, *eui))
170 break;
171 FW_GUNLOCK(fc);
175 splx(s);
176
177 if (fwdev == NULL)
178 return NULL;
179 if (fwdev->status == FWDEVINVAL)
180 return NULL;
181 return fwdev;
182}
183

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

296
297/*
298 * Async. request with given xfer structure.
299 */
300static void
301fw_asystart(struct fw_xfer *xfer)
302{
303 struct firewire_comm *fc = xfer->fc;
172
173 if (fwdev == NULL)
174 return NULL;
175 if (fwdev->status == FWDEVINVAL)
176 return NULL;
177 return fwdev;
178}
179

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

292
293/*
294 * Async. request with given xfer structure.
295 */
296static void
297fw_asystart(struct fw_xfer *xfer)
298{
299 struct firewire_comm *fc = xfer->fc;
304 int s;
305
300
306 s = splfw();
307 /* Protect from interrupt/timeout */
308 FW_GLOCK(fc);
309 xfer->flag = FWXF_INQ;
310 STAILQ_INSERT_TAIL(&xfer->q->q, xfer, link);
311#if 0
312 xfer->q->queued++;
313#endif
314 FW_GUNLOCK(fc);
301 /* Protect from interrupt/timeout */
302 FW_GLOCK(fc);
303 xfer->flag = FWXF_INQ;
304 STAILQ_INSERT_TAIL(&xfer->q->q, xfer, link);
305#if 0
306 xfer->q->queued++;
307#endif
308 FW_GUNLOCK(fc);
315 splx(s);
316 /* XXX just queue for mbuf */
317 if (xfer->mbuf == NULL)
318 xfer->q->start(fc);
319 return;
320}
321
322static void
323firewire_identify(driver_t *driver, device_t parent)
324{
325 BUS_ADD_CHILD(parent, 0, "firewire", -1);
326}
327
328static int
329firewire_probe(device_t dev)
330{
331 device_set_desc(dev, "IEEE1394(FireWire) bus");
332 return (0);
333}
334
309 /* XXX just queue for mbuf */
310 if (xfer->mbuf == NULL)
311 xfer->q->start(fc);
312 return;
313}
314
315static void
316firewire_identify(driver_t *driver, device_t parent)
317{
318 BUS_ADD_CHILD(parent, 0, "firewire", -1);
319}
320
321static int
322firewire_probe(device_t dev)
323{
324 device_set_desc(dev, "IEEE1394(FireWire) bus");
325 return (0);
326}
327
328/* Just use a per-packet callout? */
335static void
336firewire_xfer_timeout(void *arg, int pending)
337{
338 struct firewire_comm *fc = (struct firewire_comm *)arg;
339 struct fw_xfer *xfer, *txfer;
340 struct timeval tv;
341 struct timeval split_timeout;
342 STAILQ_HEAD(, fw_xfer) xfer_timeout;
329static void
330firewire_xfer_timeout(void *arg, int pending)
331{
332 struct firewire_comm *fc = (struct firewire_comm *)arg;
333 struct fw_xfer *xfer, *txfer;
334 struct timeval tv;
335 struct timeval split_timeout;
336 STAILQ_HEAD(, fw_xfer) xfer_timeout;
343 int i, s;
337 int i;
344
345 split_timeout.tv_sec = 0;
346 split_timeout.tv_usec = 200 * 1000; /* 200 msec */
347
348 microtime(&tv);
349 timevalsub(&tv, &split_timeout);
350 STAILQ_INIT(&xfer_timeout);
351
338
339 split_timeout.tv_sec = 0;
340 split_timeout.tv_usec = 200 * 1000; /* 200 msec */
341
342 microtime(&tv);
343 timevalsub(&tv, &split_timeout);
344 STAILQ_INIT(&xfer_timeout);
345
352 s = splfw();
353 mtx_lock(&fc->tlabel_lock);
346 mtx_lock(&fc->tlabel_lock);
354 for (i = 0; i < 0x40; i++) {
347 for (i = 0; i < nitems(fc->tlabels); i++) {
355 while ((xfer = STAILQ_FIRST(&fc->tlabels[i])) != NULL) {
356 if ((xfer->flag & FWXF_SENT) == 0)
357 /* not sent yet */
358 break;
359 if (timevalcmp(&xfer->tv, &tv, >))
360 /* the rests are newer than this */
361 break;
362 device_printf(fc->bdev,
363 "split transaction timeout: tl=0x%x flag=0x%02x\n",
364 i, xfer->flag);
365 fw_dump_hdr(&xfer->send.hdr, "send");
366 xfer->resp = ETIMEDOUT;
367 xfer->tl = -1;
368 STAILQ_REMOVE_HEAD(&fc->tlabels[i], tlabel);
369 STAILQ_INSERT_TAIL(&xfer_timeout, xfer, tlabel);
370 }
371 }
372 mtx_unlock(&fc->tlabel_lock);
348 while ((xfer = STAILQ_FIRST(&fc->tlabels[i])) != NULL) {
349 if ((xfer->flag & FWXF_SENT) == 0)
350 /* not sent yet */
351 break;
352 if (timevalcmp(&xfer->tv, &tv, >))
353 /* the rests are newer than this */
354 break;
355 device_printf(fc->bdev,
356 "split transaction timeout: tl=0x%x flag=0x%02x\n",
357 i, xfer->flag);
358 fw_dump_hdr(&xfer->send.hdr, "send");
359 xfer->resp = ETIMEDOUT;
360 xfer->tl = -1;
361 STAILQ_REMOVE_HEAD(&fc->tlabels[i], tlabel);
362 STAILQ_INSERT_TAIL(&xfer_timeout, xfer, tlabel);
363 }
364 }
365 mtx_unlock(&fc->tlabel_lock);
373 splx(s);
374 fc->timeout(fc);
375
376 STAILQ_FOREACH_SAFE(xfer, &xfer_timeout, tlabel, txfer)
377 xfer->hand(xfer);
378}
379
380#define WATCHDOG_HZ 10
381static void

--- 2009 unchanged lines hidden ---
366 fc->timeout(fc);
367
368 STAILQ_FOREACH_SAFE(xfer, &xfer_timeout, tlabel, txfer)
369 xfer->hand(xfer);
370}
371
372#define WATCHDOG_HZ 10
373static void

--- 2009 unchanged lines hidden ---