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 * 28c3aac50fSPeter Wemm * $FreeBSD$ 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> 373393f8daSKenneth D. Merry #ifdef CAM_NEW_TRAN_CODE 383393f8daSKenneth D. Merry #include <machine/limits.h> 393393f8daSKenneth D. Merry #endif /* CAM_NEW_TRAN_CODE */ 40c4473420SPeter Wemm #ifndef _KERNEL 418b8a9b1dSJustin T. Gibbs #include <sys/callout.h> 428b8a9b1dSJustin T. Gibbs #endif 438b8a9b1dSJustin T. Gibbs #include <cam/cam_debug.h> 448b8a9b1dSJustin T. Gibbs #include <cam/scsi/scsi_all.h> 458b8a9b1dSJustin T. Gibbs 468b8a9b1dSJustin T. Gibbs 478b8a9b1dSJustin T. Gibbs /* General allocation length definitions for CCB structures */ 488b8a9b1dSJustin T. Gibbs #define IOCDBLEN CAM_MAX_CDBLEN /* Space for CDB bytes/pointer */ 498b8a9b1dSJustin T. Gibbs #define VUHBALEN 14 /* Vendor Unique HBA length */ 508b8a9b1dSJustin T. Gibbs #define SIM_IDLEN 16 /* ASCII string len for SIM ID */ 518b8a9b1dSJustin T. Gibbs #define HBA_IDLEN 16 /* ASCII string len for HBA ID */ 528b8a9b1dSJustin T. Gibbs #define DEV_IDLEN 16 /* ASCII string len for device names */ 538b8a9b1dSJustin T. Gibbs #define CCB_PERIPH_PRIV_SIZE 2 /* size of peripheral private area */ 548b8a9b1dSJustin T. Gibbs #define CCB_SIM_PRIV_SIZE 2 /* size of sim private area */ 558b8a9b1dSJustin T. Gibbs 568b8a9b1dSJustin T. Gibbs /* Struct definitions for CAM control blocks */ 578b8a9b1dSJustin T. Gibbs 588b8a9b1dSJustin T. Gibbs /* Common CCB header */ 598b8a9b1dSJustin T. Gibbs /* CAM CCB flags */ 608b8a9b1dSJustin T. Gibbs typedef enum { 618b8a9b1dSJustin T. Gibbs CAM_CDB_POINTER = 0x00000001,/* The CDB field is a pointer */ 628b8a9b1dSJustin T. Gibbs CAM_QUEUE_ENABLE = 0x00000002,/* SIM queue actions are enabled */ 638b8a9b1dSJustin T. Gibbs CAM_CDB_LINKED = 0x00000004,/* CCB contains a linked CDB */ 64dd5bac9dSJustin T. Gibbs CAM_NEGOTIATE = 0x00000008,/* 65dd5bac9dSJustin T. Gibbs * Perform transport negotiation 66dd5bac9dSJustin T. Gibbs * with this command. 67dd5bac9dSJustin T. Gibbs */ 688b8a9b1dSJustin T. Gibbs CAM_SCATTER_VALID = 0x00000010,/* Scatter/gather list is valid */ 698b8a9b1dSJustin T. Gibbs CAM_DIS_AUTOSENSE = 0x00000020,/* Disable autosense feature */ 708b8a9b1dSJustin T. Gibbs CAM_DIR_RESV = 0x00000000,/* Data direction (00:reserved) */ 718b8a9b1dSJustin T. Gibbs CAM_DIR_IN = 0x00000040,/* Data direction (01:DATA IN) */ 728b8a9b1dSJustin T. Gibbs CAM_DIR_OUT = 0x00000080,/* Data direction (10:DATA OUT) */ 738b8a9b1dSJustin T. Gibbs CAM_DIR_NONE = 0x000000C0,/* Data direction (11:no data) */ 748b8a9b1dSJustin T. Gibbs CAM_DIR_MASK = 0x000000C0,/* Data direction Mask */ 758b8a9b1dSJustin T. Gibbs CAM_SOFT_RST_OP = 0x00000100,/* Use Soft reset alternative */ 768b8a9b1dSJustin T. Gibbs CAM_ENG_SYNC = 0x00000200,/* Flush resid bytes on complete */ 778b8a9b1dSJustin T. Gibbs CAM_DEV_QFRZDIS = 0x00000400,/* Disable DEV Q freezing */ 788b8a9b1dSJustin T. Gibbs CAM_DEV_QFREEZE = 0x00000800,/* Freeze DEV Q on execution */ 798b8a9b1dSJustin T. Gibbs CAM_HIGH_POWER = 0x00001000,/* Command takes a lot of power */ 808b8a9b1dSJustin T. Gibbs CAM_SENSE_PTR = 0x00002000,/* Sense data is a pointer */ 818b8a9b1dSJustin T. Gibbs CAM_SENSE_PHYS = 0x00004000,/* Sense pointer is physical addr*/ 828b8a9b1dSJustin T. Gibbs CAM_TAG_ACTION_VALID = 0x00008000,/* Use the tag action in this ccb*/ 838b8a9b1dSJustin T. Gibbs CAM_PASS_ERR_RECOVER = 0x00010000,/* Pass driver does err. recovery*/ 848b8a9b1dSJustin T. Gibbs CAM_DIS_DISCONNECT = 0x00020000,/* Disable disconnect */ 858b8a9b1dSJustin T. Gibbs CAM_SG_LIST_PHYS = 0x00040000,/* SG list has physical addrs. */ 868b8a9b1dSJustin T. Gibbs CAM_MSG_BUF_PHYS = 0x00080000,/* Message buffer ptr is physical*/ 878b8a9b1dSJustin T. Gibbs CAM_SNS_BUF_PHYS = 0x00100000,/* Autosense data ptr is physical*/ 888b8a9b1dSJustin T. Gibbs CAM_DATA_PHYS = 0x00200000,/* SG/Buffer data ptrs are phys. */ 898b8a9b1dSJustin T. Gibbs CAM_CDB_PHYS = 0x00400000,/* CDB poiner is physical */ 908b8a9b1dSJustin T. Gibbs CAM_ENG_SGLIST = 0x00800000,/* SG list is for the HBA engine */ 918b8a9b1dSJustin T. Gibbs 928b8a9b1dSJustin T. Gibbs /* Phase cognizant mode flags */ 930cdabce0SNick Hibma CAM_DIS_AUTOSRP = 0x01000000,/* Disable autosave/restore ptrs */ 948b8a9b1dSJustin T. Gibbs CAM_DIS_AUTODISC = 0x02000000,/* Disable auto disconnect */ 958b8a9b1dSJustin T. Gibbs CAM_TGT_CCB_AVAIL = 0x04000000,/* Target CCB available */ 968b8a9b1dSJustin T. Gibbs CAM_TGT_PHASE_MODE = 0x08000000,/* The SIM runs in phase mode */ 97826eb7c8SMatt Jacob CAM_MSGB_VALID = 0x10000000,/* Message buffer valid */ 98826eb7c8SMatt Jacob CAM_STATUS_VALID = 0x20000000,/* Status buffer valid */ 99826eb7c8SMatt Jacob CAM_DATAB_VALID = 0x40000000,/* Data buffer valid */ 1008b8a9b1dSJustin T. Gibbs 1018b8a9b1dSJustin T. Gibbs /* Host target Mode flags */ 102826eb7c8SMatt Jacob CAM_SEND_SENSE = 0x08000000,/* Send sense data with status */ 103826eb7c8SMatt Jacob CAM_TERM_IO = 0x10000000,/* Terminate I/O Message sup. */ 104826eb7c8SMatt Jacob CAM_DISCONNECT = 0x20000000,/* Disconnects are mandatory */ 105826eb7c8SMatt Jacob CAM_SEND_STATUS = 0x40000000 /* Send status after data phase */ 1068b8a9b1dSJustin T. Gibbs } ccb_flags; 1078b8a9b1dSJustin T. Gibbs 1088b8a9b1dSJustin T. Gibbs /* XPT Opcodes for xpt_action */ 1098b8a9b1dSJustin T. Gibbs typedef enum { 1109deea857SKenneth D. Merry /* Function code flags are bits greater than 0xff */ 1119deea857SKenneth D. Merry XPT_FC_QUEUED = 0x100, 1129deea857SKenneth D. Merry /* Non-immediate function code */ 1139deea857SKenneth D. Merry XPT_FC_USER_CCB = 0x200, 1149deea857SKenneth D. Merry XPT_FC_XPT_ONLY = 0x400, 1159deea857SKenneth D. Merry /* Only for the transport layer device */ 116bf8bb7acSJustin T. Gibbs XPT_FC_DEV_QUEUED = 0x800 | XPT_FC_QUEUED, 117bf8bb7acSJustin T. Gibbs /* Passes through the device queues */ 1188b8a9b1dSJustin T. Gibbs /* Common function commands: 0x00->0x0F */ 1199deea857SKenneth D. Merry XPT_NOOP = 0x00, 1209deea857SKenneth D. Merry /* Execute Nothing */ 121bf8bb7acSJustin T. Gibbs XPT_SCSI_IO = 0x01 | XPT_FC_DEV_QUEUED, 1229deea857SKenneth D. Merry /* Execute the requested I/O operation */ 1239deea857SKenneth D. Merry XPT_GDEV_TYPE = 0x02, 1249deea857SKenneth D. Merry /* Get type information for specified device */ 1259deea857SKenneth D. Merry XPT_GDEVLIST = 0x03, 1269deea857SKenneth D. Merry /* Get a list of peripheral devices */ 1279deea857SKenneth D. Merry XPT_PATH_INQ = 0x04, 1289deea857SKenneth D. Merry /* Path routing inquiry */ 1299deea857SKenneth D. Merry XPT_REL_SIMQ = 0x05, 1309deea857SKenneth D. Merry /* Release a frozen SIM queue */ 1319deea857SKenneth D. Merry XPT_SASYNC_CB = 0x06, 1329deea857SKenneth D. Merry /* Set Asynchronous Callback Parameters */ 1339deea857SKenneth D. Merry XPT_SDEV_TYPE = 0x07, 1349deea857SKenneth D. Merry /* Set device type information */ 1359deea857SKenneth D. Merry XPT_SCAN_BUS = 0x08 | XPT_FC_QUEUED | XPT_FC_USER_CCB 1369deea857SKenneth D. Merry | XPT_FC_XPT_ONLY, 1379deea857SKenneth D. Merry /* (Re)Scan the SCSI Bus */ 1389deea857SKenneth D. Merry XPT_DEV_MATCH = 0x09 | XPT_FC_XPT_ONLY, 1399deea857SKenneth D. Merry /* Get EDT entries matching the given pattern */ 1409deea857SKenneth D. Merry XPT_DEBUG = 0x0a, 1419deea857SKenneth D. Merry /* Turn on debugging for a bus, target or lun */ 14287cfaf0eSJustin T. Gibbs XPT_PATH_STATS = 0x0b, 14387cfaf0eSJustin T. Gibbs /* Path statistics (error counts, etc.) */ 14487cfaf0eSJustin T. Gibbs XPT_GDEV_STATS = 0x0c, 14587cfaf0eSJustin T. Gibbs /* Device statistics (error counts, etc.) */ 1468b8a9b1dSJustin T. Gibbs /* SCSI Control Functions: 0x10->0x1F */ 1479deea857SKenneth D. Merry XPT_ABORT = 0x10, 1489deea857SKenneth D. Merry /* Abort the specified CCB */ 1499deea857SKenneth D. Merry XPT_RESET_BUS = 0x11 | XPT_FC_XPT_ONLY, 1509deea857SKenneth D. Merry /* Reset the specified SCSI bus */ 151bf8bb7acSJustin T. Gibbs XPT_RESET_DEV = 0x12 | XPT_FC_DEV_QUEUED, 1529deea857SKenneth D. Merry /* Bus Device Reset the specified SCSI device */ 1539deea857SKenneth D. Merry XPT_TERM_IO = 0x13, 1549deea857SKenneth D. Merry /* Terminate the I/O process */ 1559deea857SKenneth D. Merry XPT_SCAN_LUN = 0x14 | XPT_FC_QUEUED | XPT_FC_USER_CCB 1569deea857SKenneth D. Merry | XPT_FC_XPT_ONLY, 1579deea857SKenneth D. Merry /* Scan Logical Unit */ 1589deea857SKenneth D. Merry XPT_GET_TRAN_SETTINGS = 0x15, 1599deea857SKenneth D. Merry /* 1608b8a9b1dSJustin T. Gibbs * Get default/user transfer settings 1618b8a9b1dSJustin T. Gibbs * for the target 1628b8a9b1dSJustin T. Gibbs */ 1639deea857SKenneth D. Merry XPT_SET_TRAN_SETTINGS = 0x16, 1649deea857SKenneth D. Merry /* 1658b8a9b1dSJustin T. Gibbs * Set transfer rate/width 1668b8a9b1dSJustin T. Gibbs * negotiation settings 1678b8a9b1dSJustin T. Gibbs */ 1689deea857SKenneth D. Merry XPT_CALC_GEOMETRY = 0x17, 1699deea857SKenneth D. Merry /* 1708b8a9b1dSJustin T. Gibbs * Calculate the geometry parameters for 1718b8a9b1dSJustin T. Gibbs * a device give the sector size and 1728b8a9b1dSJustin T. Gibbs * volume size. 1738b8a9b1dSJustin T. Gibbs */ 1748b8a9b1dSJustin T. Gibbs 1758b8a9b1dSJustin T. Gibbs /* HBA engine commands 0x20->0x2F */ 1769deea857SKenneth D. Merry XPT_ENG_INQ = 0x20 | XPT_FC_XPT_ONLY, 1779deea857SKenneth D. Merry /* HBA engine feature inquiry */ 1783393f8daSKenneth D. Merry XPT_ENG_EXEC = 0x21 | XPT_FC_DEV_QUEUED, 1799deea857SKenneth D. Merry /* HBA execute engine request */ 1808b8a9b1dSJustin T. Gibbs 1818b8a9b1dSJustin T. Gibbs /* Target mode commands: 0x30->0x3F */ 1829deea857SKenneth D. Merry XPT_EN_LUN = 0x30, 1839deea857SKenneth D. Merry /* Enable LUN as a target */ 184bf8bb7acSJustin T. Gibbs XPT_TARGET_IO = 0x31 | XPT_FC_DEV_QUEUED, 1859deea857SKenneth D. Merry /* Execute target I/O request */ 1869deea857SKenneth D. Merry XPT_ACCEPT_TARGET_IO = 0x32 | XPT_FC_QUEUED | XPT_FC_USER_CCB, 1879deea857SKenneth D. Merry /* Accept Host Target Mode CDB */ 188bf8bb7acSJustin T. Gibbs XPT_CONT_TARGET_IO = 0x33 | XPT_FC_DEV_QUEUED, 1899deea857SKenneth D. Merry /* Continue Host Target I/O Connection */ 1909deea857SKenneth D. Merry XPT_IMMED_NOTIFY = 0x34 | XPT_FC_QUEUED | XPT_FC_USER_CCB, 1919deea857SKenneth D. Merry /* Notify Host Target driver of event */ 1929deea857SKenneth D. Merry XPT_NOTIFY_ACK = 0x35, 1939deea857SKenneth D. Merry /* Acknowledgement of event */ 1948b8a9b1dSJustin T. Gibbs 1958b8a9b1dSJustin T. Gibbs /* Vendor Unique codes: 0x80->0x8F */ 1968b8a9b1dSJustin T. Gibbs XPT_VUNIQUE = 0x80 1978b8a9b1dSJustin T. Gibbs } xpt_opcode; 1988b8a9b1dSJustin T. Gibbs 1999deea857SKenneth D. Merry #define XPT_FC_GROUP_MASK 0xF0 2009deea857SKenneth D. Merry #define XPT_FC_GROUP(op) ((op) & XPT_FC_GROUP_MASK) 2019deea857SKenneth D. Merry #define XPT_FC_GROUP_COMMON 0x00 2029deea857SKenneth D. Merry #define XPT_FC_GROUP_SCSI_CONTROL 0x10 2039deea857SKenneth D. Merry #define XPT_FC_GROUP_HBA_ENGINE 0x20 2049deea857SKenneth D. Merry #define XPT_FC_GROUP_TMODE 0x30 2059deea857SKenneth D. Merry #define XPT_FC_GROUP_VENDOR_UNIQUE 0x80 206a89bb8b4SJustin T. Gibbs 207bf8bb7acSJustin T. Gibbs #define XPT_FC_IS_DEV_QUEUED(ccb) \ 208bf8bb7acSJustin T. Gibbs (((ccb)->ccb_h.func_code & XPT_FC_DEV_QUEUED) == XPT_FC_DEV_QUEUED) 209bf8bb7acSJustin T. Gibbs #define XPT_FC_IS_QUEUED(ccb) \ 210bf8bb7acSJustin T. Gibbs (((ccb)->ccb_h.func_code & XPT_FC_QUEUED) != 0) 2113393f8daSKenneth D. Merry 2123393f8daSKenneth D. Merry #ifdef CAM_NEW_TRAN_CODE 2133393f8daSKenneth D. Merry typedef enum { 2143393f8daSKenneth D. Merry PROTO_UNKNOWN, 2153393f8daSKenneth D. Merry PROTO_UNSPECIFIED, 2163393f8daSKenneth D. Merry PROTO_SCSI, /* Small Computer System Interface */ 2173393f8daSKenneth D. Merry PROTO_ATA, /* AT Attachment */ 2183393f8daSKenneth D. Merry PROTO_ATAPI, /* AT Attachment Packetized Interface */ 2193393f8daSKenneth D. Merry } cam_proto; 2203393f8daSKenneth D. Merry 2213393f8daSKenneth D. Merry typedef enum { 2223393f8daSKenneth D. Merry XPORT_UNKNOWN, 2233393f8daSKenneth D. Merry XPORT_UNSPECIFIED, 2243393f8daSKenneth D. Merry XPORT_SPI, /* SCSI Parallel Interface */ 2253393f8daSKenneth D. Merry XPORT_FC, /* Fiber Channel */ 2263393f8daSKenneth D. Merry XPORT_SSA, /* Serial Storage Architecture */ 2273393f8daSKenneth D. Merry XPORT_USB, /* Universal Serial Bus */ 2283393f8daSKenneth D. Merry XPORT_PPB, /* Parallel Port Bus */ 2293393f8daSKenneth D. Merry XPORT_ATA /* AT Attachment */ 2303393f8daSKenneth D. Merry } cam_xport; 2313393f8daSKenneth D. Merry 2323393f8daSKenneth D. Merry #define PROTO_VERSION_UNKNOWN (UINT_MAX - 1) 2333393f8daSKenneth D. Merry #define PROTO_VERSION_UNSPECIFIED UINT_MAX 2343393f8daSKenneth D. Merry #define XPORT_VERSION_UNKNOWN (UINT_MAX - 1) 2353393f8daSKenneth D. Merry #define XPORT_VERSION_UNSPECIFIED UINT_MAX 2363393f8daSKenneth D. Merry #endif /* CAM_NEW_TRAN_CODE */ 2373393f8daSKenneth D. Merry 2388b8a9b1dSJustin T. Gibbs typedef union { 239e3975643SJake Burkholder LIST_ENTRY(ccb_hdr) le; 240e3975643SJake Burkholder SLIST_ENTRY(ccb_hdr) sle; 241e3975643SJake Burkholder TAILQ_ENTRY(ccb_hdr) tqe; 242e3975643SJake Burkholder STAILQ_ENTRY(ccb_hdr) stqe; 2438b8a9b1dSJustin T. Gibbs } camq_entry; 2448b8a9b1dSJustin T. Gibbs 2458b8a9b1dSJustin T. Gibbs typedef union { 2468b8a9b1dSJustin T. Gibbs void *ptr; 2478b8a9b1dSJustin T. Gibbs u_long field; 2488b8a9b1dSJustin T. Gibbs u_int8_t bytes[sizeof(void *) > sizeof(u_long) 2498b8a9b1dSJustin T. Gibbs ? sizeof(void *) : sizeof(u_long)]; 2508b8a9b1dSJustin T. Gibbs } ccb_priv_entry; 2518b8a9b1dSJustin T. Gibbs 2528b8a9b1dSJustin T. Gibbs typedef union { 2538b8a9b1dSJustin T. Gibbs ccb_priv_entry entries[CCB_PERIPH_PRIV_SIZE]; 2548b8a9b1dSJustin T. Gibbs u_int8_t bytes[CCB_PERIPH_PRIV_SIZE * sizeof(ccb_priv_entry)]; 2558b8a9b1dSJustin T. Gibbs } ccb_ppriv_area; 2568b8a9b1dSJustin T. Gibbs 2578b8a9b1dSJustin T. Gibbs typedef union { 2588b8a9b1dSJustin T. Gibbs ccb_priv_entry entries[CCB_SIM_PRIV_SIZE]; 2598b8a9b1dSJustin T. Gibbs u_int8_t bytes[CCB_SIM_PRIV_SIZE * sizeof(ccb_priv_entry)]; 2608b8a9b1dSJustin T. Gibbs } ccb_spriv_area; 2618b8a9b1dSJustin T. Gibbs 2628b8a9b1dSJustin T. Gibbs struct ccb_hdr { 2638b8a9b1dSJustin T. Gibbs cam_pinfo pinfo; /* Info for priority scheduling */ 2648b8a9b1dSJustin T. Gibbs camq_entry xpt_links; /* For chaining in the XPT layer */ 2658b8a9b1dSJustin T. Gibbs camq_entry sim_links; /* For chaining in the SIM layer */ 2668b8a9b1dSJustin T. Gibbs camq_entry periph_links;/* For chaining in the type driver */ 2678b8a9b1dSJustin T. Gibbs u_int32_t retry_count; 2688b8a9b1dSJustin T. Gibbs /* Callback on completion function */ 2698b8a9b1dSJustin T. Gibbs void (*cbfcnp)(struct cam_periph *, union ccb *); 2708b8a9b1dSJustin T. Gibbs xpt_opcode func_code; /* XPT function code */ 2718b8a9b1dSJustin T. Gibbs u_int32_t status; /* Status returned by CAM subsystem */ 2728b8a9b1dSJustin T. Gibbs /* Compiled path for this ccb */ 2738b8a9b1dSJustin T. Gibbs struct cam_path *path; 2748b8a9b1dSJustin T. Gibbs path_id_t path_id; /* Path ID for the request */ 2758b8a9b1dSJustin T. Gibbs target_id_t target_id; /* Target device ID */ 2768b8a9b1dSJustin T. Gibbs lun_id_t target_lun; /* Target LUN number */ 2778b8a9b1dSJustin T. Gibbs u_int32_t flags; 2788b8a9b1dSJustin T. Gibbs ccb_ppriv_area periph_priv; 2798b8a9b1dSJustin T. Gibbs ccb_spriv_area sim_priv; 2808b8a9b1dSJustin T. Gibbs u_int32_t timeout; /* Timeout value */ 2818b8a9b1dSJustin T. Gibbs /* Callout handle used for timeouts */ 2828b8a9b1dSJustin T. Gibbs struct callout_handle timeout_ch; 2838b8a9b1dSJustin T. Gibbs }; 2848b8a9b1dSJustin T. Gibbs 2858b8a9b1dSJustin T. Gibbs /* Get Device Information CCB */ 2868b8a9b1dSJustin T. Gibbs struct ccb_getdev { 2878b8a9b1dSJustin T. Gibbs struct ccb_hdr ccb_h; 2888b8a9b1dSJustin T. Gibbs struct scsi_inquiry_data inq_data; 2898b8a9b1dSJustin T. Gibbs u_int8_t serial_num[252]; 2903393f8daSKenneth D. Merry u_int8_t reserved; 2918b8a9b1dSJustin T. Gibbs u_int8_t serial_num_len; 2928b8a9b1dSJustin T. Gibbs }; 2938b8a9b1dSJustin T. Gibbs 29487cfaf0eSJustin T. Gibbs /* Device Statistics CCB */ 29587cfaf0eSJustin T. Gibbs struct ccb_getdevstats { 29687cfaf0eSJustin T. Gibbs struct ccb_hdr ccb_h; 29787cfaf0eSJustin T. Gibbs int dev_openings; /* Space left for more work on device*/ 29887cfaf0eSJustin T. Gibbs int dev_active; /* Transactions running on the device */ 29987cfaf0eSJustin T. Gibbs int devq_openings; /* Space left for more queued work */ 30087cfaf0eSJustin T. Gibbs int devq_queued; /* Transactions queued to be sent */ 30187cfaf0eSJustin T. Gibbs int held; /* 30287cfaf0eSJustin T. Gibbs * CCBs held by peripheral drivers 30387cfaf0eSJustin T. Gibbs * for this device 30487cfaf0eSJustin T. Gibbs */ 30582815562SJustin T. Gibbs int maxtags; /* 30682815562SJustin T. Gibbs * Boundary conditions for number of 30782815562SJustin T. Gibbs * tagged operations 30882815562SJustin T. Gibbs */ 30982815562SJustin T. Gibbs int mintags; 31087cfaf0eSJustin T. Gibbs struct timeval last_reset; /* Time of last bus reset/loop init */ 31187cfaf0eSJustin T. Gibbs }; 3128b8a9b1dSJustin T. Gibbs 3138b8a9b1dSJustin T. Gibbs typedef enum { 3148b8a9b1dSJustin T. Gibbs CAM_GDEVLIST_LAST_DEVICE, 3158b8a9b1dSJustin T. Gibbs CAM_GDEVLIST_LIST_CHANGED, 3168b8a9b1dSJustin T. Gibbs CAM_GDEVLIST_MORE_DEVS, 3178b8a9b1dSJustin T. Gibbs CAM_GDEVLIST_ERROR 3188b8a9b1dSJustin T. Gibbs } ccb_getdevlist_status_e; 3198b8a9b1dSJustin T. Gibbs 3208b8a9b1dSJustin T. Gibbs struct ccb_getdevlist { 3218b8a9b1dSJustin T. Gibbs struct ccb_hdr ccb_h; 3228b8a9b1dSJustin T. Gibbs char periph_name[DEV_IDLEN]; 3238b8a9b1dSJustin T. Gibbs u_int32_t unit_number; 3248b8a9b1dSJustin T. Gibbs unsigned int generation; 3258b8a9b1dSJustin T. Gibbs u_int32_t index; 3268b8a9b1dSJustin T. Gibbs ccb_getdevlist_status_e status; 3278b8a9b1dSJustin T. Gibbs }; 3288b8a9b1dSJustin T. Gibbs 3298b8a9b1dSJustin T. Gibbs typedef enum { 3308b8a9b1dSJustin T. Gibbs PERIPH_MATCH_NONE = 0x000, 3318b8a9b1dSJustin T. Gibbs PERIPH_MATCH_PATH = 0x001, 3328b8a9b1dSJustin T. Gibbs PERIPH_MATCH_TARGET = 0x002, 3338b8a9b1dSJustin T. Gibbs PERIPH_MATCH_LUN = 0x004, 3348b8a9b1dSJustin T. Gibbs PERIPH_MATCH_NAME = 0x008, 3358b8a9b1dSJustin T. Gibbs PERIPH_MATCH_UNIT = 0x010, 3368b8a9b1dSJustin T. Gibbs PERIPH_MATCH_ANY = 0x01f 3378b8a9b1dSJustin T. Gibbs } periph_pattern_flags; 3388b8a9b1dSJustin T. Gibbs 3398b8a9b1dSJustin T. Gibbs struct periph_match_pattern { 3408b8a9b1dSJustin T. Gibbs char periph_name[DEV_IDLEN]; 3418b8a9b1dSJustin T. Gibbs u_int32_t unit_number; 3428b8a9b1dSJustin T. Gibbs path_id_t path_id; 3438b8a9b1dSJustin T. Gibbs target_id_t target_id; 3448b8a9b1dSJustin T. Gibbs lun_id_t target_lun; 3458b8a9b1dSJustin T. Gibbs periph_pattern_flags flags; 3468b8a9b1dSJustin T. Gibbs }; 3478b8a9b1dSJustin T. Gibbs 3488b8a9b1dSJustin T. Gibbs typedef enum { 3498b8a9b1dSJustin T. Gibbs DEV_MATCH_NONE = 0x000, 3508b8a9b1dSJustin T. Gibbs DEV_MATCH_PATH = 0x001, 3518b8a9b1dSJustin T. Gibbs DEV_MATCH_TARGET = 0x002, 3528b8a9b1dSJustin T. Gibbs DEV_MATCH_LUN = 0x004, 3538b8a9b1dSJustin T. Gibbs DEV_MATCH_INQUIRY = 0x008, 3548b8a9b1dSJustin T. Gibbs DEV_MATCH_ANY = 0x00f 3558b8a9b1dSJustin T. Gibbs } dev_pattern_flags; 3568b8a9b1dSJustin T. Gibbs 3578b8a9b1dSJustin T. Gibbs struct device_match_pattern { 3588b8a9b1dSJustin T. Gibbs path_id_t path_id; 3598b8a9b1dSJustin T. Gibbs target_id_t target_id; 3608b8a9b1dSJustin T. Gibbs lun_id_t target_lun; 3618b8a9b1dSJustin T. Gibbs struct scsi_static_inquiry_pattern inq_pat; 3628b8a9b1dSJustin T. Gibbs dev_pattern_flags flags; 3638b8a9b1dSJustin T. Gibbs }; 3648b8a9b1dSJustin T. Gibbs 3658b8a9b1dSJustin T. Gibbs typedef enum { 3668b8a9b1dSJustin T. Gibbs BUS_MATCH_NONE = 0x000, 3678b8a9b1dSJustin T. Gibbs BUS_MATCH_PATH = 0x001, 3688b8a9b1dSJustin T. Gibbs BUS_MATCH_NAME = 0x002, 3698b8a9b1dSJustin T. Gibbs BUS_MATCH_UNIT = 0x004, 3708b8a9b1dSJustin T. Gibbs BUS_MATCH_BUS_ID = 0x008, 3718b8a9b1dSJustin T. Gibbs BUS_MATCH_ANY = 0x00f 3728b8a9b1dSJustin T. Gibbs } bus_pattern_flags; 3738b8a9b1dSJustin T. Gibbs 3748b8a9b1dSJustin T. Gibbs struct bus_match_pattern { 3758b8a9b1dSJustin T. Gibbs path_id_t path_id; 3768b8a9b1dSJustin T. Gibbs char dev_name[DEV_IDLEN]; 3778b8a9b1dSJustin T. Gibbs u_int32_t unit_number; 3788b8a9b1dSJustin T. Gibbs u_int32_t bus_id; 3798b8a9b1dSJustin T. Gibbs bus_pattern_flags flags; 3808b8a9b1dSJustin T. Gibbs }; 3818b8a9b1dSJustin T. Gibbs 3828b8a9b1dSJustin T. Gibbs union match_pattern { 3838b8a9b1dSJustin T. Gibbs struct periph_match_pattern periph_pattern; 3848b8a9b1dSJustin T. Gibbs struct device_match_pattern device_pattern; 3858b8a9b1dSJustin T. Gibbs struct bus_match_pattern bus_pattern; 3868b8a9b1dSJustin T. Gibbs }; 3878b8a9b1dSJustin T. Gibbs 3888b8a9b1dSJustin T. Gibbs typedef enum { 3898b8a9b1dSJustin T. Gibbs DEV_MATCH_PERIPH, 3908b8a9b1dSJustin T. Gibbs DEV_MATCH_DEVICE, 3918b8a9b1dSJustin T. Gibbs DEV_MATCH_BUS 3928b8a9b1dSJustin T. Gibbs } dev_match_type; 3938b8a9b1dSJustin T. Gibbs 3948b8a9b1dSJustin T. Gibbs struct dev_match_pattern { 3958b8a9b1dSJustin T. Gibbs dev_match_type type; 3968b8a9b1dSJustin T. Gibbs union match_pattern pattern; 3978b8a9b1dSJustin T. Gibbs }; 3988b8a9b1dSJustin T. Gibbs 3998b8a9b1dSJustin T. Gibbs struct periph_match_result { 4008b8a9b1dSJustin T. Gibbs char periph_name[DEV_IDLEN]; 4018b8a9b1dSJustin T. Gibbs u_int32_t unit_number; 4028b8a9b1dSJustin T. Gibbs path_id_t path_id; 4038b8a9b1dSJustin T. Gibbs target_id_t target_id; 4048b8a9b1dSJustin T. Gibbs lun_id_t target_lun; 4058b8a9b1dSJustin T. Gibbs }; 4068b8a9b1dSJustin T. Gibbs 4079deea857SKenneth D. Merry typedef enum { 4089deea857SKenneth D. Merry DEV_RESULT_NOFLAG = 0x00, 4099deea857SKenneth D. Merry DEV_RESULT_UNCONFIGURED = 0x01 4109deea857SKenneth D. Merry } dev_result_flags; 4119deea857SKenneth D. Merry 4128b8a9b1dSJustin T. Gibbs struct device_match_result { 4138b8a9b1dSJustin T. Gibbs path_id_t path_id; 4148b8a9b1dSJustin T. Gibbs target_id_t target_id; 4158b8a9b1dSJustin T. Gibbs lun_id_t target_lun; 4168b8a9b1dSJustin T. Gibbs struct scsi_inquiry_data inq_data; 4179deea857SKenneth D. Merry dev_result_flags flags; 4188b8a9b1dSJustin T. Gibbs }; 4198b8a9b1dSJustin T. Gibbs 4208b8a9b1dSJustin T. Gibbs struct bus_match_result { 4218b8a9b1dSJustin T. Gibbs path_id_t path_id; 4228b8a9b1dSJustin T. Gibbs char dev_name[DEV_IDLEN]; 4238b8a9b1dSJustin T. Gibbs u_int32_t unit_number; 4248b8a9b1dSJustin T. Gibbs u_int32_t bus_id; 4258b8a9b1dSJustin T. Gibbs }; 4268b8a9b1dSJustin T. Gibbs 4278b8a9b1dSJustin T. Gibbs union match_result { 4288b8a9b1dSJustin T. Gibbs struct periph_match_result periph_result; 4298b8a9b1dSJustin T. Gibbs struct device_match_result device_result; 4308b8a9b1dSJustin T. Gibbs struct bus_match_result bus_result; 4318b8a9b1dSJustin T. Gibbs }; 4328b8a9b1dSJustin T. Gibbs 4338b8a9b1dSJustin T. Gibbs struct dev_match_result { 4348b8a9b1dSJustin T. Gibbs dev_match_type type; 4358b8a9b1dSJustin T. Gibbs union match_result result; 4368b8a9b1dSJustin T. Gibbs }; 4378b8a9b1dSJustin T. Gibbs 4388b8a9b1dSJustin T. Gibbs typedef enum { 4398b8a9b1dSJustin T. Gibbs CAM_DEV_MATCH_LAST, 4408b8a9b1dSJustin T. Gibbs CAM_DEV_MATCH_MORE, 4418b8a9b1dSJustin T. Gibbs CAM_DEV_MATCH_LIST_CHANGED, 4428b8a9b1dSJustin T. Gibbs CAM_DEV_MATCH_SIZE_ERROR, 4438b8a9b1dSJustin T. Gibbs CAM_DEV_MATCH_ERROR 4448b8a9b1dSJustin T. Gibbs } ccb_dev_match_status; 4458b8a9b1dSJustin T. Gibbs 4468b8a9b1dSJustin T. Gibbs typedef enum { 4478b8a9b1dSJustin T. Gibbs CAM_DEV_POS_NONE = 0x000, 4488b8a9b1dSJustin T. Gibbs CAM_DEV_POS_BUS = 0x001, 4498b8a9b1dSJustin T. Gibbs CAM_DEV_POS_TARGET = 0x002, 4508b8a9b1dSJustin T. Gibbs CAM_DEV_POS_DEVICE = 0x004, 4518b8a9b1dSJustin T. Gibbs CAM_DEV_POS_PERIPH = 0x008, 4528b8a9b1dSJustin T. Gibbs CAM_DEV_POS_PDPTR = 0x010, 4538b8a9b1dSJustin T. Gibbs CAM_DEV_POS_TYPEMASK = 0xf00, 4548b8a9b1dSJustin T. Gibbs CAM_DEV_POS_EDT = 0x100, 4558b8a9b1dSJustin T. Gibbs CAM_DEV_POS_PDRV = 0x200 4568b8a9b1dSJustin T. Gibbs } dev_pos_type; 4578b8a9b1dSJustin T. Gibbs 4588b8a9b1dSJustin T. Gibbs struct ccb_dm_cookie { 4598b8a9b1dSJustin T. Gibbs void *bus; 4608b8a9b1dSJustin T. Gibbs void *target; 4618b8a9b1dSJustin T. Gibbs void *device; 4628b8a9b1dSJustin T. Gibbs void *periph; 4638b8a9b1dSJustin T. Gibbs void *pdrv; 4648b8a9b1dSJustin T. Gibbs }; 4658b8a9b1dSJustin T. Gibbs 4668b8a9b1dSJustin T. Gibbs struct ccb_dev_position { 4678b8a9b1dSJustin T. Gibbs u_int generations[4]; 4688b8a9b1dSJustin T. Gibbs #define CAM_BUS_GENERATION 0x00 4698b8a9b1dSJustin T. Gibbs #define CAM_TARGET_GENERATION 0x01 4708b8a9b1dSJustin T. Gibbs #define CAM_DEV_GENERATION 0x02 4718b8a9b1dSJustin T. Gibbs #define CAM_PERIPH_GENERATION 0x03 4728b8a9b1dSJustin T. Gibbs dev_pos_type position_type; 4738b8a9b1dSJustin T. Gibbs struct ccb_dm_cookie cookie; 4748b8a9b1dSJustin T. Gibbs }; 4758b8a9b1dSJustin T. Gibbs 4768b8a9b1dSJustin T. Gibbs struct ccb_dev_match { 4778b8a9b1dSJustin T. Gibbs struct ccb_hdr ccb_h; 4788b8a9b1dSJustin T. Gibbs ccb_dev_match_status status; 4798b8a9b1dSJustin T. Gibbs u_int32_t num_patterns; 4808b8a9b1dSJustin T. Gibbs u_int32_t pattern_buf_len; 4818b8a9b1dSJustin T. Gibbs struct dev_match_pattern *patterns; 4828b8a9b1dSJustin T. Gibbs u_int32_t num_matches; 4838b8a9b1dSJustin T. Gibbs u_int32_t match_buf_len; 4848b8a9b1dSJustin T. Gibbs struct dev_match_result *matches; 4858b8a9b1dSJustin T. Gibbs struct ccb_dev_position pos; 4868b8a9b1dSJustin T. Gibbs }; 4878b8a9b1dSJustin T. Gibbs 4888b8a9b1dSJustin T. Gibbs /* 4898b8a9b1dSJustin T. Gibbs * Definitions for the path inquiry CCB fields. 4908b8a9b1dSJustin T. Gibbs */ 491c7abe45eSMatt Jacob #define CAM_VERSION 0x14 /* Hex value for current version */ 4928b8a9b1dSJustin T. Gibbs 4938b8a9b1dSJustin T. Gibbs typedef enum { 4948b8a9b1dSJustin T. Gibbs PI_MDP_ABLE = 0x80, /* Supports MDP message */ 4958b8a9b1dSJustin T. Gibbs PI_WIDE_32 = 0x40, /* Supports 32 bit wide SCSI */ 4968b8a9b1dSJustin T. Gibbs PI_WIDE_16 = 0x20, /* Supports 16 bit wide SCSI */ 4978b8a9b1dSJustin T. Gibbs PI_SDTR_ABLE = 0x10, /* Supports SDTR message */ 4988b8a9b1dSJustin T. Gibbs PI_LINKED_CDB = 0x08, /* Supports linked CDBs */ 4998b8a9b1dSJustin T. Gibbs PI_TAG_ABLE = 0x02, /* Supports tag queue messages */ 500273a1a3dSKenneth D. Merry PI_SOFT_RST = 0x01 /* Supports soft reset alternative */ 5018b8a9b1dSJustin T. Gibbs } pi_inqflag; 5028b8a9b1dSJustin T. Gibbs 5038b8a9b1dSJustin T. Gibbs typedef enum { 5048b8a9b1dSJustin T. Gibbs PIT_PROCESSOR = 0x80, /* Target mode processor mode */ 5058b8a9b1dSJustin T. Gibbs PIT_PHASE = 0x40, /* Target mode phase cog. mode */ 5068b8a9b1dSJustin T. Gibbs PIT_DISCONNECT = 0x20, /* Disconnects supported in target mode */ 5078b8a9b1dSJustin T. Gibbs PIT_TERM_IO = 0x10, /* Terminate I/O message supported in TM */ 5088b8a9b1dSJustin T. Gibbs PIT_GRP_6 = 0x08, /* Group 6 commands supported */ 509273a1a3dSKenneth D. Merry PIT_GRP_7 = 0x04 /* Group 7 commands supported */ 5108b8a9b1dSJustin T. Gibbs } pi_tmflag; 5118b8a9b1dSJustin T. Gibbs 5128b8a9b1dSJustin T. Gibbs typedef enum { 5138b8a9b1dSJustin T. Gibbs PIM_SCANHILO = 0x80, /* Bus scans from high ID to low ID */ 5148b8a9b1dSJustin T. Gibbs PIM_NOREMOVE = 0x40, /* Removeable devices not included in scan */ 51598192658SJustin T. Gibbs PIM_NOINITIATOR = 0x20, /* Initiator role not supported. */ 516273a1a3dSKenneth D. Merry PIM_NOBUSRESET = 0x10 /* User has disabled initial BUS RESET */ 5178b8a9b1dSJustin T. Gibbs } pi_miscflag; 5188b8a9b1dSJustin T. Gibbs 5193393f8daSKenneth D. Merry #ifdef CAM_NEW_TRAN_CODE 5208b8a9b1dSJustin T. Gibbs /* Path Inquiry CCB */ 5213393f8daSKenneth D. Merry struct ccb_pathinq_settings_spi { 5223393f8daSKenneth D. Merry u_int8_t ppr_options; 5233393f8daSKenneth D. Merry }; 524fd13aa47SMatt Jacob struct ccb_pathinq_settings_fc { 525fd13aa47SMatt Jacob u_int64_t wwnn; /* world wide node name */ 526fd13aa47SMatt Jacob u_int64_t wwpn; /* world wide port name */ 527fd13aa47SMatt Jacob u_int32_t port; /* 24 bit port id, if known */ 528fd13aa47SMatt Jacob u_int32_t bitrate; /* Mbps */ 529fd13aa47SMatt Jacob }; 530fd13aa47SMatt Jacob #define PATHINQ_SETTINGS_SIZE 128 5313393f8daSKenneth D. Merry #endif /* CAM_NEW_TRAN_CODE */ 5323393f8daSKenneth D. Merry 5338b8a9b1dSJustin T. Gibbs struct ccb_pathinq { 5348b8a9b1dSJustin T. Gibbs struct ccb_hdr ccb_h; 5358b8a9b1dSJustin T. Gibbs u_int8_t version_num; /* Version number for the SIM/HBA */ 5368b8a9b1dSJustin T. Gibbs u_int8_t hba_inquiry; /* Mimic of INQ byte 7 for the HBA */ 5378b8a9b1dSJustin T. Gibbs u_int8_t target_sprt; /* Flags for target mode support */ 5388b8a9b1dSJustin T. Gibbs u_int8_t hba_misc; /* Misc HBA features */ 5398b8a9b1dSJustin T. Gibbs u_int16_t hba_eng_cnt; /* HBA engine count */ 5408b8a9b1dSJustin T. Gibbs /* Vendor Unique capabilities */ 5418b8a9b1dSJustin T. Gibbs u_int8_t vuhba_flags[VUHBALEN]; 5428b8a9b1dSJustin T. Gibbs u_int32_t max_target; /* Maximum supported Target */ 5438b8a9b1dSJustin T. Gibbs u_int32_t max_lun; /* Maximum supported Lun */ 5448b8a9b1dSJustin T. Gibbs u_int32_t async_flags; /* Installed Async handlers */ 5458b8a9b1dSJustin T. Gibbs path_id_t hpath_id; /* Highest Path ID in the subsystem */ 5468b8a9b1dSJustin T. Gibbs target_id_t initiator_id; /* ID of the HBA on the SCSI bus */ 5478b8a9b1dSJustin T. Gibbs char sim_vid[SIM_IDLEN]; /* Vendor ID of the SIM */ 5488b8a9b1dSJustin T. Gibbs char hba_vid[HBA_IDLEN]; /* Vendor ID of the HBA */ 5498b8a9b1dSJustin T. Gibbs char dev_name[DEV_IDLEN];/* Device name for SIM */ 5508b8a9b1dSJustin T. Gibbs u_int32_t unit_number; /* Unit number for SIM */ 5518b8a9b1dSJustin T. Gibbs u_int32_t bus_id; /* Bus ID for SIM */ 5529deea857SKenneth D. Merry u_int32_t base_transfer_speed;/* Base bus speed in KB/sec */ 5533393f8daSKenneth D. Merry #ifdef CAM_NEW_TRAN_CODE 5543393f8daSKenneth D. Merry cam_proto protocol; 5553393f8daSKenneth D. Merry u_int protocol_version; 5563393f8daSKenneth D. Merry cam_xport transport; 5573393f8daSKenneth D. Merry u_int transport_version; 5583393f8daSKenneth D. Merry union { 5593393f8daSKenneth D. Merry struct ccb_pathinq_settings_spi spi; 560fd13aa47SMatt Jacob struct ccb_pathinq_settings_fc fc; 561fd13aa47SMatt Jacob char ccb_pathinq_settings_opaque[PATHINQ_SETTINGS_SIZE]; 5623393f8daSKenneth D. Merry } xport_specific; 5633393f8daSKenneth D. Merry #endif /* CAM_NEW_TRAN_CODE */ 5648b8a9b1dSJustin T. Gibbs }; 5658b8a9b1dSJustin T. Gibbs 56687cfaf0eSJustin T. Gibbs /* Path Statistics CCB */ 56787cfaf0eSJustin T. Gibbs struct ccb_pathstats { 56887cfaf0eSJustin T. Gibbs struct ccb_hdr ccb_h; 56987cfaf0eSJustin T. Gibbs struct timeval last_reset; /* Time of last bus reset/loop init */ 57087cfaf0eSJustin T. Gibbs }; 57187cfaf0eSJustin T. Gibbs 5728b8a9b1dSJustin T. Gibbs typedef union { 5738b8a9b1dSJustin T. Gibbs u_int8_t *sense_ptr; /* 5748b8a9b1dSJustin T. Gibbs * Pointer to storage 5758b8a9b1dSJustin T. Gibbs * for sense information 5768b8a9b1dSJustin T. Gibbs */ 5778b8a9b1dSJustin T. Gibbs /* Storage Area for sense information */ 5788b8a9b1dSJustin T. Gibbs struct scsi_sense_data sense_buf; 5798b8a9b1dSJustin T. Gibbs } sense_t; 5808b8a9b1dSJustin T. Gibbs 5818b8a9b1dSJustin T. Gibbs typedef union { 5828b8a9b1dSJustin T. Gibbs u_int8_t *cdb_ptr; /* Pointer to the CDB bytes to send */ 5838b8a9b1dSJustin T. Gibbs /* Area for the CDB send */ 5848b8a9b1dSJustin T. Gibbs u_int8_t cdb_bytes[IOCDBLEN]; 5858b8a9b1dSJustin T. Gibbs } cdb_t; 5868b8a9b1dSJustin T. Gibbs 5878b8a9b1dSJustin T. Gibbs /* 5888b8a9b1dSJustin T. Gibbs * SCSI I/O Request CCB used for the XPT_SCSI_IO and XPT_CONT_TARGET_IO 5898b8a9b1dSJustin T. Gibbs * function codes. 5908b8a9b1dSJustin T. Gibbs */ 5918b8a9b1dSJustin T. Gibbs struct ccb_scsiio { 5928b8a9b1dSJustin T. Gibbs struct ccb_hdr ccb_h; 5938b8a9b1dSJustin T. Gibbs union ccb *next_ccb; /* Ptr for next CCB for action */ 5948b8a9b1dSJustin T. Gibbs u_int8_t *req_map; /* Ptr to mapping info */ 5958b8a9b1dSJustin T. Gibbs u_int8_t *data_ptr; /* Ptr to the data buf/SG list */ 5968b8a9b1dSJustin T. Gibbs u_int32_t dxfer_len; /* Data transfer length */ 5978b8a9b1dSJustin T. Gibbs /* Autosense storage */ 5988b8a9b1dSJustin T. Gibbs struct scsi_sense_data sense_data; 5998b8a9b1dSJustin T. Gibbs u_int8_t sense_len; /* Number of bytes to autosense */ 6008b8a9b1dSJustin T. Gibbs u_int8_t cdb_len; /* Number of bytes for the CDB */ 6018b8a9b1dSJustin T. Gibbs u_int16_t sglist_cnt; /* Number of SG list entries */ 6028b8a9b1dSJustin T. Gibbs u_int8_t scsi_status; /* Returned SCSI status */ 6038b8a9b1dSJustin T. Gibbs u_int8_t sense_resid; /* Autosense resid length: 2's comp */ 6048b8a9b1dSJustin T. Gibbs u_int32_t resid; /* Transfer residual length: 2's comp */ 6058b8a9b1dSJustin T. Gibbs cdb_t cdb_io; /* Union for CDB bytes/pointer */ 6068b8a9b1dSJustin T. Gibbs u_int8_t *msg_ptr; /* Pointer to the message buffer */ 6078b8a9b1dSJustin T. Gibbs u_int16_t msg_len; /* Number of bytes for the Message */ 6088b8a9b1dSJustin T. Gibbs u_int8_t tag_action; /* What to do for tag queueing */ 609bb1f2fe4SJustin T. Gibbs /* 610bb1f2fe4SJustin T. Gibbs * The tag action should be either the define below (to send a 611bb1f2fe4SJustin T. Gibbs * non-tagged transaction) or one of the defined scsi tag messages 612bb1f2fe4SJustin T. Gibbs * from scsi_message.h. 613bb1f2fe4SJustin T. Gibbs */ 614bb1f2fe4SJustin T. Gibbs #define CAM_TAG_ACTION_NONE 0x00 615bf8bb7acSJustin T. Gibbs u_int tag_id; /* tag id from initator (target mode) */ 616bf8bb7acSJustin T. Gibbs u_int init_id; /* initiator id of who selected */ 6178b8a9b1dSJustin T. Gibbs }; 6188b8a9b1dSJustin T. Gibbs 6198b8a9b1dSJustin T. Gibbs struct ccb_accept_tio { 6208b8a9b1dSJustin T. Gibbs struct ccb_hdr ccb_h; 6218b8a9b1dSJustin T. Gibbs cdb_t cdb_io; /* Union for CDB bytes/pointer */ 6228b8a9b1dSJustin T. Gibbs u_int8_t cdb_len; /* Number of bytes for the CDB */ 6238b8a9b1dSJustin T. Gibbs u_int8_t tag_action; /* What to do for tag queueing */ 624826eb7c8SMatt Jacob u_int8_t sense_len; /* Number of bytes of Sense Data */ 6252759b3c7SMatt Jacob u_int tag_id; /* tag id from initator (target mode) */ 6262759b3c7SMatt Jacob u_int init_id; /* initiator id of who selected */ 627826eb7c8SMatt Jacob struct scsi_sense_data sense_data; 6288b8a9b1dSJustin T. Gibbs }; 6298b8a9b1dSJustin T. Gibbs 6308b8a9b1dSJustin T. Gibbs /* Release SIM Queue */ 6318b8a9b1dSJustin T. Gibbs struct ccb_relsim { 6328b8a9b1dSJustin T. Gibbs struct ccb_hdr ccb_h; 6338b8a9b1dSJustin T. Gibbs u_int32_t release_flags; 6348b8a9b1dSJustin T. Gibbs #define RELSIM_ADJUST_OPENINGS 0x01 6358b8a9b1dSJustin T. Gibbs #define RELSIM_RELEASE_AFTER_TIMEOUT 0x02 6368b8a9b1dSJustin T. Gibbs #define RELSIM_RELEASE_AFTER_CMDCMPLT 0x04 6378b8a9b1dSJustin T. Gibbs #define RELSIM_RELEASE_AFTER_QEMPTY 0x08 6388b8a9b1dSJustin T. Gibbs u_int32_t openings; 6398b8a9b1dSJustin T. Gibbs u_int32_t release_timeout; 6408b8a9b1dSJustin T. Gibbs u_int32_t qfrozen_cnt; 6418b8a9b1dSJustin T. Gibbs }; 6428b8a9b1dSJustin T. Gibbs 6438b8a9b1dSJustin T. Gibbs /* 6448b8a9b1dSJustin T. Gibbs * Definitions for the asynchronous callback CCB fields. 6458b8a9b1dSJustin T. Gibbs */ 6468b8a9b1dSJustin T. Gibbs typedef enum { 6478b8a9b1dSJustin T. Gibbs AC_GETDEV_CHANGED = 0x800,/* Getdev info might have changed */ 6488b8a9b1dSJustin T. Gibbs AC_INQ_CHANGED = 0x400,/* Inquiry info might have changed */ 6498b8a9b1dSJustin T. Gibbs AC_TRANSFER_NEG = 0x200,/* New transfer settings in effect */ 6508b8a9b1dSJustin T. Gibbs AC_LOST_DEVICE = 0x100,/* A device went away */ 6518b8a9b1dSJustin T. Gibbs AC_FOUND_DEVICE = 0x080,/* A new device was found */ 6528b8a9b1dSJustin T. Gibbs AC_PATH_DEREGISTERED = 0x040,/* A path has de-registered */ 6538b8a9b1dSJustin T. Gibbs AC_PATH_REGISTERED = 0x020,/* A new path has been registered */ 6548b8a9b1dSJustin T. Gibbs AC_SENT_BDR = 0x010,/* A BDR message was sent to target */ 6558b8a9b1dSJustin T. Gibbs AC_SCSI_AEN = 0x008,/* A SCSI AEN has been received */ 6568b8a9b1dSJustin T. Gibbs AC_UNSOL_RESEL = 0x002,/* Unsolicited reselection occurred */ 6578b8a9b1dSJustin T. Gibbs AC_BUS_RESET = 0x001 /* A SCSI bus reset occurred */ 6588b8a9b1dSJustin T. Gibbs } ac_code; 6598b8a9b1dSJustin T. Gibbs 6608b8a9b1dSJustin T. Gibbs typedef void ac_callback_t (void *softc, u_int32_t code, 6618b8a9b1dSJustin T. Gibbs struct cam_path *path, void *args); 6628b8a9b1dSJustin T. Gibbs 6638b8a9b1dSJustin T. Gibbs /* Set Asynchronous Callback CCB */ 6648b8a9b1dSJustin T. Gibbs struct ccb_setasync { 6658b8a9b1dSJustin T. Gibbs struct ccb_hdr ccb_h; 6668b8a9b1dSJustin T. Gibbs u_int32_t event_enable; /* Async Event enables */ 6678b8a9b1dSJustin T. Gibbs ac_callback_t *callback; 6688b8a9b1dSJustin T. Gibbs void *callback_arg; 6698b8a9b1dSJustin T. Gibbs }; 6708b8a9b1dSJustin T. Gibbs 6718b8a9b1dSJustin T. Gibbs /* Set Device Type CCB */ 6728b8a9b1dSJustin T. Gibbs struct ccb_setdev { 6738b8a9b1dSJustin T. Gibbs struct ccb_hdr ccb_h; 6748b8a9b1dSJustin T. Gibbs u_int8_t dev_type; /* Value for dev type field in EDT */ 6758b8a9b1dSJustin T. Gibbs }; 6768b8a9b1dSJustin T. Gibbs 6778b8a9b1dSJustin T. Gibbs /* SCSI Control Functions */ 6788b8a9b1dSJustin T. Gibbs 6798b8a9b1dSJustin T. Gibbs /* Abort XPT request CCB */ 6808b8a9b1dSJustin T. Gibbs struct ccb_abort { 6818b8a9b1dSJustin T. Gibbs struct ccb_hdr ccb_h; 6828b8a9b1dSJustin T. Gibbs union ccb *abort_ccb; /* Pointer to CCB to abort */ 6838b8a9b1dSJustin T. Gibbs }; 6848b8a9b1dSJustin T. Gibbs 6858b8a9b1dSJustin T. Gibbs /* Reset SCSI Bus CCB */ 6868b8a9b1dSJustin T. Gibbs struct ccb_resetbus { 6878b8a9b1dSJustin T. Gibbs struct ccb_hdr ccb_h; 6888b8a9b1dSJustin T. Gibbs }; 6898b8a9b1dSJustin T. Gibbs 6908b8a9b1dSJustin T. Gibbs /* Reset SCSI Device CCB */ 6918b8a9b1dSJustin T. Gibbs struct ccb_resetdev { 6928b8a9b1dSJustin T. Gibbs struct ccb_hdr ccb_h; 6938b8a9b1dSJustin T. Gibbs }; 6948b8a9b1dSJustin T. Gibbs 6958b8a9b1dSJustin T. Gibbs /* Terminate I/O Process Request CCB */ 6968b8a9b1dSJustin T. Gibbs struct ccb_termio { 6978b8a9b1dSJustin T. Gibbs struct ccb_hdr ccb_h; 6988b8a9b1dSJustin T. Gibbs union ccb *termio_ccb; /* Pointer to CCB to terminate */ 6998b8a9b1dSJustin T. Gibbs }; 7008b8a9b1dSJustin T. Gibbs 7013393f8daSKenneth D. Merry #ifndef CAM_NEW_TRAN_CODE 7028b8a9b1dSJustin T. Gibbs /* Get/Set transfer rate/width/disconnection/tag queueing settings */ 7038b8a9b1dSJustin T. Gibbs struct ccb_trans_settings { 7048b8a9b1dSJustin T. Gibbs struct ccb_hdr ccb_h; 7058b8a9b1dSJustin T. Gibbs u_int valid; /* Which fields to honor */ 7068b8a9b1dSJustin T. Gibbs #define CCB_TRANS_SYNC_RATE_VALID 0x01 7078b8a9b1dSJustin T. Gibbs #define CCB_TRANS_SYNC_OFFSET_VALID 0x02 7088b8a9b1dSJustin T. Gibbs #define CCB_TRANS_BUS_WIDTH_VALID 0x04 7098b8a9b1dSJustin T. Gibbs #define CCB_TRANS_DISC_VALID 0x08 7108b8a9b1dSJustin T. Gibbs #define CCB_TRANS_TQ_VALID 0x10 7118b8a9b1dSJustin T. Gibbs u_int flags; 7128b8a9b1dSJustin T. Gibbs #define CCB_TRANS_CURRENT_SETTINGS 0x01 7138b8a9b1dSJustin T. Gibbs #define CCB_TRANS_USER_SETTINGS 0x02 7148b8a9b1dSJustin T. Gibbs #define CCB_TRANS_DISC_ENB 0x04 7158b8a9b1dSJustin T. Gibbs #define CCB_TRANS_TAG_ENB 0x08 7168b8a9b1dSJustin T. Gibbs u_int sync_period; 7178b8a9b1dSJustin T. Gibbs u_int sync_offset; 7188b8a9b1dSJustin T. Gibbs u_int bus_width; 7198b8a9b1dSJustin T. Gibbs }; 7208b8a9b1dSJustin T. Gibbs 7213393f8daSKenneth D. Merry #else /* CAM_NEW_TRAN_CODE */ 7223393f8daSKenneth D. Merry typedef enum { 7233393f8daSKenneth D. Merry CTS_TYPE_CURRENT_SETTINGS, 7243393f8daSKenneth D. Merry CTS_TYPE_USER_SETTINGS 7253393f8daSKenneth D. Merry } cts_type; 7263393f8daSKenneth D. Merry 7273393f8daSKenneth D. Merry struct ccb_trans_settings_scsi 7283393f8daSKenneth D. Merry { 7293393f8daSKenneth D. Merry u_int valid; /* Which fields to honor */ 7303393f8daSKenneth D. Merry #define CTS_SCSI_VALID_TQ 0x01 7313393f8daSKenneth D. Merry u_int flags; 7323393f8daSKenneth D. Merry #define CTS_SCSI_FLAGS_TAG_ENB 0x01 7333393f8daSKenneth D. Merry }; 7343393f8daSKenneth D. Merry 7353393f8daSKenneth D. Merry struct ccb_trans_settings_spi 7363393f8daSKenneth D. Merry { 7373393f8daSKenneth D. Merry u_int valid; /* Which fields to honor */ 7383393f8daSKenneth D. Merry #define CTS_SPI_VALID_SYNC_RATE 0x01 7393393f8daSKenneth D. Merry #define CTS_SPI_VALID_SYNC_OFFSET 0x02 7403393f8daSKenneth D. Merry #define CTS_SPI_VALID_BUS_WIDTH 0x04 7413393f8daSKenneth D. Merry #define CTS_SPI_VALID_DISC 0x08 7423393f8daSKenneth D. Merry #define CTS_SPI_VALID_PPR_OPTIONS 0x10 7433393f8daSKenneth D. Merry u_int flags; 7443393f8daSKenneth D. Merry #define CTS_SPI_FLAGS_DISC_ENB 0x01 7453393f8daSKenneth D. Merry #define CTS_SPI_FLAGS_TAG_ENB 0x02 7463393f8daSKenneth D. Merry u_int sync_period; 7473393f8daSKenneth D. Merry u_int sync_offset; 7483393f8daSKenneth D. Merry u_int bus_width; 7493393f8daSKenneth D. Merry u_int ppr_options; 7503393f8daSKenneth D. Merry }; 7513393f8daSKenneth D. Merry 752c1c84cd9SMatt Jacob struct ccb_trans_settings_fc { 753c1c84cd9SMatt Jacob u_int valid; /* Which fields to honor */ 754c1c84cd9SMatt Jacob #define CTS_FC_VALID_WWNN 0x8000 755c1c84cd9SMatt Jacob #define CTS_FC_VALID_WWPN 0x4000 756c1c84cd9SMatt Jacob #define CTS_FC_VALID_PORT 0x2000 757c1c84cd9SMatt Jacob #define CTS_FC_VALID_SPEED 0x1000 758c1c84cd9SMatt Jacob u_int64_t wwnn; /* world wide node name */ 759c1c84cd9SMatt Jacob u_int64_t wwpn; /* world wide port name */ 760c1c84cd9SMatt Jacob u_int32_t port; /* 24 bit port id, if known */ 761c1c84cd9SMatt Jacob u_int32_t bitrate; /* Mbps */ 762c1c84cd9SMatt Jacob }; 763c1c84cd9SMatt Jacob 7643393f8daSKenneth D. Merry /* Get/Set transfer rate/width/disconnection/tag queueing settings */ 7653393f8daSKenneth D. Merry struct ccb_trans_settings { 7663393f8daSKenneth D. Merry struct ccb_hdr ccb_h; 7673393f8daSKenneth D. Merry cts_type type; /* Current or User settings */ 7683393f8daSKenneth D. Merry cam_proto protocol; 7693393f8daSKenneth D. Merry u_int protocol_version; 7703393f8daSKenneth D. Merry cam_xport transport; 7713393f8daSKenneth D. Merry u_int transport_version; 7723393f8daSKenneth D. Merry union { 7733393f8daSKenneth D. Merry u_int valid; /* Which fields to honor */ 7743393f8daSKenneth D. Merry struct ccb_trans_settings_scsi scsi; 7753393f8daSKenneth D. Merry } proto_specific; 7763393f8daSKenneth D. Merry union { 7773393f8daSKenneth D. Merry u_int valid; /* Which fields to honor */ 7783393f8daSKenneth D. Merry struct ccb_trans_settings_spi spi; 779c1c84cd9SMatt Jacob struct ccb_trans_settings_fc fc; 7803393f8daSKenneth D. Merry } xport_specific; 7813393f8daSKenneth D. Merry }; 7823393f8daSKenneth D. Merry 7833393f8daSKenneth D. Merry #endif /* CAM_NEW_TRAN_CODE */ 7843393f8daSKenneth D. Merry 7858b8a9b1dSJustin T. Gibbs /* 7868b8a9b1dSJustin T. Gibbs * Calculate the geometry parameters for a device 7878b8a9b1dSJustin T. Gibbs * give the block size and volume size in blocks. 7888b8a9b1dSJustin T. Gibbs */ 7898b8a9b1dSJustin T. Gibbs struct ccb_calc_geometry { 7908b8a9b1dSJustin T. Gibbs struct ccb_hdr ccb_h; 7918b8a9b1dSJustin T. Gibbs u_int32_t block_size; 7928b8a9b1dSJustin T. Gibbs u_int32_t volume_size; 7938b8a9b1dSJustin T. Gibbs u_int16_t cylinders; 7948b8a9b1dSJustin T. Gibbs u_int8_t heads; 7958b8a9b1dSJustin T. Gibbs u_int8_t secs_per_track; 7968b8a9b1dSJustin T. Gibbs }; 7978b8a9b1dSJustin T. Gibbs 7988b8a9b1dSJustin T. Gibbs /* 7998b8a9b1dSJustin T. Gibbs * Rescan the given bus, or bus/target/lun 8008b8a9b1dSJustin T. Gibbs */ 8018b8a9b1dSJustin T. Gibbs struct ccb_rescan { 8028b8a9b1dSJustin T. Gibbs struct ccb_hdr ccb_h; 8038b8a9b1dSJustin T. Gibbs cam_flags flags; 8048b8a9b1dSJustin T. Gibbs }; 8058b8a9b1dSJustin T. Gibbs 8068b8a9b1dSJustin T. Gibbs /* 8078b8a9b1dSJustin T. Gibbs * Turn on debugging for the given bus, bus/target, or bus/target/lun. 8088b8a9b1dSJustin T. Gibbs */ 8098b8a9b1dSJustin T. Gibbs struct ccb_debug { 8108b8a9b1dSJustin T. Gibbs struct ccb_hdr ccb_h; 8118b8a9b1dSJustin T. Gibbs cam_debug_flags flags; 8128b8a9b1dSJustin T. Gibbs }; 8138b8a9b1dSJustin T. Gibbs 8148b8a9b1dSJustin T. Gibbs /* Target mode structures. */ 8158b8a9b1dSJustin T. Gibbs 8168b8a9b1dSJustin T. Gibbs struct ccb_en_lun { 8178b8a9b1dSJustin T. Gibbs struct ccb_hdr ccb_h; 8188b8a9b1dSJustin T. Gibbs u_int16_t grp6_len; /* Group 6 VU CDB length */ 8198b8a9b1dSJustin T. Gibbs u_int16_t grp7_len; /* Group 7 VU CDB length */ 8208b8a9b1dSJustin T. Gibbs u_int8_t enable; 8218b8a9b1dSJustin T. Gibbs }; 8228b8a9b1dSJustin T. Gibbs 8238b8a9b1dSJustin T. Gibbs struct ccb_immed_notify { 8248b8a9b1dSJustin T. Gibbs struct ccb_hdr ccb_h; 8258b8a9b1dSJustin T. Gibbs struct scsi_sense_data sense_data; 826826eb7c8SMatt Jacob u_int8_t sense_len; /* Number of bytes in sense buffer */ 8278b8a9b1dSJustin T. Gibbs u_int8_t initiator_id; /* Id of initiator that selected */ 8288b8a9b1dSJustin T. Gibbs u_int8_t message_args[7]; /* Message Arguments */ 8298b8a9b1dSJustin T. Gibbs }; 8308b8a9b1dSJustin T. Gibbs 8318b8a9b1dSJustin T. Gibbs struct ccb_notify_ack { 8328b8a9b1dSJustin T. Gibbs struct ccb_hdr ccb_h; 8338b8a9b1dSJustin T. Gibbs u_int16_t seq_id; /* Sequence identifier */ 8348b8a9b1dSJustin T. Gibbs u_int8_t event; /* Event flags */ 8358b8a9b1dSJustin T. Gibbs }; 8368b8a9b1dSJustin T. Gibbs 8378b8a9b1dSJustin T. Gibbs /* HBA engine structures. */ 8388b8a9b1dSJustin T. Gibbs 8398b8a9b1dSJustin T. Gibbs typedef enum { 8408b8a9b1dSJustin T. Gibbs EIT_BUFFER, /* Engine type: buffer memory */ 8418b8a9b1dSJustin T. Gibbs EIT_LOSSLESS, /* Engine type: lossless compression */ 8428b8a9b1dSJustin T. Gibbs EIT_LOSSY, /* Engine type: lossy compression */ 8438b8a9b1dSJustin T. Gibbs EIT_ENCRYPT /* Engine type: encryption */ 8448b8a9b1dSJustin T. Gibbs } ei_type; 8458b8a9b1dSJustin T. Gibbs 8468b8a9b1dSJustin T. Gibbs typedef enum { 8478b8a9b1dSJustin T. Gibbs EAD_VUNIQUE, /* Engine algorithm ID: vendor unique */ 8488b8a9b1dSJustin T. Gibbs EAD_LZ1V1, /* Engine algorithm ID: LZ1 var.1 */ 8498b8a9b1dSJustin T. Gibbs EAD_LZ2V1, /* Engine algorithm ID: LZ2 var.1 */ 850273a1a3dSKenneth D. Merry EAD_LZ2V2 /* Engine algorithm ID: LZ2 var.2 */ 8518b8a9b1dSJustin T. Gibbs } ei_algo; 8528b8a9b1dSJustin T. Gibbs 8538b8a9b1dSJustin T. Gibbs struct ccb_eng_inq { 8548b8a9b1dSJustin T. Gibbs struct ccb_hdr ccb_h; 8558b8a9b1dSJustin T. Gibbs u_int16_t eng_num; /* The engine number for this inquiry */ 8568b8a9b1dSJustin T. Gibbs ei_type eng_type; /* Returned engine type */ 8578b8a9b1dSJustin T. Gibbs ei_algo eng_algo; /* Returned engine algorithm type */ 8588b8a9b1dSJustin T. Gibbs u_int32_t eng_memeory; /* Returned engine memory size */ 8598b8a9b1dSJustin T. Gibbs }; 8608b8a9b1dSJustin T. Gibbs 8618b8a9b1dSJustin T. Gibbs struct ccb_eng_exec { /* This structure must match SCSIIO size */ 8628b8a9b1dSJustin T. Gibbs struct ccb_hdr ccb_h; 8638b8a9b1dSJustin T. Gibbs u_int8_t *pdrv_ptr; /* Ptr used by the peripheral driver */ 8648b8a9b1dSJustin T. Gibbs u_int8_t *req_map; /* Ptr for mapping info on the req. */ 8658b8a9b1dSJustin T. Gibbs u_int8_t *data_ptr; /* Pointer to the data buf/SG list */ 8668b8a9b1dSJustin T. Gibbs u_int32_t dxfer_len; /* Data transfer length */ 8678b8a9b1dSJustin T. Gibbs u_int8_t *engdata_ptr; /* Pointer to the engine buffer data */ 8688b8a9b1dSJustin T. Gibbs u_int16_t sglist_cnt; /* Num of scatter gather list entries */ 8698b8a9b1dSJustin T. Gibbs u_int32_t dmax_len; /* Destination data maximum length */ 8708b8a9b1dSJustin T. Gibbs u_int32_t dest_len; /* Destination data length */ 8718b8a9b1dSJustin T. Gibbs int32_t src_resid; /* Source residual length: 2's comp */ 8728b8a9b1dSJustin T. Gibbs u_int32_t timeout; /* Timeout value */ 8738b8a9b1dSJustin T. Gibbs u_int16_t eng_num; /* Engine number for this request */ 8748b8a9b1dSJustin T. Gibbs u_int16_t vu_flags; /* Vendor Unique flags */ 8758b8a9b1dSJustin T. Gibbs }; 8768b8a9b1dSJustin T. Gibbs 8778b8a9b1dSJustin T. Gibbs /* 8788b8a9b1dSJustin T. Gibbs * Definitions for the timeout field in the SCSI I/O CCB. 8798b8a9b1dSJustin T. Gibbs */ 8808b8a9b1dSJustin T. Gibbs #define CAM_TIME_DEFAULT 0x00000000 /* Use SIM default value */ 8818b8a9b1dSJustin T. Gibbs #define CAM_TIME_INFINITY 0xFFFFFFFF /* Infinite timeout */ 8828b8a9b1dSJustin T. Gibbs 8838b8a9b1dSJustin T. Gibbs #define CAM_SUCCESS 0 /* For signaling general success */ 8848b8a9b1dSJustin T. Gibbs #define CAM_FAILURE 1 /* For signaling general failure */ 8858b8a9b1dSJustin T. Gibbs 8868b8a9b1dSJustin T. Gibbs #define CAM_FALSE 0 8878b8a9b1dSJustin T. Gibbs #define CAM_TRUE 1 8888b8a9b1dSJustin T. Gibbs 8898b8a9b1dSJustin T. Gibbs #define XPT_CCB_INVALID -1 /* for signaling a bad CCB to free */ 8908b8a9b1dSJustin T. Gibbs 8918b8a9b1dSJustin T. Gibbs /* 8928b8a9b1dSJustin T. Gibbs * Union of all CCB types for kernel space allocation. This union should 8938b8a9b1dSJustin T. Gibbs * never be used for manipulating CCBs - its only use is for the allocation 8948b8a9b1dSJustin T. Gibbs * and deallocation of raw CCB space and is the return type of xpt_ccb_alloc 8958b8a9b1dSJustin T. Gibbs * and the argument to xpt_ccb_free. 8968b8a9b1dSJustin T. Gibbs */ 8978b8a9b1dSJustin T. Gibbs union ccb { 8988b8a9b1dSJustin T. Gibbs struct ccb_hdr ccb_h; /* For convenience */ 8998b8a9b1dSJustin T. Gibbs struct ccb_scsiio csio; 9008b8a9b1dSJustin T. Gibbs struct ccb_getdev cgd; 9018b8a9b1dSJustin T. Gibbs struct ccb_getdevlist cgdl; 9028b8a9b1dSJustin T. Gibbs struct ccb_pathinq cpi; 9038b8a9b1dSJustin T. Gibbs struct ccb_relsim crs; 9048b8a9b1dSJustin T. Gibbs struct ccb_setasync csa; 9058b8a9b1dSJustin T. Gibbs struct ccb_setdev csd; 90687cfaf0eSJustin T. Gibbs struct ccb_pathstats cpis; 90787cfaf0eSJustin T. Gibbs struct ccb_getdevstats cgds; 9088b8a9b1dSJustin T. Gibbs struct ccb_dev_match cdm; 9098b8a9b1dSJustin T. Gibbs struct ccb_trans_settings cts; 9108b8a9b1dSJustin T. Gibbs struct ccb_calc_geometry ccg; 9118b8a9b1dSJustin T. Gibbs struct ccb_abort cab; 9128b8a9b1dSJustin T. Gibbs struct ccb_resetbus crb; 9138b8a9b1dSJustin T. Gibbs struct ccb_resetdev crd; 9148b8a9b1dSJustin T. Gibbs struct ccb_termio tio; 9158b8a9b1dSJustin T. Gibbs struct ccb_accept_tio atio; 9168b8a9b1dSJustin T. Gibbs struct ccb_scsiio ctio; 9178b8a9b1dSJustin T. Gibbs struct ccb_en_lun cel; 9188b8a9b1dSJustin T. Gibbs struct ccb_immed_notify cin; 9198b8a9b1dSJustin T. Gibbs struct ccb_notify_ack cna; 9208b8a9b1dSJustin T. Gibbs struct ccb_eng_inq cei; 9218b8a9b1dSJustin T. Gibbs struct ccb_eng_exec cee; 9228b8a9b1dSJustin T. Gibbs struct ccb_rescan crcn; 9238b8a9b1dSJustin T. Gibbs struct ccb_debug cdbg; 9248b8a9b1dSJustin T. Gibbs }; 9258b8a9b1dSJustin T. Gibbs 9268b8a9b1dSJustin T. Gibbs __BEGIN_DECLS 9278b8a9b1dSJustin T. Gibbs static __inline void 9288b8a9b1dSJustin T. Gibbs cam_fill_csio(struct ccb_scsiio *csio, u_int32_t retries, 9298b8a9b1dSJustin T. Gibbs void (*cbfcnp)(struct cam_periph *, union ccb *), 9308b8a9b1dSJustin T. Gibbs u_int32_t flags, u_int8_t tag_action, 9318b8a9b1dSJustin T. Gibbs u_int8_t *data_ptr, u_int32_t dxfer_len, 9328b8a9b1dSJustin T. Gibbs u_int8_t sense_len, u_int8_t cdb_len, 9338b8a9b1dSJustin T. Gibbs u_int32_t timeout); 9348b8a9b1dSJustin T. Gibbs 9358b8a9b1dSJustin T. Gibbs static __inline void 9368b8a9b1dSJustin T. Gibbs cam_fill_ctio(struct ccb_scsiio *csio, u_int32_t retries, 9378b8a9b1dSJustin T. Gibbs void (*cbfcnp)(struct cam_periph *, union ccb *), 9388b8a9b1dSJustin T. Gibbs u_int32_t flags, u_int tag_action, u_int tag_id, 9398b8a9b1dSJustin T. Gibbs u_int init_id, u_int scsi_status, u_int8_t *data_ptr, 9408b8a9b1dSJustin T. Gibbs u_int32_t dxfer_len, u_int32_t timeout); 9418b8a9b1dSJustin T. Gibbs 9428b8a9b1dSJustin T. Gibbs static __inline void 9438b8a9b1dSJustin T. Gibbs cam_fill_csio(struct ccb_scsiio *csio, u_int32_t retries, 9448b8a9b1dSJustin T. Gibbs void (*cbfcnp)(struct cam_periph *, union ccb *), 9458b8a9b1dSJustin T. Gibbs u_int32_t flags, u_int8_t tag_action, 9468b8a9b1dSJustin T. Gibbs u_int8_t *data_ptr, u_int32_t dxfer_len, 9478b8a9b1dSJustin T. Gibbs u_int8_t sense_len, u_int8_t cdb_len, 9488b8a9b1dSJustin T. Gibbs u_int32_t timeout) 9498b8a9b1dSJustin T. Gibbs { 9508b8a9b1dSJustin T. Gibbs csio->ccb_h.func_code = XPT_SCSI_IO; 9518b8a9b1dSJustin T. Gibbs csio->ccb_h.flags = flags; 9528b8a9b1dSJustin T. Gibbs csio->ccb_h.retry_count = retries; 9538b8a9b1dSJustin T. Gibbs csio->ccb_h.cbfcnp = cbfcnp; 9548b8a9b1dSJustin T. Gibbs csio->ccb_h.timeout = timeout; 9558b8a9b1dSJustin T. Gibbs csio->data_ptr = data_ptr; 9568b8a9b1dSJustin T. Gibbs csio->dxfer_len = dxfer_len; 9578b8a9b1dSJustin T. Gibbs csio->sense_len = sense_len; 9588b8a9b1dSJustin T. Gibbs csio->cdb_len = cdb_len; 9598b8a9b1dSJustin T. Gibbs csio->tag_action = tag_action; 9608b8a9b1dSJustin T. Gibbs } 9618b8a9b1dSJustin T. Gibbs 9628b8a9b1dSJustin T. Gibbs static __inline void 9638b8a9b1dSJustin T. Gibbs cam_fill_ctio(struct ccb_scsiio *csio, u_int32_t retries, 9648b8a9b1dSJustin T. Gibbs void (*cbfcnp)(struct cam_periph *, union ccb *), 9658b8a9b1dSJustin T. Gibbs u_int32_t flags, u_int tag_action, u_int tag_id, 9668b8a9b1dSJustin T. Gibbs u_int init_id, u_int scsi_status, u_int8_t *data_ptr, 9678b8a9b1dSJustin T. Gibbs u_int32_t dxfer_len, u_int32_t timeout) 9688b8a9b1dSJustin T. Gibbs { 9698b8a9b1dSJustin T. Gibbs csio->ccb_h.func_code = XPT_CONT_TARGET_IO; 9708b8a9b1dSJustin T. Gibbs csio->ccb_h.flags = flags; 9718b8a9b1dSJustin T. Gibbs csio->ccb_h.retry_count = retries; 9728b8a9b1dSJustin T. Gibbs csio->ccb_h.cbfcnp = cbfcnp; 9738b8a9b1dSJustin T. Gibbs csio->ccb_h.timeout = timeout; 9748b8a9b1dSJustin T. Gibbs csio->data_ptr = data_ptr; 9758b8a9b1dSJustin T. Gibbs csio->dxfer_len = dxfer_len; 9768b8a9b1dSJustin T. Gibbs csio->scsi_status = scsi_status; 9778b8a9b1dSJustin T. Gibbs csio->tag_action = tag_action; 9788b8a9b1dSJustin T. Gibbs csio->tag_id = tag_id; 9798b8a9b1dSJustin T. Gibbs csio->init_id = init_id; 9808b8a9b1dSJustin T. Gibbs } 9818b8a9b1dSJustin T. Gibbs 9828b8a9b1dSJustin T. Gibbs __END_DECLS 9838b8a9b1dSJustin T. Gibbs 9848b8a9b1dSJustin T. Gibbs #endif /* _CAM_CAM_CCB_H */ 985