diff options
author | mav <mav@FreeBSD.org> | 2015-10-05 10:52:22 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2015-10-05 10:52:22 +0000 |
commit | 7d1cbe473cd39c2c7f714f010661acc91f858d72 (patch) | |
tree | a38cc70de8a4bfe9a18de7691f08c95426c3d1c1 /sys/cam | |
parent | 2d1f539f448d1880e0e50be2a1923255db22ab90 (diff) | |
download | FreeBSD-src-7d1cbe473cd39c2c7f714f010661acc91f858d72.zip FreeBSD-src-7d1cbe473cd39c2c7f714f010661acc91f858d72.tar.gz |
MFC r288110: Add support for Control extension mode page.
Diffstat (limited to 'sys/cam')
-rw-r--r-- | sys/cam/ctl/ctl.c | 104 | ||||
-rw-r--r-- | sys/cam/ctl/ctl_private.h | 4 | ||||
-rw-r--r-- | sys/cam/scsi/scsi_all.h | 13 |
3 files changed, 94 insertions, 27 deletions
diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index 8af69e9..3dee0aa 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -261,6 +261,26 @@ const static struct scsi_control_page control_page_changeable = { /*extended_selftest_completion_time*/{0, 0} }; +#define CTL_CEM_LEN (sizeof(struct scsi_control_ext_page) - 4) + +const static struct scsi_control_ext_page control_ext_page_default = { + /*page_code*/SMS_CONTROL_MODE_PAGE | SMPH_SPF, + /*subpage_code*/0x01, + /*page_length*/{CTL_CEM_LEN >> 8, CTL_CEM_LEN}, + /*flags*/0, + /*prio*/0, + /*max_sense*/0 +}; + +const static struct scsi_control_ext_page control_ext_page_changeable = { + /*page_code*/SMS_CONTROL_MODE_PAGE | SMPH_SPF, + /*subpage_code*/0x01, + /*page_length*/{CTL_CEM_LEN >> 8, CTL_CEM_LEN}, + /*flags*/0, + /*prio*/0, + /*max_sense*/0 +}; + const static struct scsi_info_exceptions_page ie_page_default = { /*page_code*/SMS_INFO_EXCEPTIONS_PAGE, /*page_length*/sizeof(struct scsi_info_exceptions_page) - 2, @@ -3958,35 +3978,65 @@ ctl_init_page_index(struct ctl_lun *lun) break; } case SMS_CONTROL_MODE_PAGE: { - struct scsi_control_page *control_page; - - if (page_index->subpage != SMS_SUBPAGE_PAGE_0) - panic("invalid subpage value %d", - page_index->subpage); - - memcpy(&lun->mode_pages.control_page[CTL_PAGE_DEFAULT], - &control_page_default, - sizeof(control_page_default)); - memcpy(&lun->mode_pages.control_page[ - CTL_PAGE_CHANGEABLE], &control_page_changeable, - sizeof(control_page_changeable)); - memcpy(&lun->mode_pages.control_page[CTL_PAGE_SAVED], - &control_page_default, - sizeof(control_page_default)); - control_page = &lun->mode_pages.control_page[ - CTL_PAGE_SAVED]; - value = ctl_get_opt(&lun->be_lun->options, "reordering"); - if (value != NULL && strcmp(value, "unrestricted") == 0) { - control_page->queue_flags &= ~SCP_QUEUE_ALG_MASK; - control_page->queue_flags |= SCP_QUEUE_ALG_UNRESTRICTED; + switch (page_index->subpage) { + case SMS_SUBPAGE_PAGE_0: { + struct scsi_control_page *control_page; + + memcpy(&lun->mode_pages.control_page[ + CTL_PAGE_DEFAULT], + &control_page_default, + sizeof(control_page_default)); + memcpy(&lun->mode_pages.control_page[ + CTL_PAGE_CHANGEABLE], + &control_page_changeable, + sizeof(control_page_changeable)); + memcpy(&lun->mode_pages.control_page[ + CTL_PAGE_SAVED], + &control_page_default, + sizeof(control_page_default)); + control_page = &lun->mode_pages.control_page[ + CTL_PAGE_SAVED]; + value = ctl_get_opt(&lun->be_lun->options, + "reordering"); + if (value != NULL && + strcmp(value, "unrestricted") == 0) { + control_page->queue_flags &= + ~SCP_QUEUE_ALG_MASK; + control_page->queue_flags |= + SCP_QUEUE_ALG_UNRESTRICTED; + } + memcpy(&lun->mode_pages.control_page[ + CTL_PAGE_CURRENT], + &lun->mode_pages.control_page[ + CTL_PAGE_SAVED], + sizeof(control_page_default)); + page_index->page_data = + (uint8_t *)lun->mode_pages.control_page; + break; + } + case 0x01: + memcpy(&lun->mode_pages.control_ext_page[ + CTL_PAGE_DEFAULT], + &control_ext_page_default, + sizeof(control_ext_page_default)); + memcpy(&lun->mode_pages.control_ext_page[ + CTL_PAGE_CHANGEABLE], + &control_ext_page_changeable, + sizeof(control_ext_page_changeable)); + memcpy(&lun->mode_pages.control_ext_page[ + CTL_PAGE_SAVED], + &control_ext_page_default, + sizeof(control_ext_page_default)); + memcpy(&lun->mode_pages.control_ext_page[ + CTL_PAGE_CURRENT], + &lun->mode_pages.control_ext_page[ + CTL_PAGE_SAVED], + sizeof(control_ext_page_default)); + page_index->page_data = + (uint8_t *)lun->mode_pages.control_ext_page; + break; } - memcpy(&lun->mode_pages.control_page[CTL_PAGE_CURRENT], - &lun->mode_pages.control_page[CTL_PAGE_SAVED], - sizeof(control_page_default)); - page_index->page_data = - (uint8_t *)lun->mode_pages.control_page; break; - } case SMS_INFO_EXCEPTIONS_PAGE: { switch (page_index->subpage) { diff --git a/sys/cam/ctl/ctl_private.h b/sys/cam/ctl/ctl_private.h index f6b2084..caa6a4b 100644 --- a/sys/cam/ctl/ctl_private.h +++ b/sys/cam/ctl/ctl_private.h @@ -283,6 +283,9 @@ static const struct ctl_page_index page_index_template[] = { CTL_PAGE_FLAG_DISK_ONLY, NULL, ctl_caching_sp_handler}, {SMS_CONTROL_MODE_PAGE, 0, sizeof(struct scsi_control_page), NULL, CTL_PAGE_FLAG_NONE, NULL, ctl_control_page_handler}, + {SMS_CONTROL_MODE_PAGE | SMPH_SPF, 0x01, + sizeof(struct scsi_control_ext_page), NULL, + CTL_PAGE_FLAG_NONE, NULL, NULL}, {SMS_INFO_EXCEPTIONS_PAGE, 0, sizeof(struct scsi_info_exceptions_page), NULL, CTL_PAGE_FLAG_NONE, NULL, NULL}, {SMS_INFO_EXCEPTIONS_PAGE | SMPH_SPF, 0x02, @@ -302,6 +305,7 @@ struct ctl_mode_pages { struct scsi_rigid_disk_page rigid_disk_page[4]; struct scsi_caching_page caching_page[4]; struct scsi_control_page control_page[4]; + struct scsi_control_ext_page control_ext_page[4]; struct scsi_info_exceptions_page ie_page[4]; struct ctl_logical_block_provisioning_page lbp_page[4]; struct copan_debugconf_subpage debugconf_subpage[4]; diff --git a/sys/cam/scsi/scsi_all.h b/sys/cam/scsi/scsi_all.h index f860624..4f1b5b3 100644 --- a/sys/cam/scsi/scsi_all.h +++ b/sys/cam/scsi/scsi_all.h @@ -700,6 +700,19 @@ struct scsi_control_page { u_int8_t extended_selftest_completion_time[2]; }; +struct scsi_control_ext_page { + uint8_t page_code; + uint8_t subpage_code; + uint8_t page_length[2]; + uint8_t flags; +#define SCEP_TCMOS 0x04 /* Timestamp Changeable by */ +#define SCEP_SCSIP 0x02 /* SCSI Precedence (clock) */ +#define SCEP_IALUAE 0x01 /* Implicit ALUA Enabled */ + uint8_t prio; + uint8_t max_sense; + uint8_t reserve[25]; +}; + struct scsi_cache_page { u_int8_t page_code; #define SCHP_PAGE_SAVABLE 0x80 /* Page is savable */ |