summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorsimokawa <simokawa@FreeBSD.org>2003-02-01 08:55:33 +0000
committersimokawa <simokawa@FreeBSD.org>2003-02-01 08:55:33 +0000
commit095827745e3e45ebf90cbc80df0e05090f128a42 (patch)
tree3da84129c32035c1fa9d500543f2b5d8e638f498 /sys
parentcfd92eb694d961eb9ffbdc562c8a8ac985ae4be1 (diff)
downloadFreeBSD-src-095827745e3e45ebf90cbc80df0e05090f128a42.zip
FreeBSD-src-095827745e3e45ebf90cbc80df0e05090f128a42.tar.gz
Add basic support for device wiring down to specific (CAM)
target id. It still needs to be hard-coded now but will be changed to be configured by tunables or device hints.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/firewire/sbp.c59
1 files changed, 55 insertions, 4 deletions
diff --git a/sys/dev/firewire/sbp.c b/sys/dev/firewire/sbp.c
index d5d8a50..d950c98 100644
--- a/sys/dev/firewire/sbp.c
+++ b/sys/dev/firewire/sbp.c
@@ -380,6 +380,58 @@ sbp_show_sdev_info(struct sbp_dev *sdev, int new)
printf("'%s' '%s' '%s'\n", sdev->vendor, sdev->product, sdev->revision);
}
+static struct {
+ int bus;
+ int target;
+ struct fw_eui64 eui;
+} wired[] = {
+ /* Bus Target EUI64 */
+#if 0
+ {0, 2, {0x00018ea0, 0x01fd0154}}, /* Logitec HDD */
+ {0, 0, {0x00018ea6, 0x00100682}}, /* Logitec DVD */
+ {0, 1, {0x00d03200, 0xa412006a}}, /* Yano HDD */
+#endif
+ {-1, -1, {0,0}}
+};
+
+static int
+sbp_new_target(struct sbp_softc *sbp, struct fw_device *fwdev)
+{
+ int bus, i, target=-1;
+ char w[SBP_NUM_TARGETS];
+
+ bzero(w, sizeof(w));
+ bus = device_get_unit(sbp->fd.dev);
+
+ /* XXX wired-down configuration should be gotten from
+ tunable or device hint */
+ for (i = 0; wired[i].bus >= 0; i ++) {
+ if (wired[i].bus == bus) {
+ w[wired[i].target] = 1;
+ if (wired[i].eui.hi == fwdev->eui.hi &&
+ wired[i].eui.lo == fwdev->eui.lo)
+ target = wired[i].target;
+ }
+ }
+ if (target >= 0) {
+ if(target < SBP_NUM_TARGETS &&
+ sbp->targets[target].fwdev == NULL)
+ return(target);
+ device_printf(sbp->fd.dev,
+ "target %d is not free for %08x:%08x\n",
+ target, fwdev->eui.hi, fwdev->eui.lo);
+ target = -1;
+ }
+ /* non-wired target */
+ for (i = 0; i < SBP_NUM_TARGETS; i ++)
+ if (sbp->targets[i].fwdev == NULL && w[i] == 0) {
+ target = i;
+ break;
+ }
+
+ return target;
+}
+
static struct sbp_target *
sbp_alloc_target(struct sbp_softc *sbp, struct fw_device *fwdev)
{
@@ -392,10 +444,9 @@ sbp_alloc_target(struct sbp_softc *sbp, struct fw_device *fwdev)
SBP_DEBUG(1)
printf("sbp_alloc_target\n");
END_DEBUG
- for (i = 0; i < SBP_NUM_TARGETS; i++)
- if(sbp->targets[i].fwdev == NULL) break;
- if (i == SBP_NUM_TARGETS) {
- printf("increase SBP_NUM_TARGETS!\n");
+ i = sbp_new_target(sbp, fwdev);
+ if (i < 0) {
+ device_printf(sbp->fd.dev, "increase SBP_NUM_TARGETS!\n");
return NULL;
}
/* new target */
OpenPOWER on IntegriCloud