Author: mav
Date: Fri Jul  4 16:10:14 2014
New Revision: 268260
URL: http://svnweb.freebsd.org/changeset/base/268260

Log:
  MFC r267637:
  Add iSCSI Target Name ID descriptor to VPD 83h.
  
  It shall/should be there according to SPC-4, and istgt also provides it.

Modified:
  stable/10/sys/cam/ctl/ctl_frontend_iscsi.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl_frontend_iscsi.c
==============================================================================
--- stable/10/sys/cam/ctl/ctl_frontend_iscsi.c  Fri Jul  4 16:09:09 2014        
(r268259)
+++ stable/10/sys/cam/ctl/ctl_frontend_iscsi.c  Fri Jul  4 16:10:14 2014        
(r268260)
@@ -2053,12 +2053,13 @@ cfiscsi_devid(struct ctl_scsiio *ctsio, 
        struct cfiscsi_session *cs;
        struct scsi_vpd_device_id *devid_ptr;
        struct scsi_vpd_id_descriptor *desc, *desc1, *desc2, *desc3, *desc4;
+       struct scsi_vpd_id_descriptor *desc5;
        struct scsi_vpd_id_t10 *t10id;
        struct ctl_lun *lun;
        const struct icl_pdu *request;
        int i, ret;
        char *val;
-       size_t devid_len, wwpn_len, lun_name_len;
+       size_t devid_len, wwnn_len, wwpn_len, lun_name_len;
 
        lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
        request = ctsio->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr;
@@ -2070,6 +2071,11 @@ cfiscsi_devid(struct ctl_scsiio *ctsio, 
        if ((wwpn_len % 4) != 0)
                wwpn_len += (4 - (wwpn_len % 4));
 
+       wwnn_len = strlen(cs->cs_target->ct_name);
+       wwnn_len += 1; /* '\0' */
+       if ((wwnn_len % 4) != 0)
+               wwnn_len += (4 - (wwnn_len % 4));
+
        if (lun == NULL) {
                lun_name_len = 0;
        } else {
@@ -2084,6 +2090,7 @@ cfiscsi_devid(struct ctl_scsiio *ctsio, 
                sizeof(struct scsi_vpd_id_descriptor) +
                sizeof(struct scsi_vpd_id_t10) + CTL_DEVID_LEN +
                sizeof(struct scsi_vpd_id_descriptor) + lun_name_len +
+               sizeof(struct scsi_vpd_id_descriptor) + wwnn_len +
                sizeof(struct scsi_vpd_id_descriptor) + wwpn_len +
                sizeof(struct scsi_vpd_id_descriptor) +
                sizeof(struct scsi_vpd_id_rel_trgt_port_id) +
@@ -2114,8 +2121,10 @@ cfiscsi_devid(struct ctl_scsiio *ctsio, 
        desc2 = (struct scsi_vpd_id_descriptor *)(&desc1->identifier[0] +
            lun_name_len);
        desc3 = (struct scsi_vpd_id_descriptor *)(&desc2->identifier[0] +
-           wwpn_len);
+           wwnn_len);
        desc4 = (struct scsi_vpd_id_descriptor *)(&desc3->identifier[0] +
+           wwpn_len);
+       desc5 = (struct scsi_vpd_id_descriptor *)(&desc4->identifier[0] +
            sizeof(struct scsi_vpd_id_rel_trgt_port_id));
 
        if (lun != NULL)
@@ -2189,32 +2198,41 @@ cfiscsi_devid(struct ctl_scsiio *ctsio, 
        }
 
        /*
-        * desc2 is for the WWPN which is a port asscociation.
+        * desc2 is for the Target Name.
+        */
+       desc2->proto_codeset = (SCSI_PROTO_ISCSI << 4) | SVPD_ID_CODESET_UTF8;
+       desc2->id_type = SVPD_ID_PIV | SVPD_ID_ASSOC_TARGET |
+           SVPD_ID_TYPE_SCSI_NAME;
+       desc2->length = wwnn_len;
+       snprintf(desc2->identifier, wwnn_len, "%s", cs->cs_target->ct_name);
+
+       /*
+        * desc3 is for the WWPN which is a port asscociation.
         */
-               desc2->proto_codeset = (SCSI_PROTO_ISCSI << 4) | 
SVPD_ID_CODESET_UTF8;
-       desc2->id_type = SVPD_ID_PIV | SVPD_ID_ASSOC_PORT |
+       desc3->proto_codeset = (SCSI_PROTO_ISCSI << 4) | SVPD_ID_CODESET_UTF8;
+       desc3->id_type = SVPD_ID_PIV | SVPD_ID_ASSOC_PORT |
            SVPD_ID_TYPE_SCSI_NAME;
-       desc2->length = wwpn_len;
-       snprintf(desc2->identifier, wwpn_len, "%s,t,0x%4.4x",
+       desc3->length = wwpn_len;
+       snprintf(desc3->identifier, wwpn_len, "%s,t,0x%4.4x",
            cs->cs_target->ct_name, cs->cs_portal_group_tag);
 
        /*
         * desc3 is for the Relative Target Port(type 4h) identifier
         */
-               desc3->proto_codeset = (SCSI_PROTO_ISCSI << 4) | 
SVPD_ID_CODESET_BINARY;
-       desc3->id_type = SVPD_ID_PIV | SVPD_ID_ASSOC_PORT |
+       desc4->proto_codeset = (SCSI_PROTO_ISCSI << 4) | SVPD_ID_CODESET_BINARY;
+       desc4->id_type = SVPD_ID_PIV | SVPD_ID_ASSOC_PORT |
            SVPD_ID_TYPE_RELTARG;
-       desc3->length = 4;
-       desc3->identifier[3] = 1;
+       desc4->length = 4;
+       desc4->identifier[3] = 1;
 
        /*
         * desc4 is for the Target Port Group(type 5h) identifier
         */
-               desc4->proto_codeset = (SCSI_PROTO_ISCSI << 4) | 
SVPD_ID_CODESET_BINARY;
-       desc4->id_type = SVPD_ID_PIV | SVPD_ID_ASSOC_PORT |
+       desc5->proto_codeset = (SCSI_PROTO_ISCSI << 4) | SVPD_ID_CODESET_BINARY;
+       desc5->id_type = SVPD_ID_PIV | SVPD_ID_ASSOC_PORT |
            SVPD_ID_TYPE_TPORTGRP;
-       desc4->length = 4;
-       desc4->identifier[3] = 1;
+       desc5->length = 4;
+       desc5->identifier[3] = 1;
 
        ctsio->scsi_status = SCSI_STATUS_OK;
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to