xref: /freebsd/sys/cam/ctl/ctl_util.h (revision 95eb4b873b6a8b527c5bd78d7191975dfca38998)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2003 Silicon Graphics International Corp.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions, and the following disclaimer,
12  *    without modification.
13  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
14  *    substantially similar to the "NO WARRANTY" disclaimer below
15  *    ("Disclaimer") and any redistribution must be conditioned upon
16  *    including a substantially similar Disclaimer requirement for further
17  *    binary redistribution.
18  *
19  * NO WARRANTY
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGES.
31  *
32  * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl_util.h#2 $
33  */
34 /*
35  * CAM Target Layer SCSI library interface
36  *
37  * Author: Ken Merry <ken@FreeBSD.org>
38  */
39 
40 #ifndef	_CTL_UTIL_H
41 #define	_CTL_UTIL_H 1
42 
43 __BEGIN_DECLS
44 
45 void ctl_scsi_tur(union ctl_io *io, ctl_tag_type tag_type, uint8_t control);
46 void ctl_scsi_inquiry(union ctl_io *io, uint8_t *data_ptr, int32_t data_len,
47 		      uint8_t byte2, uint8_t page_code, ctl_tag_type tag_type,
48 		      uint8_t control);
49 void ctl_scsi_request_sense(union ctl_io *io, uint8_t *data_ptr,
50 			    int32_t data_len, uint8_t byte2,
51 			    ctl_tag_type tag_type, uint8_t control);
52 void ctl_scsi_report_luns(union ctl_io *io, uint8_t *data_ptr,
53 			  uint32_t data_len, uint8_t select_report,
54 			  ctl_tag_type tag_type, uint8_t control);
55 void ctl_scsi_read_write_buffer(union ctl_io *io, uint8_t *data_ptr,
56 				uint32_t data_len, int read_buffer,
57 				uint8_t mode, uint8_t buffer_id,
58 				uint32_t buffer_offset, ctl_tag_type tag_type,
59 				uint8_t control);
60 void ctl_scsi_read_write(union ctl_io *io, uint8_t *data_ptr,
61 			 uint32_t data_len, int read_op, uint8_t byte2,
62 			 int minimum_cdb_size, uint64_t lba,
63 			 uint32_t num_blocks, ctl_tag_type tag_type,
64 			 uint8_t control);
65 void ctl_scsi_write_same(union ctl_io *io, uint8_t *data_ptr,
66 			 uint32_t data_len, uint8_t byte2,
67 			 uint64_t lba, uint32_t num_blocks,
68 			 ctl_tag_type tag_type, uint8_t control);
69 void ctl_scsi_read_capacity(union ctl_io *io, uint8_t *data_ptr,
70 			    uint32_t data_len, uint32_t addr, int reladr,
71 			    int pmi, ctl_tag_type tag_type, uint8_t control);
72 void ctl_scsi_read_capacity_16(union ctl_io *io, uint8_t *data_ptr,
73 			       uint32_t data_len, uint64_t addr, int reladr,
74 			       int pmi, ctl_tag_type tag_type, uint8_t control);
75 void ctl_scsi_mode_sense(union ctl_io *io, uint8_t *data_ptr,
76 			 uint32_t data_len, int dbd, int llbaa,
77 			 uint8_t page_code, uint8_t pc, uint8_t subpage,
78 			 int minimum_cdb_size, ctl_tag_type tag_type,
79 			 uint8_t control);
80 void ctl_scsi_start_stop(union ctl_io *io, int start, int load_eject,
81 			 int immediate, int power_conditions,
82 			 ctl_tag_type tag_type, uint8_t control);
83 void ctl_scsi_sync_cache(union ctl_io *io, int immed, int reladr,
84 			 int minimum_cdb_size, uint64_t starting_lba,
85 			 uint32_t block_count, ctl_tag_type tag_type,
86 			 uint8_t control);
87 void ctl_scsi_persistent_res_in(union ctl_io *io, uint8_t *data_ptr,
88 				uint32_t data_len, int action,
89 				ctl_tag_type tag_type, uint8_t control);
90 void ctl_scsi_persistent_res_out(union ctl_io *io, uint8_t *data_ptr,
91 				 uint32_t data_len, int action, int type,
92 				 uint64_t key, uint64_t sa_key,
93 				 ctl_tag_type tag_type, uint8_t control);
94 void ctl_scsi_maintenance_in(union ctl_io *io, uint8_t *data_ptr,
95 			     uint32_t data_len, uint8_t action,
96 			     ctl_tag_type tag_type, uint8_t control);
97 #ifndef _KERNEL
98 union ctl_io *ctl_scsi_alloc_io(uint32_t initid);
99 void ctl_scsi_free_io(union ctl_io *io);
100 void ctl_scsi_zero_io(union ctl_io *io);
101 #else
102 #define	ctl_scsi_zero_io(io)	ctl_zero_io(io)
103 #endif /* !_KERNEL */
104 const char *ctl_scsi_task_string(struct ctl_taskio *taskio);
105 void ctl_io_sbuf(union ctl_io *io, struct sbuf *sb);
106 void ctl_io_error_sbuf(union ctl_io *io,
107 		       struct scsi_inquiry_data *inq_data, struct sbuf *sb);
108 char *ctl_io_string(union ctl_io *io, char *str, int str_len);
109 char *ctl_io_error_string(union ctl_io *io,
110 			  struct scsi_inquiry_data *inq_data, char *str,
111 			  int str_len);
112 #ifdef _KERNEL
113 void ctl_io_print(union ctl_io *io);
114 void ctl_io_error_print(union ctl_io *io, struct scsi_inquiry_data *inq_data);
115 void ctl_data_print(union ctl_io *io);
116 #else /* _KERNEL */
117 void ctl_io_error_print(union ctl_io *io, struct scsi_inquiry_data *inq_data,
118 		   FILE *ofile);
119 #endif /* _KERNEL */
120 
121 __END_DECLS
122 
123 #endif	/* _CTL_UTIL_H */
124 
125 /*
126  * vim: ts=8
127  */
128