90 #define MODE_SENSE_ALL_PAGES 0x3f
91 #define MODE_SENSE_PC_CURRENT 0x0
92 #define MODE_SENSE_PC_CHANGEABLE 0x1
93 #define MODE_SENSE_PC_DEFAULT 0x2
94 #define MODE_SENSE_PC_SAVED 0x3
98 0x01, 0x0a, 0x0c, 0x4b,
99 0x30, 0x00, 0x00, 0x00,
100 0x29, 0x00, 0xff, 0xff, };
104 0x02, 0x0e, 0x80, 0x80,
105 0x00, 0x00, 0x00, 0x00,
106 0x00, 0x00, 0x02, 0x84,
107 0x00, 0x00, 0x00, 0x04, };
111 0x03, 0x16, 0x00, 0x01,
112 0x00, 0x00, 0x00, 0x00,
113 0x00, 0x00, 0x00, 0x40,
114 0x00, 0x00, 0x00, 0x00,
115 0x00, 0x00, 0x00, 0x00,
116 0x00, 0x00, 0x00, 0x00, };
120 0x04, 0x16, 0x00, 0x01,
121 0x01, 0x00, 0x00, 0x00,
122 0x00, 0x00, 0x00, 0x00,
123 0x00, 0x00, 0x00, 0x00,
124 0x00, 0x00, 0x00, 0x00,
125 0x1c, 0x20, 0x00, 0x00, };
129 0x07, 0x0a, 0x00, 0x4b,
130 0x30, 0x00, 0x00, 0x00,
131 0x00, 0x00, 0xff, 0xff, };
135 0x08, 0x12, 0x10, 0x00,
136 0xff, 0xff, 0x00, 0x00,
137 0xff, 0xff, 0xff, 0xff,
138 0x80, 0x03, 0x00, 0x00,
139 0x00, 0x00, 0x00, 0x00, };
143 0x0a, 0x0a, 0x02, 0x00,
144 0x00, 0x80, 0x00, 0x00,
145 0x00, 0x00, 0x00, 0x00, };
149 0x18, 0x06, 0x00, 0x00,
150 0x00, 0x00, 0x00, 0x00, };
154 0x1c, 0x0a, 0x00, 0x00,
155 0xff, 0xff, 0xff, 0xff,
156 0x00, 0x00, 0x00, 0x00, };
160 0x00, 0x02, 0x00, 0x00, };
190 sizeof(mode_parameter_data[0]));
193 for (i = 0, param = mode_parameter_data; i < mode_parameter_data_count;
195 if (param->
page == page)
202 return ((value >> 16) & 0xff) |
204 ((value << 16) & 0xff0000);
208 uint8_t *buffer, uint32_t buffer_length)
210 uint32_t lun = io->tgt_io.lun;
211 int shortdesc = !dbd && !llbaa;
212 int longdesc = !dbd && llbaa;
216 sizeof(mode_parameter_data[0]));
221 uint8_t *parameter_data = NULL;
224 uint32_t payload_length = 0;
225 uint8_t *local_buffer;
228 ocs_t *ocs = io->ocs;
232 ocs_memset(buffer, 0, buffer_length);
240 for (i = 0, param = mode_parameter_data; i < mode_parameter_data_count;
246 local_buffer = ocs_malloc(ocs, length, OCS_M_NOWAIT);
250 ocs_memset(local_buffer, 0, length);
253 local_ptr = local_buffer;
274 parameter_data = local_ptr;
319 local_ptr = parameter_data;
320 for (i = 0, param = mode_parameter_data; i < mode_parameter_data_count;
325 #define tm_prot_luns (0)
327 #define TM_PROT_MODE_DEFAULT 0x0
328 #define TM_PROT_MODE_END2END 0x1
329 #define TM_PROT_MODE_WIRE_ONLY 0x2
330 #define TM_PROT_MODE_HOST_ONLY 0x3
331 #define tm_prot_mode TM_PROT_MODE_DEFAULT
333 if (param->
page == 0xa) {
339 }
else if (param->
page == 2) {
344 ocs_t *ocs = io->ocs;
356 payload_length = (buffer_length < length) ? buffer_length : length;
357 ocs_memcpy(buffer, local_buffer, payload_length);
360 ocs_free(ocs, local_buffer, length);
363 return payload_length;
401 uint32_t allocation_len;
406 uint32_t mode_sense_len;
411 dbd = (cdb[1] & 0x08) != 0;
412 page = cdb[2] & 0x3f;
413 pc = (cdb[2] >> 6) & 0x03;
416 llbaa = (cdb[1] & 0x10) != 0;
419 allocation_len = cdb[4];
421 allocation_len = (cdb[7] << 8) | (cdb[8] << 0);
426 if (allocation_len == 0) {
434 ocs_log_info(NULL,
"Mode Sense changeable not supported for LUN %d\n", io->tgt_io.lun);
443 ocs_log_info(NULL,
"Mode Sense saving parameters not supported for LUN %d\n", io->tgt_io.lun);
448 ocs_log_info(NULL,
"Mode Sense (6) unsupported page code 0x%02x for LUN %d\n", page, io->tgt_io.lun);
453 if (ocs_dma_alloc(io->ocs, &io->tgt_io.payload, 256, 16)) {
454 ocs_log_err(NULL,
"ocs_scsi_dma_alloc failed\n");
460 mode_sense_len =
tm_build_mode_parameter(io, page, dbd, llbaa, hdrsize, io->tgt_io.payload.virt, allocation_len);
462 sgl[0].
addr = io->tgt_io.payload.phys;
463 sgl[0].
len = mode_sense_len;
465 io->tgt_io.is_read = TRUE;
static uint8_t mode_parameter_page_02[]
static uint8_t mode_parameter_page_00[]
Defines the mode sense long parameter block descriptor.
internal structure for mode sense parameter data pages.
#define MODE_SENSE_PC_SAVED
static uint8_t mode_parameter_page_1c[]
static uint8_t mode_parameter_page_01[]
static int tm_mode_page_supported(int page)
static uint8_t mode_parameter_page_0a[]
static uint8_t mode_parameter_page_08[]
static uint8_t mode_parameter_page_03[]
generic scatter-gather list structure
static uint8_t mode_parameter_page_07[]
ramdisc instance structure
static uint32_t ocs_htobe24(uint32_t value)
#define SNSCODE_SAVE_NOT_SUPPORTED
ocs_ramd_hndlr_rtn_e ocs_ramd_mode_sense10(ocs_io_t *io, uint8_t cdb[])
Process SCSI Mode Sense 10 command.
int32_t ocs_scsi_send_rd_data(ocs_io_t *io, uint32_t flags, ocs_scsi_dif_info_t *dif_info, ocs_scsi_sgl_t *sgl, uint32_t sgl_count, uint64_t wire_len, ocs_scsi_io_cb_t cb, void *arg)
ocs_ramd_hndlr_rtn_e ocs_ramd_mode_sense6(ocs_io_t *io, uint8_t cdb[])
Process SCSI Mode Sense 6 command.
static int tm_build_mode_parameter(ocs_io_t *io, int page, int dbd, int llbaa, int hdrsize, uint8_t *buffer, uint32_t buffer_length)
#define OCS_SCSI_LAST_DATAPHASE
static struct mode_parameter_data_s mode_parameter_data[]
ocs_ramdisc_t * ocs_ramd_lookup(ocs_io_t *io, uint32_t lun)
Given an IO and a LUN number, return the ramdisc to which the IO is directed.
uint64_t number_of_blocks
#define MODE_SENSE_ALL_PAGES
unsigned number_of_blocks
ocs_ramd_hndlr_rtn_e ocs_ramd_check_cond(ocs_io_t *io, uint8_t sense_key, uint8_t asc, uint8_t ascq)
Send a SCSI check condition.
static uint8_t mode_parameter_page_04[]
Defines the mode sense parameter block descriptor.
uint32_t parameter_data_length
#define ocs_assert(cond,...)
#define MODE_SENSE_PC_CHANGEABLE
static uint8_t mode_parameter_page_18[]
static ocs_ramd_hndlr_rtn_e ocs_ramd_mode_sense(ocs_io_t *io, uint32_t hdrsize, uint8_t cdb[])
int32_t scsi_dataphase_cb(ocs_io_t *io, ocs_scsi_io_status_e scsi_status, uint32_t flags, void *arg)
ocs_ramd_hndlr_rtn_e ocs_ramd_good_status(ocs_io_t *io)
Send a good SCSI status.
uint32_t ocs_scsi_get_property(ocs_t *ocs, ocs_scsi_property_e prop)
Return SCSI API integer valued property.
#define TM_PROT_MODE_HOST_ONLY