Add support for Control extension mode page.

This commit is contained in:
Alexander Motin 2015-09-22 14:55:46 +00:00
parent a9ee805d45
commit c53993057b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=288110
3 changed files with 93 additions and 26 deletions

View File

@ -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,
@ -3956,35 +3976,65 @@ ctl_init_page_index(struct ctl_lun *lun)
break;
}
case SMS_CONTROL_MODE_PAGE: {
struct scsi_control_page *control_page;
switch (page_index->subpage) {
case SMS_SUBPAGE_PAGE_0: {
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;
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) {

View File

@ -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];

View File

@ -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 */