diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2007-12-28 16:19:16 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2007-12-28 16:19:16 +0000 |
commit | 72cfb58a94217ff9e2a3702e5d361663d7c66a37 (patch) | |
tree | f8501c3b4aef719d977927138508ddb07640d7c8 /sys | |
parent | 2683a16fffbaaaef1dc9a8e971607aa7adcc165d (diff) |
massage the way vpds are defined. rename the page used for the devices
serial number and split the vpd header out for use in other places. while
here define the device identification page bits too.
ok krw@ marco@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/ata/atascsi.c | 16 | ||||
-rw-r--r-- | sys/dev/ata/atascsi.h | 3 | ||||
-rw-r--r-- | sys/dev/ic/ami.c | 14 | ||||
-rw-r--r-- | sys/scsi/scsi_all.h | 48 | ||||
-rw-r--r-- | sys/scsi/sd.c | 4 |
5 files changed, 65 insertions, 20 deletions
diff --git a/sys/dev/ata/atascsi.c b/sys/dev/ata/atascsi.c index 45a4c5c089c..1fe99ac16ad 100644 --- a/sys/dev/ata/atascsi.c +++ b/sys/dev/ata/atascsi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atascsi.c,v 1.54 2007/12/09 01:30:59 dlg Exp $ */ +/* $OpenBSD: atascsi.c,v 1.55 2007/12/28 16:19:14 dlg Exp $ */ /* * Copyright (c) 2007 David Gwynne <dlg@openbsd.org> @@ -553,17 +553,17 @@ atascsi_disk_serial(struct scsi_xfer *xs) struct scsi_link *link = xs->sc_link; struct atascsi *as = link->adapter_softc; struct ata_port *ap = as->as_ports[link->target]; - struct scsi_inquiry_vpd vpd; + struct scsi_vpd_serial pg; - bzero(&vpd, sizeof(vpd)); + bzero(&pg, sizeof(pg)); - vpd.device = T_DIRECT; - vpd.page_code = SI_PG_SERIAL; - vpd.page_length = sizeof(ap->ap_identify.serial); - bcopy(ap->ap_identify.serial, vpd.serial, + pg.hdr.device = T_DIRECT; + pg.hdr.page_code = SI_PG_SERIAL; + pg.hdr.page_length = sizeof(ap->ap_identify.serial); + bcopy(ap->ap_identify.serial, pg.serial, sizeof(ap->ap_identify.serial)); - bcopy(&vpd, xs->data, MIN(sizeof(vpd), xs->datalen)); + bcopy(&pg, xs->data, MIN(sizeof(pg), xs->datalen)); return (atascsi_done(xs, XS_NOERROR)); } diff --git a/sys/dev/ata/atascsi.h b/sys/dev/ata/atascsi.h index 58de6156786..39472937452 100644 --- a/sys/dev/ata/atascsi.h +++ b/sys/dev/ata/atascsi.h @@ -1,4 +1,4 @@ -/* $OpenBSD: atascsi.h,v 1.30 2007/12/06 12:19:01 jsg Exp $ */ +/* $OpenBSD: atascsi.h,v 1.31 2007/12/28 16:19:14 dlg Exp $ */ /* * Copyright (c) 2007 David Gwynne <dlg@openbsd.org> @@ -93,6 +93,7 @@ struct ata_identify { u_int16_t features85; /* 85 */ u_int16_t features86; /* 86 */ u_int16_t features87; /* 87 */ +#define ATA_ID_F87_WWN (1<<8) u_int16_t ultradma; /* 88 */ u_int16_t erasetime; /* 89 */ u_int16_t erasetimex; /* 90 */ diff --git a/sys/dev/ic/ami.c b/sys/dev/ic/ami.c index 8f5669e4dd3..f1858af47cc 100644 --- a/sys/dev/ic/ami.c +++ b/sys/dev/ic/ami.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ami.c,v 1.185 2007/09/27 08:45:19 chl Exp $ */ +/* $OpenBSD: ami.c,v 1.186 2007/12/28 16:19:14 dlg Exp $ */ /* * Copyright (c) 2001 Michael Shalayeff @@ -2013,7 +2013,7 @@ ami_disk(struct ami_softc *sc, struct bioc_disk *bd, struct ami_big_diskarray *p) { struct scsi_inquiry_data inqbuf; - struct scsi_inquiry_vpd vpdbuf; + struct scsi_vpd_serial vpdbuf; char *plist; int i, s, t, off; int ld = p->ada_nld, error = EINVAL; @@ -2073,8 +2073,8 @@ ami_disk(struct ami_softc *sc, struct bioc_disk *bd, bcopy(vpdbuf.serial, ser, sizeof ser - 1); ser[sizeof ser - 1] = '\0'; - if (vpdbuf.page_length < sizeof ser) - ser[vpdbuf.page_length] = '\0'; + if (vpdbuf.hdr.page_length < sizeof ser) + ser[vpdbuf.hdr.page_length] = '\0'; strlcpy(bd->bd_serial, ser, sizeof(bd->bd_serial)); } @@ -2233,7 +2233,7 @@ int ami_ioctl_disk(struct ami_softc *sc, struct bioc_disk *bd) { struct scsi_inquiry_data inqbuf; - struct scsi_inquiry_vpd vpdbuf; + struct scsi_vpd_serial vpdbuf; struct ami_big_diskarray *p; /* struct too large for stack */ int i, s, t, d; int off; @@ -2313,8 +2313,8 @@ ami_ioctl_disk(struct ami_softc *sc, struct bioc_disk *bd) bcopy(vpdbuf.serial, ser, sizeof ser - 1); ser[sizeof ser - 1] = '\0'; - if (vpdbuf.page_length < sizeof ser) - ser[vpdbuf.page_length] = '\0'; + if (vpdbuf.hdr.page_length < sizeof ser) + ser[vpdbuf.hdr.page_length] = '\0'; strlcpy(bd->bd_serial, ser, sizeof(bd->bd_serial)); } diff --git a/sys/scsi/scsi_all.h b/sys/scsi/scsi_all.h index 0a79d2622ec..5eb63b5de24 100644 --- a/sys/scsi/scsi_all.h +++ b/sys/scsi/scsi_all.h @@ -1,4 +1,4 @@ -/* $OpenBSD: scsi_all.h,v 1.43 2007/04/12 16:33:27 weingart Exp $ */ +/* $OpenBSD: scsi_all.h,v 1.44 2007/12/28 16:19:15 dlg Exp $ */ /* $NetBSD: scsi_all.h,v 1.10 1996/09/12 01:57:17 thorpej Exp $ */ /* @@ -82,7 +82,9 @@ struct scsi_inquiry { u_int8_t flags; #define SI_EVPD 0x01 u_int8_t pagecode; +#define SI_PG_SUPPORTED 0x00 #define SI_PG_SERIAL 0x80 +#define SI_PG_DEVID 0x83 u_int8_t length[2]; u_int8_t control; }; @@ -257,14 +259,56 @@ struct scsi_inquiry_data { u_int8_t reserved; }; -struct scsi_inquiry_vpd { +struct scsi_vpd_hdr { u_int8_t device; u_int8_t page_code; u_int8_t reserved; u_int8_t page_length; +}; + +struct scsi_vpd_serial { + struct scsi_vpd_hdr hdr; char serial[32]; }; +#define VPD_PROTO_ID_FC 0x0 /* Fibre Channel */ +#define VPD_PROTO_ID_SPI 0x1 /* Parallel SCSI */ +#define VPD_PROTO_ID_SSA 0x2 +#define VPD_PROTO_ID_IEEE1394 0x3 +#define VPD_PROTO_ID_SRP 0x4 /* SCSI RDMA Protocol */ +#define VPD_PROTO_ID_ISCSI 0x5 /* Internet SCSI (iSCSI) */ +#define VPD_PROTO_ID_SAS 0x6 /* Serial Attached SCSI */ +#define VPD_PROTO_ID_ADT 0x7 /* Automation/Drive Interface Transport */ +#define VPD_PROTO_ID_ATA 0x7 /* ATA/ATAPI */ +#define VPD_PROTO_ID_NONE 0xf + +struct scsi_vpd_devid_hdr { + u_int8_t pi_code; +#define VPD_DEVID_PI(_f) (((_f) >> 4) & 0xf0) +#define VPD_DEVID_CODE(_f) (((_f) >> 0) & 0x0f) +#define VPD_DEVID_CODE_BINARY 0x1 +#define VPD_DEVID_CODE_ASCII 0x2 +#define VPD_DEVID_CODE_UTF8 0x3 + u_int8_t flags; +#define VPD_DEVID_PIV 0x80 +#define VPD_DEVID_ASSOC 0x30 +#define VPD_DEVID_ASSOC_LU 0x00 +#define VPD_DEVID_ASSOC_PORT 0x10 +#define VPD_DEVID_ASSOC_TARG 0x20 +#define VPD_DEVID_TYPE (((_f) >> 0) & 0x0f) +#define VPD_DEVID_TYPE_VENDOR 0x0 +#define VPD_DEVID_TYPE_T10 0x1 +#define VPD_DEVID_TYPE_EUI64 0x2 +#define VPD_DEVID_TYPE_NAA 0x3 +#define VPD_DEVID_TYPE_RELATIVE 0x4 +#define VPD_DEVID_TYPE_PORT 0x5 +#define VPD_DEVID_TYPE_LU 0x6 +#define VPD_DEVID_TYPE_MD5 0x7 +#define VPD_DEVID_TYPE_NAME 0x8 + u_int8_t reserved; + u_int8_t len; +}; + struct scsi_sense_data_unextended { /* 1*/ u_int8_t error_code; /* 4*/ u_int8_t block[3]; diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c index 5337ed16285..290b7832f6a 100644 --- a/sys/scsi/sd.c +++ b/sys/scsi/sd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sd.c,v 1.140 2007/11/23 14:44:59 dlg Exp $ */ +/* $OpenBSD: sd.c,v 1.141 2007/12/28 16:19:15 dlg Exp $ */ /* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */ /*- @@ -967,7 +967,7 @@ sdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) int sd_ioctl_inquiry(struct sd_softc *sd, struct dk_inquiry *di) { - struct scsi_inquiry_vpd vpd; + struct scsi_vpd_serial vpd; bzero(di, sizeof(struct dk_inquiry)); scsi_strvis(di->vendor, sd->sc_link->inqdata.vendor, |