xref: /freebsd/sys/cam/cam.h (revision 174b32ced4be75344530fcbd5d56bb49c5250401)
1898b0535SWarner Losh /*-
28b8a9b1dSJustin T. Gibbs  * Data structures and definitions for the CAM system.
38b8a9b1dSJustin T. Gibbs  *
48b8a9b1dSJustin T. Gibbs  * Copyright (c) 1997 Justin T. Gibbs.
58b8a9b1dSJustin T. Gibbs  * All rights reserved.
68b8a9b1dSJustin T. Gibbs  *
78b8a9b1dSJustin T. Gibbs  * Redistribution and use in source and binary forms, with or without
88b8a9b1dSJustin T. Gibbs  * modification, are permitted provided that the following conditions
98b8a9b1dSJustin T. Gibbs  * are met:
108b8a9b1dSJustin T. Gibbs  * 1. Redistributions of source code must retain the above copyright
118b8a9b1dSJustin T. Gibbs  *    notice, this list of conditions, and the following disclaimer,
128b8a9b1dSJustin T. Gibbs  *    without modification, immediately at the beginning of the file.
138b8a9b1dSJustin T. Gibbs  * 2. The name of the author may not be used to endorse or promote products
148b8a9b1dSJustin T. Gibbs  *    derived from this software without specific prior written permission.
158b8a9b1dSJustin T. Gibbs  *
168b8a9b1dSJustin T. Gibbs  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
178b8a9b1dSJustin T. Gibbs  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
188b8a9b1dSJustin T. Gibbs  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
198b8a9b1dSJustin T. Gibbs  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
208b8a9b1dSJustin T. Gibbs  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
218b8a9b1dSJustin T. Gibbs  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
228b8a9b1dSJustin T. Gibbs  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
238b8a9b1dSJustin T. Gibbs  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
248b8a9b1dSJustin T. Gibbs  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
258b8a9b1dSJustin T. Gibbs  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
268b8a9b1dSJustin T. Gibbs  * SUCH DAMAGE.
278b8a9b1dSJustin T. Gibbs  *
28c3aac50fSPeter Wemm  * $FreeBSD$
298b8a9b1dSJustin T. Gibbs  */
308b8a9b1dSJustin T. Gibbs 
318b8a9b1dSJustin T. Gibbs #ifndef _CAM_CAM_H
328b8a9b1dSJustin T. Gibbs #define _CAM_CAM_H 1
338b8a9b1dSJustin T. Gibbs 
34c4473420SPeter Wemm #ifdef _KERNEL
358b8a9b1dSJustin T. Gibbs #include <opt_cam.h>
36c4473420SPeter Wemm #endif
378b8a9b1dSJustin T. Gibbs 
388b8a9b1dSJustin T. Gibbs #include <sys/cdefs.h>
398b8a9b1dSJustin T. Gibbs 
408b8a9b1dSJustin T. Gibbs typedef u_int path_id_t;
418b8a9b1dSJustin T. Gibbs typedef u_int target_id_t;
4292be6c51SNathan Whitehorn typedef u_int64_t lun_id_t;
438b8a9b1dSJustin T. Gibbs 
448b8a9b1dSJustin T. Gibbs #define	CAM_XPT_PATH_ID	((path_id_t)~0)
458b8a9b1dSJustin T. Gibbs #define	CAM_BUS_WILDCARD ((path_id_t)~0)
468b8a9b1dSJustin T. Gibbs #define	CAM_TARGET_WILDCARD ((target_id_t)~0)
4792be6c51SNathan Whitehorn #define	CAM_LUN_WILDCARD (~(u_int)0)
488b8a9b1dSJustin T. Gibbs 
49ef5758faSNathan Whitehorn #define CAM_EXTLUN_BYTE_SWIZZLE(lun) (	\
50ef5758faSNathan Whitehorn 	((((u_int64_t)lun) & 0xffff000000000000L) >> 48) | \
51ef5758faSNathan Whitehorn 	((((u_int64_t)lun) & 0x0000ffff00000000L) >> 16) | \
52ef5758faSNathan Whitehorn 	((((u_int64_t)lun) & 0x00000000ffff0000L) << 16) | \
53ef5758faSNathan Whitehorn 	((((u_int64_t)lun) & 0x000000000000ffffL) << 48))
54ef5758faSNathan Whitehorn 
558b8a9b1dSJustin T. Gibbs /*
568b8a9b1dSJustin T. Gibbs  * Maximum length for a CAM CDB.
578b8a9b1dSJustin T. Gibbs  */
588b8a9b1dSJustin T. Gibbs #define CAM_MAX_CDBLEN 16
598b8a9b1dSJustin T. Gibbs 
608b8a9b1dSJustin T. Gibbs /*
618b8a9b1dSJustin T. Gibbs  * Definition of a CAM peripheral driver entry.  Peripheral drivers instantiate
628b8a9b1dSJustin T. Gibbs  * one of these for each device they wish to communicate with and pass it into
638b8a9b1dSJustin T. Gibbs  * the xpt layer when they wish to schedule work on that device via the
640cdabce0SNick Hibma  * xpt_schedule API.
658b8a9b1dSJustin T. Gibbs  */
668b8a9b1dSJustin T. Gibbs struct cam_periph;
678b8a9b1dSJustin T. Gibbs 
688b8a9b1dSJustin T. Gibbs /*
6983c5d981SAlexander Motin  * Priority information for a CAM structure.
7083c5d981SAlexander Motin  */
7183c5d981SAlexander Motin typedef enum {
7283c5d981SAlexander Motin     CAM_RL_HOST,
7383c5d981SAlexander Motin     CAM_RL_BUS,
7483c5d981SAlexander Motin     CAM_RL_XPT,
7583c5d981SAlexander Motin     CAM_RL_DEV,
7683c5d981SAlexander Motin     CAM_RL_NORMAL,
7783c5d981SAlexander Motin     CAM_RL_VALUES
7883c5d981SAlexander Motin } cam_rl;
7983c5d981SAlexander Motin /*
8083c5d981SAlexander Motin  * The generation number is incremented everytime a new entry is entered into
8183c5d981SAlexander Motin  * the queue giving round robin per priority level scheduling.
828b8a9b1dSJustin T. Gibbs  */
838b8a9b1dSJustin T. Gibbs typedef struct {
848b8a9b1dSJustin T. Gibbs 	u_int32_t priority;
8583c5d981SAlexander Motin #define CAM_PRIORITY_HOST	((CAM_RL_HOST << 8) + 0x80)
8683c5d981SAlexander Motin #define CAM_PRIORITY_BUS	((CAM_RL_BUS << 8) + 0x80)
8783c5d981SAlexander Motin #define CAM_PRIORITY_XPT	((CAM_RL_XPT << 8) + 0x80)
8883c5d981SAlexander Motin #define CAM_PRIORITY_DEV	((CAM_RL_DEV << 8) + 0x80)
89cccf4220SAlexander Motin #define CAM_PRIORITY_OOB	(CAM_RL_DEV << 8)
9083c5d981SAlexander Motin #define CAM_PRIORITY_NORMAL	((CAM_RL_NORMAL << 8) + 0x80)
918b8a9b1dSJustin T. Gibbs #define CAM_PRIORITY_NONE	(u_int32_t)-1
928b8a9b1dSJustin T. Gibbs 	u_int32_t generation;
938b8a9b1dSJustin T. Gibbs 	int       index;
948b8a9b1dSJustin T. Gibbs #define CAM_UNQUEUED_INDEX	-1
958b8a9b1dSJustin T. Gibbs #define CAM_ACTIVE_INDEX	-2
968b8a9b1dSJustin T. Gibbs #define CAM_DONEQ_INDEX		-3
97ea541bfdSAlexander Motin #define CAM_EXTRAQ_INDEX	INT_MAX
988b8a9b1dSJustin T. Gibbs } cam_pinfo;
998b8a9b1dSJustin T. Gibbs 
1008bad620dSJustin T. Gibbs /*
1018bad620dSJustin T. Gibbs  * Macro to compare two generation numbers.  It is used like this:
1028bad620dSJustin T. Gibbs  *
1038bad620dSJustin T. Gibbs  *	if (GENERATIONCMP(a, >=, b))
1048bad620dSJustin T. Gibbs  *		...;
1058bad620dSJustin T. Gibbs  *
1068bad620dSJustin T. Gibbs  * GERERATIONCMP uses modular arithmetic to guard against wraps
1078bad620dSJustin T. Gibbs  * wraps in the generation number.
1088bad620dSJustin T. Gibbs  */
1098bad620dSJustin T. Gibbs #define GENERATIONCMP(x, op, y) ((int32_t)((x) - (y)) op 0)
1108bad620dSJustin T. Gibbs 
1113393f8daSKenneth D. Merry /* CAM flags XXX Move to cam_periph.h ??? */
1128b8a9b1dSJustin T. Gibbs typedef enum {
1138b8a9b1dSJustin T. Gibbs 	CAM_FLAG_NONE		= 0x00,
1143393f8daSKenneth D. Merry 	CAM_EXPECT_INQ_CHANGE	= 0x01,
1153393f8daSKenneth D. Merry 	CAM_RETRY_SELTO		= 0x02 /* Retry Selection Timeouts */
1168b8a9b1dSJustin T. Gibbs } cam_flags;
1178b8a9b1dSJustin T. Gibbs 
1180191d9b3SAlexander Motin enum {
1190191d9b3SAlexander Motin 	SF_RETRY_UA		= 0x01,	/* Retry UNIT ATTENTION conditions. */
1200191d9b3SAlexander Motin 	SF_NO_PRINT		= 0x02,	/* Never print error status. */
1210191d9b3SAlexander Motin 	SF_QUIET_IR		= 0x04,	/* Be quiet about Illegal Request reponses */
1220191d9b3SAlexander Motin 	SF_PRINT_ALWAYS		= 0x08,	/* Always print error status. */
1230191d9b3SAlexander Motin 	SF_NO_RECOVERY		= 0x10,	/* Don't do active error recovery. */
124*174b32ceSAlexander Motin 	SF_NO_RETRY		= 0x20,	/* Don't do any retries. */
125*174b32ceSAlexander Motin 	SF_RETRY_BUSY		= 0x40	/* Retry BUSY status. */
1260191d9b3SAlexander Motin };
1270191d9b3SAlexander Motin 
1288b8a9b1dSJustin T. Gibbs /* CAM  Status field values */
1298b8a9b1dSJustin T. Gibbs typedef enum {
130f564de00SScott Long 	/* CCB request is in progress */
131f564de00SScott Long 	CAM_REQ_INPROG		= 0x00,
132f564de00SScott Long 
133f564de00SScott Long 	/* CCB request completed without error */
134f564de00SScott Long 	CAM_REQ_CMP		= 0x01,
135f564de00SScott Long 
136f564de00SScott Long 	/* CCB request aborted by the host */
137f564de00SScott Long 	CAM_REQ_ABORTED		= 0x02,
138f564de00SScott Long 
139f564de00SScott Long 	/* Unable to abort CCB request */
140f564de00SScott Long 	CAM_UA_ABORT		= 0x03,
141f564de00SScott Long 
142f564de00SScott Long 	/* CCB request completed with an error */
143f564de00SScott Long 	CAM_REQ_CMP_ERR		= 0x04,
144f564de00SScott Long 
145f564de00SScott Long 	/* CAM subsystem is busy */
146f564de00SScott Long 	CAM_BUSY		= 0x05,
147f564de00SScott Long 
148f564de00SScott Long 	/* CCB request was invalid */
149f564de00SScott Long 	CAM_REQ_INVALID		= 0x06,
150f564de00SScott Long 
151f564de00SScott Long 	/* Supplied Path ID is invalid */
152f564de00SScott Long 	CAM_PATH_INVALID	= 0x07,
153f564de00SScott Long 
154f564de00SScott Long 	/* SCSI Device Not Installed/there */
155f564de00SScott Long 	CAM_DEV_NOT_THERE	= 0x08,
156f564de00SScott Long 
157f564de00SScott Long 	/* Unable to terminate I/O CCB request */
158f564de00SScott Long 	CAM_UA_TERMIO		= 0x09,
159f564de00SScott Long 
160f564de00SScott Long 	/* Target Selection Timeout */
161f564de00SScott Long 	CAM_SEL_TIMEOUT		= 0x0a,
162f564de00SScott Long 
163f564de00SScott Long 	/* Command timeout */
164f564de00SScott Long 	CAM_CMD_TIMEOUT		= 0x0b,
165f564de00SScott Long 
166f564de00SScott Long 	/* SCSI error, look at error code in CCB */
167f564de00SScott Long 	CAM_SCSI_STATUS_ERROR	= 0x0c,
168f564de00SScott Long 
169f564de00SScott Long 	/* Message Reject Received */
170f564de00SScott Long 	CAM_MSG_REJECT_REC	= 0x0d,
171f564de00SScott Long 
172f564de00SScott Long 	/* SCSI Bus Reset Sent/Received */
173f564de00SScott Long 	CAM_SCSI_BUS_RESET	= 0x0e,
174f564de00SScott Long 
175f564de00SScott Long 	/* Uncorrectable parity error occurred */
176f564de00SScott Long 	CAM_UNCOR_PARITY	= 0x0f,
177f564de00SScott Long 
178f564de00SScott Long 	/* Autosense: request sense cmd fail */
179f564de00SScott Long 	CAM_AUTOSENSE_FAIL	= 0x10,
180f564de00SScott Long 
181f564de00SScott Long 	/* No HBA Detected error */
182f564de00SScott Long 	CAM_NO_HBA		= 0x11,
183f564de00SScott Long 
184f564de00SScott Long 	/* Data Overrun error */
185f564de00SScott Long 	CAM_DATA_RUN_ERR	= 0x12,
186f564de00SScott Long 
187f564de00SScott Long 	/* Unexpected Bus Free */
188f564de00SScott Long 	CAM_UNEXP_BUSFREE	= 0x13,
189f564de00SScott Long 
190f564de00SScott Long 	/* Target Bus Phase Sequence Failure */
191f564de00SScott Long 	CAM_SEQUENCE_FAIL	= 0x14,
192f564de00SScott Long 
193f564de00SScott Long 	/* CCB length supplied is inadequate */
194f564de00SScott Long 	CAM_CCB_LEN_ERR		= 0x15,
195f564de00SScott Long 
196f564de00SScott Long 	/* Unable to provide requested capability*/
197f564de00SScott Long 	CAM_PROVIDE_FAIL	= 0x16,
198f564de00SScott Long 
199f564de00SScott Long 	/* A SCSI BDR msg was sent to target */
200f564de00SScott Long 	CAM_BDR_SENT		= 0x17,
201f564de00SScott Long 
202f564de00SScott Long 	/* CCB request terminated by the host */
203f564de00SScott Long 	CAM_REQ_TERMIO		= 0x18,
204f564de00SScott Long 
205f564de00SScott Long 	/* Unrecoverable Host Bus Adapter Error */
206f564de00SScott Long 	CAM_UNREC_HBA_ERROR	= 0x19,
207f564de00SScott Long 
208f564de00SScott Long 	/* Request was too large for this host */
209f564de00SScott Long 	CAM_REQ_TOO_BIG		= 0x1a,
210f564de00SScott Long 
211f564de00SScott Long 	/*
2128b8a9b1dSJustin T. Gibbs 	 * This request should be requeued to preserve
2138b8a9b1dSJustin T. Gibbs 	 * transaction ordering.  This typically occurs
2148b8a9b1dSJustin T. Gibbs 	 * when the SIM recognizes an error that should
2158b8a9b1dSJustin T. Gibbs 	 * freeze the queue and must place additional
2168b8a9b1dSJustin T. Gibbs 	 * requests for the target at the sim level
2178b8a9b1dSJustin T. Gibbs 	 * back into the XPT queue.
2188b8a9b1dSJustin T. Gibbs 	 */
219f564de00SScott Long 	CAM_REQUEUE_REQ		= 0x1b,
2208b8a9b1dSJustin T. Gibbs 
221f564de00SScott Long 	/* ATA error, look at error code in CCB */
222f564de00SScott Long 	CAM_ATA_STATUS_ERROR	= 0x1c,
223f564de00SScott Long 
224f564de00SScott Long 	/* Initiator/Target Nexus lost. */
225f564de00SScott Long 	CAM_SCSI_IT_NEXUS_LOST	= 0x1d,
226f564de00SScott Long 
227f564de00SScott Long 	/* SMP error, look at error code in CCB */
228f564de00SScott Long 	CAM_SMP_STATUS_ERROR	= 0x1e,
229f564de00SScott Long 
230f564de00SScott Long 	/*
231f564de00SScott Long 	 * Command completed without error but  exceeded the soft
232f564de00SScott Long 	 * timeout threshold.
233f564de00SScott Long 	 */
234f564de00SScott Long 	CAM_REQ_SOFTTIMEOUT	= 0x1f,
235f564de00SScott Long 
236f564de00SScott Long 	/*
237f564de00SScott Long 	 * 0x20 - 0x32 are unassigned
238f564de00SScott Long 	 */
239f564de00SScott Long 
240f564de00SScott Long 	/* Initiator Detected Error */
241f564de00SScott Long 	CAM_IDE			= 0x33,
242f564de00SScott Long 
243f564de00SScott Long 	/* Resource Unavailable */
244f564de00SScott Long 	CAM_RESRC_UNAVAIL	= 0x34,
245f564de00SScott Long 
246f564de00SScott Long 	/* Unacknowledged Event by Host */
247f564de00SScott Long 	CAM_UNACKED_EVENT	= 0x35,
248f564de00SScott Long 
249f564de00SScott Long 	/* Message Received in Host Target Mode */
250f564de00SScott Long 	CAM_MESSAGE_RECV	= 0x36,
251f564de00SScott Long 
252f564de00SScott Long 	/* Invalid CDB received in Host Target Mode */
253f564de00SScott Long 	CAM_INVALID_CDB		= 0x37,
254f564de00SScott Long 
255f564de00SScott Long 	/* Lun supplied is invalid */
256f564de00SScott Long 	CAM_LUN_INVALID		= 0x38,
257f564de00SScott Long 
258f564de00SScott Long 	/* Target ID supplied is invalid */
259f564de00SScott Long 	CAM_TID_INVALID		= 0x39,
260f564de00SScott Long 
261f564de00SScott Long 	/* The requested function is not available */
262f564de00SScott Long 	CAM_FUNC_NOTAVAIL	= 0x3a,
263f564de00SScott Long 
264f564de00SScott Long 	/* Nexus is not established */
265f564de00SScott Long 	CAM_NO_NEXUS		= 0x3b,
266f564de00SScott Long 
267f564de00SScott Long 	/* The initiator ID is invalid */
268f564de00SScott Long 	CAM_IID_INVALID		= 0x3c,
269f564de00SScott Long 
270f564de00SScott Long 	/* The SCSI CDB has been received */
271f564de00SScott Long 	CAM_CDB_RECVD		= 0x3d,
272f564de00SScott Long 
273f564de00SScott Long 	/* The LUN is already enabled for target mode */
274f564de00SScott Long 	CAM_LUN_ALRDY_ENA	= 0x3e,
275f564de00SScott Long 
276f564de00SScott Long 	/* SCSI Bus Busy */
277f564de00SScott Long 	CAM_SCSI_BUSY		= 0x3f,
278f564de00SScott Long 
279f564de00SScott Long 
280f564de00SScott Long 	/*
281f564de00SScott Long 	 * Flags
282f564de00SScott Long 	 */
283f564de00SScott Long 
284f564de00SScott Long 	/* The DEV queue is frozen w/this err */
285f564de00SScott Long 	CAM_DEV_QFRZN		= 0x40,
2868b8a9b1dSJustin T. Gibbs 
2878b8a9b1dSJustin T. Gibbs 	/* Autosense data valid for target */
2888b8a9b1dSJustin T. Gibbs 	CAM_AUTOSNS_VALID	= 0x80,
2898b8a9b1dSJustin T. Gibbs 
290f564de00SScott Long 	/* SIM ready to take more commands */
291f564de00SScott Long 	CAM_RELEASE_SIMQ	= 0x100,
2925fd6140dSMatt Jacob 
293f564de00SScott Long 	/* SIM has this command in it's queue */
294f564de00SScott Long 	CAM_SIM_QUEUED		= 0x200,
295f564de00SScott Long 
296f564de00SScott Long 	/* Quality of service data is valid */
297f564de00SScott Long 	CAM_QOS_VALID		= 0x400,
298f564de00SScott Long 
299f564de00SScott Long 	/* Mask bits for just the status # */
300f564de00SScott Long 	CAM_STATUS_MASK = 0x3F,
301f564de00SScott Long 
302f564de00SScott Long 	/*
303f564de00SScott Long 	 * Target Specific Adjunct Status
304f564de00SScott Long 	 */
305f564de00SScott Long 
306f564de00SScott Long 	/* sent sense with status */
307f564de00SScott Long 	CAM_SENT_SENSE		= 0x40000000
3088b8a9b1dSJustin T. Gibbs } cam_status;
3098b8a9b1dSJustin T. Gibbs 
3103393f8daSKenneth D. Merry typedef enum {
3113393f8daSKenneth D. Merry 	CAM_ESF_NONE		= 0x00,
3123393f8daSKenneth D. Merry 	CAM_ESF_COMMAND		= 0x01,
3133393f8daSKenneth D. Merry 	CAM_ESF_CAM_STATUS	= 0x02,
3143393f8daSKenneth D. Merry 	CAM_ESF_PROTO_STATUS	= 0x04,
3153393f8daSKenneth D. Merry 	CAM_ESF_ALL		= 0xff
3163393f8daSKenneth D. Merry } cam_error_string_flags;
3173393f8daSKenneth D. Merry 
3183393f8daSKenneth D. Merry typedef enum {
3193393f8daSKenneth D. Merry 	CAM_EPF_NONE		= 0x00,
3203393f8daSKenneth D. Merry 	CAM_EPF_MINIMAL		= 0x01,
3213393f8daSKenneth D. Merry 	CAM_EPF_NORMAL		= 0x02,
3223393f8daSKenneth D. Merry 	CAM_EPF_ALL		= 0x03,
3233393f8daSKenneth D. Merry 	CAM_EPF_LEVEL_MASK	= 0x0f
3243393f8daSKenneth D. Merry 	/* All bits above bit 3 are protocol-specific */
3253393f8daSKenneth D. Merry } cam_error_proto_flags;
3263393f8daSKenneth D. Merry 
3273393f8daSKenneth D. Merry typedef enum {
3283393f8daSKenneth D. Merry 	CAM_ESF_PRINT_NONE	= 0x00,
3293393f8daSKenneth D. Merry 	CAM_ESF_PRINT_STATUS	= 0x10,
3303393f8daSKenneth D. Merry 	CAM_ESF_PRINT_SENSE	= 0x20
3313393f8daSKenneth D. Merry } cam_error_scsi_flags;
3323393f8daSKenneth D. Merry 
3338691755dSAlexander Motin typedef enum {
33406e79492SKenneth D. Merry 	CAM_ESMF_PRINT_NONE	= 0x00,
33506e79492SKenneth D. Merry 	CAM_ESMF_PRINT_STATUS	= 0x10,
33606e79492SKenneth D. Merry 	CAM_ESMF_PRINT_FULL_CMD	= 0x20,
33706e79492SKenneth D. Merry } cam_error_smp_flags;
33806e79492SKenneth D. Merry 
33906e79492SKenneth D. Merry typedef enum {
3408691755dSAlexander Motin 	CAM_EAF_PRINT_NONE	= 0x00,
3418691755dSAlexander Motin 	CAM_EAF_PRINT_STATUS	= 0x10,
3428691755dSAlexander Motin 	CAM_EAF_PRINT_RESULT	= 0x20
3438691755dSAlexander Motin } cam_error_ata_flags;
3448691755dSAlexander Motin 
3453393f8daSKenneth D. Merry struct cam_status_entry
3463393f8daSKenneth D. Merry {
3473393f8daSKenneth D. Merry 	cam_status  status_code;
3483393f8daSKenneth D. Merry 	const char *status_text;
3493393f8daSKenneth D. Merry };
3503393f8daSKenneth D. Merry 
3513393f8daSKenneth D. Merry extern const struct cam_status_entry cam_status_table[];
3523393f8daSKenneth D. Merry extern const int num_cam_status_entries;
3535f83aee5SSteven Hartland #ifdef _KERNEL
3545f83aee5SSteven Hartland extern int cam_sort_io_queues;
3555f83aee5SSteven Hartland #endif
3563393f8daSKenneth D. Merry union ccb;
3573393f8daSKenneth D. Merry 
35865c38256SMike Smith #ifdef SYSCTL_DECL	/* from sysctl.h */
35965c38256SMike Smith SYSCTL_DECL(_kern_cam);
36065c38256SMike Smith #endif
36165c38256SMike Smith 
3628b8a9b1dSJustin T. Gibbs __BEGIN_DECLS
3638b8a9b1dSJustin T. Gibbs typedef int (cam_quirkmatch_t)(caddr_t, caddr_t);
3648b8a9b1dSJustin T. Gibbs 
3658b8a9b1dSJustin T. Gibbs caddr_t	cam_quirkmatch(caddr_t target, caddr_t quirk_table, int num_entries,
3668b8a9b1dSJustin T. Gibbs 		       int entry_size, cam_quirkmatch_t *comp_func);
3678b8a9b1dSJustin T. Gibbs 
3688b8a9b1dSJustin T. Gibbs void	cam_strvis(u_int8_t *dst, const u_int8_t *src, int srclen, int dstlen);
3698b8a9b1dSJustin T. Gibbs 
3708b8a9b1dSJustin T. Gibbs int	cam_strmatch(const u_int8_t *str, const u_int8_t *pattern, int str_len);
3713393f8daSKenneth D. Merry const struct cam_status_entry*
3723393f8daSKenneth D. Merry 	cam_fetch_status_entry(cam_status status);
3733393f8daSKenneth D. Merry #ifdef _KERNEL
3743393f8daSKenneth D. Merry char *	cam_error_string(union ccb *ccb, char *str, int str_len,
3753393f8daSKenneth D. Merry 			 cam_error_string_flags flags,
3763393f8daSKenneth D. Merry 			 cam_error_proto_flags proto_flags);
3773393f8daSKenneth D. Merry void	cam_error_print(union ccb *ccb, cam_error_string_flags flags,
3783393f8daSKenneth D. Merry 			cam_error_proto_flags proto_flags);
3793393f8daSKenneth D. Merry #else /* _KERNEL */
3803393f8daSKenneth D. Merry struct cam_device;
3813393f8daSKenneth D. Merry 
3823393f8daSKenneth D. Merry char *	cam_error_string(struct cam_device *device, union ccb *ccb, char *str,
3833393f8daSKenneth D. Merry 			 int str_len, cam_error_string_flags flags,
3843393f8daSKenneth D. Merry 			 cam_error_proto_flags proto_flags);
3853393f8daSKenneth D. Merry void	cam_error_print(struct cam_device *device, union ccb *ccb,
3863393f8daSKenneth D. Merry 			cam_error_string_flags flags,
3873393f8daSKenneth D. Merry 			cam_error_proto_flags proto_flags, FILE *ofile);
3883393f8daSKenneth D. Merry #endif /* _KERNEL */
3898b8a9b1dSJustin T. Gibbs __END_DECLS
3908b8a9b1dSJustin T. Gibbs 
391c4473420SPeter Wemm #ifdef _KERNEL
3928b8a9b1dSJustin T. Gibbs static __inline void cam_init_pinfo(cam_pinfo *pinfo);
3938b8a9b1dSJustin T. Gibbs 
3948b8a9b1dSJustin T. Gibbs static __inline void cam_init_pinfo(cam_pinfo *pinfo)
3958b8a9b1dSJustin T. Gibbs {
3968b8a9b1dSJustin T. Gibbs 	pinfo->priority = CAM_PRIORITY_NONE;
3978b8a9b1dSJustin T. Gibbs 	pinfo->index = CAM_UNQUEUED_INDEX;
3988b8a9b1dSJustin T. Gibbs }
399c4473420SPeter Wemm #endif
4008b8a9b1dSJustin T. Gibbs 
4018b8a9b1dSJustin T. Gibbs #endif /* _CAM_CAM_H */
402