xref: /freebsd/sys/cam/cam.h (revision 7381bbee29df959e88ec59866cf2878263e7f3b2)
1898b0535SWarner Losh /*-
28b8a9b1dSJustin T. Gibbs  * Data structures and definitions for the CAM system.
38b8a9b1dSJustin T. Gibbs  *
4bec9534dSPedro F. Giffuni  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
5bec9534dSPedro F. Giffuni  *
68b8a9b1dSJustin T. Gibbs  * Copyright (c) 1997 Justin T. Gibbs.
78b8a9b1dSJustin T. Gibbs  * All rights reserved.
88b8a9b1dSJustin T. Gibbs  *
98b8a9b1dSJustin T. Gibbs  * Redistribution and use in source and binary forms, with or without
108b8a9b1dSJustin T. Gibbs  * modification, are permitted provided that the following conditions
118b8a9b1dSJustin T. Gibbs  * are met:
128b8a9b1dSJustin T. Gibbs  * 1. Redistributions of source code must retain the above copyright
138b8a9b1dSJustin T. Gibbs  *    notice, this list of conditions, and the following disclaimer,
148b8a9b1dSJustin T. Gibbs  *    without modification, immediately at the beginning of the file.
158b8a9b1dSJustin T. Gibbs  * 2. The name of the author may not be used to endorse or promote products
168b8a9b1dSJustin T. Gibbs  *    derived from this software without specific prior written permission.
178b8a9b1dSJustin T. Gibbs  *
188b8a9b1dSJustin T. Gibbs  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
198b8a9b1dSJustin T. Gibbs  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
208b8a9b1dSJustin T. Gibbs  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
218b8a9b1dSJustin T. Gibbs  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
228b8a9b1dSJustin T. Gibbs  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
238b8a9b1dSJustin T. Gibbs  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
248b8a9b1dSJustin T. Gibbs  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
258b8a9b1dSJustin T. Gibbs  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
268b8a9b1dSJustin T. Gibbs  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
278b8a9b1dSJustin T. Gibbs  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
288b8a9b1dSJustin T. Gibbs  * SUCH DAMAGE.
298b8a9b1dSJustin T. Gibbs  *
30c3aac50fSPeter Wemm  * $FreeBSD$
318b8a9b1dSJustin T. Gibbs  */
328b8a9b1dSJustin T. Gibbs 
338b8a9b1dSJustin T. Gibbs #ifndef _CAM_CAM_H
348b8a9b1dSJustin T. Gibbs #define _CAM_CAM_H 1
358b8a9b1dSJustin T. Gibbs 
36c4473420SPeter Wemm #ifdef _KERNEL
376df06cd6SWarner Losh #include "opt_cam.h"
38c4473420SPeter Wemm #endif
398b8a9b1dSJustin T. Gibbs 
408b8a9b1dSJustin T. Gibbs #include <sys/cdefs.h>
418b8a9b1dSJustin T. Gibbs 
428b8a9b1dSJustin T. Gibbs typedef u_int path_id_t;
438b8a9b1dSJustin T. Gibbs typedef u_int target_id_t;
4492be6c51SNathan Whitehorn typedef u_int64_t lun_id_t;
458b8a9b1dSJustin T. Gibbs 
468b8a9b1dSJustin T. Gibbs #define	CAM_XPT_PATH_ID	((path_id_t)~0)
478b8a9b1dSJustin T. Gibbs #define	CAM_BUS_WILDCARD ((path_id_t)~0)
488b8a9b1dSJustin T. Gibbs #define	CAM_TARGET_WILDCARD ((target_id_t)~0)
4992be6c51SNathan Whitehorn #define	CAM_LUN_WILDCARD (~(u_int)0)
508b8a9b1dSJustin T. Gibbs 
51ef5758faSNathan Whitehorn #define CAM_EXTLUN_BYTE_SWIZZLE(lun) (	\
52ef5758faSNathan Whitehorn 	((((u_int64_t)lun) & 0xffff000000000000L) >> 48) | \
53ef5758faSNathan Whitehorn 	((((u_int64_t)lun) & 0x0000ffff00000000L) >> 16) | \
54ef5758faSNathan Whitehorn 	((((u_int64_t)lun) & 0x00000000ffff0000L) << 16) | \
55ef5758faSNathan Whitehorn 	((((u_int64_t)lun) & 0x000000000000ffffL) << 48))
56ef5758faSNathan Whitehorn 
578b8a9b1dSJustin T. Gibbs /*
588b8a9b1dSJustin T. Gibbs  * Maximum length for a CAM CDB.
598b8a9b1dSJustin T. Gibbs  */
608b8a9b1dSJustin T. Gibbs #define CAM_MAX_CDBLEN 16
618b8a9b1dSJustin T. Gibbs 
628b8a9b1dSJustin T. Gibbs /*
638b8a9b1dSJustin T. Gibbs  * Definition of a CAM peripheral driver entry.  Peripheral drivers instantiate
648b8a9b1dSJustin T. Gibbs  * one of these for each device they wish to communicate with and pass it into
658b8a9b1dSJustin T. Gibbs  * the xpt layer when they wish to schedule work on that device via the
660cdabce0SNick Hibma  * xpt_schedule API.
678b8a9b1dSJustin T. Gibbs  */
688b8a9b1dSJustin T. Gibbs struct cam_periph;
698b8a9b1dSJustin T. Gibbs 
708b8a9b1dSJustin T. Gibbs /*
7183c5d981SAlexander Motin  * Priority information for a CAM structure.
7283c5d981SAlexander Motin  */
7383c5d981SAlexander Motin typedef enum {
7483c5d981SAlexander Motin     CAM_RL_HOST,
7583c5d981SAlexander Motin     CAM_RL_BUS,
7683c5d981SAlexander Motin     CAM_RL_XPT,
7783c5d981SAlexander Motin     CAM_RL_DEV,
7883c5d981SAlexander Motin     CAM_RL_NORMAL,
7983c5d981SAlexander Motin     CAM_RL_VALUES
8083c5d981SAlexander Motin } cam_rl;
8183c5d981SAlexander Motin /*
8283c5d981SAlexander Motin  * The generation number is incremented every time a new entry is entered into
8383c5d981SAlexander Motin  * the queue giving round robin per priority level scheduling.
848b8a9b1dSJustin T. Gibbs  */
858b8a9b1dSJustin T. Gibbs typedef struct {
868b8a9b1dSJustin T. Gibbs 	u_int32_t priority;
8783c5d981SAlexander Motin #define CAM_PRIORITY_HOST	((CAM_RL_HOST << 8) + 0x80)
8883c5d981SAlexander Motin #define CAM_PRIORITY_BUS	((CAM_RL_BUS << 8) + 0x80)
8983c5d981SAlexander Motin #define CAM_PRIORITY_XPT	((CAM_RL_XPT << 8) + 0x80)
9083c5d981SAlexander Motin #define CAM_PRIORITY_DEV	((CAM_RL_DEV << 8) + 0x80)
91cccf4220SAlexander Motin #define CAM_PRIORITY_OOB	(CAM_RL_DEV << 8)
9283c5d981SAlexander Motin #define CAM_PRIORITY_NORMAL	((CAM_RL_NORMAL << 8) + 0x80)
938b8a9b1dSJustin T. Gibbs #define CAM_PRIORITY_NONE	(u_int32_t)-1
948b8a9b1dSJustin T. Gibbs 	u_int32_t generation;
958b8a9b1dSJustin T. Gibbs 	int       index;
968b8a9b1dSJustin T. Gibbs #define CAM_UNQUEUED_INDEX	-1
978b8a9b1dSJustin T. Gibbs #define CAM_ACTIVE_INDEX	-2
988b8a9b1dSJustin T. Gibbs #define CAM_DONEQ_INDEX		-3
99*7381bbeeSWarner Losh #define CAM_ASYNC_INDEX		-4
100ea541bfdSAlexander Motin #define CAM_EXTRAQ_INDEX	INT_MAX
1018b8a9b1dSJustin T. Gibbs } cam_pinfo;
1028b8a9b1dSJustin T. Gibbs 
1038bad620dSJustin T. Gibbs /*
1048bad620dSJustin T. Gibbs  * Macro to compare two generation numbers.  It is used like this:
1058bad620dSJustin T. Gibbs  *
1068bad620dSJustin T. Gibbs  *	if (GENERATIONCMP(a, >=, b))
1078bad620dSJustin T. Gibbs  *		...;
1088bad620dSJustin T. Gibbs  *
1098bad620dSJustin T. Gibbs  * GERERATIONCMP uses modular arithmetic to guard against wraps
1108bad620dSJustin T. Gibbs  * wraps in the generation number.
1118bad620dSJustin T. Gibbs  */
1128bad620dSJustin T. Gibbs #define GENERATIONCMP(x, op, y) ((int32_t)((x) - (y)) op 0)
1138bad620dSJustin T. Gibbs 
1143393f8daSKenneth D. Merry /* CAM flags XXX Move to cam_periph.h ??? */
1158b8a9b1dSJustin T. Gibbs typedef enum {
1168b8a9b1dSJustin T. Gibbs 	CAM_FLAG_NONE		= 0x00,
1173393f8daSKenneth D. Merry 	CAM_EXPECT_INQ_CHANGE	= 0x01,
1183393f8daSKenneth D. Merry 	CAM_RETRY_SELTO		= 0x02 /* Retry Selection Timeouts */
1198b8a9b1dSJustin T. Gibbs } cam_flags;
1208b8a9b1dSJustin T. Gibbs 
1210191d9b3SAlexander Motin enum {
1220191d9b3SAlexander Motin 	SF_RETRY_UA		= 0x01,	/* Retry UNIT ATTENTION conditions. */
1230191d9b3SAlexander Motin 	SF_NO_PRINT		= 0x02,	/* Never print error status. */
1241ffe5851SPedro F. Giffuni 	SF_QUIET_IR		= 0x04,	/* Be quiet about Illegal Request responses */
1250191d9b3SAlexander Motin 	SF_PRINT_ALWAYS		= 0x08,	/* Always print error status. */
1260191d9b3SAlexander Motin 	SF_NO_RECOVERY		= 0x10,	/* Don't do active error recovery. */
127174b32ceSAlexander Motin 	SF_NO_RETRY		= 0x20,	/* Don't do any retries. */
128174b32ceSAlexander Motin 	SF_RETRY_BUSY		= 0x40	/* Retry BUSY status. */
1290191d9b3SAlexander Motin };
1300191d9b3SAlexander Motin 
1318b8a9b1dSJustin T. Gibbs /* CAM  Status field values */
1328b8a9b1dSJustin T. Gibbs typedef enum {
133f564de00SScott Long 	/* CCB request is in progress */
134f564de00SScott Long 	CAM_REQ_INPROG		= 0x00,
135f564de00SScott Long 
136f564de00SScott Long 	/* CCB request completed without error */
137f564de00SScott Long 	CAM_REQ_CMP		= 0x01,
138f564de00SScott Long 
139f564de00SScott Long 	/* CCB request aborted by the host */
140f564de00SScott Long 	CAM_REQ_ABORTED		= 0x02,
141f564de00SScott Long 
142f564de00SScott Long 	/* Unable to abort CCB request */
143f564de00SScott Long 	CAM_UA_ABORT		= 0x03,
144f564de00SScott Long 
145f564de00SScott Long 	/* CCB request completed with an error */
146f564de00SScott Long 	CAM_REQ_CMP_ERR		= 0x04,
147f564de00SScott Long 
148f564de00SScott Long 	/* CAM subsystem is busy */
149f564de00SScott Long 	CAM_BUSY		= 0x05,
150f564de00SScott Long 
151f564de00SScott Long 	/* CCB request was invalid */
152f564de00SScott Long 	CAM_REQ_INVALID		= 0x06,
153f564de00SScott Long 
154f564de00SScott Long 	/* Supplied Path ID is invalid */
155f564de00SScott Long 	CAM_PATH_INVALID	= 0x07,
156f564de00SScott Long 
157f564de00SScott Long 	/* SCSI Device Not Installed/there */
158f564de00SScott Long 	CAM_DEV_NOT_THERE	= 0x08,
159f564de00SScott Long 
160f564de00SScott Long 	/* Unable to terminate I/O CCB request */
161f564de00SScott Long 	CAM_UA_TERMIO		= 0x09,
162f564de00SScott Long 
163f564de00SScott Long 	/* Target Selection Timeout */
164f564de00SScott Long 	CAM_SEL_TIMEOUT		= 0x0a,
165f564de00SScott Long 
166f564de00SScott Long 	/* Command timeout */
167f564de00SScott Long 	CAM_CMD_TIMEOUT		= 0x0b,
168f564de00SScott Long 
169f564de00SScott Long 	/* SCSI error, look at error code in CCB */
170f564de00SScott Long 	CAM_SCSI_STATUS_ERROR	= 0x0c,
171f564de00SScott Long 
172f564de00SScott Long 	/* Message Reject Received */
173f564de00SScott Long 	CAM_MSG_REJECT_REC	= 0x0d,
174f564de00SScott Long 
175f564de00SScott Long 	/* SCSI Bus Reset Sent/Received */
176f564de00SScott Long 	CAM_SCSI_BUS_RESET	= 0x0e,
177f564de00SScott Long 
178f564de00SScott Long 	/* Uncorrectable parity error occurred */
179f564de00SScott Long 	CAM_UNCOR_PARITY	= 0x0f,
180f564de00SScott Long 
181f564de00SScott Long 	/* Autosense: request sense cmd fail */
182f564de00SScott Long 	CAM_AUTOSENSE_FAIL	= 0x10,
183f564de00SScott Long 
184f564de00SScott Long 	/* No HBA Detected error */
185f564de00SScott Long 	CAM_NO_HBA		= 0x11,
186f564de00SScott Long 
187f564de00SScott Long 	/* Data Overrun error */
188f564de00SScott Long 	CAM_DATA_RUN_ERR	= 0x12,
189f564de00SScott Long 
190f564de00SScott Long 	/* Unexpected Bus Free */
191f564de00SScott Long 	CAM_UNEXP_BUSFREE	= 0x13,
192f564de00SScott Long 
193f564de00SScott Long 	/* Target Bus Phase Sequence Failure */
194f564de00SScott Long 	CAM_SEQUENCE_FAIL	= 0x14,
195f564de00SScott Long 
196f564de00SScott Long 	/* CCB length supplied is inadequate */
197f564de00SScott Long 	CAM_CCB_LEN_ERR		= 0x15,
198f564de00SScott Long 
199f564de00SScott Long 	/* Unable to provide requested capability*/
200f564de00SScott Long 	CAM_PROVIDE_FAIL	= 0x16,
201f564de00SScott Long 
202f564de00SScott Long 	/* A SCSI BDR msg was sent to target */
203f564de00SScott Long 	CAM_BDR_SENT		= 0x17,
204f564de00SScott Long 
205f564de00SScott Long 	/* CCB request terminated by the host */
206f564de00SScott Long 	CAM_REQ_TERMIO		= 0x18,
207f564de00SScott Long 
208f564de00SScott Long 	/* Unrecoverable Host Bus Adapter Error */
209f564de00SScott Long 	CAM_UNREC_HBA_ERROR	= 0x19,
210f564de00SScott Long 
211f564de00SScott Long 	/* Request was too large for this host */
212f564de00SScott Long 	CAM_REQ_TOO_BIG		= 0x1a,
213f564de00SScott Long 
214f564de00SScott Long 	/*
2158b8a9b1dSJustin T. Gibbs 	 * This request should be requeued to preserve
2168b8a9b1dSJustin T. Gibbs 	 * transaction ordering.  This typically occurs
2178b8a9b1dSJustin T. Gibbs 	 * when the SIM recognizes an error that should
2188b8a9b1dSJustin T. Gibbs 	 * freeze the queue and must place additional
2198b8a9b1dSJustin T. Gibbs 	 * requests for the target at the sim level
2208b8a9b1dSJustin T. Gibbs 	 * back into the XPT queue.
2218b8a9b1dSJustin T. Gibbs 	 */
222f564de00SScott Long 	CAM_REQUEUE_REQ		= 0x1b,
2238b8a9b1dSJustin T. Gibbs 
224f564de00SScott Long 	/* ATA error, look at error code in CCB */
225f564de00SScott Long 	CAM_ATA_STATUS_ERROR	= 0x1c,
226f564de00SScott Long 
227f564de00SScott Long 	/* Initiator/Target Nexus lost. */
228f564de00SScott Long 	CAM_SCSI_IT_NEXUS_LOST	= 0x1d,
229f564de00SScott Long 
230f564de00SScott Long 	/* SMP error, look at error code in CCB */
231f564de00SScott Long 	CAM_SMP_STATUS_ERROR	= 0x1e,
232f564de00SScott Long 
233f564de00SScott Long 	/*
234f564de00SScott Long 	 * Command completed without error but  exceeded the soft
235f564de00SScott Long 	 * timeout threshold.
236f564de00SScott Long 	 */
237f564de00SScott Long 	CAM_REQ_SOFTTIMEOUT	= 0x1f,
238f564de00SScott Long 
239f564de00SScott Long 	/*
240f564de00SScott Long 	 * 0x20 - 0x32 are unassigned
241f564de00SScott Long 	 */
242f564de00SScott Long 
243f564de00SScott Long 	/* Initiator Detected Error */
244f564de00SScott Long 	CAM_IDE			= 0x33,
245f564de00SScott Long 
246f564de00SScott Long 	/* Resource Unavailable */
247f564de00SScott Long 	CAM_RESRC_UNAVAIL	= 0x34,
248f564de00SScott Long 
249f564de00SScott Long 	/* Unacknowledged Event by Host */
250f564de00SScott Long 	CAM_UNACKED_EVENT	= 0x35,
251f564de00SScott Long 
252f564de00SScott Long 	/* Message Received in Host Target Mode */
253f564de00SScott Long 	CAM_MESSAGE_RECV	= 0x36,
254f564de00SScott Long 
255f564de00SScott Long 	/* Invalid CDB received in Host Target Mode */
256f564de00SScott Long 	CAM_INVALID_CDB		= 0x37,
257f564de00SScott Long 
258f564de00SScott Long 	/* Lun supplied is invalid */
259f564de00SScott Long 	CAM_LUN_INVALID		= 0x38,
260f564de00SScott Long 
261f564de00SScott Long 	/* Target ID supplied is invalid */
262f564de00SScott Long 	CAM_TID_INVALID		= 0x39,
263f564de00SScott Long 
264f564de00SScott Long 	/* The requested function is not available */
265f564de00SScott Long 	CAM_FUNC_NOTAVAIL	= 0x3a,
266f564de00SScott Long 
267f564de00SScott Long 	/* Nexus is not established */
268f564de00SScott Long 	CAM_NO_NEXUS		= 0x3b,
269f564de00SScott Long 
270f564de00SScott Long 	/* The initiator ID is invalid */
271f564de00SScott Long 	CAM_IID_INVALID		= 0x3c,
272f564de00SScott Long 
273f564de00SScott Long 	/* The SCSI CDB has been received */
274f564de00SScott Long 	CAM_CDB_RECVD		= 0x3d,
275f564de00SScott Long 
276f564de00SScott Long 	/* The LUN is already enabled for target mode */
277f564de00SScott Long 	CAM_LUN_ALRDY_ENA	= 0x3e,
278f564de00SScott Long 
279f564de00SScott Long 	/* SCSI Bus Busy */
280f564de00SScott Long 	CAM_SCSI_BUSY		= 0x3f,
281f564de00SScott Long 
282f564de00SScott Long 	/*
283f564de00SScott Long 	 * Flags
284f564de00SScott Long 	 */
285f564de00SScott Long 
286f564de00SScott Long 	/* The DEV queue is frozen w/this err */
287f564de00SScott Long 	CAM_DEV_QFRZN		= 0x40,
2888b8a9b1dSJustin T. Gibbs 
2898b8a9b1dSJustin T. Gibbs 	/* Autosense data valid for target */
2908b8a9b1dSJustin T. Gibbs 	CAM_AUTOSNS_VALID	= 0x80,
2918b8a9b1dSJustin T. Gibbs 
292f564de00SScott Long 	/* SIM ready to take more commands */
293f564de00SScott Long 	CAM_RELEASE_SIMQ	= 0x100,
2945fd6140dSMatt Jacob 
29528323addSBryan Drewery 	/* SIM has this command in its queue */
296f564de00SScott Long 	CAM_SIM_QUEUED		= 0x200,
297f564de00SScott Long 
298f564de00SScott Long 	/* Quality of service data is valid */
299f564de00SScott Long 	CAM_QOS_VALID		= 0x400,
300f564de00SScott Long 
301f564de00SScott Long 	/* Mask bits for just the status # */
302f564de00SScott Long 	CAM_STATUS_MASK = 0x3F,
303f564de00SScott Long 
304f564de00SScott Long 	/*
305f564de00SScott Long 	 * Target Specific Adjunct Status
306f564de00SScott Long 	 */
307f564de00SScott Long 
308f564de00SScott Long 	/* sent sense with status */
309f564de00SScott Long 	CAM_SENT_SENSE		= 0x40000000
3108b8a9b1dSJustin T. Gibbs } cam_status;
3118b8a9b1dSJustin T. Gibbs 
3123393f8daSKenneth D. Merry typedef enum {
3133393f8daSKenneth D. Merry 	CAM_ESF_NONE		= 0x00,
3143393f8daSKenneth D. Merry 	CAM_ESF_COMMAND		= 0x01,
3153393f8daSKenneth D. Merry 	CAM_ESF_CAM_STATUS	= 0x02,
3163393f8daSKenneth D. Merry 	CAM_ESF_PROTO_STATUS	= 0x04,
3173393f8daSKenneth D. Merry 	CAM_ESF_ALL		= 0xff
3183393f8daSKenneth D. Merry } cam_error_string_flags;
3193393f8daSKenneth D. Merry 
3203393f8daSKenneth D. Merry typedef enum {
3213393f8daSKenneth D. Merry 	CAM_EPF_NONE		= 0x00,
3223393f8daSKenneth D. Merry 	CAM_EPF_MINIMAL		= 0x01,
3233393f8daSKenneth D. Merry 	CAM_EPF_NORMAL		= 0x02,
3243393f8daSKenneth D. Merry 	CAM_EPF_ALL		= 0x03,
3253393f8daSKenneth D. Merry 	CAM_EPF_LEVEL_MASK	= 0x0f
3263393f8daSKenneth D. Merry 	/* All bits above bit 3 are protocol-specific */
3273393f8daSKenneth D. Merry } cam_error_proto_flags;
3283393f8daSKenneth D. Merry 
3293393f8daSKenneth D. Merry typedef enum {
3303393f8daSKenneth D. Merry 	CAM_ESF_PRINT_NONE	= 0x00,
3313393f8daSKenneth D. Merry 	CAM_ESF_PRINT_STATUS	= 0x10,
3323393f8daSKenneth D. Merry 	CAM_ESF_PRINT_SENSE	= 0x20
3333393f8daSKenneth D. Merry } cam_error_scsi_flags;
3343393f8daSKenneth D. Merry 
3358691755dSAlexander Motin typedef enum {
33606e79492SKenneth D. Merry 	CAM_ESMF_PRINT_NONE	= 0x00,
33706e79492SKenneth D. Merry 	CAM_ESMF_PRINT_STATUS	= 0x10,
33806e79492SKenneth D. Merry 	CAM_ESMF_PRINT_FULL_CMD	= 0x20,
33906e79492SKenneth D. Merry } cam_error_smp_flags;
34006e79492SKenneth D. Merry 
34106e79492SKenneth D. Merry typedef enum {
3428691755dSAlexander Motin 	CAM_EAF_PRINT_NONE	= 0x00,
3438691755dSAlexander Motin 	CAM_EAF_PRINT_STATUS	= 0x10,
3448691755dSAlexander Motin 	CAM_EAF_PRINT_RESULT	= 0x20
3458691755dSAlexander Motin } cam_error_ata_flags;
3468691755dSAlexander Motin 
3475672fac9SKenneth D. Merry typedef enum {
3485672fac9SKenneth D. Merry 	CAM_STRVIS_FLAG_NONE		= 0x00,
3495672fac9SKenneth D. Merry 	CAM_STRVIS_FLAG_NONASCII_MASK	= 0x03,
3505672fac9SKenneth D. Merry 	CAM_STRVIS_FLAG_NONASCII_TRIM	= 0x00,
3515672fac9SKenneth D. Merry 	CAM_STRVIS_FLAG_NONASCII_RAW	= 0x01,
3525672fac9SKenneth D. Merry 	CAM_STRVIS_FLAG_NONASCII_SPC	= 0x02,
3535672fac9SKenneth D. Merry 	CAM_STRVIS_FLAG_NONASCII_ESC	= 0x03
3545672fac9SKenneth D. Merry } cam_strvis_flags;
3555672fac9SKenneth D. Merry 
3563393f8daSKenneth D. Merry struct cam_status_entry
3573393f8daSKenneth D. Merry {
3583393f8daSKenneth D. Merry 	cam_status  status_code;
3593393f8daSKenneth D. Merry 	const char *status_text;
3603393f8daSKenneth D. Merry };
3613393f8daSKenneth D. Merry 
3623393f8daSKenneth D. Merry extern const struct cam_status_entry cam_status_table[];
3633393f8daSKenneth D. Merry extern const int num_cam_status_entries;
3645f83aee5SSteven Hartland #ifdef _KERNEL
3655f83aee5SSteven Hartland extern int cam_sort_io_queues;
3665f83aee5SSteven Hartland #endif
3673393f8daSKenneth D. Merry union ccb;
3685672fac9SKenneth D. Merry struct sbuf;
3693393f8daSKenneth D. Merry 
37065c38256SMike Smith #ifdef SYSCTL_DECL	/* from sysctl.h */
37165c38256SMike Smith SYSCTL_DECL(_kern_cam);
37265c38256SMike Smith #endif
37365c38256SMike Smith 
3748b8a9b1dSJustin T. Gibbs __BEGIN_DECLS
3758b8a9b1dSJustin T. Gibbs typedef int (cam_quirkmatch_t)(caddr_t, caddr_t);
3768b8a9b1dSJustin T. Gibbs 
3778b8a9b1dSJustin T. Gibbs caddr_t	cam_quirkmatch(caddr_t target, caddr_t quirk_table, int num_entries,
3788b8a9b1dSJustin T. Gibbs 		       int entry_size, cam_quirkmatch_t *comp_func);
3798b8a9b1dSJustin T. Gibbs 
3808b8a9b1dSJustin T. Gibbs void	cam_strvis(u_int8_t *dst, const u_int8_t *src, int srclen, int dstlen);
3815672fac9SKenneth D. Merry void	cam_strvis_sbuf(struct sbuf *sb, const u_int8_t *src, int srclen,
3825672fac9SKenneth D. Merry 			uint32_t flags);
3838b8a9b1dSJustin T. Gibbs 
3848b8a9b1dSJustin T. Gibbs int	cam_strmatch(const u_int8_t *str, const u_int8_t *pattern, int str_len);
3853393f8daSKenneth D. Merry const struct cam_status_entry*
3863393f8daSKenneth D. Merry 	cam_fetch_status_entry(cam_status status);
3873393f8daSKenneth D. Merry #ifdef _KERNEL
3883393f8daSKenneth D. Merry char *	cam_error_string(union ccb *ccb, char *str, int str_len,
3893393f8daSKenneth D. Merry 			 cam_error_string_flags flags,
3903393f8daSKenneth D. Merry 			 cam_error_proto_flags proto_flags);
3913393f8daSKenneth D. Merry void	cam_error_print(union ccb *ccb, cam_error_string_flags flags,
3923393f8daSKenneth D. Merry 			cam_error_proto_flags proto_flags);
3933393f8daSKenneth D. Merry #else /* _KERNEL */
3943393f8daSKenneth D. Merry struct cam_device;
3953393f8daSKenneth D. Merry 
3963393f8daSKenneth D. Merry char *	cam_error_string(struct cam_device *device, union ccb *ccb, char *str,
3973393f8daSKenneth D. Merry 			 int str_len, cam_error_string_flags flags,
3983393f8daSKenneth D. Merry 			 cam_error_proto_flags proto_flags);
3993393f8daSKenneth D. Merry void	cam_error_print(struct cam_device *device, union ccb *ccb,
4003393f8daSKenneth D. Merry 			cam_error_string_flags flags,
4013393f8daSKenneth D. Merry 			cam_error_proto_flags proto_flags, FILE *ofile);
4023393f8daSKenneth D. Merry #endif /* _KERNEL */
4038b8a9b1dSJustin T. Gibbs __END_DECLS
4048b8a9b1dSJustin T. Gibbs 
405c4473420SPeter Wemm #ifdef _KERNEL
4068b8a9b1dSJustin T. Gibbs static __inline void cam_init_pinfo(cam_pinfo *pinfo)
4078b8a9b1dSJustin T. Gibbs {
4088b8a9b1dSJustin T. Gibbs 	pinfo->priority = CAM_PRIORITY_NONE;
4098b8a9b1dSJustin T. Gibbs 	pinfo->index = CAM_UNQUEUED_INDEX;
4108b8a9b1dSJustin T. Gibbs }
411c4473420SPeter Wemm #endif
4128b8a9b1dSJustin T. Gibbs 
4138b8a9b1dSJustin T. Gibbs #endif /* _CAM_CAM_H */
414