Skip to content

Commit fbfe858

Browse files
hreineckeNicholas Bellinger
authored andcommitted
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>
1 parent 03ba84c commit fbfe858

2 files changed

Lines changed: 43 additions & 2 deletions

File tree

‎drivers/target/target_core_spc.c‎

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ spc_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf)
267267
port = lun->lun_sep;
268268
if (port) {
269269
struct t10_alua_lu_gp *lu_gp;
270-
u32 padding, scsi_name_len;
270+
u32 padding, scsi_name_len, scsi_target_len;
271271
u16 lu_gp_id = 0;
272272
u16 tg_pt_gp_id = 0;
273273
u16 tpgt;
@@ -402,6 +402,47 @@ spc_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf)
402402
off += scsi_name_len;
403403
/* Header size + Designation descriptor */
404404
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);
405446
}
406447
buf[2] = ((len >> 8) & 0xff);
407448
buf[3] = (len & 0xff); /* Page Length for VPD 0x83 */

‎include/target/target_core_base.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
/* Queue Algorithm Modifier default for restricted reordering in control mode page */
113113
#define DA_EMULATE_REST_REORD 0
114114

115-
#define SE_INQUIRY_BUF 512
115+
#define SE_INQUIRY_BUF 768
116116
#define SE_MODE_PAGE_BUF 512
117117
#define SE_SENSE_BUF 96
118118

0 commit comments

Comments
 (0)