From fc5f527c21476e453a8a6d9514565a95cd35bf71 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Mon, 16 Oct 2017 13:12:03 -0700 Subject: [PATCH] scsi: split Inquiry peripheral type and qualifier The SCSI spec defines two separate fields within the first byte of the Inquiry data. Define them as bitfields and add enum values for the peripheral qualifier field. Change-Id: Ibbb158338da199fc1b67b04c52ec91633577c571 Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/382713 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Changpeng Liu --- include/spdk/scsi_spec.h | 12 ++++++++++-- lib/scsi/scsi_bdev.c | 6 ++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/spdk/scsi_spec.h b/include/spdk/scsi_spec.h index 6163eb25c..53ef52b2c 100644 --- a/include/spdk/scsi_spec.h +++ b/include/spdk/scsi_spec.h @@ -328,6 +328,12 @@ enum spdk_spc_vpd { SPDK_SPC_VPD_BLOCK_THIN_PROVISION = 0xb2, }; +enum spdk_spc_peripheral_qualifier { + SPDK_SPC_PERIPHERAL_QUALIFIER_CONNECTED = 0, + SPDK_SPC_PERIPHERAL_QUALIFIER_NOT_CONNECTED = 1, + SPDK_SPC_PERIPHERAL_QUALIFIER_NOT_CAPABLE = 3, +}; + enum { SPDK_SPC_PERIPHERAL_DEVICE_TYPE_DISK = 0x00, SPDK_SPC_PERIPHERAL_DEVICE_TYPE_TAPE = 0x01, @@ -379,7 +385,8 @@ struct spdk_scsi_cdb_inquiry { SPDK_STATIC_ASSERT(sizeof(struct spdk_scsi_cdb_inquiry) == 6, "incorrect CDB size"); struct spdk_scsi_cdb_inquiry_data { - uint8_t peripheral; + uint8_t peripheral_device_type : 5; + uint8_t peripheral_qualifier : 3; uint8_t rmb; uint8_t version; uint8_t response; @@ -397,7 +404,8 @@ struct spdk_scsi_cdb_inquiry_data { }; struct spdk_scsi_vpd_page { - uint8_t peripheral; + uint8_t peripheral_device_type : 5; + uint8_t peripheral_qualifier : 3; uint8_t page_code; uint8_t alloc_len[2]; uint8_t params[]; diff --git a/lib/scsi/scsi_bdev.c b/lib/scsi/scsi_bdev.c index a2617c7aa..bc34fde72 100644 --- a/lib/scsi/scsi_bdev.c +++ b/lib/scsi/scsi_bdev.c @@ -202,7 +202,8 @@ spdk_bdev_scsi_inquiry(struct spdk_bdev *bdev, struct spdk_scsi_task *task, struct spdk_scsi_vpd_page *vpage = (struct spdk_scsi_vpd_page *)data; /* PERIPHERAL QUALIFIER(7-5) PERIPHERAL DEVICE TYPE(4-0) */ - vpage->peripheral = pd; + vpage->peripheral_device_type = pd; + vpage->peripheral_qualifier = SPDK_SPC_PERIPHERAL_QUALIFIER_CONNECTED; /* PAGE CODE */ vpage->page_code = pc; @@ -670,7 +671,8 @@ spdk_bdev_scsi_inquiry(struct spdk_bdev *bdev, struct spdk_scsi_task *task, /* Standard INQUIRY data */ /* PERIPHERAL QUALIFIER(7-5) PERIPHERAL DEVICE TYPE(4-0) */ - inqdata->peripheral = pd; + inqdata->peripheral_device_type = pd; + inqdata->peripheral_qualifier = SPDK_SPC_PERIPHERAL_QUALIFIER_CONNECTED; /* RMB(7) */ inqdata->rmb = 0;