diff options
author | Hannes Reinecke <hare@suse.de> | 2013-12-17 03:18:48 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2013-12-17 21:04:30 -0500 |
commit | fbfe858fea2a45df6339eb03dd1715b51f1bdc92 (patch) | |
tree | f65f3bc17c6762a7e6bccd7272118ef0788f8ca1 | |
parent | 03ba84ca95a84dba9b42492edd2632dc3c7eb359 (diff) |
target_core_spc: Include target device descriptor in VPD page 83
We should be including a descriptor referring to the target device
to allow identification of different TCM instances.
(nab: Bump SE_INQUIRY_BUF to 1024 bytes to handle 2x 256 byte SCSI names)
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r-- | drivers/target/target_core_spc.c | 43 | ||||
-rw-r--r-- | include/target/target_core_base.h | 2 |
2 files changed, 43 insertions, 2 deletions
diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c index 603c41105aa7..39054d9029f3 100644 --- a/drivers/target/target_core_spc.c +++ b/drivers/target/target_core_spc.c | |||
@@ -267,7 +267,7 @@ check_t10_vend_desc: | |||
267 | port = lun->lun_sep; | 267 | port = lun->lun_sep; |
268 | if (port) { | 268 | if (port) { |
269 | struct t10_alua_lu_gp *lu_gp; | 269 | struct t10_alua_lu_gp *lu_gp; |
270 | u32 padding, scsi_name_len; | 270 | u32 padding, scsi_name_len, scsi_target_len; |
271 | u16 lu_gp_id = 0; | 271 | u16 lu_gp_id = 0; |
272 | u16 tg_pt_gp_id = 0; | 272 | u16 tg_pt_gp_id = 0; |
273 | u16 tpgt; | 273 | u16 tpgt; |
@@ -402,6 +402,47 @@ check_scsi_name: | |||
402 | off += scsi_name_len; | 402 | off += scsi_name_len; |
403 | /* Header size + Designation descriptor */ | 403 | /* Header size + Designation descriptor */ |
404 | len += (scsi_name_len + 4); | 404 | len += (scsi_name_len + 4); |
405 | |||
406 | /* | ||
407 | * Target device designator | ||
408 | */ | ||
409 | buf[off] = | ||
410 | (tpg->se_tpg_tfo->get_fabric_proto_ident(tpg) << 4); | ||
411 | buf[off++] |= 0x3; /* CODE SET == UTF-8 */ | ||
412 | buf[off] = 0x80; /* Set PIV=1 */ | ||
413 | /* Set ASSOCIATION == target device: 10b */ | ||
414 | buf[off] |= 0x20; | ||
415 | /* DESIGNATOR TYPE == SCSI name string */ | ||
416 | buf[off++] |= 0x8; | ||
417 | off += 2; /* Skip over Reserved and length */ | ||
418 | /* | ||
419 | * SCSI name string identifer containing, $FABRIC_MOD | ||
420 | * dependent information. For LIO-Target and iSCSI | ||
421 | * Target Port, this means "<iSCSI name>" in | ||
422 | * UTF-8 encoding. | ||
423 | */ | ||
424 | scsi_target_len = sprintf(&buf[off], "%s", | ||
425 | tpg->se_tpg_tfo->tpg_get_wwn(tpg)); | ||
426 | scsi_target_len += 1 /* Include NULL terminator */; | ||
427 | /* | ||
428 | * The null-terminated, null-padded (see 4.4.2) SCSI | ||
429 | * NAME STRING field contains a UTF-8 format string. | ||
430 | * The number of bytes in the SCSI NAME STRING field | ||
431 | * (i.e., the value in the DESIGNATOR LENGTH field) | ||
432 | * shall be no larger than 256 and shall be a multiple | ||
433 | * of four. | ||
434 | */ | ||
435 | padding = ((-scsi_target_len) & 3); | ||
436 | if (padding) | ||
437 | scsi_target_len += padding; | ||
438 | if (scsi_name_len > 256) | ||
439 | scsi_name_len = 256; | ||
440 | |||
441 | buf[off-1] = scsi_target_len; | ||
442 | off += scsi_target_len; | ||
443 | |||
444 | /* Header size + Designation descriptor */ | ||
445 | len += (scsi_target_len + 4); | ||
405 | } | 446 | } |
406 | buf[2] = ((len >> 8) & 0xff); | 447 | buf[2] = ((len >> 8) & 0xff); |
407 | buf[3] = (len & 0xff); /* Page Length for VPD 0x83 */ | 448 | buf[3] = (len & 0xff); /* Page Length for VPD 0x83 */ |
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index e653110acb61..6c8001516c6d 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h | |||
@@ -112,7 +112,7 @@ | |||
112 | /* Queue Algorithm Modifier default for restricted reordering in control mode page */ | 112 | /* Queue Algorithm Modifier default for restricted reordering in control mode page */ |
113 | #define DA_EMULATE_REST_REORD 0 | 113 | #define DA_EMULATE_REST_REORD 0 |
114 | 114 | ||
115 | #define SE_INQUIRY_BUF 512 | 115 | #define SE_INQUIRY_BUF 768 |
116 | #define SE_MODE_PAGE_BUF 512 | 116 | #define SE_MODE_PAGE_BUF 512 |
117 | #define SE_SENSE_BUF 96 | 117 | #define SE_SENSE_BUF 96 |
118 | 118 | ||