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