xref: /freebsd/sys/cam/ctl/ctl_util.h (revision d4eeb02986980bf33dd56c41ceb9fc5f180c0d47)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
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  * $FreeBSD$
34  */
35 /*
36  * CAM Target Layer SCSI library interface
37  *
38  * Author: Ken Merry <ken@FreeBSD.org>
39  */
40 
41 #ifndef	_CTL_UTIL_H
42 #define	_CTL_UTIL_H 1
43 
44 __BEGIN_DECLS
45 
46 void ctl_scsi_tur(union ctl_io *io, ctl_tag_type tag_type, uint8_t control);
47 void ctl_scsi_inquiry(union ctl_io *io, uint8_t *data_ptr, int32_t data_len,
48 		      uint8_t byte2, uint8_t page_code, ctl_tag_type tag_type,
49 		      uint8_t control);
50 void ctl_scsi_request_sense(union ctl_io *io, uint8_t *data_ptr,
51 			    int32_t data_len, uint8_t byte2,
52 			    ctl_tag_type tag_type, uint8_t control);
53 void ctl_scsi_report_luns(union ctl_io *io, uint8_t *data_ptr,
54 			  uint32_t data_len, uint8_t select_report,
55 			  ctl_tag_type tag_type, uint8_t control);
56 void ctl_scsi_read_write_buffer(union ctl_io *io, uint8_t *data_ptr,
57 				uint32_t data_len, int read_buffer,
58 				uint8_t mode, uint8_t buffer_id,
59 				uint32_t buffer_offset, ctl_tag_type tag_type,
60 				uint8_t control);
61 void ctl_scsi_read_write(union ctl_io *io, uint8_t *data_ptr,
62 			 uint32_t data_len, int read_op, uint8_t byte2,
63 			 int minimum_cdb_size, uint64_t lba,
64 			 uint32_t num_blocks, ctl_tag_type tag_type,
65 			 uint8_t control);
66 void ctl_scsi_write_same(union ctl_io *io, uint8_t *data_ptr,
67 			 uint32_t data_len, uint8_t byte2,
68 			 uint64_t lba, uint32_t num_blocks,
69 			 ctl_tag_type tag_type, uint8_t control);
70 void ctl_scsi_read_capacity(union ctl_io *io, uint8_t *data_ptr,
71 			    uint32_t data_len, uint32_t addr, int reladr,
72 			    int pmi, ctl_tag_type tag_type, uint8_t control);
73 void ctl_scsi_read_capacity_16(union ctl_io *io, uint8_t *data_ptr,
74 			       uint32_t data_len, uint64_t addr, int reladr,
75 			       int pmi, ctl_tag_type tag_type, uint8_t control);
76 void ctl_scsi_mode_sense(union ctl_io *io, uint8_t *data_ptr,
77 			 uint32_t data_len, int dbd, int llbaa,
78 			 uint8_t page_code, uint8_t pc, uint8_t subpage,
79 			 int minimum_cdb_size, ctl_tag_type tag_type,
80 			 uint8_t control);
81 void ctl_scsi_start_stop(union ctl_io *io, int start, int load_eject,
82 			 int immediate, int power_conditions,
83 			 ctl_tag_type tag_type, uint8_t control);
84 void ctl_scsi_sync_cache(union ctl_io *io, int immed, int reladr,
85 			 int minimum_cdb_size, uint64_t starting_lba,
86 			 uint32_t block_count, ctl_tag_type tag_type,
87 			 uint8_t control);
88 void ctl_scsi_persistent_res_in(union ctl_io *io, uint8_t *data_ptr,
89 				uint32_t data_len, int action,
90 				ctl_tag_type tag_type, uint8_t control);
91 void ctl_scsi_persistent_res_out(union ctl_io *io, uint8_t *data_ptr,
92 				 uint32_t data_len, int action, int type,
93 				 uint64_t key, uint64_t sa_key,
94 				 ctl_tag_type tag_type, uint8_t control);
95 void ctl_scsi_maintenance_in(union ctl_io *io, uint8_t *data_ptr,
96 			     uint32_t data_len, uint8_t action,
97 			     ctl_tag_type tag_type, uint8_t control);
98 #ifndef _KERNEL
99 union ctl_io *ctl_scsi_alloc_io(uint32_t initid);
100 void ctl_scsi_free_io(union ctl_io *io);
101 void ctl_scsi_zero_io(union ctl_io *io);
102 #else
103 #define	ctl_scsi_zero_io(io)	ctl_zero_io(io)
104 #endif /* !_KERNEL */
105 const char *ctl_scsi_task_string(struct ctl_taskio *taskio);
106 void ctl_io_sbuf(union ctl_io *io, struct sbuf *sb);
107 void ctl_io_error_sbuf(union ctl_io *io,
108 		       struct scsi_inquiry_data *inq_data, struct sbuf *sb);
109 char *ctl_io_string(union ctl_io *io, char *str, int str_len);
110 char *ctl_io_error_string(union ctl_io *io,
111 			  struct scsi_inquiry_data *inq_data, char *str,
112 			  int str_len);
113 #ifdef _KERNEL
114 void ctl_io_print(union ctl_io *io);
115 void ctl_io_error_print(union ctl_io *io, struct scsi_inquiry_data *inq_data);
116 void ctl_data_print(union ctl_io *io);
117 #else /* _KERNEL */
118 void ctl_io_error_print(union ctl_io *io, struct scsi_inquiry_data *inq_data,
119 		   FILE *ofile);
120 #endif /* _KERNEL */
121 
122 __END_DECLS
123 
124 #endif	/* _CTL_UTIL_H */
125 
126 /*
127  * vim: ts=8
128  */
129