]> Pileus Git - ~andy/linux/blobdiff - drivers/target/target_core_cdb.c
Merge branch 'sh-latest' of git://git.kernel.org/pub/scm/linux/kernel/git/lethal...
[~andy/linux] / drivers / target / target_core_cdb.c
index 9828300236619354f98a082e3670a8f9a280a2dc..8ae09a1bdf74a8744b4884df7cddb792af6f8f0f 100644 (file)
@@ -23,6 +23,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
+#include <linux/kernel.h>
 #include <asm/unaligned.h>
 #include <scsi/scsi.h>
 
@@ -162,11 +163,9 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf)
        struct t10_alua_lu_gp_member *lu_gp_mem;
        struct t10_alua_tg_pt_gp *tg_pt_gp;
        struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem;
-       unsigned char binary, binary_new;
        unsigned char *prod = &dev->se_sub_dev->t10_wwn.model[0];
        u32 prod_len;
        u32 unit_serial_len, off = 0;
-       int i;
        u16 len = 0, id_len;
 
        off = 4;
@@ -188,11 +187,11 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf)
        /* CODE SET == Binary */
        buf[off++] = 0x1;
 
-       /* Set ASSOICATION == addressed logical unit: 0)b */
+       /* Set ASSOCIATION == addressed logical unit: 0)b */
        buf[off] = 0x00;
 
        /* Identifier/Designator type == NAA identifier */
-       buf[off++] = 0x3;
+       buf[off++] |= 0x3;
        off++;
 
        /* Identifier/Designator length */
@@ -215,16 +214,9 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf)
         * VENDOR_SPECIFIC_IDENTIFIER and
         * VENDOR_SPECIFIC_IDENTIFIER_EXTENTION
         */
-       binary = transport_asciihex_to_binaryhex(
-                               &dev->se_sub_dev->t10_wwn.unit_serial[0]);
-       buf[off++] |= (binary & 0xf0) >> 4;
-       for (i = 0; i < 24; i += 2) {
-               binary_new = transport_asciihex_to_binaryhex(
-                       &dev->se_sub_dev->t10_wwn.unit_serial[i+2]);
-               buf[off] = (binary & 0x0f) << 4;
-               buf[off++] |= (binary_new & 0xf0) >> 4;
-               binary = binary_new;
-       }
+       buf[off++] |= hex_to_bin(dev->se_sub_dev->t10_wwn.unit_serial[0]);
+       hex2bin(&buf[off], &dev->se_sub_dev->t10_wwn.unit_serial[1], 12);
+
        len = 20;
        off = (len + 4);
 
@@ -293,7 +285,7 @@ check_port:
                        (tpg->se_tpg_tfo->get_fabric_proto_ident(tpg) << 4);
                buf[off++] |= 0x1; /* CODE SET == Binary */
                buf[off] = 0x80; /* Set PIV=1 */
-               /* Set ASSOICATION == target port: 01b */
+               /* Set ASSOCIATION == target port: 01b */
                buf[off] |= 0x10;
                /* DESIGNATOR TYPE == Relative target port identifer */
                buf[off++] |= 0x4;
@@ -338,7 +330,7 @@ check_tpgi:
                        (tpg->se_tpg_tfo->get_fabric_proto_ident(tpg) << 4);
                buf[off++] |= 0x1; /* CODE SET == Binary */
                buf[off] = 0x80; /* Set PIV=1 */
-               /* Set ASSOICATION == target port: 01b */
+               /* Set ASSOCIATION == target port: 01b */
                buf[off] |= 0x10;
                /* DESIGNATOR TYPE == Target port group identifier */
                buf[off++] |= 0x5;
@@ -405,7 +397,7 @@ check_scsi_name:
                        (tpg->se_tpg_tfo->get_fabric_proto_ident(tpg) << 4);
                buf[off++] |= 0x3; /* CODE SET == UTF-8 */
                buf[off] = 0x80; /* Set PIV=1 */
-               /* Set ASSOICATION == target port: 01b */
+               /* Set ASSOCIATION == target port: 01b */
                buf[off] |= 0x10;
                /* DESIGNATOR TYPE == SCSI name string */
                buf[off++] |= 0x8;
@@ -774,6 +766,35 @@ target_modesense_control(struct se_device *dev, unsigned char *p)
        p[0] = 0x0a;
        p[1] = 0x0a;
        p[2] = 2;
+       /*
+        * From spc4r23, 7.4.7 Control mode page
+        *
+        * The QUEUE ALGORITHM MODIFIER field (see table 368) specifies
+        * restrictions on the algorithm used for reordering commands
+        * having the SIMPLE task attribute (see SAM-4).
+        *
+        *                    Table 368 -- QUEUE ALGORITHM MODIFIER field
+        *                         Code      Description
+        *                          0h       Restricted reordering
+        *                          1h       Unrestricted reordering allowed
+        *                          2h to 7h    Reserved
+        *                          8h to Fh    Vendor specific
+        *
+        * A value of zero in the QUEUE ALGORITHM MODIFIER field specifies that
+        * the device server shall order the processing sequence of commands
+        * having the SIMPLE task attribute such that data integrity is maintained
+        * for that I_T nexus (i.e., if the transmission of new SCSI transport protocol
+        * requests is halted at any time, the final value of all data observable
+        * on the medium shall be the same as if all the commands had been processed
+        * with the ORDERED task attribute).
+        *
+        * A value of one in the QUEUE ALGORITHM MODIFIER field specifies that the
+        * device server may reorder the processing sequence of commands having the
+        * SIMPLE task attribute in any manner. Any data integrity exposures related to
+        * command sequence order shall be explicitly handled by the application client
+        * through the selection of appropriate ommands and task attributes.
+        */
+       p[3] = (dev->se_sub_dev->se_dev_attrib.emulate_rest_reord == 1) ? 0x00 : 0x10;
        /*
         * From spc4r17, section 7.4.6 Control mode Page
         *