Add LUN options to specify 64-bit EUI and NAA identifiers.

This commit is contained in:
Alexander Motin 2014-07-09 04:37:50 +00:00
parent d3fe75eb62
commit 409a3c1383
2 changed files with 32 additions and 2 deletions

View File

@ -4432,7 +4432,7 @@ ctl_alloc_lun(struct ctl_softc *ctl_softc, struct ctl_lun *ctl_lun,
struct ctl_port *port;
struct scsi_vpd_id_descriptor *desc;
struct scsi_vpd_id_t10 *t10id;
const char *scsiname, *vendor;
const char *eui, *naa, *scsiname, *vendor;
int lun_number, i, lun_malloced;
int devidlen, idlen1, idlen2 = 0, len;
@ -4476,6 +4476,14 @@ ctl_alloc_lun(struct ctl_softc *ctl_softc, struct ctl_lun *ctl_lun,
idlen2 = roundup2(strlen(scsiname) + 1, 4);
len += sizeof(struct scsi_vpd_id_descriptor) + idlen2;
}
eui = ctl_get_opt(&be_lun->options, "eui");
if (eui != NULL) {
len += sizeof(struct scsi_vpd_id_descriptor) + 8;
}
naa = ctl_get_opt(&be_lun->options, "naa");
if (naa != NULL) {
len += sizeof(struct scsi_vpd_id_descriptor) + 8;
}
lun->lun_devid = malloc(sizeof(struct ctl_devid) + len,
M_CTL, M_WAITOK | M_ZERO);
lun->lun_devid->len = len;
@ -4502,6 +4510,24 @@ ctl_alloc_lun(struct ctl_softc *ctl_softc, struct ctl_lun *ctl_lun,
desc->length = idlen2;
strlcpy(desc->identifier, scsiname, idlen2);
}
if (eui != NULL) {
desc = (struct scsi_vpd_id_descriptor *)(&desc->identifier[0] +
desc->length);
desc->proto_codeset = SVPD_ID_CODESET_BINARY;
desc->id_type = SVPD_ID_PIV | SVPD_ID_ASSOC_LUN |
SVPD_ID_TYPE_EUI64;
desc->length = 8;
scsi_u64to8b(strtouq(eui, NULL, 0), desc->identifier);
}
if (naa != NULL) {
desc = (struct scsi_vpd_id_descriptor *)(&desc->identifier[0] +
desc->length);
desc->proto_codeset = SVPD_ID_CODESET_BINARY;
desc->id_type = SVPD_ID_PIV | SVPD_ID_ASSOC_LUN |
SVPD_ID_TYPE_NAA;
desc->length = 8;
scsi_u64to8b(strtouq(naa, NULL, 0), desc->identifier);
}
mtx_lock(&ctl_softc->ctl_lock);
/*

View File

@ -34,7 +34,7 @@
.\" $Id: //depot/users/kenm/FreeBSD-test2/usr.sbin/ctladm/ctladm.8#3 $
.\" $FreeBSD$
.\"
.Dd June 15, 2014
.Dd July 9, 2014
.Dt CTLADM 8
.Os
.Sh NAME
@ -947,6 +947,10 @@ Specifies LUN product string up to 16 chars.
Specifies LUN revision string up to 4 chars.
.It Va scsiname
Specifies LUN SCSI name string.
.It Va eui
Specifies LUN EUI-64 identified.
.It Va naa
Specifies LUN NAA identifier.
.It Va unmap
Set to "on", enables UNMAP support for the LUN.
.El