Lines Matching +full:sense +full:-
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2003-2009 Silicon Graphics International Corp.
6 * Copyright (c) 2014-2015 Alexander Motin <mav@FreeBSD.org>
34 * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl_error.c#2 $
76 * Determine whether to return fixed or descriptor format sense
81 * SPC-3 and up require some UAs to be returned as fixed.
88 * sense if the LUN exists and descriptor sense is turned
91 if ((lun != NULL) && (lun->MODE_CTRL.rlec & SCP_DSENSE))
98 * Determine maximum sense data length to return.
101 if ((lun != NULL) && (lun->MODE_CTRLE.max_sense != 0))
102 *sense_len = lun->MODE_CTRLE.max_sense;
141 ctl_set_sense_data_va(&ctsio->sense_data, &sense_len,
151 ctsio->scsi_status = SCSI_STATUS_CHECK_COND;
152 ctsio->sense_len = sense_len;
153 ctsio->io_hdr.status = CTL_SCSI_ERROR | CTL_AUTOSENSE;
157 * Transform fixed sense data into descriptor sense data.
159 * For simplicity's sake, we assume that both sense structures are
173 if ((sense_src->error_code & SSD_ERRCODE) == SSD_DEFERRED_ERROR)
181 * Check to see whether any of the tape-specific bits are set. If
182 * so, we'll need a stream sense descriptor.
184 if (sense_src->flags & (SSD_ILI|SSD_EOM|SSD_FILEMARK))
185 stream_bits = sense_src->flags & ~SSD_KEY;
190 * Utilize our sense setting routine to do the transform. If a
191 * value is set in the fixed sense data, set it in the descriptor
199 /*sense_key*/ sense_src->flags & SSD_KEY,
200 /*asc*/ sense_src->add_sense_code,
201 /*ascq*/ sense_src->add_sense_code_qual,
204 (sense_src->error_code & SSD_ERRCODE_VALID) ?
206 sizeof(sense_src->info),
207 sense_src->info,
210 (scsi_4btoul(sense_src->cmd_spec_info) != 0) ?
212 sizeof(sense_src->cmd_spec_info),
213 sense_src->cmd_spec_info,
216 (sense_src->fru != 0) ?
218 sizeof(sense_src->fru),
219 &sense_src->fru,
221 /* Sense Key Specific */
222 (sense_src->sense_key_spec[0] & SSD_SCS_VALID) ?
224 sizeof(sense_src->sense_key_spec),
225 sense_src->sense_key_spec,
237 * Transform descriptor format sense data into fixed sense data.
240 * thant can't be represented as fixed sense data.
242 * For simplicity's sake, we assume that both sense structures are
257 if ((sense_src->error_code & SSD_ERRCODE) == SSD_DESC_CURRENT_ERROR)
262 for (pos = 0; pos < (int)(sense_src->extra_len - 1);) {
266 &sense_src->sense_desc[pos];
269 * See if this record goes past the end of the sense data.
272 if ((pos + header->length + sizeof(*header)) >
273 sense_src->extra_len)
276 switch (sense_src->sense_desc[pos]) {
282 info_ptr = info->info;
283 info_size = sizeof(info->info);
285 pos += info->length +
293 cmd_ptr = cmd->command_info;
294 cmd_size = sizeof(cmd->command_info);
296 pos += cmd->length +
304 fru_ptr = &fru->fru;
305 fru_size = sizeof(fru->fru);
306 pos += fru->length +
314 sks_ptr = sks->sense_key_spec;
315 sks_size = sizeof(sks->sense_key_spec);
317 pos = sks->length +
325 stream_ptr = &stream_sense->byte3;
326 stream_size = sizeof(stream_sense->byte3);
327 pos = stream_sense->length +
333 * We don't recognize this particular sense
336 pos += sizeof(*header) + header->length;
346 /*sense_key*/ sense_src->sense_key & SSD_KEY,
347 /*asc*/ sense_src->add_sense_code,
348 /*ascq*/ sense_src->add_sense_code_qual,
365 /* Sense Key Specific */
477 *info = lun->ua_tpt_info;
486 *asc = lun->ie_asc;
487 *ascq = lun->ie_ascq;
503 mtx_assert(&lun->lun_lock, MA_OWNED);
506 if (lun->pending_ua[p] == NULL)
509 ua = lun->pending_ua[p][i];
513 ua_to_build = (1 << (ffs(ua) - 1));
530 struct scsi_sense_data *sense, u_int *sense_len,
539 mtx_assert(&lun->lun_lock, MA_OWNED);
540 mtx_assert(&lun->ctl_softc->ctl_lock, MA_NOTOWNED);
542 if ((ua = lun->pending_ua[p]) == NULL) {
543 mtx_unlock(&lun->lun_lock);
546 mtx_lock(&lun->lun_lock);
547 if (lun->pending_ua[p] == NULL) {
548 lun->pending_ua[p] = ua;
553 ua = lun->pending_ua[p];
560 ua_to_build = (1 << (ffs(ua[i]) - 1));
565 ctl_set_sense_data(sense, sense_len, lun, sense_format, 1,
574 mtx_unlock(&lun->lun_lock);
575 mtx_lock(&lun->ctl_softc->ctl_lock);
576 ctl_clr_ua_allluns(lun->ctl_softc, initidx, ua_to_build);
577 mtx_unlock(&lun->ctl_softc->ctl_lock);
578 mtx_lock(&lun->lun_lock);
580 (lun->MODE_LBP.main.flags & SLBPP_SITUA) != 0) {
581 ctl_clr_ua_all(lun, -1, ua_to_build);
754 /* "Write error - auto reallocation failed" */
820 /* "Medium not present - tray open" */
832 /* "Medium not present - tray closed" */
929 ctsio->scsi_status = SCSI_STATUS_RESERV_CONFLICT;
930 ctsio->sense_len = 0;
931 ctsio->io_hdr.status = CTL_SCSI_ERROR;
938 ctsio->scsi_status = SCSI_STATUS_QUEUE_FULL;
939 ctsio->sense_len = 0;
940 ctsio->io_hdr.status = CTL_SCSI_ERROR;
947 ctsio->scsi_status = SCSI_STATUS_BUSY;
948 ctsio->sense_len = 0;
949 ctsio->io_hdr.status = CTL_SCSI_ERROR;
956 ctsio->scsi_status = SCSI_STATUS_TASK_ABORTED;
957 ctsio->sense_len = 0;
958 ctsio->io_hdr.status = CTL_CMD_ABORTED;
989 ctsio->scsi_status = SCSI_STATUS_OK;
990 ctsio->sense_len = 0;
991 ctsio->io_hdr.status = CTL_SUCCESS;
1000 memset(&ctnio->cpl, 0, sizeof(ctnio->cpl));
1003 ctnio->cpl.status = htole16(status);
1004 ctnio->io_hdr.status = CTL_NVME_ERROR;
1110 memset(&ctnio->cpl, 0, sizeof(ctnio->cpl));
1111 ctnio->io_hdr.status = CTL_SUCCESS;
1117 switch (io->io_hdr.io_type) {
1119 ctl_set_invalid_opcode(&io->scsiio);
1122 ctl_nvme_set_invalid_opcode(&io->nvmeio);
1132 switch (io->io_hdr.io_type) {
1134 ctl_set_hw_write_protected(&io->scsiio);
1137 ctl_nvme_set_namespace_is_write_protected(&io->nvmeio);
1147 switch (io->io_hdr.io_type) {
1149 ctl_set_busy(&io->scsiio);
1152 ctl_nvme_set_namespace_not_ready(&io->nvmeio);
1164 switch (io->io_hdr.io_type) {
1167 ctl_set_sense(&io->scsiio, /*current_error*/ 1,
1175 ctl_nvme_set_compare_failure(&io->nvmeio);
1185 switch (io->io_hdr.io_type) {
1187 ctl_set_space_alloc_fail(&io->scsiio);
1190 ctl_nvme_set_space_alloc_fail(&io->nvmeio);
1200 switch (io->io_hdr.io_type) {
1202 ctl_set_success(&io->scsiio);
1206 ctl_nvme_set_success(&io->nvmeio);