aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target/target_core_cdb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/target/target_core_cdb.c')
-rw-r--r--drivers/target/target_core_cdb.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/drivers/target/target_core_cdb.c b/drivers/target/target_core_cdb.c
index 89ae923c5da6..f04d4ef99dca 100644
--- a/drivers/target/target_core_cdb.c
+++ b/drivers/target/target_core_cdb.c
@@ -24,6 +24,7 @@
24 */ 24 */
25 25
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/ctype.h>
27#include <asm/unaligned.h> 28#include <asm/unaligned.h>
28#include <scsi/scsi.h> 29#include <scsi/scsi.h>
29 30
@@ -154,6 +155,37 @@ target_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf)
154 return 0; 155 return 0;
155} 156}
156 157
158static void
159target_parse_naa_6h_vendor_specific(struct se_device *dev, unsigned char *buf_off)
160{
161 unsigned char *p = &dev->se_sub_dev->t10_wwn.unit_serial[0];
162 unsigned char *buf = buf_off;
163 int cnt = 0, next = 1;
164 /*
165 * Generate up to 36 bits of VENDOR SPECIFIC IDENTIFIER starting on
166 * byte 3 bit 3-0 for NAA IEEE Registered Extended DESIGNATOR field
167 * format, followed by 64 bits of VENDOR SPECIFIC IDENTIFIER EXTENSION
168 * to complete the payload. These are based from VPD=0x80 PRODUCT SERIAL
169 * NUMBER set via vpd_unit_serial in target_core_configfs.c to ensure
170 * per device uniqeness.
171 */
172 while (*p != '\0') {
173 if (cnt >= 13)
174 break;
175 if (!isxdigit(*p)) {
176 p++;
177 continue;
178 }
179 if (next != 0) {
180 buf[cnt++] |= hex_to_bin(*p++);
181 next = 0;
182 } else {
183 buf[cnt] = hex_to_bin(*p++) << 4;
184 next = 1;
185 }
186 }
187}
188
157/* 189/*
158 * Device identification VPD, for a complete list of 190 * Device identification VPD, for a complete list of
159 * DESIGNATOR TYPEs see spc4r17 Table 459. 191 * DESIGNATOR TYPEs see spc4r17 Table 459.
@@ -219,8 +251,7 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf)
219 * VENDOR_SPECIFIC_IDENTIFIER and 251 * VENDOR_SPECIFIC_IDENTIFIER and
220 * VENDOR_SPECIFIC_IDENTIFIER_EXTENTION 252 * VENDOR_SPECIFIC_IDENTIFIER_EXTENTION
221 */ 253 */
222 buf[off++] |= hex_to_bin(dev->se_sub_dev->t10_wwn.unit_serial[0]); 254 target_parse_naa_6h_vendor_specific(dev, &buf[off]);
223 hex2bin(&buf[off], &dev->se_sub_dev->t10_wwn.unit_serial[1], 12);
224 255
225 len = 20; 256 len = 20;
226 off = (len + 4); 257 off = (len + 4);