xref: /freebsd/sys/cam/ctl/ctl_util.h (revision c6063d0da8e1f8d8452b0c2ee1c7ad718c1a7052)
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_read_capacity(union ctl_io *io, uint8_t *data_ptr,
65 			    uint32_t data_len, uint32_t addr, int reladr,
66 			    int pmi, ctl_tag_type tag_type, uint8_t control);
67 void ctl_scsi_read_capacity_16(union ctl_io *io, uint8_t *data_ptr,
68 			       uint32_t data_len, uint64_t addr, int reladr,
69 			       int pmi, ctl_tag_type tag_type, uint8_t control);
70 void ctl_scsi_mode_sense(union ctl_io *io, uint8_t *data_ptr,
71 			 uint32_t data_len, int dbd, int llbaa,
72 			 uint8_t page_code, uint8_t pc, uint8_t subpage,
73 			 int minimum_cdb_size, ctl_tag_type tag_type,
74 			 uint8_t control);
75 void ctl_scsi_start_stop(union ctl_io *io, int start, int load_eject,
76 			 int immediate, int power_conditions, int onoffline,
77 			 ctl_tag_type tag_type, uint8_t control);
78 void ctl_scsi_sync_cache(union ctl_io *io, int immed, int reladr,
79 			 int minimum_cdb_size, uint64_t starting_lba,
80 			 uint32_t block_count, ctl_tag_type tag_type,
81 			 uint8_t control);
82 void ctl_scsi_persistent_res_in(union ctl_io *io, uint8_t *data_ptr,
83 				uint32_t data_len, int action,
84 				ctl_tag_type tag_type, uint8_t control);
85 void ctl_scsi_persistent_res_out(union ctl_io *io, uint8_t *data_ptr,
86 				 uint32_t data_len, int action, int type,
87 				 uint64_t key, uint64_t sa_key,
88 				 ctl_tag_type tag_type, uint8_t control);
89 void ctl_scsi_maintenance_in(union ctl_io *io, uint8_t *data_ptr,
90 			     uint32_t data_len, uint8_t action,
91 			     ctl_tag_type tag_type, uint8_t control);
92 #ifndef _KERNEL
93 union ctl_io *ctl_scsi_alloc_io(struct ctl_id initid);
94 void ctl_scsi_free_io(union ctl_io *io);
95 #endif /* !_KERNEL */
96 void ctl_scsi_zero_io(union ctl_io *io);
97 const char *ctl_scsi_task_string(struct ctl_taskio *taskio);
98 void ctl_io_error_sbuf(union ctl_io *io,
99 		       struct scsi_inquiry_data *inq_data, struct sbuf *sb);
100 char *ctl_io_error_string(union ctl_io *io,
101 			  struct scsi_inquiry_data *inq_data, char *str,
102 			  int str_len);
103 #ifdef _KERNEL
104 
105 void ctl_io_error_print(union ctl_io *io, struct scsi_inquiry_data *inq_data);
106 #else /* _KERNEL */
107 void
108 ctl_io_error_print(union ctl_io *io, struct scsi_inquiry_data *inq_data,
109 		   FILE *ofile);
110 
111 #endif /* _KERNEL */
112 
113 __END_DECLS
114 
115 #endif	/* _CTL_UTIL_H */
116 
117 /*
118  * vim: ts=8
119  */
120