1898b0535SWarner Losh /*-
28b8a9b1dSJustin T. Gibbs * Data structures and definitions for the CAM system.
38b8a9b1dSJustin T. Gibbs *
44d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause
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 */
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
356df06cd6SWarner Losh #include "opt_cam.h"
36c4473420SPeter Wemm #endif
378b8a9b1dSJustin T. Gibbs
38757fc666SWarner Losh #ifndef _KERNEL
39757fc666SWarner Losh #include <stdbool.h>
40*0f838111SWarner Losh #include <stdio.h>
41757fc666SWarner Losh #endif
428b8a9b1dSJustin T. Gibbs
438b8a9b1dSJustin T. Gibbs typedef u_int path_id_t;
448b8a9b1dSJustin T. Gibbs typedef u_int target_id_t;
457af2f2c8SWarner Losh typedef uint64_t lun_id_t;
468b8a9b1dSJustin T. Gibbs
478b8a9b1dSJustin T. Gibbs #define CAM_XPT_PATH_ID ((path_id_t)~0)
488b8a9b1dSJustin T. Gibbs #define CAM_BUS_WILDCARD ((path_id_t)~0)
498b8a9b1dSJustin T. Gibbs #define CAM_TARGET_WILDCARD ((target_id_t)~0)
5092be6c51SNathan Whitehorn #define CAM_LUN_WILDCARD (~(u_int)0)
518b8a9b1dSJustin T. Gibbs
52ef5758faSNathan Whitehorn #define CAM_EXTLUN_BYTE_SWIZZLE(lun) ( \
537af2f2c8SWarner Losh ((((uint64_t)lun) & 0xffff000000000000L) >> 48) | \
547af2f2c8SWarner Losh ((((uint64_t)lun) & 0x0000ffff00000000L) >> 16) | \
557af2f2c8SWarner Losh ((((uint64_t)lun) & 0x00000000ffff0000L) << 16) | \
567af2f2c8SWarner Losh ((((uint64_t)lun) & 0x000000000000ffffL) << 48))
57ef5758faSNathan Whitehorn
588b8a9b1dSJustin T. Gibbs /*
598b8a9b1dSJustin T. Gibbs * Maximum length for a CAM CDB.
608b8a9b1dSJustin T. Gibbs */
618b8a9b1dSJustin T. Gibbs #define CAM_MAX_CDBLEN 16
628b8a9b1dSJustin T. Gibbs
638b8a9b1dSJustin T. Gibbs /*
648b8a9b1dSJustin T. Gibbs * Definition of a CAM peripheral driver entry. Peripheral drivers instantiate
658b8a9b1dSJustin T. Gibbs * one of these for each device they wish to communicate with and pass it into
668b8a9b1dSJustin T. Gibbs * the xpt layer when they wish to schedule work on that device via the
670cdabce0SNick Hibma * xpt_schedule API.
688b8a9b1dSJustin T. Gibbs */
698b8a9b1dSJustin T. Gibbs struct cam_periph;
708b8a9b1dSJustin T. Gibbs
718b8a9b1dSJustin T. Gibbs /*
7283c5d981SAlexander Motin * Priority information for a CAM structure.
7383c5d981SAlexander Motin */
7483c5d981SAlexander Motin typedef enum {
7583c5d981SAlexander Motin CAM_RL_HOST,
7683c5d981SAlexander Motin CAM_RL_BUS,
7783c5d981SAlexander Motin CAM_RL_XPT,
7883c5d981SAlexander Motin CAM_RL_DEV,
7983c5d981SAlexander Motin CAM_RL_NORMAL,
8083c5d981SAlexander Motin CAM_RL_VALUES
8183c5d981SAlexander Motin } cam_rl;
8283c5d981SAlexander Motin /*
8383c5d981SAlexander Motin * The generation number is incremented every time a new entry is entered into
8483c5d981SAlexander Motin * the queue giving round robin per priority level scheduling.
858b8a9b1dSJustin T. Gibbs */
868b8a9b1dSJustin T. Gibbs typedef struct {
877af2f2c8SWarner Losh uint32_t priority;
8883c5d981SAlexander Motin #define CAM_PRIORITY_HOST ((CAM_RL_HOST << 8) + 0x80)
8983c5d981SAlexander Motin #define CAM_PRIORITY_BUS ((CAM_RL_BUS << 8) + 0x80)
9083c5d981SAlexander Motin #define CAM_PRIORITY_XPT ((CAM_RL_XPT << 8) + 0x80)
9183c5d981SAlexander Motin #define CAM_PRIORITY_DEV ((CAM_RL_DEV << 8) + 0x80)
92cccf4220SAlexander Motin #define CAM_PRIORITY_OOB (CAM_RL_DEV << 8)
9383c5d981SAlexander Motin #define CAM_PRIORITY_NORMAL ((CAM_RL_NORMAL << 8) + 0x80)
947af2f2c8SWarner Losh #define CAM_PRIORITY_NONE (uint32_t)-1
957af2f2c8SWarner Losh uint32_t generation;
968b8a9b1dSJustin T. Gibbs int index;
978b8a9b1dSJustin T. Gibbs #define CAM_UNQUEUED_INDEX -1
988b8a9b1dSJustin T. Gibbs #define CAM_ACTIVE_INDEX -2
998b8a9b1dSJustin T. Gibbs #define CAM_DONEQ_INDEX -3
1007381bbeeSWarner Losh #define CAM_ASYNC_INDEX -4
101ea541bfdSAlexander Motin #define CAM_EXTRAQ_INDEX INT_MAX
1028b8a9b1dSJustin T. Gibbs } cam_pinfo;
1038b8a9b1dSJustin T. Gibbs
1048bad620dSJustin T. Gibbs /*
1058bad620dSJustin T. Gibbs * Macro to compare two generation numbers. It is used like this:
1068bad620dSJustin T. Gibbs *
1078bad620dSJustin T. Gibbs * if (GENERATIONCMP(a, >=, b))
1088bad620dSJustin T. Gibbs * ...;
1098bad620dSJustin T. Gibbs *
1108bad620dSJustin T. Gibbs * GERERATIONCMP uses modular arithmetic to guard against wraps
1118bad620dSJustin T. Gibbs * wraps in the generation number.
1128bad620dSJustin T. Gibbs */
1138bad620dSJustin T. Gibbs #define GENERATIONCMP(x, op, y) ((int32_t)((x) - (y)) op 0)
1148bad620dSJustin T. Gibbs
1153393f8daSKenneth D. Merry /* CAM flags XXX Move to cam_periph.h ??? */
1168b8a9b1dSJustin T. Gibbs typedef enum {
1178b8a9b1dSJustin T. Gibbs CAM_FLAG_NONE = 0x00,
1183393f8daSKenneth D. Merry CAM_EXPECT_INQ_CHANGE = 0x01,
1193393f8daSKenneth D. Merry CAM_RETRY_SELTO = 0x02 /* Retry Selection Timeouts */
1208b8a9b1dSJustin T. Gibbs } cam_flags;
1218b8a9b1dSJustin T. Gibbs
1220191d9b3SAlexander Motin enum {
1230191d9b3SAlexander Motin SF_RETRY_UA = 0x01, /* Retry UNIT ATTENTION conditions. */
1240191d9b3SAlexander Motin SF_NO_PRINT = 0x02, /* Never print error status. */
1251ffe5851SPedro F. Giffuni SF_QUIET_IR = 0x04, /* Be quiet about Illegal Request responses */
1260191d9b3SAlexander Motin SF_PRINT_ALWAYS = 0x08, /* Always print error status. */
1270191d9b3SAlexander Motin SF_NO_RECOVERY = 0x10, /* Don't do active error recovery. */
128174b32ceSAlexander Motin SF_NO_RETRY = 0x20, /* Don't do any retries. */
129174b32ceSAlexander Motin SF_RETRY_BUSY = 0x40 /* Retry BUSY status. */
1300191d9b3SAlexander Motin };
1310191d9b3SAlexander Motin
1328b8a9b1dSJustin T. Gibbs /* CAM Status field values */
1338b8a9b1dSJustin T. Gibbs typedef enum {
134f564de00SScott Long /* CCB request is in progress */
135f564de00SScott Long CAM_REQ_INPROG = 0x00,
136f564de00SScott Long
137f564de00SScott Long /* CCB request completed without error */
138f564de00SScott Long CAM_REQ_CMP = 0x01,
139f564de00SScott Long
140f564de00SScott Long /* CCB request aborted by the host */
141f564de00SScott Long CAM_REQ_ABORTED = 0x02,
142f564de00SScott Long
143f564de00SScott Long /* Unable to abort CCB request */
144f564de00SScott Long CAM_UA_ABORT = 0x03,
145f564de00SScott Long
146f564de00SScott Long /* CCB request completed with an error */
147f564de00SScott Long CAM_REQ_CMP_ERR = 0x04,
148f564de00SScott Long
149f564de00SScott Long /* CAM subsystem is busy */
150f564de00SScott Long CAM_BUSY = 0x05,
151f564de00SScott Long
152f564de00SScott Long /* CCB request was invalid */
153f564de00SScott Long CAM_REQ_INVALID = 0x06,
154f564de00SScott Long
155f564de00SScott Long /* Supplied Path ID is invalid */
156f564de00SScott Long CAM_PATH_INVALID = 0x07,
157f564de00SScott Long
158f564de00SScott Long /* SCSI Device Not Installed/there */
159f564de00SScott Long CAM_DEV_NOT_THERE = 0x08,
160f564de00SScott Long
161f564de00SScott Long /* Unable to terminate I/O CCB request */
162f564de00SScott Long CAM_UA_TERMIO = 0x09,
163f564de00SScott Long
164f564de00SScott Long /* Target Selection Timeout */
165f564de00SScott Long CAM_SEL_TIMEOUT = 0x0a,
166f564de00SScott Long
167f564de00SScott Long /* Command timeout */
168f564de00SScott Long CAM_CMD_TIMEOUT = 0x0b,
169f564de00SScott Long
170f564de00SScott Long /* SCSI error, look at error code in CCB */
171f564de00SScott Long CAM_SCSI_STATUS_ERROR = 0x0c,
172f564de00SScott Long
173f564de00SScott Long /* Message Reject Received */
174f564de00SScott Long CAM_MSG_REJECT_REC = 0x0d,
175f564de00SScott Long
176f564de00SScott Long /* SCSI Bus Reset Sent/Received */
177f564de00SScott Long CAM_SCSI_BUS_RESET = 0x0e,
178f564de00SScott Long
179f564de00SScott Long /* Uncorrectable parity error occurred */
180f564de00SScott Long CAM_UNCOR_PARITY = 0x0f,
181f564de00SScott Long
182f564de00SScott Long /* Autosense: request sense cmd fail */
183f564de00SScott Long CAM_AUTOSENSE_FAIL = 0x10,
184f564de00SScott Long
185f564de00SScott Long /* No HBA Detected error */
186f564de00SScott Long CAM_NO_HBA = 0x11,
187f564de00SScott Long
188f564de00SScott Long /* Data Overrun error */
189f564de00SScott Long CAM_DATA_RUN_ERR = 0x12,
190f564de00SScott Long
191f564de00SScott Long /* Unexpected Bus Free */
192f564de00SScott Long CAM_UNEXP_BUSFREE = 0x13,
193f564de00SScott Long
194f564de00SScott Long /* Target Bus Phase Sequence Failure */
195f564de00SScott Long CAM_SEQUENCE_FAIL = 0x14,
196f564de00SScott Long
197f564de00SScott Long /* CCB length supplied is inadequate */
198f564de00SScott Long CAM_CCB_LEN_ERR = 0x15,
199f564de00SScott Long
200f564de00SScott Long /* Unable to provide requested capability*/
201f564de00SScott Long CAM_PROVIDE_FAIL = 0x16,
202f564de00SScott Long
203f564de00SScott Long /* A SCSI BDR msg was sent to target */
204f564de00SScott Long CAM_BDR_SENT = 0x17,
205f564de00SScott Long
206f564de00SScott Long /* CCB request terminated by the host */
207f564de00SScott Long CAM_REQ_TERMIO = 0x18,
208f564de00SScott Long
209f564de00SScott Long /* Unrecoverable Host Bus Adapter Error */
210f564de00SScott Long CAM_UNREC_HBA_ERROR = 0x19,
211f564de00SScott Long
212f564de00SScott Long /* Request was too large for this host */
213f564de00SScott Long CAM_REQ_TOO_BIG = 0x1a,
214f564de00SScott Long
215f564de00SScott Long /*
2168b8a9b1dSJustin T. Gibbs * This request should be requeued to preserve
2178b8a9b1dSJustin T. Gibbs * transaction ordering. This typically occurs
2188b8a9b1dSJustin T. Gibbs * when the SIM recognizes an error that should
2198b8a9b1dSJustin T. Gibbs * freeze the queue and must place additional
2208b8a9b1dSJustin T. Gibbs * requests for the target at the sim level
2218b8a9b1dSJustin T. Gibbs * back into the XPT queue.
2228b8a9b1dSJustin T. Gibbs */
223f564de00SScott Long CAM_REQUEUE_REQ = 0x1b,
2248b8a9b1dSJustin T. Gibbs
225f564de00SScott Long /* ATA error, look at error code in CCB */
226f564de00SScott Long CAM_ATA_STATUS_ERROR = 0x1c,
227f564de00SScott Long
228f564de00SScott Long /* Initiator/Target Nexus lost. */
229f564de00SScott Long CAM_SCSI_IT_NEXUS_LOST = 0x1d,
230f564de00SScott Long
231f564de00SScott Long /* SMP error, look at error code in CCB */
232f564de00SScott Long CAM_SMP_STATUS_ERROR = 0x1e,
233f564de00SScott Long
234f564de00SScott Long /*
235f564de00SScott Long * Command completed without error but exceeded the soft
236f564de00SScott Long * timeout threshold.
237f564de00SScott Long */
238f564de00SScott Long CAM_REQ_SOFTTIMEOUT = 0x1f,
239f564de00SScott Long
240f564de00SScott Long /*
241774ab87cSWarner Losh * NVME error, look at errro code in CCB
242774ab87cSWarner Losh */
243774ab87cSWarner Losh CAM_NVME_STATUS_ERROR = 0x20,
244774ab87cSWarner Losh
245774ab87cSWarner Losh /*
246774ab87cSWarner Losh * 0x21 - 0x32 are unassigned
247f564de00SScott Long */
248f564de00SScott Long
249f564de00SScott Long /* Initiator Detected Error */
250f564de00SScott Long CAM_IDE = 0x33,
251f564de00SScott Long
252f564de00SScott Long /* Resource Unavailable */
253f564de00SScott Long CAM_RESRC_UNAVAIL = 0x34,
254f564de00SScott Long
255f564de00SScott Long /* Unacknowledged Event by Host */
256f564de00SScott Long CAM_UNACKED_EVENT = 0x35,
257f564de00SScott Long
258f564de00SScott Long /* Message Received in Host Target Mode */
259f564de00SScott Long CAM_MESSAGE_RECV = 0x36,
260f564de00SScott Long
261f564de00SScott Long /* Invalid CDB received in Host Target Mode */
262f564de00SScott Long CAM_INVALID_CDB = 0x37,
263f564de00SScott Long
264f564de00SScott Long /* Lun supplied is invalid */
265f564de00SScott Long CAM_LUN_INVALID = 0x38,
266f564de00SScott Long
267f564de00SScott Long /* Target ID supplied is invalid */
268f564de00SScott Long CAM_TID_INVALID = 0x39,
269f564de00SScott Long
270f564de00SScott Long /* The requested function is not available */
271f564de00SScott Long CAM_FUNC_NOTAVAIL = 0x3a,
272f564de00SScott Long
273f564de00SScott Long /* Nexus is not established */
274f564de00SScott Long CAM_NO_NEXUS = 0x3b,
275f564de00SScott Long
276f564de00SScott Long /* The initiator ID is invalid */
277f564de00SScott Long CAM_IID_INVALID = 0x3c,
278f564de00SScott Long
279f564de00SScott Long /* The SCSI CDB has been received */
280f564de00SScott Long CAM_CDB_RECVD = 0x3d,
281f564de00SScott Long
282f564de00SScott Long /* The LUN is already enabled for target mode */
283f564de00SScott Long CAM_LUN_ALRDY_ENA = 0x3e,
284f564de00SScott Long
285f564de00SScott Long /* SCSI Bus Busy */
286f564de00SScott Long CAM_SCSI_BUSY = 0x3f,
287f564de00SScott Long
288f564de00SScott Long /*
289f564de00SScott Long * Flags
290f564de00SScott Long */
291f564de00SScott Long
292f564de00SScott Long /* The DEV queue is frozen w/this err */
293f564de00SScott Long CAM_DEV_QFRZN = 0x40,
2948b8a9b1dSJustin T. Gibbs
2958b8a9b1dSJustin T. Gibbs /* Autosense data valid for target */
2968b8a9b1dSJustin T. Gibbs CAM_AUTOSNS_VALID = 0x80,
2978b8a9b1dSJustin T. Gibbs
298f564de00SScott Long /* SIM ready to take more commands */
299f564de00SScott Long CAM_RELEASE_SIMQ = 0x100,
3005fd6140dSMatt Jacob
30128323addSBryan Drewery /* SIM has this command in its queue */
302f564de00SScott Long CAM_SIM_QUEUED = 0x200,
303f564de00SScott Long
304f564de00SScott Long /* Quality of service data is valid */
305f564de00SScott Long CAM_QOS_VALID = 0x400,
306f564de00SScott Long
307f564de00SScott Long /* Mask bits for just the status # */
308f564de00SScott Long CAM_STATUS_MASK = 0x3F,
309f564de00SScott Long
310f564de00SScott Long /*
311f564de00SScott Long * Target Specific Adjunct Status
312f564de00SScott Long */
313f564de00SScott Long
314f564de00SScott Long /* sent sense with status */
315f564de00SScott Long CAM_SENT_SENSE = 0x40000000
3168b8a9b1dSJustin T. Gibbs } cam_status;
3178b8a9b1dSJustin T. Gibbs
3183393f8daSKenneth D. Merry typedef enum {
3193393f8daSKenneth D. Merry CAM_ESF_NONE = 0x00,
3203393f8daSKenneth D. Merry CAM_ESF_COMMAND = 0x01,
3213393f8daSKenneth D. Merry CAM_ESF_CAM_STATUS = 0x02,
3223393f8daSKenneth D. Merry CAM_ESF_PROTO_STATUS = 0x04,
3233393f8daSKenneth D. Merry CAM_ESF_ALL = 0xff
3243393f8daSKenneth D. Merry } cam_error_string_flags;
3253393f8daSKenneth D. Merry
3263393f8daSKenneth D. Merry typedef enum {
3273393f8daSKenneth D. Merry CAM_EPF_NONE = 0x00,
3283393f8daSKenneth D. Merry CAM_EPF_MINIMAL = 0x01,
3293393f8daSKenneth D. Merry CAM_EPF_NORMAL = 0x02,
3303393f8daSKenneth D. Merry CAM_EPF_ALL = 0x03,
3313393f8daSKenneth D. Merry CAM_EPF_LEVEL_MASK = 0x0f
3323393f8daSKenneth D. Merry /* All bits above bit 3 are protocol-specific */
3333393f8daSKenneth D. Merry } cam_error_proto_flags;
3343393f8daSKenneth D. Merry
3353393f8daSKenneth D. Merry typedef enum {
3363393f8daSKenneth D. Merry CAM_ESF_PRINT_NONE = 0x00,
3373393f8daSKenneth D. Merry CAM_ESF_PRINT_STATUS = 0x10,
3383393f8daSKenneth D. Merry CAM_ESF_PRINT_SENSE = 0x20
3393393f8daSKenneth D. Merry } cam_error_scsi_flags;
3403393f8daSKenneth D. Merry
3418691755dSAlexander Motin typedef enum {
34206e79492SKenneth D. Merry CAM_ESMF_PRINT_NONE = 0x00,
34306e79492SKenneth D. Merry CAM_ESMF_PRINT_STATUS = 0x10,
34406e79492SKenneth D. Merry CAM_ESMF_PRINT_FULL_CMD = 0x20,
34506e79492SKenneth D. Merry } cam_error_smp_flags;
34606e79492SKenneth D. Merry
34706e79492SKenneth D. Merry typedef enum {
3488691755dSAlexander Motin CAM_EAF_PRINT_NONE = 0x00,
3498691755dSAlexander Motin CAM_EAF_PRINT_STATUS = 0x10,
3508691755dSAlexander Motin CAM_EAF_PRINT_RESULT = 0x20
3518691755dSAlexander Motin } cam_error_ata_flags;
3528691755dSAlexander Motin
3535672fac9SKenneth D. Merry typedef enum {
3545672fac9SKenneth D. Merry CAM_STRVIS_FLAG_NONE = 0x00,
3555672fac9SKenneth D. Merry CAM_STRVIS_FLAG_NONASCII_MASK = 0x03,
3565672fac9SKenneth D. Merry CAM_STRVIS_FLAG_NONASCII_TRIM = 0x00,
3575672fac9SKenneth D. Merry CAM_STRVIS_FLAG_NONASCII_RAW = 0x01,
3585672fac9SKenneth D. Merry CAM_STRVIS_FLAG_NONASCII_SPC = 0x02,
3595672fac9SKenneth D. Merry CAM_STRVIS_FLAG_NONASCII_ESC = 0x03
3605672fac9SKenneth D. Merry } cam_strvis_flags;
3615672fac9SKenneth D. Merry
3623393f8daSKenneth D. Merry struct cam_status_entry
3633393f8daSKenneth D. Merry {
3643393f8daSKenneth D. Merry cam_status status_code;
3653393f8daSKenneth D. Merry const char *status_text;
3663393f8daSKenneth D. Merry };
3673393f8daSKenneth D. Merry
3683393f8daSKenneth D. Merry extern const struct cam_status_entry cam_status_table[];
3693393f8daSKenneth D. Merry extern const int num_cam_status_entries;
3705f83aee5SSteven Hartland #ifdef _KERNEL
3715f83aee5SSteven Hartland extern int cam_sort_io_queues;
3725f83aee5SSteven Hartland #endif
3733393f8daSKenneth D. Merry union ccb;
3745672fac9SKenneth D. Merry struct sbuf;
3753393f8daSKenneth D. Merry
37665c38256SMike Smith #ifdef SYSCTL_DECL /* from sysctl.h */
37765c38256SMike Smith SYSCTL_DECL(_kern_cam);
37865c38256SMike Smith #endif
37965c38256SMike Smith
3808b8a9b1dSJustin T. Gibbs __BEGIN_DECLS
3818b8a9b1dSJustin T. Gibbs typedef int (cam_quirkmatch_t)(caddr_t, caddr_t);
3828b8a9b1dSJustin T. Gibbs
3838b8a9b1dSJustin T. Gibbs caddr_t cam_quirkmatch(caddr_t target, caddr_t quirk_table, int num_entries,
3848b8a9b1dSJustin T. Gibbs int entry_size, cam_quirkmatch_t *comp_func);
3858b8a9b1dSJustin T. Gibbs
3867af2f2c8SWarner Losh void cam_strvis(uint8_t *dst, const uint8_t *src, int srclen, int dstlen);
3877af2f2c8SWarner Losh void cam_strvis_flag(uint8_t *dst, const uint8_t *src, int srclen,
3883090d504SKenneth D. Merry int dstlen, uint32_t flags);
3897af2f2c8SWarner Losh void cam_strvis_sbuf(struct sbuf *sb, const uint8_t *src, int srclen,
3905672fac9SKenneth D. Merry uint32_t flags);
3918b8a9b1dSJustin T. Gibbs
3927af2f2c8SWarner Losh int cam_strmatch(const uint8_t *str, const uint8_t *pattern, int str_len);
3933393f8daSKenneth D. Merry const struct cam_status_entry*
3943393f8daSKenneth D. Merry cam_fetch_status_entry(cam_status status);
3953393f8daSKenneth D. Merry #ifdef _KERNEL
3963393f8daSKenneth D. Merry char * cam_error_string(union ccb *ccb, char *str, int str_len,
3973393f8daSKenneth D. Merry cam_error_string_flags flags,
3983393f8daSKenneth D. Merry cam_error_proto_flags proto_flags);
3993393f8daSKenneth D. Merry void cam_error_print(union ccb *ccb, cam_error_string_flags flags,
4003393f8daSKenneth D. Merry cam_error_proto_flags proto_flags);
4013393f8daSKenneth D. Merry #else /* _KERNEL */
4023393f8daSKenneth D. Merry struct cam_device;
4033393f8daSKenneth D. Merry
4043393f8daSKenneth D. Merry char * cam_error_string(struct cam_device *device, union ccb *ccb, char *str,
4053393f8daSKenneth D. Merry int str_len, cam_error_string_flags flags,
4063393f8daSKenneth D. Merry cam_error_proto_flags proto_flags);
4073393f8daSKenneth D. Merry void cam_error_print(struct cam_device *device, union ccb *ccb,
4083393f8daSKenneth D. Merry cam_error_string_flags flags,
4093393f8daSKenneth D. Merry cam_error_proto_flags proto_flags, FILE *ofile);
4103393f8daSKenneth D. Merry #endif /* _KERNEL */
4118b8a9b1dSJustin T. Gibbs __END_DECLS
4128b8a9b1dSJustin T. Gibbs
413c4473420SPeter Wemm #ifdef _KERNEL
cam_init_pinfo(cam_pinfo * pinfo)4148b8a9b1dSJustin T. Gibbs static __inline void cam_init_pinfo(cam_pinfo *pinfo)
4158b8a9b1dSJustin T. Gibbs {
4168b8a9b1dSJustin T. Gibbs pinfo->priority = CAM_PRIORITY_NONE;
4178b8a9b1dSJustin T. Gibbs pinfo->index = CAM_UNQUEUED_INDEX;
4188b8a9b1dSJustin T. Gibbs }
419c4473420SPeter Wemm #endif
4208b8a9b1dSJustin T. Gibbs
4218b8a9b1dSJustin T. Gibbs #endif /* _CAM_CAM_H */
422