xref: /freebsd/sys/cam/ctl/ctl_error.h (revision a90b9d0159070121c221b966469c3e36d912bf82)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2003 Silicon Graphics International Corp.
5  * Copyright (c) 2014-2015 Alexander Motin <mav@FreeBSD.org>
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions, and the following disclaimer,
13  *    without modification.
14  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
15  *    substantially similar to the "NO WARRANTY" disclaimer below
16  *    ("Disclaimer") and any redistribution must be conditioned upon
17  *    including a substantially similar Disclaimer requirement for further
18  *    binary redistribution.
19  *
20  * NO WARRANTY
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
30  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGES.
32  *
33  * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl_error.h#1 $
34  */
35 /*
36  * Function definitions for various error reporting routines used both
37  * within CTL and various CTL clients.
38  *
39  * Author: Ken Merry <ken@FreeBSD.org>
40  */
41 
42 #include <machine/stdarg.h>
43 
44 #ifndef	_CTL_ERROR_H_
45 #define	_CTL_ERROR_H_
46 
47 struct ctl_lun;
48 
49 void ctl_set_sense_data_va(struct scsi_sense_data *sense_data, u_int *sense_len,
50     void *lun, scsi_sense_data_type sense_format, int current_error,
51     int sense_key, int asc, int ascq, va_list ap);
52 void ctl_set_sense_data(struct scsi_sense_data *sense_data, u_int *sense_len,
53     void *lun, scsi_sense_data_type sense_format, int current_error,
54     int sense_key, int asc, int ascq, ...);
55 void ctl_set_sense(struct ctl_scsiio *ctsio, int current_error, int sense_key,
56 		   int asc, int ascq, ...);
57 void ctl_sense_to_desc(struct scsi_sense_data_fixed *sense_src,
58 		      struct scsi_sense_data_desc *sense_dest);
59 void ctl_sense_to_fixed(struct scsi_sense_data_desc *sense_src,
60 			struct scsi_sense_data_fixed *sense_dest);
61 void ctl_set_ua(struct ctl_scsiio *ctsio, int asc, int ascq);
62 ctl_ua_type ctl_build_qae(struct ctl_lun *lun, uint32_t initidx, uint8_t *resp);
63 ctl_ua_type ctl_build_ua(struct ctl_lun *lun, uint32_t initidx,
64     struct scsi_sense_data *sense, u_int *sense_len,
65     scsi_sense_data_type sense_format);
66 void ctl_set_overlapped_cmd(struct ctl_scsiio *ctsio);
67 void ctl_set_overlapped_tag(struct ctl_scsiio *ctsio, uint8_t tag);
68 void ctl_set_invalid_field(struct ctl_scsiio *ctsio, int sks_valid, int command,
69 			   int field, int bit_valid, int bit);
70 void ctl_set_invalid_field_ciu(struct ctl_scsiio *ctsio);
71 void ctl_set_invalid_opcode(struct ctl_scsiio *ctsio);
72 void ctl_set_param_len_error(struct ctl_scsiio *ctsio);
73 void ctl_set_already_locked(struct ctl_scsiio *ctsio);
74 void ctl_set_unsupported_lun(struct ctl_scsiio *ctsio);
75 void ctl_set_lun_transit(struct ctl_scsiio *ctsio);
76 void ctl_set_lun_standby(struct ctl_scsiio *ctsio);
77 void ctl_set_lun_unavail(struct ctl_scsiio *ctsio);
78 void ctl_set_internal_failure(struct ctl_scsiio *ctsio, int sks_valid,
79 			      uint16_t retry_count);
80 void ctl_set_medium_error(struct ctl_scsiio *ctsio, int read);
81 void ctl_set_aborted(struct ctl_scsiio *ctsio);
82 void ctl_set_lba_out_of_range(struct ctl_scsiio *ctsio, uint64_t lba);
83 void ctl_set_lun_stopped(struct ctl_scsiio *ctsio);
84 void ctl_set_lun_int_reqd(struct ctl_scsiio *ctsio);
85 void ctl_set_lun_ejected(struct ctl_scsiio *ctsio);
86 void ctl_set_lun_no_media(struct ctl_scsiio *ctsio);
87 void ctl_set_illegal_pr_release(struct ctl_scsiio *ctsio);
88 void ctl_set_medium_format_corrupted(struct ctl_scsiio *ctsio);
89 void ctl_set_medium_magazine_inaccessible(struct ctl_scsiio *ctsio);
90 void ctl_set_data_phase_error(struct ctl_scsiio *ctsio);
91 void ctl_set_reservation_conflict(struct ctl_scsiio *ctsio);
92 void ctl_set_queue_full(struct ctl_scsiio *ctsio);
93 void ctl_set_busy(struct ctl_scsiio *ctsio);
94 void ctl_set_task_aborted(struct ctl_scsiio *ctsio);
95 void ctl_set_hw_write_protected(struct ctl_scsiio *ctsio);
96 void ctl_set_space_alloc_fail(struct ctl_scsiio *ctsio);
97 void ctl_set_success(struct ctl_scsiio *ctsio);
98 
99 void ctl_nvme_set_error(struct ctl_nvmeio *ctnio, uint8_t sc_type,
100 			uint8_t sc_status);
101 void ctl_nvme_set_generic_error(struct ctl_nvmeio *ctnio, uint8_t sc_status);
102 void ctl_nvme_set_invalid_opcode(struct ctl_nvmeio *ctnio);
103 void ctl_nvme_set_invalid_field(struct ctl_nvmeio *ctnio);
104 void ctl_nvme_set_data_transfer_error(struct ctl_nvmeio *ctnio);
105 void ctl_nvme_set_internal_error(struct ctl_nvmeio *ctnio);
106 void ctl_nvme_set_invalid_namespace(struct ctl_nvmeio *ctnio);
107 void ctl_nvme_set_command_aborted(struct ctl_nvmeio *ctnio);
108 void ctl_nvme_set_failed_fused_command(struct ctl_nvmeio *ctnio);
109 void ctl_nvme_set_missing_fused_command(struct ctl_nvmeio *ctnio);
110 void ctl_nvme_set_namespace_is_write_protected(struct ctl_nvmeio *ctnio);
111 void ctl_nvme_set_lba_out_of_range(struct ctl_nvmeio *ctnio);
112 void ctl_nvme_set_namespace_not_ready(struct ctl_nvmeio *ctnio);
113 void ctl_nvme_set_write_fault(struct ctl_nvmeio *ctnio);
114 void ctl_nvme_set_unrecoverable_read_error(struct ctl_nvmeio *ctnio);
115 void ctl_nvme_set_compare_failure(struct ctl_nvmeio *ctnio);
116 void ctl_nvme_set_space_alloc_fail(struct ctl_nvmeio *ctnio);
117 void ctl_nvme_set_success(struct ctl_nvmeio *ctnio);
118 
119 void ctl_io_set_invalid_opcode(union ctl_io *io);
120 void ctl_io_set_hw_write_protected(union ctl_io *io);
121 void ctl_io_set_busy(union ctl_io *io);
122 void ctl_io_set_compare_failure(union ctl_io *io, uint64_t offset);
123 void ctl_io_set_space_alloc_fail(union ctl_io *io);
124 void ctl_io_set_success(union ctl_io *io);
125 
126 #endif	/* _CTL_ERROR_H_ */
127