summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2014-01-31 02:53:42 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2014-01-31 02:53:42 +0000
commitea289196291c91bf6f36717f5fd0fee6c199f730 (patch)
tree281aa817dc055bfd6fe3a7893c365ffeeb07805c /sys
parent71158f516d8f21cdc4935fffc881fbd213772d05 (diff)
if a device doesnt have device ids or serial numbers, try using node_wwn to
generate a devid. if its an fc device this is good enough.
Diffstat (limited to 'sys')
-rw-r--r--sys/scsi/scsiconf.c25
-rw-r--r--sys/scsi/scsiconf.h3
2 files changed, 25 insertions, 3 deletions
diff --git a/sys/scsi/scsiconf.c b/sys/scsi/scsiconf.c
index 1a7b4674a17..ec60a46dd32 100644
--- a/sys/scsi/scsiconf.c
+++ b/sys/scsi/scsiconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsiconf.c,v 1.185 2013/12/06 21:03:02 deraadt Exp $ */
+/* $OpenBSD: scsiconf.c,v 1.186 2014/01/31 02:53:41 dlg Exp $ */
/* $NetBSD: scsiconf.c,v 1.57 1996/05/02 01:09:01 neil Exp $ */
/*
@@ -77,6 +77,7 @@ int scsi_probedev(struct scsibus_softc *, int, int);
void scsi_devid(struct scsi_link *);
int scsi_devid_pg80(struct scsi_link *);
int scsi_devid_pg83(struct scsi_link *);
+int scsi_devid_wwn(struct scsi_link *);
int scsibusmatch(struct device *, void *, void *);
void scsibusattach(struct device *, struct device *, void *);
@@ -778,6 +779,9 @@ scsibus_printlink(struct scsi_link *link)
case DEVID_SERIAL:
printf(" serial.");
break;
+ case DEVID_WWN:
+ printf(" wwn.");
+ break;
}
if (ISSET(link->id->d_flags, DEVID_F_PRINT)) {
@@ -1133,7 +1137,7 @@ scsi_devid(struct scsi_link *link)
if (SCSISPC(link->inqdata.version) >= 2) {
if (scsi_inquire_vpd(link, pg, sizeof(*pg), SI_PG_SUPPORTED,
scsi_autoconf) != 0)
- goto done;
+ goto wwn;
len = MIN(sizeof(pg->list), _2btol(pg->hdr.page_length));
for (i = 0; i < len; i++) {
@@ -1152,6 +1156,9 @@ scsi_devid(struct scsi_link *link)
if (pg80 && scsi_devid_pg80(link) == 0)
goto done;
}
+
+wwn:
+ scsi_devid_wwn(link);
done:
dma_free(pg, sizeof(*pg));
}
@@ -1301,6 +1308,20 @@ freehdr:
return (rv);
}
+int
+scsi_devid_wwn(struct scsi_link *link)
+{
+ u_int64_t wwnn;
+
+ if (link->lun != 0 || link->node_wwn == 0)
+ return (EOPNOTSUPP);
+
+ wwnn = htobe64(link->node_wwn);
+ link->id = devid_alloc(DEVID_WWN, 0, sizeof(wwnn), (u_int8_t *)&wwnn);
+
+ return (0);
+}
+
/*
* scsi_minphys member of struct scsi_adapter for drivers which don't
* need any specific routine.
diff --git a/sys/scsi/scsiconf.h b/sys/scsi/scsiconf.h
index 691b753a480..511c44b3146 100644
--- a/sys/scsi/scsiconf.h
+++ b/sys/scsi/scsiconf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsiconf.h,v 1.159 2014/01/27 23:44:39 dlg Exp $ */
+/* $OpenBSD: scsiconf.h,v 1.160 2014/01/31 02:53:41 dlg Exp $ */
/* $NetBSD: scsiconf.h,v 1.35 1997/04/02 02:29:38 mycroft Exp $ */
/*
@@ -171,6 +171,7 @@ _8btol(u_int8_t *bytes)
#define DEVID_EUI 2
#define DEVID_T10 3
#define DEVID_SERIAL 4
+#define DEVID_WWN 5
struct devid {
u_int8_t d_type;