diff options
author | Sergey Samoylenko <s.samoylenko@yadro.com> | 2021-04-20 21:59:19 +0300 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2021-05-15 14:14:28 -0400 |
commit | 17f947b8b06f57615d31e4159dec1d5d7dda775f (patch) | |
tree | 74d54aecc068a040d468782e2a7fd9918407ec49 /drivers/target/target_core_spc.c | |
parent | f8a78e9118ee6cee7c24113891a0e24b77486f5e (diff) |
scsi: target: core: Unify NAA identifier generation
Both the INQUIRY handling and the XCOPY implementation provide functions to
generate an NAA designator. In addition, these functions are poorly named:
- spc_parse_naa_6h_vendor_specific()
- target_xcopy_gen_naa_ieee()
Introduce a common NAA 6 designator generation function,
spc_gen_naa_6h_vendor_specific().
Link: https://lore.kernel.org/r/20210420185920.42431-2-s.samoylenko@yadro.com
Signed-off-by: Sergey Samoylenko <s.samoylenko@yadro.com>
Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/target/target_core_spc.c')
-rw-r--r-- | drivers/target/target_core_spc.c | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c index 70a661801cb9..b2d19493a994 100644 --- a/drivers/target/target_core_spc.c +++ b/drivers/target/target_core_spc.c @@ -129,14 +129,29 @@ spc_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf) return 0; } -void spc_parse_naa_6h_vendor_specific(struct se_device *dev, - unsigned char *buf) +/* + * Generate NAA IEEE Registered Extended designator + */ +void spc_gen_naa_6h_vendor_specific(struct se_device *dev, + unsigned char *buf) { unsigned char *p = &dev->t10_wwn.unit_serial[0]; - int cnt; + int cnt, off = 0; bool next = true; /* + * Start NAA IEEE Registered Extended Identifier/Designator + */ + buf[off++] = 0x6 << 4; + + /* + * Use OpenFabrics IEEE Company ID: 00 14 05 + */ + buf[off++] = 0x01; + buf[off++] = 0x40; + buf[off] = (0x5 << 4); + + /* * Generate up to 36 bits of VENDOR SPECIFIC IDENTIFIER starting on * byte 3 bit 3-0 for NAA IEEE Registered Extended DESIGNATOR field * format, followed by 64 bits of VENDOR SPECIFIC IDENTIFIER EXTENSION @@ -144,7 +159,7 @@ void spc_parse_naa_6h_vendor_specific(struct se_device *dev, * NUMBER set via vpd_unit_serial in target_core_configfs.c to ensure * per device uniqeness. */ - for (cnt = 0; *p && cnt < 13; p++) { + for (cnt = off + 13; *p && off < cnt; p++) { int val = hex_to_bin(*p); if (val < 0) @@ -152,10 +167,10 @@ void spc_parse_naa_6h_vendor_specific(struct se_device *dev, if (next) { next = false; - buf[cnt++] |= val; + buf[off++] |= val; } else { next = true; - buf[cnt] = val << 4; + buf[off] = val << 4; } } } @@ -203,24 +218,8 @@ spc_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf) /* Identifier/Designator length */ buf[off++] = 0x10; - /* - * Start NAA IEEE Registered Extended Identifier/Designator - */ - buf[off++] = (0x6 << 4); - - /* - * Use OpenFabrics IEEE Company ID: 00 14 05 - */ - buf[off++] = 0x01; - buf[off++] = 0x40; - buf[off] = (0x5 << 4); - - /* - * Return ConfigFS Unit Serial Number information for - * VENDOR_SPECIFIC_IDENTIFIER and - * VENDOR_SPECIFIC_IDENTIFIER_EXTENTION - */ - spc_parse_naa_6h_vendor_specific(dev, &buf[off]); + /* NAA IEEE Registered Extended designator */ + spc_gen_naa_6h_vendor_specific(dev, &buf[off]); len = 20; off = (len + 4); |