xref: /freebsd/sys/cam/cam_ccb.h (revision bf8bb7acc02b8e3bdcf16c64d7c28ec1f45a04c0)
18b8a9b1dSJustin T. Gibbs /*
28b8a9b1dSJustin T. Gibbs  * Data structures and definitions for CAM Control Blocks (CCBs).
38b8a9b1dSJustin T. Gibbs  *
48b8a9b1dSJustin T. Gibbs  * Copyright (c) 1997, 1998 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  *
28bf8bb7acSJustin T. Gibbs  *      $Id: cam_ccb.h,v 1.7 1999/05/23 18:57:28 gibbs Exp $
298b8a9b1dSJustin T. Gibbs  */
308b8a9b1dSJustin T. Gibbs 
318b8a9b1dSJustin T. Gibbs #ifndef _CAM_CAM_CCB_H
328b8a9b1dSJustin T. Gibbs #define _CAM_CAM_CCB_H 1
338b8a9b1dSJustin T. Gibbs 
348b8a9b1dSJustin T. Gibbs #include <sys/queue.h>
358b8a9b1dSJustin T. Gibbs #include <sys/cdefs.h>
3687cfaf0eSJustin T. Gibbs #include <sys/time.h>
378b8a9b1dSJustin T. Gibbs #ifndef KERNEL
388b8a9b1dSJustin T. Gibbs #include <sys/callout.h>
398b8a9b1dSJustin T. Gibbs #endif
408b8a9b1dSJustin T. Gibbs #include <cam/cam_debug.h>
418b8a9b1dSJustin T. Gibbs #include <cam/scsi/scsi_all.h>
428b8a9b1dSJustin T. Gibbs 
438b8a9b1dSJustin T. Gibbs 
448b8a9b1dSJustin T. Gibbs /* General allocation length definitions for CCB structures */
458b8a9b1dSJustin T. Gibbs #define	IOCDBLEN	CAM_MAX_CDBLEN	/* Space for CDB bytes/pointer */
468b8a9b1dSJustin T. Gibbs #define	VUHBALEN	14		/* Vendor Unique HBA length */
478b8a9b1dSJustin T. Gibbs #define	SIM_IDLEN	16		/* ASCII string len for SIM ID */
488b8a9b1dSJustin T. Gibbs #define	HBA_IDLEN	16		/* ASCII string len for HBA ID */
498b8a9b1dSJustin T. Gibbs #define	DEV_IDLEN	16		/* ASCII string len for device names */
508b8a9b1dSJustin T. Gibbs #define CCB_PERIPH_PRIV_SIZE 	2	/* size of peripheral private area */
518b8a9b1dSJustin T. Gibbs #define CCB_SIM_PRIV_SIZE 	2	/* size of sim private area */
528b8a9b1dSJustin T. Gibbs 
538b8a9b1dSJustin T. Gibbs /* Struct definitions for CAM control blocks */
548b8a9b1dSJustin T. Gibbs 
558b8a9b1dSJustin T. Gibbs /* Common CCB header */
568b8a9b1dSJustin T. Gibbs /* CAM CCB flags */
578b8a9b1dSJustin T. Gibbs typedef enum {
588b8a9b1dSJustin T. Gibbs 	CAM_CDB_POINTER		= 0x00000001,/* The CDB field is a pointer    */
598b8a9b1dSJustin T. Gibbs 	CAM_QUEUE_ENABLE	= 0x00000002,/* SIM queue actions are enabled */
608b8a9b1dSJustin T. Gibbs 	CAM_CDB_LINKED		= 0x00000004,/* CCB contains a linked CDB     */
618b8a9b1dSJustin T. Gibbs 	CAM_SCATTER_VALID	= 0x00000010,/* Scatter/gather list is valid  */
628b8a9b1dSJustin T. Gibbs 	CAM_DIS_AUTOSENSE	= 0x00000020,/* Disable autosense feature     */
638b8a9b1dSJustin T. Gibbs 	CAM_DIR_RESV		= 0x00000000,/* Data direction (00:reserved)  */
648b8a9b1dSJustin T. Gibbs 	CAM_DIR_IN		= 0x00000040,/* Data direction (01:DATA IN)   */
658b8a9b1dSJustin T. Gibbs 	CAM_DIR_OUT		= 0x00000080,/* Data direction (10:DATA OUT)  */
668b8a9b1dSJustin T. Gibbs 	CAM_DIR_NONE		= 0x000000C0,/* Data direction (11:no data)   */
678b8a9b1dSJustin T. Gibbs 	CAM_DIR_MASK		= 0x000000C0,/* Data direction Mask	      */
688b8a9b1dSJustin T. Gibbs 	CAM_SOFT_RST_OP		= 0x00000100,/* Use Soft reset alternative    */
698b8a9b1dSJustin T. Gibbs 	CAM_ENG_SYNC		= 0x00000200,/* Flush resid bytes on complete */
708b8a9b1dSJustin T. Gibbs 	CAM_DEV_QFRZDIS		= 0x00000400,/* Disable DEV Q freezing	      */
718b8a9b1dSJustin T. Gibbs 	CAM_DEV_QFREEZE		= 0x00000800,/* Freeze DEV Q on execution     */
728b8a9b1dSJustin T. Gibbs 	CAM_HIGH_POWER		= 0x00001000,/* Command takes a lot of power  */
738b8a9b1dSJustin T. Gibbs 	CAM_SENSE_PTR		= 0x00002000,/* Sense data is a pointer	      */
748b8a9b1dSJustin T. Gibbs 	CAM_SENSE_PHYS		= 0x00004000,/* Sense pointer is physical addr*/
758b8a9b1dSJustin T. Gibbs 	CAM_TAG_ACTION_VALID	= 0x00008000,/* Use the tag action in this ccb*/
768b8a9b1dSJustin T. Gibbs 	CAM_PASS_ERR_RECOVER	= 0x00010000,/* Pass driver does err. recovery*/
778b8a9b1dSJustin T. Gibbs 	CAM_DIS_DISCONNECT	= 0x00020000,/* Disable disconnect	      */
788b8a9b1dSJustin T. Gibbs 	CAM_SG_LIST_PHYS	= 0x00040000,/* SG list has physical addrs.   */
798b8a9b1dSJustin T. Gibbs 	CAM_MSG_BUF_PHYS	= 0x00080000,/* Message buffer ptr is physical*/
808b8a9b1dSJustin T. Gibbs 	CAM_SNS_BUF_PHYS	= 0x00100000,/* Autosense data ptr is physical*/
818b8a9b1dSJustin T. Gibbs 	CAM_DATA_PHYS		= 0x00200000,/* SG/Buffer data ptrs are phys. */
828b8a9b1dSJustin T. Gibbs 	CAM_CDB_PHYS		= 0x00400000,/* CDB poiner is physical	      */
838b8a9b1dSJustin T. Gibbs 	CAM_ENG_SGLIST		= 0x00800000,/* SG list is for the HBA engine */
848b8a9b1dSJustin T. Gibbs 
858b8a9b1dSJustin T. Gibbs /* Phase cognizant mode flags */
868b8a9b1dSJustin T. Gibbs 	CAM_DIS_AUTOSRP		= 0x01000000,/* Diable autosave/restore ptrs  */
878b8a9b1dSJustin T. Gibbs 	CAM_DIS_AUTODISC	= 0x02000000,/* Disable auto disconnect	      */
888b8a9b1dSJustin T. Gibbs 	CAM_TGT_CCB_AVAIL	= 0x04000000,/* Target CCB available	      */
898b8a9b1dSJustin T. Gibbs 	CAM_TGT_PHASE_MODE	= 0x08000000,/* The SIM runs in phase mode    */
908b8a9b1dSJustin T. Gibbs 	CAM_MSGB_VALID		= 0x20000000,/* Message buffer valid	      */
918b8a9b1dSJustin T. Gibbs 	CAM_STATUS_VALID	= 0x40000000,/* Status buffer valid	      */
928b8a9b1dSJustin T. Gibbs 	CAM_DATAB_VALID		= 0x80000000,/* Data buffer valid	      */
938b8a9b1dSJustin T. Gibbs 
948b8a9b1dSJustin T. Gibbs /* Host target Mode flags */
958b8a9b1dSJustin T. Gibbs 	CAM_TERM_IO		= 0x20000000,/* Terminate I/O Message sup.    */
968b8a9b1dSJustin T. Gibbs 	CAM_DISCONNECT		= 0x40000000,/* Disconnects are mandatory     */
978b8a9b1dSJustin T. Gibbs 	CAM_SEND_STATUS		= 0x80000000,/* Send status after data phase  */
988b8a9b1dSJustin T. Gibbs } ccb_flags;
998b8a9b1dSJustin T. Gibbs 
1008b8a9b1dSJustin T. Gibbs /* XPT Opcodes for xpt_action */
1018b8a9b1dSJustin T. Gibbs typedef enum {
1029deea857SKenneth D. Merry /* Function code flags are bits greater than 0xff */
1039deea857SKenneth D. Merry 	XPT_FC_QUEUED		= 0x100,
1049deea857SKenneth D. Merry 				/* Non-immediate function code */
1059deea857SKenneth D. Merry 	XPT_FC_USER_CCB		= 0x200,
1069deea857SKenneth D. Merry 	XPT_FC_XPT_ONLY		= 0x400,
1079deea857SKenneth D. Merry 				/* Only for the transport layer device */
108bf8bb7acSJustin T. Gibbs 	XPT_FC_DEV_QUEUED	= 0x800 | XPT_FC_QUEUED,
109bf8bb7acSJustin T. Gibbs 				/* Passes through the device queues */
1108b8a9b1dSJustin T. Gibbs /* Common function commands: 0x00->0x0F */
1119deea857SKenneth D. Merry 	XPT_NOOP 		= 0x00,
1129deea857SKenneth D. Merry 				/* Execute Nothing */
113bf8bb7acSJustin T. Gibbs 	XPT_SCSI_IO		= 0x01 | XPT_FC_DEV_QUEUED,
1149deea857SKenneth D. Merry 				/* Execute the requested I/O operation */
1159deea857SKenneth D. Merry 	XPT_GDEV_TYPE		= 0x02,
1169deea857SKenneth D. Merry 				/* Get type information for specified device */
1179deea857SKenneth D. Merry 	XPT_GDEVLIST		= 0x03,
1189deea857SKenneth D. Merry 				/* Get a list of peripheral devices */
1199deea857SKenneth D. Merry 	XPT_PATH_INQ		= 0x04,
1209deea857SKenneth D. Merry 				/* Path routing inquiry */
1219deea857SKenneth D. Merry 	XPT_REL_SIMQ		= 0x05,
1229deea857SKenneth D. Merry 				/* Release a frozen SIM queue */
1239deea857SKenneth D. Merry 	XPT_SASYNC_CB		= 0x06,
1249deea857SKenneth D. Merry 				/* Set Asynchronous Callback Parameters */
1259deea857SKenneth D. Merry 	XPT_SDEV_TYPE		= 0x07,
1269deea857SKenneth D. Merry 				/* Set device type information */
1279deea857SKenneth D. Merry 	XPT_SCAN_BUS		= 0x08 | XPT_FC_QUEUED | XPT_FC_USER_CCB
1289deea857SKenneth D. Merry 				       | XPT_FC_XPT_ONLY,
1299deea857SKenneth D. Merry 				/* (Re)Scan the SCSI Bus */
1309deea857SKenneth D. Merry 	XPT_DEV_MATCH		= 0x09 | XPT_FC_XPT_ONLY,
1319deea857SKenneth D. Merry 				/* Get EDT entries matching the given pattern */
1329deea857SKenneth D. Merry 	XPT_DEBUG		= 0x0a,
1339deea857SKenneth D. Merry 				/* Turn on debugging for a bus, target or lun */
13487cfaf0eSJustin T. Gibbs 	XPT_PATH_STATS		= 0x0b,
13587cfaf0eSJustin T. Gibbs 				/* Path statistics (error counts, etc.) */
13687cfaf0eSJustin T. Gibbs 	XPT_GDEV_STATS		= 0x0c,
13787cfaf0eSJustin T. Gibbs 				/* Device statistics (error counts, etc.) */
1388b8a9b1dSJustin T. Gibbs /* SCSI Control Functions: 0x10->0x1F */
1399deea857SKenneth D. Merry 	XPT_ABORT		= 0x10,
1409deea857SKenneth D. Merry 				/* Abort the specified CCB */
1419deea857SKenneth D. Merry 	XPT_RESET_BUS		= 0x11 | XPT_FC_XPT_ONLY,
1429deea857SKenneth D. Merry 				/* Reset the specified SCSI bus */
143bf8bb7acSJustin T. Gibbs 	XPT_RESET_DEV		= 0x12 | XPT_FC_DEV_QUEUED,
1449deea857SKenneth D. Merry 				/* Bus Device Reset the specified SCSI device */
1459deea857SKenneth D. Merry 	XPT_TERM_IO		= 0x13,
1469deea857SKenneth D. Merry 				/* Terminate the I/O process */
1479deea857SKenneth D. Merry 	XPT_SCAN_LUN		= 0x14 | XPT_FC_QUEUED | XPT_FC_USER_CCB
1489deea857SKenneth D. Merry 				       | XPT_FC_XPT_ONLY,
1499deea857SKenneth D. Merry 				/* Scan Logical Unit */
1509deea857SKenneth D. Merry 	XPT_GET_TRAN_SETTINGS	= 0x15,
1519deea857SKenneth D. Merry 				/*
1528b8a9b1dSJustin T. Gibbs 				 * Get default/user transfer settings
1538b8a9b1dSJustin T. Gibbs 				 * for the target
1548b8a9b1dSJustin T. Gibbs 				 */
1559deea857SKenneth D. Merry 	XPT_SET_TRAN_SETTINGS	= 0x16,
1569deea857SKenneth D. Merry 				/*
1578b8a9b1dSJustin T. Gibbs 				 * Set transfer rate/width
1588b8a9b1dSJustin T. Gibbs 				 * negotiation settings
1598b8a9b1dSJustin T. Gibbs 				 */
1609deea857SKenneth D. Merry 	XPT_CALC_GEOMETRY	= 0x17,
1619deea857SKenneth D. Merry 				/*
1628b8a9b1dSJustin T. Gibbs 				 * Calculate the geometry parameters for
1638b8a9b1dSJustin T. Gibbs 				 * a device give the sector size and
1648b8a9b1dSJustin T. Gibbs 				 * volume size.
1658b8a9b1dSJustin T. Gibbs 				 */
1668b8a9b1dSJustin T. Gibbs 
1678b8a9b1dSJustin T. Gibbs /* HBA engine commands 0x20->0x2F */
1689deea857SKenneth D. Merry 	XPT_ENG_INQ		= 0x20 | XPT_FC_XPT_ONLY,
1699deea857SKenneth D. Merry 				/* HBA engine feature inquiry */
170bf8bb7acSJustin T. Gibbs 	XPT_ENG_EXEC		= 0x21 | XPT_FC_DEV_QUEUED | XPT_FC_XPT_ONLY,
1719deea857SKenneth D. Merry 				/* HBA execute engine request */
1728b8a9b1dSJustin T. Gibbs 
1738b8a9b1dSJustin T. Gibbs /* Target mode commands: 0x30->0x3F */
1749deea857SKenneth D. Merry 	XPT_EN_LUN		= 0x30,
1759deea857SKenneth D. Merry 				/* Enable LUN as a target */
176bf8bb7acSJustin T. Gibbs 	XPT_TARGET_IO		= 0x31 | XPT_FC_DEV_QUEUED,
1779deea857SKenneth D. Merry 				/* Execute target I/O request */
1789deea857SKenneth D. Merry 	XPT_ACCEPT_TARGET_IO	= 0x32 | XPT_FC_QUEUED | XPT_FC_USER_CCB,
1799deea857SKenneth D. Merry 				/* Accept Host Target Mode CDB */
180bf8bb7acSJustin T. Gibbs 	XPT_CONT_TARGET_IO	= 0x33 | XPT_FC_DEV_QUEUED,
1819deea857SKenneth D. Merry 				/* Continue Host Target I/O Connection */
1829deea857SKenneth D. Merry 	XPT_IMMED_NOTIFY	= 0x34 | XPT_FC_QUEUED | XPT_FC_USER_CCB,
1839deea857SKenneth D. Merry 				/* Notify Host Target driver of event */
1849deea857SKenneth D. Merry 	XPT_NOTIFY_ACK		= 0x35,
1859deea857SKenneth D. Merry 				/* Acknowledgement of event */
1868b8a9b1dSJustin T. Gibbs 
1878b8a9b1dSJustin T. Gibbs /* Vendor Unique codes: 0x80->0x8F */
1888b8a9b1dSJustin T. Gibbs 	XPT_VUNIQUE		= 0x80
1898b8a9b1dSJustin T. Gibbs } xpt_opcode;
1908b8a9b1dSJustin T. Gibbs 
1919deea857SKenneth D. Merry #define XPT_FC_GROUP_MASK		0xF0
1929deea857SKenneth D. Merry #define XPT_FC_GROUP(op) ((op) & XPT_FC_GROUP_MASK)
1939deea857SKenneth D. Merry #define XPT_FC_GROUP_COMMON		0x00
1949deea857SKenneth D. Merry #define XPT_FC_GROUP_SCSI_CONTROL	0x10
1959deea857SKenneth D. Merry #define XPT_FC_GROUP_HBA_ENGINE		0x20
1969deea857SKenneth D. Merry #define XPT_FC_GROUP_TMODE		0x30
1979deea857SKenneth D. Merry #define XPT_FC_GROUP_VENDOR_UNIQUE	0x80
198a89bb8b4SJustin T. Gibbs 
199bf8bb7acSJustin T. Gibbs #define XPT_FC_IS_DEV_QUEUED(ccb) 	\
200bf8bb7acSJustin T. Gibbs     (((ccb)->ccb_h.func_code & XPT_FC_DEV_QUEUED) == XPT_FC_DEV_QUEUED)
201bf8bb7acSJustin T. Gibbs #define XPT_FC_IS_QUEUED(ccb) 	\
202bf8bb7acSJustin T. Gibbs     (((ccb)->ccb_h.func_code & XPT_FC_QUEUED) != 0)
2038b8a9b1dSJustin T. Gibbs typedef union {
2048b8a9b1dSJustin T. Gibbs 	LIST_ENTRY(ccb_hdr) le;
2058b8a9b1dSJustin T. Gibbs 	SLIST_ENTRY(ccb_hdr) sle;
2068b8a9b1dSJustin T. Gibbs 	TAILQ_ENTRY(ccb_hdr) tqe;
2078b8a9b1dSJustin T. Gibbs 	STAILQ_ENTRY(ccb_hdr) stqe;
2088b8a9b1dSJustin T. Gibbs } camq_entry;
2098b8a9b1dSJustin T. Gibbs 
2108b8a9b1dSJustin T. Gibbs typedef union {
2118b8a9b1dSJustin T. Gibbs 	void		*ptr;
2128b8a9b1dSJustin T. Gibbs 	u_long		field;
2138b8a9b1dSJustin T. Gibbs 	u_int8_t	bytes[sizeof(void *) > sizeof(u_long)
2148b8a9b1dSJustin T. Gibbs 			      ? sizeof(void *) : sizeof(u_long)];
2158b8a9b1dSJustin T. Gibbs } ccb_priv_entry;
2168b8a9b1dSJustin T. Gibbs 
2178b8a9b1dSJustin T. Gibbs typedef union {
2188b8a9b1dSJustin T. Gibbs 	ccb_priv_entry	entries[CCB_PERIPH_PRIV_SIZE];
2198b8a9b1dSJustin T. Gibbs 	u_int8_t	bytes[CCB_PERIPH_PRIV_SIZE * sizeof(ccb_priv_entry)];
2208b8a9b1dSJustin T. Gibbs } ccb_ppriv_area;
2218b8a9b1dSJustin T. Gibbs 
2228b8a9b1dSJustin T. Gibbs typedef union {
2238b8a9b1dSJustin T. Gibbs 	ccb_priv_entry	entries[CCB_SIM_PRIV_SIZE];
2248b8a9b1dSJustin T. Gibbs 	u_int8_t	bytes[CCB_SIM_PRIV_SIZE * sizeof(ccb_priv_entry)];
2258b8a9b1dSJustin T. Gibbs } ccb_spriv_area;
2268b8a9b1dSJustin T. Gibbs 
2278b8a9b1dSJustin T. Gibbs struct ccb_hdr {
2288b8a9b1dSJustin T. Gibbs 	cam_pinfo	pinfo;	/* Info for priority scheduling */
2298b8a9b1dSJustin T. Gibbs 	camq_entry	xpt_links;	/* For chaining in the XPT layer */
2308b8a9b1dSJustin T. Gibbs 	camq_entry	sim_links;	/* For chaining in the SIM layer */
2318b8a9b1dSJustin T. Gibbs 	camq_entry	periph_links;/* For chaining in the type driver */
2328b8a9b1dSJustin T. Gibbs 	u_int32_t	retry_count;
2338b8a9b1dSJustin T. Gibbs 	                        /* Callback on completion function */
2348b8a9b1dSJustin T. Gibbs 	void		(*cbfcnp)(struct cam_periph *, union ccb *);
2358b8a9b1dSJustin T. Gibbs 	xpt_opcode	func_code;	/* XPT function code */
2368b8a9b1dSJustin T. Gibbs 	u_int32_t	status;	/* Status returned by CAM subsystem */
2378b8a9b1dSJustin T. Gibbs 				/* Compiled path for this ccb */
2388b8a9b1dSJustin T. Gibbs 	struct		cam_path *path;
2398b8a9b1dSJustin T. Gibbs 	path_id_t	path_id;	/* Path ID for the request */
2408b8a9b1dSJustin T. Gibbs 	target_id_t	target_id;	/* Target device ID */
2418b8a9b1dSJustin T. Gibbs 	lun_id_t	target_lun;	/* Target LUN number */
2428b8a9b1dSJustin T. Gibbs 	u_int32_t	flags;
2438b8a9b1dSJustin T. Gibbs 	ccb_ppriv_area	periph_priv;
2448b8a9b1dSJustin T. Gibbs 	ccb_spriv_area	sim_priv;
2458b8a9b1dSJustin T. Gibbs 	u_int32_t	timeout;	/* Timeout value */
2468b8a9b1dSJustin T. Gibbs 					/* Callout handle used for timeouts */
2478b8a9b1dSJustin T. Gibbs 	struct		callout_handle timeout_ch;
2488b8a9b1dSJustin T. Gibbs };
2498b8a9b1dSJustin T. Gibbs 
2508b8a9b1dSJustin T. Gibbs /* Get Device Information CCB */
2518b8a9b1dSJustin T. Gibbs struct ccb_getdev {
2528b8a9b1dSJustin T. Gibbs 	struct	  ccb_hdr ccb_h;
2538b8a9b1dSJustin T. Gibbs 	struct	  scsi_inquiry_data inq_data;
2548b8a9b1dSJustin T. Gibbs 	u_int8_t  serial_num[252];
2558b8a9b1dSJustin T. Gibbs 	u_int8_t  serial_num_len;
2568b8a9b1dSJustin T. Gibbs 	u_int8_t  pd_type;	/* returned peripheral device type */
25787cfaf0eSJustin T. Gibbs /*
25887cfaf0eSJustin T. Gibbs  * GARBAGE COLLECT
25987cfaf0eSJustin T. Gibbs  * Moved to ccb_getdevstats but left here for binary compatibility.
26082815562SJustin T. Gibbs  * Remove during next bump in CAM major version.
26187cfaf0eSJustin T. Gibbs  */
2628b8a9b1dSJustin T. Gibbs 	int	  dev_openings;	/* Space left for more work on device*/
2638b8a9b1dSJustin T. Gibbs 	int	  dev_active;	/* Transactions running on the device */
2648b8a9b1dSJustin T. Gibbs 	int	  devq_openings;/* Space left for more queued work */
2658b8a9b1dSJustin T. Gibbs 	int	  devq_queued;	/* Transactions queued to be sent */
2668b8a9b1dSJustin T. Gibbs 	int	  held;		/*
2678b8a9b1dSJustin T. Gibbs 				 * CCBs held by peripheral drivers
2688b8a9b1dSJustin T. Gibbs 				 * for this device
2698b8a9b1dSJustin T. Gibbs 				 */
2709deea857SKenneth D. Merry 	int	  maxtags;	/*
2718b8a9b1dSJustin T. Gibbs 				 * Boundary conditions for number of
2728b8a9b1dSJustin T. Gibbs 				 * tagged operations
2738b8a9b1dSJustin T. Gibbs 				 */
2749deea857SKenneth D. Merry 	int	  mintags;
2758b8a9b1dSJustin T. Gibbs };
2768b8a9b1dSJustin T. Gibbs 
27787cfaf0eSJustin T. Gibbs /* Device Statistics CCB */
27887cfaf0eSJustin T. Gibbs struct ccb_getdevstats {
27987cfaf0eSJustin T. Gibbs 	struct	ccb_hdr	ccb_h;
28087cfaf0eSJustin T. Gibbs 	int	dev_openings;	/* Space left for more work on device*/
28187cfaf0eSJustin T. Gibbs 	int	dev_active;	/* Transactions running on the device */
28287cfaf0eSJustin T. Gibbs 	int	devq_openings;	/* Space left for more queued work */
28387cfaf0eSJustin T. Gibbs 	int	devq_queued;	/* Transactions queued to be sent */
28487cfaf0eSJustin T. Gibbs 	int	held;		/*
28587cfaf0eSJustin T. Gibbs 				 * CCBs held by peripheral drivers
28687cfaf0eSJustin T. Gibbs 				 * for this device
28787cfaf0eSJustin T. Gibbs 				 */
28882815562SJustin T. Gibbs 	int	maxtags;	/*
28982815562SJustin T. Gibbs 				 * Boundary conditions for number of
29082815562SJustin T. Gibbs 				 * tagged operations
29182815562SJustin T. Gibbs 				 */
29282815562SJustin T. Gibbs 	int	mintags;
29387cfaf0eSJustin T. Gibbs 	struct	timeval last_reset;	/* Time of last bus reset/loop init */
29487cfaf0eSJustin T. Gibbs };
2958b8a9b1dSJustin T. Gibbs 
2968b8a9b1dSJustin T. Gibbs typedef enum {
2978b8a9b1dSJustin T. Gibbs 	CAM_GDEVLIST_LAST_DEVICE,
2988b8a9b1dSJustin T. Gibbs 	CAM_GDEVLIST_LIST_CHANGED,
2998b8a9b1dSJustin T. Gibbs 	CAM_GDEVLIST_MORE_DEVS,
3008b8a9b1dSJustin T. Gibbs 	CAM_GDEVLIST_ERROR
3018b8a9b1dSJustin T. Gibbs } ccb_getdevlist_status_e;
3028b8a9b1dSJustin T. Gibbs 
3038b8a9b1dSJustin T. Gibbs struct ccb_getdevlist {
3048b8a9b1dSJustin T. Gibbs 	struct ccb_hdr		ccb_h;
3058b8a9b1dSJustin T. Gibbs 	char 			periph_name[DEV_IDLEN];
3068b8a9b1dSJustin T. Gibbs 	u_int32_t		unit_number;
3078b8a9b1dSJustin T. Gibbs 	unsigned int		generation;
3088b8a9b1dSJustin T. Gibbs 	u_int32_t		index;
3098b8a9b1dSJustin T. Gibbs 	ccb_getdevlist_status_e	status;
3108b8a9b1dSJustin T. Gibbs };
3118b8a9b1dSJustin T. Gibbs 
3128b8a9b1dSJustin T. Gibbs typedef enum {
3138b8a9b1dSJustin T. Gibbs 	PERIPH_MATCH_NONE	= 0x000,
3148b8a9b1dSJustin T. Gibbs 	PERIPH_MATCH_PATH	= 0x001,
3158b8a9b1dSJustin T. Gibbs 	PERIPH_MATCH_TARGET	= 0x002,
3168b8a9b1dSJustin T. Gibbs 	PERIPH_MATCH_LUN	= 0x004,
3178b8a9b1dSJustin T. Gibbs 	PERIPH_MATCH_NAME	= 0x008,
3188b8a9b1dSJustin T. Gibbs 	PERIPH_MATCH_UNIT	= 0x010,
3198b8a9b1dSJustin T. Gibbs 	PERIPH_MATCH_ANY	= 0x01f
3208b8a9b1dSJustin T. Gibbs } periph_pattern_flags;
3218b8a9b1dSJustin T. Gibbs 
3228b8a9b1dSJustin T. Gibbs struct periph_match_pattern {
3238b8a9b1dSJustin T. Gibbs 	char			periph_name[DEV_IDLEN];
3248b8a9b1dSJustin T. Gibbs 	u_int32_t		unit_number;
3258b8a9b1dSJustin T. Gibbs 	path_id_t		path_id;
3268b8a9b1dSJustin T. Gibbs 	target_id_t		target_id;
3278b8a9b1dSJustin T. Gibbs 	lun_id_t		target_lun;
3288b8a9b1dSJustin T. Gibbs 	periph_pattern_flags	flags;
3298b8a9b1dSJustin T. Gibbs };
3308b8a9b1dSJustin T. Gibbs 
3318b8a9b1dSJustin T. Gibbs typedef enum {
3328b8a9b1dSJustin T. Gibbs 	DEV_MATCH_NONE		= 0x000,
3338b8a9b1dSJustin T. Gibbs 	DEV_MATCH_PATH		= 0x001,
3348b8a9b1dSJustin T. Gibbs 	DEV_MATCH_TARGET	= 0x002,
3358b8a9b1dSJustin T. Gibbs 	DEV_MATCH_LUN		= 0x004,
3368b8a9b1dSJustin T. Gibbs 	DEV_MATCH_INQUIRY	= 0x008,
3378b8a9b1dSJustin T. Gibbs 	DEV_MATCH_ANY		= 0x00f
3388b8a9b1dSJustin T. Gibbs } dev_pattern_flags;
3398b8a9b1dSJustin T. Gibbs 
3408b8a9b1dSJustin T. Gibbs struct device_match_pattern {
3418b8a9b1dSJustin T. Gibbs 	path_id_t				path_id;
3428b8a9b1dSJustin T. Gibbs 	target_id_t				target_id;
3438b8a9b1dSJustin T. Gibbs 	lun_id_t				target_lun;
3448b8a9b1dSJustin T. Gibbs 	struct scsi_static_inquiry_pattern	inq_pat;
3458b8a9b1dSJustin T. Gibbs 	dev_pattern_flags			flags;
3468b8a9b1dSJustin T. Gibbs };
3478b8a9b1dSJustin T. Gibbs 
3488b8a9b1dSJustin T. Gibbs typedef enum {
3498b8a9b1dSJustin T. Gibbs 	BUS_MATCH_NONE		= 0x000,
3508b8a9b1dSJustin T. Gibbs 	BUS_MATCH_PATH		= 0x001,
3518b8a9b1dSJustin T. Gibbs 	BUS_MATCH_NAME		= 0x002,
3528b8a9b1dSJustin T. Gibbs 	BUS_MATCH_UNIT		= 0x004,
3538b8a9b1dSJustin T. Gibbs 	BUS_MATCH_BUS_ID	= 0x008,
3548b8a9b1dSJustin T. Gibbs 	BUS_MATCH_ANY		= 0x00f
3558b8a9b1dSJustin T. Gibbs } bus_pattern_flags;
3568b8a9b1dSJustin T. Gibbs 
3578b8a9b1dSJustin T. Gibbs struct bus_match_pattern {
3588b8a9b1dSJustin T. Gibbs 	path_id_t		path_id;
3598b8a9b1dSJustin T. Gibbs 	char			dev_name[DEV_IDLEN];
3608b8a9b1dSJustin T. Gibbs 	u_int32_t		unit_number;
3618b8a9b1dSJustin T. Gibbs 	u_int32_t		bus_id;
3628b8a9b1dSJustin T. Gibbs 	bus_pattern_flags	flags;
3638b8a9b1dSJustin T. Gibbs };
3648b8a9b1dSJustin T. Gibbs 
3658b8a9b1dSJustin T. Gibbs union match_pattern {
3668b8a9b1dSJustin T. Gibbs 	struct periph_match_pattern	periph_pattern;
3678b8a9b1dSJustin T. Gibbs 	struct device_match_pattern	device_pattern;
3688b8a9b1dSJustin T. Gibbs 	struct bus_match_pattern	bus_pattern;
3698b8a9b1dSJustin T. Gibbs };
3708b8a9b1dSJustin T. Gibbs 
3718b8a9b1dSJustin T. Gibbs typedef enum {
3728b8a9b1dSJustin T. Gibbs 	DEV_MATCH_PERIPH,
3738b8a9b1dSJustin T. Gibbs 	DEV_MATCH_DEVICE,
3748b8a9b1dSJustin T. Gibbs 	DEV_MATCH_BUS
3758b8a9b1dSJustin T. Gibbs } dev_match_type;
3768b8a9b1dSJustin T. Gibbs 
3778b8a9b1dSJustin T. Gibbs struct dev_match_pattern {
3788b8a9b1dSJustin T. Gibbs 	dev_match_type		type;
3798b8a9b1dSJustin T. Gibbs 	union match_pattern	pattern;
3808b8a9b1dSJustin T. Gibbs };
3818b8a9b1dSJustin T. Gibbs 
3828b8a9b1dSJustin T. Gibbs struct periph_match_result {
3838b8a9b1dSJustin T. Gibbs 	char			periph_name[DEV_IDLEN];
3848b8a9b1dSJustin T. Gibbs 	u_int32_t		unit_number;
3858b8a9b1dSJustin T. Gibbs 	path_id_t		path_id;
3868b8a9b1dSJustin T. Gibbs 	target_id_t		target_id;
3878b8a9b1dSJustin T. Gibbs 	lun_id_t		target_lun;
3888b8a9b1dSJustin T. Gibbs };
3898b8a9b1dSJustin T. Gibbs 
3909deea857SKenneth D. Merry typedef enum {
3919deea857SKenneth D. Merry 	DEV_RESULT_NOFLAG		= 0x00,
3929deea857SKenneth D. Merry 	DEV_RESULT_UNCONFIGURED		= 0x01
3939deea857SKenneth D. Merry } dev_result_flags;
3949deea857SKenneth D. Merry 
3958b8a9b1dSJustin T. Gibbs struct device_match_result {
3968b8a9b1dSJustin T. Gibbs 	path_id_t			path_id;
3978b8a9b1dSJustin T. Gibbs 	target_id_t			target_id;
3988b8a9b1dSJustin T. Gibbs 	lun_id_t			target_lun;
3998b8a9b1dSJustin T. Gibbs 	struct scsi_inquiry_data	inq_data;
4009deea857SKenneth D. Merry 	dev_result_flags		flags;
4018b8a9b1dSJustin T. Gibbs };
4028b8a9b1dSJustin T. Gibbs 
4038b8a9b1dSJustin T. Gibbs struct bus_match_result {
4048b8a9b1dSJustin T. Gibbs 	path_id_t	path_id;
4058b8a9b1dSJustin T. Gibbs 	char		dev_name[DEV_IDLEN];
4068b8a9b1dSJustin T. Gibbs 	u_int32_t	unit_number;
4078b8a9b1dSJustin T. Gibbs 	u_int32_t	bus_id;
4088b8a9b1dSJustin T. Gibbs };
4098b8a9b1dSJustin T. Gibbs 
4108b8a9b1dSJustin T. Gibbs union match_result {
4118b8a9b1dSJustin T. Gibbs 	struct periph_match_result	periph_result;
4128b8a9b1dSJustin T. Gibbs 	struct device_match_result	device_result;
4138b8a9b1dSJustin T. Gibbs 	struct bus_match_result		bus_result;
4148b8a9b1dSJustin T. Gibbs };
4158b8a9b1dSJustin T. Gibbs 
4168b8a9b1dSJustin T. Gibbs struct dev_match_result {
4178b8a9b1dSJustin T. Gibbs 	dev_match_type		type;
4188b8a9b1dSJustin T. Gibbs 	union match_result	result;
4198b8a9b1dSJustin T. Gibbs };
4208b8a9b1dSJustin T. Gibbs 
4218b8a9b1dSJustin T. Gibbs typedef enum {
4228b8a9b1dSJustin T. Gibbs 	CAM_DEV_MATCH_LAST,
4238b8a9b1dSJustin T. Gibbs 	CAM_DEV_MATCH_MORE,
4248b8a9b1dSJustin T. Gibbs 	CAM_DEV_MATCH_LIST_CHANGED,
4258b8a9b1dSJustin T. Gibbs 	CAM_DEV_MATCH_SIZE_ERROR,
4268b8a9b1dSJustin T. Gibbs 	CAM_DEV_MATCH_ERROR
4278b8a9b1dSJustin T. Gibbs } ccb_dev_match_status;
4288b8a9b1dSJustin T. Gibbs 
4298b8a9b1dSJustin T. Gibbs typedef enum {
4308b8a9b1dSJustin T. Gibbs 	CAM_DEV_POS_NONE	= 0x000,
4318b8a9b1dSJustin T. Gibbs 	CAM_DEV_POS_BUS		= 0x001,
4328b8a9b1dSJustin T. Gibbs 	CAM_DEV_POS_TARGET	= 0x002,
4338b8a9b1dSJustin T. Gibbs 	CAM_DEV_POS_DEVICE	= 0x004,
4348b8a9b1dSJustin T. Gibbs 	CAM_DEV_POS_PERIPH	= 0x008,
4358b8a9b1dSJustin T. Gibbs 	CAM_DEV_POS_PDPTR	= 0x010,
4368b8a9b1dSJustin T. Gibbs 	CAM_DEV_POS_TYPEMASK	= 0xf00,
4378b8a9b1dSJustin T. Gibbs 	CAM_DEV_POS_EDT		= 0x100,
4388b8a9b1dSJustin T. Gibbs 	CAM_DEV_POS_PDRV	= 0x200
4398b8a9b1dSJustin T. Gibbs } dev_pos_type;
4408b8a9b1dSJustin T. Gibbs 
4418b8a9b1dSJustin T. Gibbs struct ccb_dm_cookie {
4428b8a9b1dSJustin T. Gibbs 	void 	*bus;
4438b8a9b1dSJustin T. Gibbs 	void	*target;
4448b8a9b1dSJustin T. Gibbs 	void	*device;
4458b8a9b1dSJustin T. Gibbs 	void	*periph;
4468b8a9b1dSJustin T. Gibbs 	void	*pdrv;
4478b8a9b1dSJustin T. Gibbs };
4488b8a9b1dSJustin T. Gibbs 
4498b8a9b1dSJustin T. Gibbs struct ccb_dev_position {
4508b8a9b1dSJustin T. Gibbs 	u_int			generations[4];
4518b8a9b1dSJustin T. Gibbs #define	CAM_BUS_GENERATION	0x00
4528b8a9b1dSJustin T. Gibbs #define CAM_TARGET_GENERATION	0x01
4538b8a9b1dSJustin T. Gibbs #define CAM_DEV_GENERATION	0x02
4548b8a9b1dSJustin T. Gibbs #define CAM_PERIPH_GENERATION	0x03
4558b8a9b1dSJustin T. Gibbs 	dev_pos_type		position_type;
4568b8a9b1dSJustin T. Gibbs 	struct ccb_dm_cookie	cookie;
4578b8a9b1dSJustin T. Gibbs };
4588b8a9b1dSJustin T. Gibbs 
4598b8a9b1dSJustin T. Gibbs struct ccb_dev_match {
4608b8a9b1dSJustin T. Gibbs 	struct ccb_hdr			ccb_h;
4618b8a9b1dSJustin T. Gibbs 	ccb_dev_match_status		status;
4628b8a9b1dSJustin T. Gibbs 	u_int32_t			num_patterns;
4638b8a9b1dSJustin T. Gibbs 	u_int32_t			pattern_buf_len;
4648b8a9b1dSJustin T. Gibbs 	struct dev_match_pattern	*patterns;
4658b8a9b1dSJustin T. Gibbs 	u_int32_t			num_matches;
4668b8a9b1dSJustin T. Gibbs 	u_int32_t			match_buf_len;
4678b8a9b1dSJustin T. Gibbs 	struct dev_match_result		*matches;
4688b8a9b1dSJustin T. Gibbs 	struct ccb_dev_position		pos;
4698b8a9b1dSJustin T. Gibbs };
4708b8a9b1dSJustin T. Gibbs 
4718b8a9b1dSJustin T. Gibbs /*
4728b8a9b1dSJustin T. Gibbs  * Definitions for the path inquiry CCB fields.
4738b8a9b1dSJustin T. Gibbs  */
4749deea857SKenneth D. Merry #define CAM_VERSION	0x11	/* Hex value for current version */
4758b8a9b1dSJustin T. Gibbs 
4768b8a9b1dSJustin T. Gibbs typedef enum {
4778b8a9b1dSJustin T. Gibbs 	PI_MDP_ABLE	= 0x80,	/* Supports MDP message */
4788b8a9b1dSJustin T. Gibbs 	PI_WIDE_32	= 0x40,	/* Supports 32 bit wide SCSI */
4798b8a9b1dSJustin T. Gibbs 	PI_WIDE_16	= 0x20, /* Supports 16 bit wide SCSI */
4808b8a9b1dSJustin T. Gibbs 	PI_SDTR_ABLE	= 0x10,	/* Supports SDTR message */
4818b8a9b1dSJustin T. Gibbs 	PI_LINKED_CDB	= 0x08, /* Supports linked CDBs */
4828b8a9b1dSJustin T. Gibbs 	PI_TAG_ABLE	= 0x02,	/* Supports tag queue messages */
4838b8a9b1dSJustin T. Gibbs 	PI_SOFT_RST	= 0x01,	/* Supports soft reset alternative */
4848b8a9b1dSJustin T. Gibbs } pi_inqflag;
4858b8a9b1dSJustin T. Gibbs 
4868b8a9b1dSJustin T. Gibbs typedef enum {
4878b8a9b1dSJustin T. Gibbs 	PIT_PROCESSOR	= 0x80,	/* Target mode processor mode */
4888b8a9b1dSJustin T. Gibbs 	PIT_PHASE	= 0x40,	/* Target mode phase cog. mode */
4898b8a9b1dSJustin T. Gibbs 	PIT_DISCONNECT	= 0x20,	/* Disconnects supported in target mode */
4908b8a9b1dSJustin T. Gibbs 	PIT_TERM_IO	= 0x10,	/* Terminate I/O message supported in TM */
4918b8a9b1dSJustin T. Gibbs 	PIT_GRP_6	= 0x08,	/* Group 6 commands supported */
4928b8a9b1dSJustin T. Gibbs 	PIT_GRP_7	= 0x04,	/* Group 7 commands supported */
4938b8a9b1dSJustin T. Gibbs } pi_tmflag;
4948b8a9b1dSJustin T. Gibbs 
4958b8a9b1dSJustin T. Gibbs typedef enum {
4968b8a9b1dSJustin T. Gibbs 	PIM_SCANHILO	= 0x80,	/* Bus scans from high ID to low ID */
4978b8a9b1dSJustin T. Gibbs 	PIM_NOREMOVE	= 0x40,	/* Removeable devices not included in scan */
49898192658SJustin T. Gibbs 	PIM_NOINITIATOR	= 0x20,	/* Initiator role not supported. */
49998192658SJustin T. Gibbs 	PIM_NOBUSRESET  = 0x10, /* User has disabled initial BUS RESET */
5008b8a9b1dSJustin T. Gibbs } pi_miscflag;
5018b8a9b1dSJustin T. Gibbs 
5028b8a9b1dSJustin T. Gibbs /* Path Inquiry CCB */
5038b8a9b1dSJustin T. Gibbs struct ccb_pathinq {
5048b8a9b1dSJustin T. Gibbs 	struct 	    ccb_hdr ccb_h;
5058b8a9b1dSJustin T. Gibbs 	u_int8_t    version_num;	/* Version number for the SIM/HBA */
5068b8a9b1dSJustin T. Gibbs 	u_int8_t    hba_inquiry;	/* Mimic of INQ byte 7 for the HBA */
5078b8a9b1dSJustin T. Gibbs 	u_int8_t    target_sprt;	/* Flags for target mode support */
5088b8a9b1dSJustin T. Gibbs 	u_int8_t    hba_misc;		/* Misc HBA features */
5098b8a9b1dSJustin T. Gibbs 	u_int16_t   hba_eng_cnt;	/* HBA engine count */
5108b8a9b1dSJustin T. Gibbs 					/* Vendor Unique capabilities */
5118b8a9b1dSJustin T. Gibbs 	u_int8_t    vuhba_flags[VUHBALEN];
5128b8a9b1dSJustin T. Gibbs 	u_int32_t   max_target;		/* Maximum supported Target */
5138b8a9b1dSJustin T. Gibbs 	u_int32_t   max_lun;		/* Maximum supported Lun */
5148b8a9b1dSJustin T. Gibbs 	u_int32_t   async_flags;	/* Installed Async handlers */
5158b8a9b1dSJustin T. Gibbs 	path_id_t   hpath_id;		/* Highest Path ID in the subsystem */
5168b8a9b1dSJustin T. Gibbs 	target_id_t initiator_id;	/* ID of the HBA on the SCSI bus */
5178b8a9b1dSJustin T. Gibbs 	char	    sim_vid[SIM_IDLEN];	/* Vendor ID of the SIM */
5188b8a9b1dSJustin T. Gibbs 	char	    hba_vid[HBA_IDLEN];	/* Vendor ID of the HBA */
5198b8a9b1dSJustin T. Gibbs 	char 	    dev_name[DEV_IDLEN];/* Device name for SIM */
5208b8a9b1dSJustin T. Gibbs 	u_int32_t   unit_number;	/* Unit number for SIM */
5218b8a9b1dSJustin T. Gibbs 	u_int32_t   bus_id;		/* Bus ID for SIM */
5229deea857SKenneth D. Merry 	u_int32_t   base_transfer_speed;/* Base bus speed in KB/sec */
5238b8a9b1dSJustin T. Gibbs };
5248b8a9b1dSJustin T. Gibbs 
52587cfaf0eSJustin T. Gibbs /* Path Statistics CCB */
52687cfaf0eSJustin T. Gibbs struct ccb_pathstats {
52787cfaf0eSJustin T. Gibbs 	struct	ccb_hdr	ccb_h;
52887cfaf0eSJustin T. Gibbs 	struct	timeval last_reset;	/* Time of last bus reset/loop init */
52987cfaf0eSJustin T. Gibbs };
53087cfaf0eSJustin T. Gibbs 
5318b8a9b1dSJustin T. Gibbs typedef union {
5328b8a9b1dSJustin T. Gibbs 	u_int8_t *sense_ptr;		/*
5338b8a9b1dSJustin T. Gibbs 					 * Pointer to storage
5348b8a9b1dSJustin T. Gibbs 					 * for sense information
5358b8a9b1dSJustin T. Gibbs 					 */
5368b8a9b1dSJustin T. Gibbs 	                                /* Storage Area for sense information */
5378b8a9b1dSJustin T. Gibbs 	struct	 scsi_sense_data sense_buf;
5388b8a9b1dSJustin T. Gibbs } sense_t;
5398b8a9b1dSJustin T. Gibbs 
5408b8a9b1dSJustin T. Gibbs typedef union {
5418b8a9b1dSJustin T. Gibbs 	u_int8_t  *cdb_ptr;		/* Pointer to the CDB bytes to send */
5428b8a9b1dSJustin T. Gibbs 					/* Area for the CDB send */
5438b8a9b1dSJustin T. Gibbs 	u_int8_t  cdb_bytes[IOCDBLEN];
5448b8a9b1dSJustin T. Gibbs } cdb_t;
5458b8a9b1dSJustin T. Gibbs 
5468b8a9b1dSJustin T. Gibbs /*
5478b8a9b1dSJustin T. Gibbs  * SCSI I/O Request CCB used for the XPT_SCSI_IO and XPT_CONT_TARGET_IO
5488b8a9b1dSJustin T. Gibbs  * function codes.
5498b8a9b1dSJustin T. Gibbs  */
5508b8a9b1dSJustin T. Gibbs struct ccb_scsiio {
5518b8a9b1dSJustin T. Gibbs 	struct	   ccb_hdr ccb_h;
5528b8a9b1dSJustin T. Gibbs 	union	   ccb *next_ccb;	/* Ptr for next CCB for action */
5538b8a9b1dSJustin T. Gibbs 	u_int8_t   *req_map;		/* Ptr to mapping info */
5548b8a9b1dSJustin T. Gibbs 	u_int8_t   *data_ptr;		/* Ptr to the data buf/SG list */
5558b8a9b1dSJustin T. Gibbs 	u_int32_t  dxfer_len;		/* Data transfer length */
5568b8a9b1dSJustin T. Gibbs 					/* Autosense storage */
5578b8a9b1dSJustin T. Gibbs 	struct     scsi_sense_data sense_data;
5588b8a9b1dSJustin T. Gibbs 	u_int8_t   sense_len;		/* Number of bytes to autosense */
5598b8a9b1dSJustin T. Gibbs 	u_int8_t   cdb_len;		/* Number of bytes for the CDB */
5608b8a9b1dSJustin T. Gibbs 	u_int16_t  sglist_cnt;		/* Number of SG list entries */
5618b8a9b1dSJustin T. Gibbs 	u_int8_t   scsi_status;		/* Returned SCSI status */
5628b8a9b1dSJustin T. Gibbs 	u_int8_t   sense_resid;		/* Autosense resid length: 2's comp */
5638b8a9b1dSJustin T. Gibbs 	u_int32_t  resid;		/* Transfer residual length: 2's comp */
5648b8a9b1dSJustin T. Gibbs 	cdb_t	   cdb_io;		/* Union for CDB bytes/pointer */
5658b8a9b1dSJustin T. Gibbs 	u_int8_t   *msg_ptr;		/* Pointer to the message buffer */
5668b8a9b1dSJustin T. Gibbs 	u_int16_t  msg_len;		/* Number of bytes for the Message */
5678b8a9b1dSJustin T. Gibbs 	u_int8_t   tag_action;		/* What to do for tag queueing */
568bb1f2fe4SJustin T. Gibbs 	/*
569bb1f2fe4SJustin T. Gibbs 	 * The tag action should be either the define below (to send a
570bb1f2fe4SJustin T. Gibbs 	 * non-tagged transaction) or one of the defined scsi tag messages
571bb1f2fe4SJustin T. Gibbs 	 * from scsi_message.h.
572bb1f2fe4SJustin T. Gibbs 	 */
573bb1f2fe4SJustin T. Gibbs #define		CAM_TAG_ACTION_NONE	0x00
574bf8bb7acSJustin T. Gibbs 	u_int	   tag_id;		/* tag id from initator (target mode) */
575bf8bb7acSJustin T. Gibbs 	u_int	   init_id;		/* initiator id of who selected */
5768b8a9b1dSJustin T. Gibbs };
5778b8a9b1dSJustin T. Gibbs 
5788b8a9b1dSJustin T. Gibbs struct ccb_accept_tio {
5798b8a9b1dSJustin T. Gibbs 	struct	   ccb_hdr ccb_h;
5808b8a9b1dSJustin T. Gibbs 	cdb_t	   cdb_io;		/* Union for CDB bytes/pointer */
5818b8a9b1dSJustin T. Gibbs 	u_int8_t   cdb_len;		/* Number of bytes for the CDB */
5828b8a9b1dSJustin T. Gibbs 	u_int8_t   tag_action;		/* What to do for tag queueing */
5838b8a9b1dSJustin T. Gibbs 	u_int8_t   tag_id;		/* tag id from initator (target mode) */
5848b8a9b1dSJustin T. Gibbs 	u_int8_t   init_id;		/* initiator id of who selected */
5858b8a9b1dSJustin T. Gibbs };
5868b8a9b1dSJustin T. Gibbs 
5878b8a9b1dSJustin T. Gibbs /* Release SIM Queue */
5888b8a9b1dSJustin T. Gibbs struct ccb_relsim {
5898b8a9b1dSJustin T. Gibbs 	struct ccb_hdr ccb_h;
5908b8a9b1dSJustin T. Gibbs 	u_int32_t      release_flags;
5918b8a9b1dSJustin T. Gibbs #define RELSIM_ADJUST_OPENINGS		0x01
5928b8a9b1dSJustin T. Gibbs #define RELSIM_RELEASE_AFTER_TIMEOUT	0x02
5938b8a9b1dSJustin T. Gibbs #define RELSIM_RELEASE_AFTER_CMDCMPLT	0x04
5948b8a9b1dSJustin T. Gibbs #define RELSIM_RELEASE_AFTER_QEMPTY	0x08
5958b8a9b1dSJustin T. Gibbs 	u_int32_t      openings;
5968b8a9b1dSJustin T. Gibbs 	u_int32_t      release_timeout;
5978b8a9b1dSJustin T. Gibbs 	u_int32_t      qfrozen_cnt;
5988b8a9b1dSJustin T. Gibbs };
5998b8a9b1dSJustin T. Gibbs 
6008b8a9b1dSJustin T. Gibbs /*
6018b8a9b1dSJustin T. Gibbs  * Definitions for the asynchronous callback CCB fields.
6028b8a9b1dSJustin T. Gibbs  */
6038b8a9b1dSJustin T. Gibbs typedef enum {
6048b8a9b1dSJustin T. Gibbs 	AC_GETDEV_CHANGED	= 0x800,/* Getdev info might have changed */
6058b8a9b1dSJustin T. Gibbs 	AC_INQ_CHANGED		= 0x400,/* Inquiry info might have changed */
6068b8a9b1dSJustin T. Gibbs 	AC_TRANSFER_NEG		= 0x200,/* New transfer settings in effect */
6078b8a9b1dSJustin T. Gibbs 	AC_LOST_DEVICE		= 0x100,/* A device went away */
6088b8a9b1dSJustin T. Gibbs 	AC_FOUND_DEVICE		= 0x080,/* A new device was found */
6098b8a9b1dSJustin T. Gibbs 	AC_PATH_DEREGISTERED	= 0x040,/* A path has de-registered */
6108b8a9b1dSJustin T. Gibbs 	AC_PATH_REGISTERED	= 0x020,/* A new path has been registered */
6118b8a9b1dSJustin T. Gibbs 	AC_SENT_BDR		= 0x010,/* A BDR message was sent to target */
6128b8a9b1dSJustin T. Gibbs 	AC_SCSI_AEN		= 0x008,/* A SCSI AEN has been received */
6138b8a9b1dSJustin T. Gibbs 	AC_UNSOL_RESEL		= 0x002,/* Unsolicited reselection occurred */
6148b8a9b1dSJustin T. Gibbs 	AC_BUS_RESET		= 0x001	/* A SCSI bus reset occurred */
6158b8a9b1dSJustin T. Gibbs } ac_code;
6168b8a9b1dSJustin T. Gibbs 
6178b8a9b1dSJustin T. Gibbs typedef void ac_callback_t (void *softc, u_int32_t code,
6188b8a9b1dSJustin T. Gibbs 			    struct cam_path *path, void *args);
6198b8a9b1dSJustin T. Gibbs 
6208b8a9b1dSJustin T. Gibbs /* Set Asynchronous Callback CCB */
6218b8a9b1dSJustin T. Gibbs struct ccb_setasync {
6228b8a9b1dSJustin T. Gibbs 	struct ccb_hdr	 ccb_h;
6238b8a9b1dSJustin T. Gibbs 	u_int32_t	 event_enable;	/* Async Event enables */
6248b8a9b1dSJustin T. Gibbs 	ac_callback_t	*callback;
6258b8a9b1dSJustin T. Gibbs 	void		*callback_arg;
6268b8a9b1dSJustin T. Gibbs };
6278b8a9b1dSJustin T. Gibbs 
6288b8a9b1dSJustin T. Gibbs /* Set Device Type CCB */
6298b8a9b1dSJustin T. Gibbs struct ccb_setdev {
6308b8a9b1dSJustin T. Gibbs 	struct	   ccb_hdr ccb_h;
6318b8a9b1dSJustin T. Gibbs 	u_int8_t   dev_type;	/* Value for dev type field in EDT */
6328b8a9b1dSJustin T. Gibbs };
6338b8a9b1dSJustin T. Gibbs 
6348b8a9b1dSJustin T. Gibbs /* SCSI Control Functions */
6358b8a9b1dSJustin T. Gibbs 
6368b8a9b1dSJustin T. Gibbs /* Abort XPT request CCB */
6378b8a9b1dSJustin T. Gibbs struct ccb_abort {
6388b8a9b1dSJustin T. Gibbs 	struct 	ccb_hdr ccb_h;
6398b8a9b1dSJustin T. Gibbs 	union	ccb *abort_ccb;	/* Pointer to CCB to abort */
6408b8a9b1dSJustin T. Gibbs };
6418b8a9b1dSJustin T. Gibbs 
6428b8a9b1dSJustin T. Gibbs /* Reset SCSI Bus CCB */
6438b8a9b1dSJustin T. Gibbs struct ccb_resetbus {
6448b8a9b1dSJustin T. Gibbs 	struct	ccb_hdr ccb_h;
6458b8a9b1dSJustin T. Gibbs };
6468b8a9b1dSJustin T. Gibbs 
6478b8a9b1dSJustin T. Gibbs /* Reset SCSI Device CCB */
6488b8a9b1dSJustin T. Gibbs struct ccb_resetdev {
6498b8a9b1dSJustin T. Gibbs 	struct	ccb_hdr ccb_h;
6508b8a9b1dSJustin T. Gibbs };
6518b8a9b1dSJustin T. Gibbs 
6528b8a9b1dSJustin T. Gibbs /* Terminate I/O Process Request CCB */
6538b8a9b1dSJustin T. Gibbs struct ccb_termio {
6548b8a9b1dSJustin T. Gibbs 	struct	ccb_hdr ccb_h;
6558b8a9b1dSJustin T. Gibbs 	union	ccb *termio_ccb;	/* Pointer to CCB to terminate */
6568b8a9b1dSJustin T. Gibbs };
6578b8a9b1dSJustin T. Gibbs 
6588b8a9b1dSJustin T. Gibbs /* Get/Set transfer rate/width/disconnection/tag queueing settings */
6598b8a9b1dSJustin T. Gibbs struct ccb_trans_settings {
6608b8a9b1dSJustin T. Gibbs 	struct	ccb_hdr ccb_h;
6618b8a9b1dSJustin T. Gibbs 	u_int	valid;	/* Which fields to honor */
6628b8a9b1dSJustin T. Gibbs #define	CCB_TRANS_SYNC_RATE_VALID	0x01
6638b8a9b1dSJustin T. Gibbs #define	CCB_TRANS_SYNC_OFFSET_VALID	0x02
6648b8a9b1dSJustin T. Gibbs #define	CCB_TRANS_BUS_WIDTH_VALID	0x04
6658b8a9b1dSJustin T. Gibbs #define	CCB_TRANS_DISC_VALID		0x08
6668b8a9b1dSJustin T. Gibbs #define	CCB_TRANS_TQ_VALID		0x10
6678b8a9b1dSJustin T. Gibbs 	u_int	flags;
6688b8a9b1dSJustin T. Gibbs #define	CCB_TRANS_CURRENT_SETTINGS	0x01
6698b8a9b1dSJustin T. Gibbs #define	CCB_TRANS_USER_SETTINGS		0x02
6708b8a9b1dSJustin T. Gibbs #define	CCB_TRANS_DISC_ENB		0x04
6718b8a9b1dSJustin T. Gibbs #define	CCB_TRANS_TAG_ENB		0x08
6728b8a9b1dSJustin T. Gibbs 	u_int	sync_period;
6738b8a9b1dSJustin T. Gibbs 	u_int	sync_offset;
6748b8a9b1dSJustin T. Gibbs 	u_int	bus_width;
6758b8a9b1dSJustin T. Gibbs };
6768b8a9b1dSJustin T. Gibbs 
6778b8a9b1dSJustin T. Gibbs /*
6788b8a9b1dSJustin T. Gibbs  * Calculate the geometry parameters for a device
6798b8a9b1dSJustin T. Gibbs  * give the block size and volume size in blocks.
6808b8a9b1dSJustin T. Gibbs  */
6818b8a9b1dSJustin T. Gibbs struct ccb_calc_geometry {
6828b8a9b1dSJustin T. Gibbs 	struct	  ccb_hdr ccb_h;
6838b8a9b1dSJustin T. Gibbs 	u_int32_t block_size;
6848b8a9b1dSJustin T. Gibbs 	u_int32_t volume_size;
6858b8a9b1dSJustin T. Gibbs 	u_int16_t cylinders;
6868b8a9b1dSJustin T. Gibbs 	u_int8_t  heads;
6878b8a9b1dSJustin T. Gibbs 	u_int8_t  secs_per_track;
6888b8a9b1dSJustin T. Gibbs };
6898b8a9b1dSJustin T. Gibbs 
6908b8a9b1dSJustin T. Gibbs /*
6918b8a9b1dSJustin T. Gibbs  * Rescan the given bus, or bus/target/lun
6928b8a9b1dSJustin T. Gibbs  */
6938b8a9b1dSJustin T. Gibbs struct ccb_rescan {
6948b8a9b1dSJustin T. Gibbs 	struct	ccb_hdr ccb_h;
6958b8a9b1dSJustin T. Gibbs 	cam_flags	flags;
6968b8a9b1dSJustin T. Gibbs };
6978b8a9b1dSJustin T. Gibbs 
6988b8a9b1dSJustin T. Gibbs /*
6998b8a9b1dSJustin T. Gibbs  * Turn on debugging for the given bus, bus/target, or bus/target/lun.
7008b8a9b1dSJustin T. Gibbs  */
7018b8a9b1dSJustin T. Gibbs struct ccb_debug {
7028b8a9b1dSJustin T. Gibbs 	struct	ccb_hdr ccb_h;
7038b8a9b1dSJustin T. Gibbs 	cam_debug_flags flags;
7048b8a9b1dSJustin T. Gibbs };
7058b8a9b1dSJustin T. Gibbs 
7068b8a9b1dSJustin T. Gibbs /* Target mode structures. */
7078b8a9b1dSJustin T. Gibbs 
7088b8a9b1dSJustin T. Gibbs struct ccb_en_lun {
7098b8a9b1dSJustin T. Gibbs 	struct	  ccb_hdr ccb_h;
7108b8a9b1dSJustin T. Gibbs 	u_int16_t grp6_len;		/* Group 6 VU CDB length */
7118b8a9b1dSJustin T. Gibbs 	u_int16_t grp7_len;		/* Group 7 VU CDB length */
7128b8a9b1dSJustin T. Gibbs 	u_int8_t  enable;
7138b8a9b1dSJustin T. Gibbs };
7148b8a9b1dSJustin T. Gibbs 
7158b8a9b1dSJustin T. Gibbs struct ccb_immed_notify {
7168b8a9b1dSJustin T. Gibbs 	struct	  ccb_hdr ccb_h;
7178b8a9b1dSJustin T. Gibbs 	struct    scsi_sense_data sense_data;
7188b8a9b1dSJustin T. Gibbs 	u_int8_t  sense_len;		/* Number of bytes in sese buffer */
7198b8a9b1dSJustin T. Gibbs 	u_int8_t  initiator_id;		/* Id of initiator that selected */
7208b8a9b1dSJustin T. Gibbs 	u_int8_t  message_args[7];	/* Message Arguments */
7218b8a9b1dSJustin T. Gibbs };
7228b8a9b1dSJustin T. Gibbs 
7238b8a9b1dSJustin T. Gibbs struct ccb_notify_ack {
7248b8a9b1dSJustin T. Gibbs 	struct	  ccb_hdr ccb_h;
7258b8a9b1dSJustin T. Gibbs 	u_int16_t seq_id;		/* Sequence identifier */
7268b8a9b1dSJustin T. Gibbs 	u_int8_t  event;		/* Event flags */
7278b8a9b1dSJustin T. Gibbs };
7288b8a9b1dSJustin T. Gibbs 
7298b8a9b1dSJustin T. Gibbs /* HBA engine structures. */
7308b8a9b1dSJustin T. Gibbs 
7318b8a9b1dSJustin T. Gibbs typedef enum {
7328b8a9b1dSJustin T. Gibbs 	EIT_BUFFER,	/* Engine type: buffer memory */
7338b8a9b1dSJustin T. Gibbs 	EIT_LOSSLESS,	/* Engine type: lossless compression */
7348b8a9b1dSJustin T. Gibbs 	EIT_LOSSY,	/* Engine type: lossy compression */
7358b8a9b1dSJustin T. Gibbs 	EIT_ENCRYPT	/* Engine type: encryption */
7368b8a9b1dSJustin T. Gibbs } ei_type;
7378b8a9b1dSJustin T. Gibbs 
7388b8a9b1dSJustin T. Gibbs typedef enum {
7398b8a9b1dSJustin T. Gibbs 	EAD_VUNIQUE,	/* Engine algorithm ID: vendor unique */
7408b8a9b1dSJustin T. Gibbs 	EAD_LZ1V1,	/* Engine algorithm ID: LZ1 var.1 */
7418b8a9b1dSJustin T. Gibbs 	EAD_LZ2V1,	/* Engine algorithm ID: LZ2 var.1 */
7428b8a9b1dSJustin T. Gibbs 	EAD_LZ2V2,	/* Engine algorithm ID: LZ2 var.2 */
7438b8a9b1dSJustin T. Gibbs } ei_algo;
7448b8a9b1dSJustin T. Gibbs 
7458b8a9b1dSJustin T. Gibbs struct ccb_eng_inq {
7468b8a9b1dSJustin T. Gibbs 	struct	  ccb_hdr ccb_h;
7478b8a9b1dSJustin T. Gibbs 	u_int16_t eng_num;	/* The engine number for this inquiry */
7488b8a9b1dSJustin T. Gibbs 	ei_type   eng_type;	/* Returned engine type */
7498b8a9b1dSJustin T. Gibbs 	ei_algo   eng_algo;	/* Returned engine algorithm type */
7508b8a9b1dSJustin T. Gibbs 	u_int32_t eng_memeory;	/* Returned engine memory size */
7518b8a9b1dSJustin T. Gibbs };
7528b8a9b1dSJustin T. Gibbs 
7538b8a9b1dSJustin T. Gibbs struct ccb_eng_exec {	/* This structure must match SCSIIO size */
7548b8a9b1dSJustin T. Gibbs 	struct	  ccb_hdr ccb_h;
7558b8a9b1dSJustin T. Gibbs 	u_int8_t  *pdrv_ptr;	/* Ptr used by the peripheral driver */
7568b8a9b1dSJustin T. Gibbs 	u_int8_t  *req_map;	/* Ptr for mapping info on the req. */
7578b8a9b1dSJustin T. Gibbs 	u_int8_t  *data_ptr;	/* Pointer to the data buf/SG list */
7588b8a9b1dSJustin T. Gibbs 	u_int32_t dxfer_len;	/* Data transfer length */
7598b8a9b1dSJustin T. Gibbs 	u_int8_t  *engdata_ptr;	/* Pointer to the engine buffer data */
7608b8a9b1dSJustin T. Gibbs 	u_int16_t sglist_cnt;	/* Num of scatter gather list entries */
7618b8a9b1dSJustin T. Gibbs 	u_int32_t dmax_len;	/* Destination data maximum length */
7628b8a9b1dSJustin T. Gibbs 	u_int32_t dest_len;	/* Destination data length */
7638b8a9b1dSJustin T. Gibbs 	int32_t	  src_resid;	/* Source residual length: 2's comp */
7648b8a9b1dSJustin T. Gibbs 	u_int32_t timeout;	/* Timeout value */
7658b8a9b1dSJustin T. Gibbs 	u_int16_t eng_num;	/* Engine number for this request */
7668b8a9b1dSJustin T. Gibbs 	u_int16_t vu_flags;	/* Vendor Unique flags */
7678b8a9b1dSJustin T. Gibbs };
7688b8a9b1dSJustin T. Gibbs 
7698b8a9b1dSJustin T. Gibbs /*
7708b8a9b1dSJustin T. Gibbs  * Definitions for the timeout field in the SCSI I/O CCB.
7718b8a9b1dSJustin T. Gibbs  */
7728b8a9b1dSJustin T. Gibbs #define	CAM_TIME_DEFAULT	0x00000000	/* Use SIM default value */
7738b8a9b1dSJustin T. Gibbs #define	CAM_TIME_INFINITY	0xFFFFFFFF	/* Infinite timeout */
7748b8a9b1dSJustin T. Gibbs 
7758b8a9b1dSJustin T. Gibbs #define	CAM_SUCCESS	0	/* For signaling general success */
7768b8a9b1dSJustin T. Gibbs #define	CAM_FAILURE	1	/* For signaling general failure */
7778b8a9b1dSJustin T. Gibbs 
7788b8a9b1dSJustin T. Gibbs #define CAM_FALSE	0
7798b8a9b1dSJustin T. Gibbs #define CAM_TRUE	1
7808b8a9b1dSJustin T. Gibbs 
7818b8a9b1dSJustin T. Gibbs #define XPT_CCB_INVALID	-1	/* for signaling a bad CCB to free */
7828b8a9b1dSJustin T. Gibbs 
7838b8a9b1dSJustin T. Gibbs /*
7848b8a9b1dSJustin T. Gibbs  * Union of all CCB types for kernel space allocation.  This union should
7858b8a9b1dSJustin T. Gibbs  * never be used for manipulating CCBs - its only use is for the allocation
7868b8a9b1dSJustin T. Gibbs  * and deallocation of raw CCB space and is the return type of xpt_ccb_alloc
7878b8a9b1dSJustin T. Gibbs  * and the argument to xpt_ccb_free.
7888b8a9b1dSJustin T. Gibbs  */
7898b8a9b1dSJustin T. Gibbs union ccb {
7908b8a9b1dSJustin T. Gibbs 	struct	ccb_hdr			ccb_h;	/* For convenience */
7918b8a9b1dSJustin T. Gibbs 	struct	ccb_scsiio		csio;
7928b8a9b1dSJustin T. Gibbs 	struct	ccb_getdev		cgd;
7938b8a9b1dSJustin T. Gibbs 	struct	ccb_getdevlist		cgdl;
7948b8a9b1dSJustin T. Gibbs 	struct	ccb_pathinq		cpi;
7958b8a9b1dSJustin T. Gibbs 	struct	ccb_relsim		crs;
7968b8a9b1dSJustin T. Gibbs 	struct	ccb_setasync		csa;
7978b8a9b1dSJustin T. Gibbs 	struct	ccb_setdev		csd;
79887cfaf0eSJustin T. Gibbs 	struct	ccb_pathstats		cpis;
79987cfaf0eSJustin T. Gibbs 	struct	ccb_getdevstats		cgds;
8008b8a9b1dSJustin T. Gibbs 	struct	ccb_dev_match		cdm;
8018b8a9b1dSJustin T. Gibbs 	struct	ccb_trans_settings	cts;
8028b8a9b1dSJustin T. Gibbs 	struct	ccb_calc_geometry	ccg;
8038b8a9b1dSJustin T. Gibbs 	struct	ccb_abort		cab;
8048b8a9b1dSJustin T. Gibbs 	struct	ccb_resetbus		crb;
8058b8a9b1dSJustin T. Gibbs 	struct	ccb_resetdev		crd;
8068b8a9b1dSJustin T. Gibbs 	struct	ccb_termio		tio;
8078b8a9b1dSJustin T. Gibbs 	struct	ccb_accept_tio		atio;
8088b8a9b1dSJustin T. Gibbs 	struct	ccb_scsiio		ctio;
8098b8a9b1dSJustin T. Gibbs 	struct	ccb_en_lun		cel;
8108b8a9b1dSJustin T. Gibbs 	struct	ccb_immed_notify	cin;
8118b8a9b1dSJustin T. Gibbs 	struct	ccb_notify_ack		cna;
8128b8a9b1dSJustin T. Gibbs 	struct	ccb_eng_inq		cei;
8138b8a9b1dSJustin T. Gibbs 	struct	ccb_eng_exec		cee;
8148b8a9b1dSJustin T. Gibbs 	struct 	ccb_rescan		crcn;
8158b8a9b1dSJustin T. Gibbs 	struct  ccb_debug		cdbg;
8168b8a9b1dSJustin T. Gibbs };
8178b8a9b1dSJustin T. Gibbs 
8188b8a9b1dSJustin T. Gibbs __BEGIN_DECLS
8198b8a9b1dSJustin T. Gibbs static __inline void
8208b8a9b1dSJustin T. Gibbs cam_fill_csio(struct ccb_scsiio *csio, u_int32_t retries,
8218b8a9b1dSJustin T. Gibbs 	      void (*cbfcnp)(struct cam_periph *, union ccb *),
8228b8a9b1dSJustin T. Gibbs 	      u_int32_t flags, u_int8_t tag_action,
8238b8a9b1dSJustin T. Gibbs 	      u_int8_t *data_ptr, u_int32_t dxfer_len,
8248b8a9b1dSJustin T. Gibbs 	      u_int8_t sense_len, u_int8_t cdb_len,
8258b8a9b1dSJustin T. Gibbs 	      u_int32_t timeout);
8268b8a9b1dSJustin T. Gibbs 
8278b8a9b1dSJustin T. Gibbs static __inline void
8288b8a9b1dSJustin T. Gibbs cam_fill_ctio(struct ccb_scsiio *csio, u_int32_t retries,
8298b8a9b1dSJustin T. Gibbs 	      void (*cbfcnp)(struct cam_periph *, union ccb *),
8308b8a9b1dSJustin T. Gibbs 	      u_int32_t flags, u_int tag_action, u_int tag_id,
8318b8a9b1dSJustin T. Gibbs 	      u_int init_id, u_int scsi_status, u_int8_t *data_ptr,
8328b8a9b1dSJustin T. Gibbs 	      u_int32_t dxfer_len, u_int32_t timeout);
8338b8a9b1dSJustin T. Gibbs 
8348b8a9b1dSJustin T. Gibbs static __inline void
8358b8a9b1dSJustin T. Gibbs cam_fill_csio(struct ccb_scsiio *csio, u_int32_t retries,
8368b8a9b1dSJustin T. Gibbs 	      void (*cbfcnp)(struct cam_periph *, union ccb *),
8378b8a9b1dSJustin T. Gibbs 	      u_int32_t flags, u_int8_t tag_action,
8388b8a9b1dSJustin T. Gibbs 	      u_int8_t *data_ptr, u_int32_t dxfer_len,
8398b8a9b1dSJustin T. Gibbs 	      u_int8_t sense_len, u_int8_t cdb_len,
8408b8a9b1dSJustin T. Gibbs 	      u_int32_t timeout)
8418b8a9b1dSJustin T. Gibbs {
8428b8a9b1dSJustin T. Gibbs 	csio->ccb_h.func_code = XPT_SCSI_IO;
8438b8a9b1dSJustin T. Gibbs 	csio->ccb_h.flags = flags;
8448b8a9b1dSJustin T. Gibbs 	csio->ccb_h.retry_count = retries;
8458b8a9b1dSJustin T. Gibbs 	csio->ccb_h.cbfcnp = cbfcnp;
8468b8a9b1dSJustin T. Gibbs 	csio->ccb_h.timeout = timeout;
8478b8a9b1dSJustin T. Gibbs 	csio->data_ptr = data_ptr;
8488b8a9b1dSJustin T. Gibbs 	csio->dxfer_len = dxfer_len;
8498b8a9b1dSJustin T. Gibbs 	csio->sense_len = sense_len;
8508b8a9b1dSJustin T. Gibbs 	csio->cdb_len = cdb_len;
8518b8a9b1dSJustin T. Gibbs 	csio->tag_action = tag_action;
8528b8a9b1dSJustin T. Gibbs }
8538b8a9b1dSJustin T. Gibbs 
8548b8a9b1dSJustin T. Gibbs static __inline void
8558b8a9b1dSJustin T. Gibbs cam_fill_ctio(struct ccb_scsiio *csio, u_int32_t retries,
8568b8a9b1dSJustin T. Gibbs 	      void (*cbfcnp)(struct cam_periph *, union ccb *),
8578b8a9b1dSJustin T. Gibbs 	      u_int32_t flags, u_int tag_action, u_int tag_id,
8588b8a9b1dSJustin T. Gibbs 	      u_int init_id, u_int scsi_status, u_int8_t *data_ptr,
8598b8a9b1dSJustin T. Gibbs 	      u_int32_t dxfer_len, u_int32_t timeout)
8608b8a9b1dSJustin T. Gibbs {
8618b8a9b1dSJustin T. Gibbs 	csio->ccb_h.func_code = XPT_CONT_TARGET_IO;
8628b8a9b1dSJustin T. Gibbs 	csio->ccb_h.flags = flags;
8638b8a9b1dSJustin T. Gibbs 	csio->ccb_h.retry_count = retries;
8648b8a9b1dSJustin T. Gibbs 	csio->ccb_h.cbfcnp = cbfcnp;
8658b8a9b1dSJustin T. Gibbs 	csio->ccb_h.timeout = timeout;
8668b8a9b1dSJustin T. Gibbs 	csio->data_ptr = data_ptr;
8678b8a9b1dSJustin T. Gibbs 	csio->dxfer_len = dxfer_len;
8688b8a9b1dSJustin T. Gibbs 	csio->scsi_status = scsi_status;
8698b8a9b1dSJustin T. Gibbs 	csio->tag_action = tag_action;
8708b8a9b1dSJustin T. Gibbs 	csio->tag_id = tag_id;
8718b8a9b1dSJustin T. Gibbs 	csio->init_id = init_id;
8728b8a9b1dSJustin T. Gibbs }
8738b8a9b1dSJustin T. Gibbs 
8748b8a9b1dSJustin T. Gibbs __END_DECLS
8758b8a9b1dSJustin T. Gibbs 
8768b8a9b1dSJustin T. Gibbs #endif /* _CAM_CAM_CCB_H */
877