1139743Simp/*- 239212Sgibbs * Data structures and definitions for CAM Control Blocks (CCBs). 339212Sgibbs * 439212Sgibbs * Copyright (c) 1997, 1998 Justin T. Gibbs. 539212Sgibbs * All rights reserved. 639212Sgibbs * 739212Sgibbs * Redistribution and use in source and binary forms, with or without 839212Sgibbs * modification, are permitted provided that the following conditions 939212Sgibbs * are met: 1039212Sgibbs * 1. Redistributions of source code must retain the above copyright 1139212Sgibbs * notice, this list of conditions, and the following disclaimer, 1239212Sgibbs * without modification, immediately at the beginning of the file. 1339212Sgibbs * 2. The name of the author may not be used to endorse or promote products 1439212Sgibbs * derived from this software without specific prior written permission. 1539212Sgibbs * 1639212Sgibbs * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1739212Sgibbs * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1839212Sgibbs * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1939212Sgibbs * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 2039212Sgibbs * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2139212Sgibbs * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2239212Sgibbs * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2339212Sgibbs * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2439212Sgibbs * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2539212Sgibbs * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2639212Sgibbs * SUCH DAMAGE. 2739212Sgibbs * 2850477Speter * $FreeBSD$ 2939212Sgibbs */ 3039212Sgibbs 3139212Sgibbs#ifndef _CAM_CAM_CCB_H 3239212Sgibbs#define _CAM_CAM_CCB_H 1 3339212Sgibbs 3439212Sgibbs#include <sys/queue.h> 3539212Sgibbs#include <sys/cdefs.h> 3647412Sgibbs#include <sys/time.h> 37114216Skan#include <sys/limits.h> 3855206Speter#ifndef _KERNEL 3939212Sgibbs#include <sys/callout.h> 4039212Sgibbs#endif 4139212Sgibbs#include <cam/cam_debug.h> 4239212Sgibbs#include <cam/scsi/scsi_all.h> 43195534Sscottl#include <cam/ata/ata_all.h> 4439212Sgibbs 4539212Sgibbs/* General allocation length definitions for CCB structures */ 4639212Sgibbs#define IOCDBLEN CAM_MAX_CDBLEN /* Space for CDB bytes/pointer */ 4739212Sgibbs#define VUHBALEN 14 /* Vendor Unique HBA length */ 4839212Sgibbs#define SIM_IDLEN 16 /* ASCII string len for SIM ID */ 4939212Sgibbs#define HBA_IDLEN 16 /* ASCII string len for HBA ID */ 5039212Sgibbs#define DEV_IDLEN 16 /* ASCII string len for device names */ 5139212Sgibbs#define CCB_PERIPH_PRIV_SIZE 2 /* size of peripheral private area */ 5239212Sgibbs#define CCB_SIM_PRIV_SIZE 2 /* size of sim private area */ 5339212Sgibbs 5439212Sgibbs/* Struct definitions for CAM control blocks */ 5539212Sgibbs 5639212Sgibbs/* Common CCB header */ 5739212Sgibbs/* CAM CCB flags */ 5839212Sgibbstypedef enum { 5939212Sgibbs CAM_CDB_POINTER = 0x00000001,/* The CDB field is a pointer */ 6039212Sgibbs CAM_QUEUE_ENABLE = 0x00000002,/* SIM queue actions are enabled */ 6139212Sgibbs CAM_CDB_LINKED = 0x00000004,/* CCB contains a linked CDB */ 6263455Sgibbs CAM_NEGOTIATE = 0x00000008,/* 6363455Sgibbs * Perform transport negotiation 6463455Sgibbs * with this command. 6563455Sgibbs */ 66251986Sscottl CAM_DATA_ISPHYS = 0x00200000,/* Data type with physical addrs */ 6739212Sgibbs CAM_DIS_AUTOSENSE = 0x00000020,/* Disable autosense feature */ 68216088Sken CAM_DIR_BOTH = 0x00000000,/* Data direction (00:IN/OUT) */ 6939212Sgibbs CAM_DIR_IN = 0x00000040,/* Data direction (01:DATA IN) */ 7039212Sgibbs CAM_DIR_OUT = 0x00000080,/* Data direction (10:DATA OUT) */ 7139212Sgibbs CAM_DIR_NONE = 0x000000C0,/* Data direction (11:no data) */ 7239212Sgibbs CAM_DIR_MASK = 0x000000C0,/* Data direction Mask */ 73251874Sscottl CAM_DATA_VADDR = 0x00000000,/* Data type (000:Virtual) */ 74251986Sscottl CAM_DATA_PADDR = 0x00200000,/* Data type (001:Physical) */ 75251986Sscottl CAM_DATA_SG = 0x00000010,/* Data type (010:sglist) */ 76251986Sscottl CAM_DATA_SG_PADDR = 0x00200010,/* Data type (011:sglist phys) */ 77251986Sscottl CAM_DATA_BIO = 0x00040000,/* Data type (100:bio) */ 78251874Sscottl CAM_DATA_MASK = 0x00240010,/* Data type mask */ 7939212Sgibbs CAM_SOFT_RST_OP = 0x00000100,/* Use Soft reset alternative */ 8039212Sgibbs CAM_ENG_SYNC = 0x00000200,/* Flush resid bytes on complete */ 8139212Sgibbs CAM_DEV_QFRZDIS = 0x00000400,/* Disable DEV Q freezing */ 8239212Sgibbs CAM_DEV_QFREEZE = 0x00000800,/* Freeze DEV Q on execution */ 8339212Sgibbs CAM_HIGH_POWER = 0x00001000,/* Command takes a lot of power */ 8439212Sgibbs CAM_SENSE_PTR = 0x00002000,/* Sense data is a pointer */ 8539212Sgibbs CAM_SENSE_PHYS = 0x00004000,/* Sense pointer is physical addr*/ 8639212Sgibbs CAM_TAG_ACTION_VALID = 0x00008000,/* Use the tag action in this ccb*/ 8739212Sgibbs CAM_PASS_ERR_RECOVER = 0x00010000,/* Pass driver does err. recovery*/ 8839212Sgibbs CAM_DIS_DISCONNECT = 0x00020000,/* Disable disconnect */ 8939212Sgibbs CAM_MSG_BUF_PHYS = 0x00080000,/* Message buffer ptr is physical*/ 9039212Sgibbs CAM_SNS_BUF_PHYS = 0x00100000,/* Autosense data ptr is physical*/ 9139212Sgibbs CAM_CDB_PHYS = 0x00400000,/* CDB poiner is physical */ 9239212Sgibbs CAM_ENG_SGLIST = 0x00800000,/* SG list is for the HBA engine */ 9339212Sgibbs 94251986Sscottl/* Compatibility for FreeBSD 9.x*/ 95251986Sscottl CAM_SCATTER_VALID = 0x00000010,/* These exist for src compat for*/ 96251986Sscottl CAM_SG_LIST_PHYS = 0x00200010,/* old drivers. Hardly anything */ 97251986Sscottl CAM_DATA_PHYS = 0x00200000,/* uses them. */ 98251986Sscottl 9939212Sgibbs/* Phase cognizant mode flags */ 10058111Sn_hibma CAM_DIS_AUTOSRP = 0x01000000,/* Disable autosave/restore ptrs */ 10139212Sgibbs CAM_DIS_AUTODISC = 0x02000000,/* Disable auto disconnect */ 10239212Sgibbs CAM_TGT_CCB_AVAIL = 0x04000000,/* Target CCB available */ 10339212Sgibbs CAM_TGT_PHASE_MODE = 0x08000000,/* The SIM runs in phase mode */ 10456145Smjacob CAM_MSGB_VALID = 0x10000000,/* Message buffer valid */ 10556145Smjacob CAM_STATUS_VALID = 0x20000000,/* Status buffer valid */ 10656145Smjacob CAM_DATAB_VALID = 0x40000000,/* Data buffer valid */ 107251897Sscottl 10839212Sgibbs/* Host target Mode flags */ 10956145Smjacob CAM_SEND_SENSE = 0x08000000,/* Send sense data with status */ 11056145Smjacob CAM_TERM_IO = 0x10000000,/* Terminate I/O Message sup. */ 11156145Smjacob CAM_DISCONNECT = 0x20000000,/* Disconnects are mandatory */ 11256145Smjacob CAM_SEND_STATUS = 0x40000000 /* Send status after data phase */ 11339212Sgibbs} ccb_flags; 11439212Sgibbs 11539212Sgibbs/* XPT Opcodes for xpt_action */ 11639212Sgibbstypedef enum { 11746581Sken/* Function code flags are bits greater than 0xff */ 11846581Sken XPT_FC_QUEUED = 0x100, 11946581Sken /* Non-immediate function code */ 12046581Sken XPT_FC_USER_CCB = 0x200, 12146581Sken XPT_FC_XPT_ONLY = 0x400, 12246581Sken /* Only for the transport layer device */ 12349925Sgibbs XPT_FC_DEV_QUEUED = 0x800 | XPT_FC_QUEUED, 12449925Sgibbs /* Passes through the device queues */ 12539212Sgibbs/* Common function commands: 0x00->0x0F */ 12646581Sken XPT_NOOP = 0x00, 12746581Sken /* Execute Nothing */ 12849925Sgibbs XPT_SCSI_IO = 0x01 | XPT_FC_DEV_QUEUED, 12946581Sken /* Execute the requested I/O operation */ 13046581Sken XPT_GDEV_TYPE = 0x02, 13146581Sken /* Get type information for specified device */ 13246581Sken XPT_GDEVLIST = 0x03, 13346581Sken /* Get a list of peripheral devices */ 13446581Sken XPT_PATH_INQ = 0x04, 13546581Sken /* Path routing inquiry */ 13646581Sken XPT_REL_SIMQ = 0x05, 137203108Smav /* Release a frozen device queue */ 13846581Sken XPT_SASYNC_CB = 0x06, 13946581Sken /* Set Asynchronous Callback Parameters */ 14046581Sken XPT_SDEV_TYPE = 0x07, 14146581Sken /* Set device type information */ 14246581Sken XPT_SCAN_BUS = 0x08 | XPT_FC_QUEUED | XPT_FC_USER_CCB 14346581Sken | XPT_FC_XPT_ONLY, 14446581Sken /* (Re)Scan the SCSI Bus */ 14546581Sken XPT_DEV_MATCH = 0x09 | XPT_FC_XPT_ONLY, 14646581Sken /* Get EDT entries matching the given pattern */ 14746581Sken XPT_DEBUG = 0x0a, 14846581Sken /* Turn on debugging for a bus, target or lun */ 14947412Sgibbs XPT_PATH_STATS = 0x0b, 15047412Sgibbs /* Path statistics (error counts, etc.) */ 15147412Sgibbs XPT_GDEV_STATS = 0x0c, 15247412Sgibbs /* Device statistics (error counts, etc.) */ 153223081Sgibbs XPT_DEV_ADVINFO = 0x0e, 154223081Sgibbs /* Get/Set Device advanced information */ 15539212Sgibbs/* SCSI Control Functions: 0x10->0x1F */ 15646581Sken XPT_ABORT = 0x10, 15746581Sken /* Abort the specified CCB */ 15846581Sken XPT_RESET_BUS = 0x11 | XPT_FC_XPT_ONLY, 15946581Sken /* Reset the specified SCSI bus */ 16049925Sgibbs XPT_RESET_DEV = 0x12 | XPT_FC_DEV_QUEUED, 16146581Sken /* Bus Device Reset the specified SCSI device */ 16246581Sken XPT_TERM_IO = 0x13, 16346581Sken /* Terminate the I/O process */ 16446581Sken XPT_SCAN_LUN = 0x14 | XPT_FC_QUEUED | XPT_FC_USER_CCB 16546581Sken | XPT_FC_XPT_ONLY, 16646581Sken /* Scan Logical Unit */ 16746581Sken XPT_GET_TRAN_SETTINGS = 0x15, 16846581Sken /* 16939212Sgibbs * Get default/user transfer settings 17039212Sgibbs * for the target 17139212Sgibbs */ 17246581Sken XPT_SET_TRAN_SETTINGS = 0x16, 17346581Sken /* 17439212Sgibbs * Set transfer rate/width 17539212Sgibbs * negotiation settings 17639212Sgibbs */ 17746581Sken XPT_CALC_GEOMETRY = 0x17, 17846581Sken /* 17939212Sgibbs * Calculate the geometry parameters for 18039212Sgibbs * a device give the sector size and 18139212Sgibbs * volume size. 18239212Sgibbs */ 183195534Sscottl XPT_ATA_IO = 0x18 | XPT_FC_DEV_QUEUED, 184195534Sscottl /* Execute the requested ATA I/O operation */ 18539212Sgibbs 186196008Smjacob XPT_GET_SIM_KNOB = 0x18, 187196008Smjacob /* 188196008Smjacob * Get SIM specific knob values. 189196008Smjacob */ 190196008Smjacob 191196008Smjacob XPT_SET_SIM_KNOB = 0x19, 192196008Smjacob /* 193196008Smjacob * Set SIM specific knob values. 194196008Smjacob */ 195208582Smjacob 196216088Sken XPT_SMP_IO = 0x1b | XPT_FC_DEV_QUEUED, 197216088Sken /* Serial Management Protocol */ 198216088Sken 199208582Smjacob XPT_SCAN_TGT = 0x1E | XPT_FC_QUEUED | XPT_FC_USER_CCB 200208582Smjacob | XPT_FC_XPT_ONLY, 201208582Smjacob /* Scan Target */ 202208582Smjacob 20339212Sgibbs/* HBA engine commands 0x20->0x2F */ 20446581Sken XPT_ENG_INQ = 0x20 | XPT_FC_XPT_ONLY, 20546581Sken /* HBA engine feature inquiry */ 20674840Sken XPT_ENG_EXEC = 0x21 | XPT_FC_DEV_QUEUED, 20746581Sken /* HBA execute engine request */ 20839212Sgibbs 20939212Sgibbs/* Target mode commands: 0x30->0x3F */ 21046581Sken XPT_EN_LUN = 0x30, 21146581Sken /* Enable LUN as a target */ 21249925Sgibbs XPT_TARGET_IO = 0x31 | XPT_FC_DEV_QUEUED, 21346581Sken /* Execute target I/O request */ 21446581Sken XPT_ACCEPT_TARGET_IO = 0x32 | XPT_FC_QUEUED | XPT_FC_USER_CCB, 21546581Sken /* Accept Host Target Mode CDB */ 21649925Sgibbs XPT_CONT_TARGET_IO = 0x33 | XPT_FC_DEV_QUEUED, 21746581Sken /* Continue Host Target I/O Connection */ 21846581Sken XPT_IMMED_NOTIFY = 0x34 | XPT_FC_QUEUED | XPT_FC_USER_CCB, 219196008Smjacob /* Notify Host Target driver of event (obsolete) */ 220196008Smjacob XPT_NOTIFY_ACK = 0x35, 221196008Smjacob /* Acknowledgement of event (obsolete) */ 222196008Smjacob XPT_IMMEDIATE_NOTIFY = 0x36 | XPT_FC_QUEUED | XPT_FC_USER_CCB, 22346581Sken /* Notify Host Target driver of event */ 224196008Smjacob XPT_NOTIFY_ACKNOWLEDGE = 0x37 | XPT_FC_QUEUED | XPT_FC_USER_CCB, 22546581Sken /* Acknowledgement of event */ 22639212Sgibbs 22739212Sgibbs/* Vendor Unique codes: 0x80->0x8F */ 22846581Sken XPT_VUNIQUE = 0x80 22939212Sgibbs} xpt_opcode; 23039212Sgibbs 23146581Sken#define XPT_FC_GROUP_MASK 0xF0 23246581Sken#define XPT_FC_GROUP(op) ((op) & XPT_FC_GROUP_MASK) 23346581Sken#define XPT_FC_GROUP_COMMON 0x00 23446581Sken#define XPT_FC_GROUP_SCSI_CONTROL 0x10 23549925Sgibbs#define XPT_FC_GROUP_HBA_ENGINE 0x20 23646581Sken#define XPT_FC_GROUP_TMODE 0x30 23746581Sken#define XPT_FC_GROUP_VENDOR_UNIQUE 0x80 23844499Sgibbs 23949925Sgibbs#define XPT_FC_IS_DEV_QUEUED(ccb) \ 24049925Sgibbs (((ccb)->ccb_h.func_code & XPT_FC_DEV_QUEUED) == XPT_FC_DEV_QUEUED) 24149925Sgibbs#define XPT_FC_IS_QUEUED(ccb) \ 24249925Sgibbs (((ccb)->ccb_h.func_code & XPT_FC_QUEUED) != 0) 24374840Sken 24474840Skentypedef enum { 24574840Sken PROTO_UNKNOWN, 24674840Sken PROTO_UNSPECIFIED, 24774840Sken PROTO_SCSI, /* Small Computer System Interface */ 24874840Sken PROTO_ATA, /* AT Attachment */ 24974840Sken PROTO_ATAPI, /* AT Attachment Packetized Interface */ 250195534Sscottl PROTO_SATAPM, /* SATA Port Multiplier */ 251236778Smav PROTO_SEMB, /* SATA Enclosure Management Bridge */ 25274840Sken} cam_proto; 25374840Sken 25474840Skentypedef enum { 25574840Sken XPORT_UNKNOWN, 25674840Sken XPORT_UNSPECIFIED, 25774840Sken XPORT_SPI, /* SCSI Parallel Interface */ 25874840Sken XPORT_FC, /* Fiber Channel */ 25974840Sken XPORT_SSA, /* Serial Storage Architecture */ 26074840Sken XPORT_USB, /* Universal Serial Bus */ 26174840Sken XPORT_PPB, /* Parallel Port Bus */ 262154593Smjacob XPORT_ATA, /* AT Attachment */ 263154593Smjacob XPORT_SAS, /* Serial Attached SCSI */ 264195534Sscottl XPORT_SATA, /* Serial AT Attachment */ 265196352Smav XPORT_ISCSI, /* iSCSI */ 26674840Sken} cam_xport; 26774840Sken 268220644Smav#define XPORT_IS_ATA(t) ((t) == XPORT_ATA || (t) == XPORT_SATA) 269220644Smav#define XPORT_IS_SCSI(t) ((t) != XPORT_UNKNOWN && \ 270220644Smav (t) != XPORT_UNSPECIFIED && \ 271220644Smav !XPORT_IS_ATA(t)) 272220644Smav#define XPORT_DEVSTAT_TYPE(t) (XPORT_IS_ATA(t) ? DEVSTAT_TYPE_IF_IDE : \ 273220644Smav XPORT_IS_SCSI(t) ? DEVSTAT_TYPE_IF_SCSI : \ 274220644Smav DEVSTAT_TYPE_IF_OTHER) 275220644Smav 276154593Smjacob#define PROTO_VERSION_UNKNOWN (UINT_MAX - 1) 277154593Smjacob#define PROTO_VERSION_UNSPECIFIED UINT_MAX 278154593Smjacob#define XPORT_VERSION_UNKNOWN (UINT_MAX - 1) 279154593Smjacob#define XPORT_VERSION_UNSPECIFIED UINT_MAX 28074840Sken 28139212Sgibbstypedef union { 28260938Sjake LIST_ENTRY(ccb_hdr) le; 28360938Sjake SLIST_ENTRY(ccb_hdr) sle; 28460938Sjake TAILQ_ENTRY(ccb_hdr) tqe; 28560938Sjake STAILQ_ENTRY(ccb_hdr) stqe; 28639212Sgibbs} camq_entry; 28739212Sgibbs 28839212Sgibbstypedef union { 28939212Sgibbs void *ptr; 29039212Sgibbs u_long field; 291168752Sscottl u_int8_t bytes[sizeof(uintptr_t)]; 29239212Sgibbs} ccb_priv_entry; 29339212Sgibbs 29439212Sgibbstypedef union { 29539212Sgibbs ccb_priv_entry entries[CCB_PERIPH_PRIV_SIZE]; 29639212Sgibbs u_int8_t bytes[CCB_PERIPH_PRIV_SIZE * sizeof(ccb_priv_entry)]; 29739212Sgibbs} ccb_ppriv_area; 29839212Sgibbs 29939212Sgibbstypedef union { 30039212Sgibbs ccb_priv_entry entries[CCB_SIM_PRIV_SIZE]; 30139212Sgibbs u_int8_t bytes[CCB_SIM_PRIV_SIZE * sizeof(ccb_priv_entry)]; 30239212Sgibbs} ccb_spriv_area; 30339212Sgibbs 30439212Sgibbsstruct ccb_hdr { 305130200Sscottl cam_pinfo pinfo; /* Info for priority scheduling */ 30639212Sgibbs camq_entry xpt_links; /* For chaining in the XPT layer */ 30739212Sgibbs camq_entry sim_links; /* For chaining in the SIM layer */ 308130200Sscottl camq_entry periph_links; /* For chaining in the type driver */ 30939212Sgibbs u_int32_t retry_count; 31039212Sgibbs void (*cbfcnp)(struct cam_periph *, union ccb *); 311130200Sscottl /* Callback on completion function */ 31239212Sgibbs xpt_opcode func_code; /* XPT function code */ 313130200Sscottl u_int32_t status; /* Status returned by CAM subsystem */ 314130200Sscottl struct cam_path *path; /* Compiled path for this ccb */ 31539212Sgibbs path_id_t path_id; /* Path ID for the request */ 31639212Sgibbs target_id_t target_id; /* Target device ID */ 31739212Sgibbs lun_id_t target_lun; /* Target LUN number */ 318130200Sscottl u_int32_t flags; /* ccb_flags */ 31939212Sgibbs ccb_ppriv_area periph_priv; 32039212Sgibbs ccb_spriv_area sim_priv; 32139212Sgibbs u_int32_t timeout; /* Timeout value */ 322168752Sscottl 323168752Sscottl /* 324168752Sscottl * Deprecated, only for use by non-MPSAFE SIMs. All others must 325168752Sscottl * allocate and initialize their own callout storage. 326168752Sscottl */ 327130200Sscottl struct callout_handle timeout_ch; 32839212Sgibbs}; 32939212Sgibbs 33039212Sgibbs/* Get Device Information CCB */ 33139212Sgibbsstruct ccb_getdev { 33239212Sgibbs struct ccb_hdr ccb_h; 333195534Sscottl cam_proto protocol; 33456145Smjacob struct scsi_inquiry_data inq_data; 335195534Sscottl struct ata_params ident_data; 33639212Sgibbs u_int8_t serial_num[252]; 337199178Smav u_int8_t inq_flags; 33839212Sgibbs u_int8_t serial_num_len; 33939212Sgibbs}; 34039212Sgibbs 34147412Sgibbs/* Device Statistics CCB */ 34247412Sgibbsstruct ccb_getdevstats { 34347412Sgibbs struct ccb_hdr ccb_h; 34447412Sgibbs int dev_openings; /* Space left for more work on device*/ 34547412Sgibbs int dev_active; /* Transactions running on the device */ 34647412Sgibbs int devq_openings; /* Space left for more queued work */ 34747412Sgibbs int devq_queued; /* Transactions queued to be sent */ 34847412Sgibbs int held; /* 34947412Sgibbs * CCBs held by peripheral drivers 35047412Sgibbs * for this device 35147412Sgibbs */ 35247434Sgibbs int maxtags; /* 35347434Sgibbs * Boundary conditions for number of 35447434Sgibbs * tagged operations 35547434Sgibbs */ 35647434Sgibbs int mintags; 35747412Sgibbs struct timeval last_reset; /* Time of last bus reset/loop init */ 35847412Sgibbs}; 35939212Sgibbs 36039212Sgibbstypedef enum { 36139212Sgibbs CAM_GDEVLIST_LAST_DEVICE, 36239212Sgibbs CAM_GDEVLIST_LIST_CHANGED, 36339212Sgibbs CAM_GDEVLIST_MORE_DEVS, 36439212Sgibbs CAM_GDEVLIST_ERROR 36539212Sgibbs} ccb_getdevlist_status_e; 36639212Sgibbs 36739212Sgibbsstruct ccb_getdevlist { 36839212Sgibbs struct ccb_hdr ccb_h; 36939212Sgibbs char periph_name[DEV_IDLEN]; 37039212Sgibbs u_int32_t unit_number; 37139212Sgibbs unsigned int generation; 37239212Sgibbs u_int32_t index; 37339212Sgibbs ccb_getdevlist_status_e status; 37439212Sgibbs}; 37539212Sgibbs 37639212Sgibbstypedef enum { 37739212Sgibbs PERIPH_MATCH_NONE = 0x000, 37839212Sgibbs PERIPH_MATCH_PATH = 0x001, 37939212Sgibbs PERIPH_MATCH_TARGET = 0x002, 38039212Sgibbs PERIPH_MATCH_LUN = 0x004, 38139212Sgibbs PERIPH_MATCH_NAME = 0x008, 38239212Sgibbs PERIPH_MATCH_UNIT = 0x010, 38339212Sgibbs PERIPH_MATCH_ANY = 0x01f 38439212Sgibbs} periph_pattern_flags; 38539212Sgibbs 38639212Sgibbsstruct periph_match_pattern { 38739212Sgibbs char periph_name[DEV_IDLEN]; 38839212Sgibbs u_int32_t unit_number; 38939212Sgibbs path_id_t path_id; 39039212Sgibbs target_id_t target_id; 39139212Sgibbs lun_id_t target_lun; 39239212Sgibbs periph_pattern_flags flags; 39339212Sgibbs}; 39439212Sgibbs 39539212Sgibbstypedef enum { 39639212Sgibbs DEV_MATCH_NONE = 0x000, 39739212Sgibbs DEV_MATCH_PATH = 0x001, 39839212Sgibbs DEV_MATCH_TARGET = 0x002, 39939212Sgibbs DEV_MATCH_LUN = 0x004, 40039212Sgibbs DEV_MATCH_INQUIRY = 0x008, 401223081Sgibbs DEV_MATCH_DEVID = 0x010, 40239212Sgibbs DEV_MATCH_ANY = 0x00f 40339212Sgibbs} dev_pattern_flags; 40439212Sgibbs 405223081Sgibbsstruct device_id_match_pattern { 406223081Sgibbs uint8_t id_len; 407223081Sgibbs uint8_t id[256]; 408223081Sgibbs}; 409223081Sgibbs 41039212Sgibbsstruct device_match_pattern { 411223081Sgibbs path_id_t path_id; 412223081Sgibbs target_id_t target_id; 413223081Sgibbs lun_id_t target_lun; 414223081Sgibbs dev_pattern_flags flags; 415223081Sgibbs union { 416223081Sgibbs struct scsi_static_inquiry_pattern inq_pat; 417223081Sgibbs struct device_id_match_pattern devid_pat; 418223081Sgibbs } data; 41939212Sgibbs}; 42039212Sgibbs 42139212Sgibbstypedef enum { 42239212Sgibbs BUS_MATCH_NONE = 0x000, 42339212Sgibbs BUS_MATCH_PATH = 0x001, 42439212Sgibbs BUS_MATCH_NAME = 0x002, 42539212Sgibbs BUS_MATCH_UNIT = 0x004, 42639212Sgibbs BUS_MATCH_BUS_ID = 0x008, 42739212Sgibbs BUS_MATCH_ANY = 0x00f 42839212Sgibbs} bus_pattern_flags; 42939212Sgibbs 43039212Sgibbsstruct bus_match_pattern { 43139212Sgibbs path_id_t path_id; 43239212Sgibbs char dev_name[DEV_IDLEN]; 43339212Sgibbs u_int32_t unit_number; 43439212Sgibbs u_int32_t bus_id; 43539212Sgibbs bus_pattern_flags flags; 43639212Sgibbs}; 43739212Sgibbs 43839212Sgibbsunion match_pattern { 43939212Sgibbs struct periph_match_pattern periph_pattern; 44039212Sgibbs struct device_match_pattern device_pattern; 44139212Sgibbs struct bus_match_pattern bus_pattern; 44239212Sgibbs}; 44339212Sgibbs 44439212Sgibbstypedef enum { 44539212Sgibbs DEV_MATCH_PERIPH, 44639212Sgibbs DEV_MATCH_DEVICE, 44739212Sgibbs DEV_MATCH_BUS 44839212Sgibbs} dev_match_type; 44939212Sgibbs 45039212Sgibbsstruct dev_match_pattern { 45139212Sgibbs dev_match_type type; 45239212Sgibbs union match_pattern pattern; 45339212Sgibbs}; 45439212Sgibbs 45539212Sgibbsstruct periph_match_result { 45639212Sgibbs char periph_name[DEV_IDLEN]; 45739212Sgibbs u_int32_t unit_number; 45839212Sgibbs path_id_t path_id; 45939212Sgibbs target_id_t target_id; 46039212Sgibbs lun_id_t target_lun; 46139212Sgibbs}; 46239212Sgibbs 46346581Skentypedef enum { 46446581Sken DEV_RESULT_NOFLAG = 0x00, 46546581Sken DEV_RESULT_UNCONFIGURED = 0x01 46646581Sken} dev_result_flags; 46746581Sken 46839212Sgibbsstruct device_match_result { 46939212Sgibbs path_id_t path_id; 47039212Sgibbs target_id_t target_id; 47139212Sgibbs lun_id_t target_lun; 472195534Sscottl cam_proto protocol; 47339212Sgibbs struct scsi_inquiry_data inq_data; 474195534Sscottl struct ata_params ident_data; 47546581Sken dev_result_flags flags; 47639212Sgibbs}; 47739212Sgibbs 47839212Sgibbsstruct bus_match_result { 47939212Sgibbs path_id_t path_id; 48039212Sgibbs char dev_name[DEV_IDLEN]; 48139212Sgibbs u_int32_t unit_number; 48239212Sgibbs u_int32_t bus_id; 48339212Sgibbs}; 48439212Sgibbs 48539212Sgibbsunion match_result { 48639212Sgibbs struct periph_match_result periph_result; 48739212Sgibbs struct device_match_result device_result; 48839212Sgibbs struct bus_match_result bus_result; 48939212Sgibbs}; 49039212Sgibbs 49139212Sgibbsstruct dev_match_result { 49239212Sgibbs dev_match_type type; 49339212Sgibbs union match_result result; 49439212Sgibbs}; 49539212Sgibbs 49639212Sgibbstypedef enum { 49739212Sgibbs CAM_DEV_MATCH_LAST, 49839212Sgibbs CAM_DEV_MATCH_MORE, 49939212Sgibbs CAM_DEV_MATCH_LIST_CHANGED, 50039212Sgibbs CAM_DEV_MATCH_SIZE_ERROR, 50139212Sgibbs CAM_DEV_MATCH_ERROR 50239212Sgibbs} ccb_dev_match_status; 50339212Sgibbs 50439212Sgibbstypedef enum { 50539212Sgibbs CAM_DEV_POS_NONE = 0x000, 50639212Sgibbs CAM_DEV_POS_BUS = 0x001, 50739212Sgibbs CAM_DEV_POS_TARGET = 0x002, 50839212Sgibbs CAM_DEV_POS_DEVICE = 0x004, 50939212Sgibbs CAM_DEV_POS_PERIPH = 0x008, 51039212Sgibbs CAM_DEV_POS_PDPTR = 0x010, 51139212Sgibbs CAM_DEV_POS_TYPEMASK = 0xf00, 51239212Sgibbs CAM_DEV_POS_EDT = 0x100, 51339212Sgibbs CAM_DEV_POS_PDRV = 0x200 51439212Sgibbs} dev_pos_type; 51539212Sgibbs 51639212Sgibbsstruct ccb_dm_cookie { 51739212Sgibbs void *bus; 51839212Sgibbs void *target; 51939212Sgibbs void *device; 52039212Sgibbs void *periph; 52139212Sgibbs void *pdrv; 52239212Sgibbs}; 52339212Sgibbs 52439212Sgibbsstruct ccb_dev_position { 52539212Sgibbs u_int generations[4]; 52639212Sgibbs#define CAM_BUS_GENERATION 0x00 52739212Sgibbs#define CAM_TARGET_GENERATION 0x01 52839212Sgibbs#define CAM_DEV_GENERATION 0x02 52939212Sgibbs#define CAM_PERIPH_GENERATION 0x03 53039212Sgibbs dev_pos_type position_type; 53139212Sgibbs struct ccb_dm_cookie cookie; 53239212Sgibbs}; 53339212Sgibbs 53439212Sgibbsstruct ccb_dev_match { 53539212Sgibbs struct ccb_hdr ccb_h; 53639212Sgibbs ccb_dev_match_status status; 53739212Sgibbs u_int32_t num_patterns; 53839212Sgibbs u_int32_t pattern_buf_len; 53939212Sgibbs struct dev_match_pattern *patterns; 54039212Sgibbs u_int32_t num_matches; 54139212Sgibbs u_int32_t match_buf_len; 54239212Sgibbs struct dev_match_result *matches; 54339212Sgibbs struct ccb_dev_position pos; 54439212Sgibbs}; 54539212Sgibbs 54639212Sgibbs/* 54739212Sgibbs * Definitions for the path inquiry CCB fields. 54839212Sgibbs */ 549251874Sscottl#define CAM_VERSION 0x17 /* Hex value for current version */ 55039212Sgibbs 55139212Sgibbstypedef enum { 55239212Sgibbs PI_MDP_ABLE = 0x80, /* Supports MDP message */ 55339212Sgibbs PI_WIDE_32 = 0x40, /* Supports 32 bit wide SCSI */ 55439212Sgibbs PI_WIDE_16 = 0x20, /* Supports 16 bit wide SCSI */ 55539212Sgibbs PI_SDTR_ABLE = 0x10, /* Supports SDTR message */ 55639212Sgibbs PI_LINKED_CDB = 0x08, /* Supports linked CDBs */ 557195534Sscottl PI_SATAPM = 0x04, /* Supports SATA PM */ 55839212Sgibbs PI_TAG_ABLE = 0x02, /* Supports tag queue messages */ 55953258Sken PI_SOFT_RST = 0x01 /* Supports soft reset alternative */ 56039212Sgibbs} pi_inqflag; 56139212Sgibbs 56239212Sgibbstypedef enum { 56339212Sgibbs PIT_PROCESSOR = 0x80, /* Target mode processor mode */ 56439212Sgibbs PIT_PHASE = 0x40, /* Target mode phase cog. mode */ 56539212Sgibbs PIT_DISCONNECT = 0x20, /* Disconnects supported in target mode */ 56639212Sgibbs PIT_TERM_IO = 0x10, /* Terminate I/O message supported in TM */ 56739212Sgibbs PIT_GRP_6 = 0x08, /* Group 6 commands supported */ 56853258Sken PIT_GRP_7 = 0x04 /* Group 7 commands supported */ 56939212Sgibbs} pi_tmflag; 57039212Sgibbs 57139212Sgibbstypedef enum { 57239212Sgibbs PIM_SCANHILO = 0x80, /* Bus scans from high ID to low ID */ 57339212Sgibbs PIM_NOREMOVE = 0x40, /* Removeable devices not included in scan */ 57441644Sgibbs PIM_NOINITIATOR = 0x20, /* Initiator role not supported. */ 575118105Snjl PIM_NOBUSRESET = 0x10, /* User has disabled initial BUS RESET */ 576159311Smjacob PIM_NO_6_BYTE = 0x08, /* Do not send 6-byte commands */ 577251897Sscottl PIM_SEQSCAN = 0x04, /* Do bus scans sequentially, not in parallel */ 578251897Sscottl PIM_UNMAPPED = 0x02, 579254938Sken PIM_NOSCAN = 0x01 /* SIM does its own scanning */ 58039212Sgibbs} pi_miscflag; 58139212Sgibbs 58239212Sgibbs/* Path Inquiry CCB */ 58374840Skenstruct ccb_pathinq_settings_spi { 58474840Sken u_int8_t ppr_options; 58574840Sken}; 586196008Smjacob 58777708Smjacobstruct ccb_pathinq_settings_fc { 58877708Smjacob u_int64_t wwnn; /* world wide node name */ 58977708Smjacob u_int64_t wwpn; /* world wide port name */ 59077708Smjacob u_int32_t port; /* 24 bit port id, if known */ 59177708Smjacob u_int32_t bitrate; /* Mbps */ 59277708Smjacob}; 593196008Smjacob 594154593Smjacobstruct ccb_pathinq_settings_sas { 595154593Smjacob u_int32_t bitrate; /* Mbps */ 596154593Smjacob}; 59777708Smjacob#define PATHINQ_SETTINGS_SIZE 128 59874840Sken 59939212Sgibbsstruct ccb_pathinq { 60039212Sgibbs struct ccb_hdr ccb_h; 60139212Sgibbs u_int8_t version_num; /* Version number for the SIM/HBA */ 60239212Sgibbs u_int8_t hba_inquiry; /* Mimic of INQ byte 7 for the HBA */ 60339212Sgibbs u_int8_t target_sprt; /* Flags for target mode support */ 60439212Sgibbs u_int8_t hba_misc; /* Misc HBA features */ 60539212Sgibbs u_int16_t hba_eng_cnt; /* HBA engine count */ 60639212Sgibbs /* Vendor Unique capabilities */ 60739212Sgibbs u_int8_t vuhba_flags[VUHBALEN]; 60839212Sgibbs u_int32_t max_target; /* Maximum supported Target */ 60939212Sgibbs u_int32_t max_lun; /* Maximum supported Lun */ 61039212Sgibbs u_int32_t async_flags; /* Installed Async handlers */ 61139212Sgibbs path_id_t hpath_id; /* Highest Path ID in the subsystem */ 61239212Sgibbs target_id_t initiator_id; /* ID of the HBA on the SCSI bus */ 61339212Sgibbs char sim_vid[SIM_IDLEN]; /* Vendor ID of the SIM */ 61439212Sgibbs char hba_vid[HBA_IDLEN]; /* Vendor ID of the HBA */ 61539212Sgibbs char dev_name[DEV_IDLEN];/* Device name for SIM */ 61639212Sgibbs u_int32_t unit_number; /* Unit number for SIM */ 61739212Sgibbs u_int32_t bus_id; /* Bus ID for SIM */ 61846581Sken u_int32_t base_transfer_speed;/* Base bus speed in KB/sec */ 61974840Sken cam_proto protocol; 62074840Sken u_int protocol_version; 62174840Sken cam_xport transport; 62274840Sken u_int transport_version; 62374840Sken union { 62474840Sken struct ccb_pathinq_settings_spi spi; 62577708Smjacob struct ccb_pathinq_settings_fc fc; 626154593Smjacob struct ccb_pathinq_settings_sas sas; 62777708Smjacob char ccb_pathinq_settings_opaque[PATHINQ_SETTINGS_SIZE]; 62874840Sken } xport_specific; 629195534Sscottl u_int maxio; /* Max supported I/O size, in bytes. */ 630210471Smav u_int16_t hba_vendor; /* HBA vendor ID */ 631210471Smav u_int16_t hba_device; /* HBA device ID */ 632210471Smav u_int16_t hba_subvendor; /* HBA subvendor ID */ 633210471Smav u_int16_t hba_subdevice; /* HBA subdevice ID */ 63439212Sgibbs}; 63539212Sgibbs 63647412Sgibbs/* Path Statistics CCB */ 63747412Sgibbsstruct ccb_pathstats { 63847412Sgibbs struct ccb_hdr ccb_h; 63947412Sgibbs struct timeval last_reset; /* Time of last bus reset/loop init */ 64047412Sgibbs}; 64147412Sgibbs 642216088Skentypedef enum { 643216088Sken SMP_FLAG_NONE = 0x00, 644216088Sken SMP_FLAG_REQ_SG = 0x01, 645216088Sken SMP_FLAG_RSP_SG = 0x02 646216088Sken} ccb_smp_pass_flags; 647216088Sken 648216088Sken/* 649216088Sken * Serial Management Protocol CCB 650216088Sken * XXX Currently the semantics for this CCB are that it is executed either 651216088Sken * by the addressed device, or that device's parent (i.e. an expander for 652216088Sken * any device on an expander) if the addressed device doesn't support SMP. 653216088Sken * Later, once we have the ability to probe SMP-only devices and put them 654216088Sken * in CAM's topology, the CCB will only be executed by the addressed device 655216088Sken * if possible. 656216088Sken */ 657216088Skenstruct ccb_smpio { 658216088Sken struct ccb_hdr ccb_h; 659216088Sken uint8_t *smp_request; 660216088Sken int smp_request_len; 661216088Sken uint16_t smp_request_sglist_cnt; 662216088Sken uint8_t *smp_response; 663216088Sken int smp_response_len; 664216088Sken uint16_t smp_response_sglist_cnt; 665216088Sken ccb_smp_pass_flags flags; 666216088Sken}; 667216088Sken 66839212Sgibbstypedef union { 66939212Sgibbs u_int8_t *sense_ptr; /* 67039212Sgibbs * Pointer to storage 67139212Sgibbs * for sense information 67239212Sgibbs */ 67339212Sgibbs /* Storage Area for sense information */ 67439212Sgibbs struct scsi_sense_data sense_buf; 67539212Sgibbs} sense_t; 67639212Sgibbs 67739212Sgibbstypedef union { 67839212Sgibbs u_int8_t *cdb_ptr; /* Pointer to the CDB bytes to send */ 67939212Sgibbs /* Area for the CDB send */ 68039212Sgibbs u_int8_t cdb_bytes[IOCDBLEN]; 68139212Sgibbs} cdb_t; 68239212Sgibbs 68339212Sgibbs/* 68439212Sgibbs * SCSI I/O Request CCB used for the XPT_SCSI_IO and XPT_CONT_TARGET_IO 68539212Sgibbs * function codes. 68639212Sgibbs */ 68739212Sgibbsstruct ccb_scsiio { 68839212Sgibbs struct ccb_hdr ccb_h; 68939212Sgibbs union ccb *next_ccb; /* Ptr for next CCB for action */ 69039212Sgibbs u_int8_t *req_map; /* Ptr to mapping info */ 69139212Sgibbs u_int8_t *data_ptr; /* Ptr to the data buf/SG list */ 69239212Sgibbs u_int32_t dxfer_len; /* Data transfer length */ 69339212Sgibbs /* Autosense storage */ 69439212Sgibbs struct scsi_sense_data sense_data; 69539212Sgibbs u_int8_t sense_len; /* Number of bytes to autosense */ 69639212Sgibbs u_int8_t cdb_len; /* Number of bytes for the CDB */ 69739212Sgibbs u_int16_t sglist_cnt; /* Number of SG list entries */ 69839212Sgibbs u_int8_t scsi_status; /* Returned SCSI status */ 69939212Sgibbs u_int8_t sense_resid; /* Autosense resid length: 2's comp */ 70039212Sgibbs u_int32_t resid; /* Transfer residual length: 2's comp */ 70139212Sgibbs cdb_t cdb_io; /* Union for CDB bytes/pointer */ 70239212Sgibbs u_int8_t *msg_ptr; /* Pointer to the message buffer */ 70339212Sgibbs u_int16_t msg_len; /* Number of bytes for the Message */ 70439212Sgibbs u_int8_t tag_action; /* What to do for tag queueing */ 70540417Sgibbs /* 70640417Sgibbs * The tag action should be either the define below (to send a 70740417Sgibbs * non-tagged transaction) or one of the defined scsi tag messages 70840417Sgibbs * from scsi_message.h. 70940417Sgibbs */ 71040417Sgibbs#define CAM_TAG_ACTION_NONE 0x00 71149925Sgibbs u_int tag_id; /* tag id from initator (target mode) */ 71249925Sgibbs u_int init_id; /* initiator id of who selected */ 71339212Sgibbs}; 71439212Sgibbs 715195534Sscottl/* 716195534Sscottl * ATA I/O Request CCB used for the XPT_ATA_IO function code. 717195534Sscottl */ 718195534Sscottlstruct ccb_ataio { 719195534Sscottl struct ccb_hdr ccb_h; 720195534Sscottl union ccb *next_ccb; /* Ptr for next CCB for action */ 721195534Sscottl struct ata_cmd cmd; /* ATA command register set */ 722195534Sscottl struct ata_res res; /* ATA result register set */ 723195534Sscottl u_int8_t *data_ptr; /* Ptr to the data buf/SG list */ 724195534Sscottl u_int32_t dxfer_len; /* Data transfer length */ 725195534Sscottl u_int32_t resid; /* Transfer residual length: 2's comp */ 726195534Sscottl u_int8_t tag_action; /* What to do for tag queueing */ 727195534Sscottl /* 728195534Sscottl * The tag action should be either the define below (to send a 729195534Sscottl * non-tagged transaction) or one of the defined scsi tag messages 730195534Sscottl * from scsi_message.h. 731195534Sscottl */ 732195534Sscottl#define CAM_TAG_ACTION_NONE 0x00 733195534Sscottl u_int tag_id; /* tag id from initator (target mode) */ 734195534Sscottl u_int init_id; /* initiator id of who selected */ 735195534Sscottl}; 736195534Sscottl 73739212Sgibbsstruct ccb_accept_tio { 73839212Sgibbs struct ccb_hdr ccb_h; 73939212Sgibbs cdb_t cdb_io; /* Union for CDB bytes/pointer */ 74039212Sgibbs u_int8_t cdb_len; /* Number of bytes for the CDB */ 74139212Sgibbs u_int8_t tag_action; /* What to do for tag queueing */ 74256145Smjacob u_int8_t sense_len; /* Number of bytes of Sense Data */ 74355328Smjacob u_int tag_id; /* tag id from initator (target mode) */ 74455328Smjacob u_int init_id; /* initiator id of who selected */ 74556145Smjacob struct scsi_sense_data sense_data; 74639212Sgibbs}; 74739212Sgibbs 74839212Sgibbs/* Release SIM Queue */ 74939212Sgibbsstruct ccb_relsim { 75039212Sgibbs struct ccb_hdr ccb_h; 75139212Sgibbs u_int32_t release_flags; 75239212Sgibbs#define RELSIM_ADJUST_OPENINGS 0x01 75339212Sgibbs#define RELSIM_RELEASE_AFTER_TIMEOUT 0x02 75439212Sgibbs#define RELSIM_RELEASE_AFTER_CMDCMPLT 0x04 75539212Sgibbs#define RELSIM_RELEASE_AFTER_QEMPTY 0x08 75639212Sgibbs u_int32_t openings; 757203108Smav u_int32_t release_timeout; /* Abstract argument. */ 75839212Sgibbs u_int32_t qfrozen_cnt; 75939212Sgibbs}; 76039212Sgibbs 76139212Sgibbs/* 76239212Sgibbs * Definitions for the asynchronous callback CCB fields. 76339212Sgibbs */ 76439212Sgibbstypedef enum { 765249152Smav AC_UNIT_ATTENTION = 0x4000,/* Device reported UNIT ATTENTION */ 766223081Sgibbs AC_ADVINFO_CHANGED = 0x2000,/* Advance info might have changes */ 767196008Smjacob AC_CONTRACT = 0x1000,/* A contractual callback */ 76839212Sgibbs AC_GETDEV_CHANGED = 0x800,/* Getdev info might have changed */ 76939212Sgibbs AC_INQ_CHANGED = 0x400,/* Inquiry info might have changed */ 77039212Sgibbs AC_TRANSFER_NEG = 0x200,/* New transfer settings in effect */ 77139212Sgibbs AC_LOST_DEVICE = 0x100,/* A device went away */ 77239212Sgibbs AC_FOUND_DEVICE = 0x080,/* A new device was found */ 77339212Sgibbs AC_PATH_DEREGISTERED = 0x040,/* A path has de-registered */ 77439212Sgibbs AC_PATH_REGISTERED = 0x020,/* A new path has been registered */ 77539212Sgibbs AC_SENT_BDR = 0x010,/* A BDR message was sent to target */ 77639212Sgibbs AC_SCSI_AEN = 0x008,/* A SCSI AEN has been received */ 77739212Sgibbs AC_UNSOL_RESEL = 0x002,/* Unsolicited reselection occurred */ 77839212Sgibbs AC_BUS_RESET = 0x001 /* A SCSI bus reset occurred */ 77939212Sgibbs} ac_code; 78039212Sgibbs 78139212Sgibbstypedef void ac_callback_t (void *softc, u_int32_t code, 78239212Sgibbs struct cam_path *path, void *args); 78339212Sgibbs 784196008Smjacob/* 785196008Smjacob * Generic Asynchronous callbacks. 786196008Smjacob * 787196008Smjacob * Generic arguments passed bac which are then interpreted between a per-system 788196008Smjacob * contract number. 789196008Smjacob */ 790196008Smjacob#define AC_CONTRACT_DATA_MAX (128 - sizeof (u_int64_t)) 791196008Smjacobstruct ac_contract { 792196008Smjacob u_int64_t contract_number; 793196008Smjacob u_int8_t contract_data[AC_CONTRACT_DATA_MAX]; 794196008Smjacob}; 795196008Smjacob 796196008Smjacob#define AC_CONTRACT_DEV_CHG 1 797196008Smjacobstruct ac_device_changed { 798196008Smjacob u_int64_t wwpn; 799196008Smjacob u_int32_t port; 800196008Smjacob target_id_t target; 801196008Smjacob u_int8_t arrived; 802196008Smjacob}; 803196008Smjacob 80439212Sgibbs/* Set Asynchronous Callback CCB */ 80539212Sgibbsstruct ccb_setasync { 80639212Sgibbs struct ccb_hdr ccb_h; 80739212Sgibbs u_int32_t event_enable; /* Async Event enables */ 80839212Sgibbs ac_callback_t *callback; 80939212Sgibbs void *callback_arg; 81039212Sgibbs}; 81139212Sgibbs 81239212Sgibbs/* Set Device Type CCB */ 81339212Sgibbsstruct ccb_setdev { 81439212Sgibbs struct ccb_hdr ccb_h; 81539212Sgibbs u_int8_t dev_type; /* Value for dev type field in EDT */ 81639212Sgibbs}; 81739212Sgibbs 81839212Sgibbs/* SCSI Control Functions */ 81939212Sgibbs 82039212Sgibbs/* Abort XPT request CCB */ 82139212Sgibbsstruct ccb_abort { 82239212Sgibbs struct ccb_hdr ccb_h; 82339212Sgibbs union ccb *abort_ccb; /* Pointer to CCB to abort */ 82439212Sgibbs}; 82539212Sgibbs 82639212Sgibbs/* Reset SCSI Bus CCB */ 82739212Sgibbsstruct ccb_resetbus { 82839212Sgibbs struct ccb_hdr ccb_h; 82939212Sgibbs}; 83039212Sgibbs 83139212Sgibbs/* Reset SCSI Device CCB */ 83239212Sgibbsstruct ccb_resetdev { 83339212Sgibbs struct ccb_hdr ccb_h; 83439212Sgibbs}; 83539212Sgibbs 83639212Sgibbs/* Terminate I/O Process Request CCB */ 83739212Sgibbsstruct ccb_termio { 83839212Sgibbs struct ccb_hdr ccb_h; 83939212Sgibbs union ccb *termio_ccb; /* Pointer to CCB to terminate */ 84039212Sgibbs}; 84139212Sgibbs 84274840Skentypedef enum { 84374840Sken CTS_TYPE_CURRENT_SETTINGS, 84474840Sken CTS_TYPE_USER_SETTINGS 84574840Sken} cts_type; 84674840Sken 84774840Skenstruct ccb_trans_settings_scsi 84874840Sken{ 84939212Sgibbs u_int valid; /* Which fields to honor */ 85074840Sken#define CTS_SCSI_VALID_TQ 0x01 85139212Sgibbs u_int flags; 85274840Sken#define CTS_SCSI_FLAGS_TAG_ENB 0x01 85374840Sken}; 85474840Sken 855236786Smavstruct ccb_trans_settings_ata 856236786Smav{ 857236786Smav u_int valid; /* Which fields to honor */ 858236786Smav#define CTS_ATA_VALID_TQ 0x01 859236786Smav u_int flags; 860236786Smav#define CTS_ATA_FLAGS_TAG_ENB 0x01 861236786Smav}; 862236786Smav 86374840Skenstruct ccb_trans_settings_spi 86474840Sken{ 86574840Sken u_int valid; /* Which fields to honor */ 86674840Sken#define CTS_SPI_VALID_SYNC_RATE 0x01 86774840Sken#define CTS_SPI_VALID_SYNC_OFFSET 0x02 86874840Sken#define CTS_SPI_VALID_BUS_WIDTH 0x04 86974840Sken#define CTS_SPI_VALID_DISC 0x08 87074840Sken#define CTS_SPI_VALID_PPR_OPTIONS 0x10 87174840Sken u_int flags; 87274840Sken#define CTS_SPI_FLAGS_DISC_ENB 0x01 87339212Sgibbs u_int sync_period; 87439212Sgibbs u_int sync_offset; 87539212Sgibbs u_int bus_width; 87674840Sken u_int ppr_options; 87739212Sgibbs}; 87839212Sgibbs 87978709Smjacobstruct ccb_trans_settings_fc { 88078709Smjacob u_int valid; /* Which fields to honor */ 88178709Smjacob#define CTS_FC_VALID_WWNN 0x8000 88278709Smjacob#define CTS_FC_VALID_WWPN 0x4000 88378709Smjacob#define CTS_FC_VALID_PORT 0x2000 88478709Smjacob#define CTS_FC_VALID_SPEED 0x1000 88578709Smjacob u_int64_t wwnn; /* world wide node name */ 88678709Smjacob u_int64_t wwpn; /* world wide port name */ 88778709Smjacob u_int32_t port; /* 24 bit port id, if known */ 88878709Smjacob u_int32_t bitrate; /* Mbps */ 88978709Smjacob}; 89078709Smjacob 891154593Smjacobstruct ccb_trans_settings_sas { 892154593Smjacob u_int valid; /* Which fields to honor */ 893154593Smjacob#define CTS_SAS_VALID_SPEED 0x1000 894154593Smjacob u_int32_t bitrate; /* Mbps */ 895154593Smjacob}; 896154593Smjacob 897236786Smavstruct ccb_trans_settings_pata { 898198708Smav u_int valid; /* Which fields to honor */ 899198708Smav#define CTS_ATA_VALID_MODE 0x01 900199747Smav#define CTS_ATA_VALID_BYTECOUNT 0x02 901203376Smav#define CTS_ATA_VALID_ATAPI 0x20 902251081Smarius#define CTS_ATA_VALID_CAPS 0x40 903199821Smav int mode; /* Mode */ 904198708Smav u_int bytecount; /* Length of PIO transaction */ 905203376Smav u_int atapi; /* Length of ATAPI CDB */ 906251081Smarius u_int caps; /* Device and host SATA caps. */ 907251081Smarius#define CTS_ATA_CAPS_H 0x0000ffff 908251081Smarius#define CTS_ATA_CAPS_H_DMA48 0x00000001 /* 48-bit DMA */ 909251081Smarius#define CTS_ATA_CAPS_D 0xffff0000 910198708Smav}; 911198708Smav 912195534Sscottlstruct ccb_trans_settings_sata { 913195534Sscottl u_int valid; /* Which fields to honor */ 914199747Smav#define CTS_SATA_VALID_MODE 0x01 915199747Smav#define CTS_SATA_VALID_BYTECOUNT 0x02 916199747Smav#define CTS_SATA_VALID_REVISION 0x04 917199747Smav#define CTS_SATA_VALID_PM 0x08 918199747Smav#define CTS_SATA_VALID_TAGS 0x10 919203376Smav#define CTS_SATA_VALID_ATAPI 0x20 920207499Smav#define CTS_SATA_VALID_CAPS 0x40 921199821Smav int mode; /* Legacy PATA mode */ 922199747Smav u_int bytecount; /* Length of PIO transaction */ 923199821Smav int revision; /* SATA revision */ 924195534Sscottl u_int pm_present; /* PM is present (XPT->SIM) */ 925199747Smav u_int tags; /* Number of allowed tags */ 926203376Smav u_int atapi; /* Length of ATAPI CDB */ 927207499Smav u_int caps; /* Device and host SATA caps. */ 928207499Smav#define CTS_SATA_CAPS_H 0x0000ffff 929207499Smav#define CTS_SATA_CAPS_H_PMREQ 0x00000001 930207499Smav#define CTS_SATA_CAPS_H_APST 0x00000002 931207499Smav#define CTS_SATA_CAPS_H_DMAAA 0x00000010 /* Auto-activation */ 932220602Smav#define CTS_SATA_CAPS_H_AN 0x00000020 /* Async. notification */ 933207499Smav#define CTS_SATA_CAPS_D 0xffff0000 934207499Smav#define CTS_SATA_CAPS_D_PMREQ 0x00010000 935207499Smav#define CTS_SATA_CAPS_D_APST 0x00020000 936195534Sscottl}; 937154593Smjacob 93874840Sken/* Get/Set transfer rate/width/disconnection/tag queueing settings */ 93974840Skenstruct ccb_trans_settings { 94074840Sken struct ccb_hdr ccb_h; 94174840Sken cts_type type; /* Current or User settings */ 94274840Sken cam_proto protocol; 94374840Sken u_int protocol_version; 94474840Sken cam_xport transport; 94574840Sken u_int transport_version; 94674840Sken union { 94774840Sken u_int valid; /* Which fields to honor */ 948236786Smav struct ccb_trans_settings_ata ata; 94974840Sken struct ccb_trans_settings_scsi scsi; 95074840Sken } proto_specific; 95174840Sken union { 95274840Sken u_int valid; /* Which fields to honor */ 95374840Sken struct ccb_trans_settings_spi spi; 95478709Smjacob struct ccb_trans_settings_fc fc; 955154593Smjacob struct ccb_trans_settings_sas sas; 956236786Smav struct ccb_trans_settings_pata ata; 957195534Sscottl struct ccb_trans_settings_sata sata; 95874840Sken } xport_specific; 95974840Sken}; 96074840Sken 96174840Sken 96239212Sgibbs/* 96339212Sgibbs * Calculate the geometry parameters for a device 96439212Sgibbs * give the block size and volume size in blocks. 96539212Sgibbs */ 96639212Sgibbsstruct ccb_calc_geometry { 96739212Sgibbs struct ccb_hdr ccb_h; 96839212Sgibbs u_int32_t block_size; 969114261Sken u_int64_t volume_size; 970114261Sken u_int32_t cylinders; 97139212Sgibbs u_int8_t heads; 97239212Sgibbs u_int8_t secs_per_track; 97339212Sgibbs}; 97439212Sgibbs 97539212Sgibbs/* 976196008Smjacob * Set or get SIM (and transport) specific knobs 977196008Smjacob */ 978196008Smjacob 979196008Smjacob#define KNOB_VALID_ADDRESS 0x1 980196008Smjacob#define KNOB_VALID_ROLE 0x2 981196008Smjacob 982196008Smjacob 983196008Smjacob#define KNOB_ROLE_NONE 0x0 984196008Smjacob#define KNOB_ROLE_INITIATOR 0x1 985196008Smjacob#define KNOB_ROLE_TARGET 0x2 986196008Smjacob#define KNOB_ROLE_BOTH 0x3 987196008Smjacob 988196008Smjacobstruct ccb_sim_knob_settings_spi { 989196008Smjacob u_int valid; 990196008Smjacob u_int initiator_id; 991196008Smjacob u_int role; 992196008Smjacob}; 993196008Smjacob 994196008Smjacobstruct ccb_sim_knob_settings_fc { 995196008Smjacob u_int valid; 996196008Smjacob u_int64_t wwnn; /* world wide node name */ 997196008Smjacob u_int64_t wwpn; /* world wide port name */ 998196008Smjacob u_int role; 999196008Smjacob}; 1000196008Smjacob 1001196008Smjacobstruct ccb_sim_knob_settings_sas { 1002196008Smjacob u_int valid; 1003196008Smjacob u_int64_t wwnn; /* world wide node name */ 1004196008Smjacob u_int role; 1005196008Smjacob}; 1006196008Smjacob#define KNOB_SETTINGS_SIZE 128 1007196008Smjacob 1008196008Smjacobstruct ccb_sim_knob { 1009196008Smjacob struct ccb_hdr ccb_h; 1010196008Smjacob union { 1011196008Smjacob u_int valid; /* Which fields to honor */ 1012196008Smjacob struct ccb_sim_knob_settings_spi spi; 1013196008Smjacob struct ccb_sim_knob_settings_fc fc; 1014196008Smjacob struct ccb_sim_knob_settings_sas sas; 1015196008Smjacob char pad[KNOB_SETTINGS_SIZE]; 1016196008Smjacob } xport_specific; 1017196008Smjacob}; 1018196008Smjacob 1019196008Smjacob/* 102039212Sgibbs * Rescan the given bus, or bus/target/lun 102139212Sgibbs */ 102239212Sgibbsstruct ccb_rescan { 102339212Sgibbs struct ccb_hdr ccb_h; 102439212Sgibbs cam_flags flags; 102539212Sgibbs}; 102639212Sgibbs 102739212Sgibbs/* 102839212Sgibbs * Turn on debugging for the given bus, bus/target, or bus/target/lun. 102939212Sgibbs */ 103039212Sgibbsstruct ccb_debug { 103139212Sgibbs struct ccb_hdr ccb_h; 103239212Sgibbs cam_debug_flags flags; 103339212Sgibbs}; 103439212Sgibbs 103539212Sgibbs/* Target mode structures. */ 103639212Sgibbs 103739212Sgibbsstruct ccb_en_lun { 103839212Sgibbs struct ccb_hdr ccb_h; 103939212Sgibbs u_int16_t grp6_len; /* Group 6 VU CDB length */ 104039212Sgibbs u_int16_t grp7_len; /* Group 7 VU CDB length */ 104139212Sgibbs u_int8_t enable; 104239212Sgibbs}; 104339212Sgibbs 1044196008Smjacob/* old, barely used immediate notify, binary compatibility */ 104539212Sgibbsstruct ccb_immed_notify { 104639212Sgibbs struct ccb_hdr ccb_h; 104739212Sgibbs struct scsi_sense_data sense_data; 104856145Smjacob u_int8_t sense_len; /* Number of bytes in sense buffer */ 104939212Sgibbs u_int8_t initiator_id; /* Id of initiator that selected */ 105039212Sgibbs u_int8_t message_args[7]; /* Message Arguments */ 105139212Sgibbs}; 105239212Sgibbs 105339212Sgibbsstruct ccb_notify_ack { 105439212Sgibbs struct ccb_hdr ccb_h; 105539212Sgibbs u_int16_t seq_id; /* Sequence identifier */ 105639212Sgibbs u_int8_t event; /* Event flags */ 105739212Sgibbs}; 105839212Sgibbs 1059196008Smjacobstruct ccb_immediate_notify { 1060196008Smjacob struct ccb_hdr ccb_h; 1061196008Smjacob u_int tag_id; /* Tag for immediate notify */ 1062196008Smjacob u_int seq_id; /* Tag for target of notify */ 1063196008Smjacob u_int initiator_id; /* Initiator Identifier */ 1064196008Smjacob u_int arg; /* Function specific */ 1065196008Smjacob}; 1066196008Smjacob 1067196008Smjacobstruct ccb_notify_acknowledge { 1068196008Smjacob struct ccb_hdr ccb_h; 1069196008Smjacob u_int tag_id; /* Tag for immediate notify */ 1070196008Smjacob u_int seq_id; /* Tar for target of notify */ 1071196008Smjacob u_int initiator_id; /* Initiator Identifier */ 1072196008Smjacob u_int arg; /* Function specific */ 1073196008Smjacob}; 1074196008Smjacob 107539212Sgibbs/* HBA engine structures. */ 107639212Sgibbs 107739212Sgibbstypedef enum { 107839212Sgibbs EIT_BUFFER, /* Engine type: buffer memory */ 107939212Sgibbs EIT_LOSSLESS, /* Engine type: lossless compression */ 108039212Sgibbs EIT_LOSSY, /* Engine type: lossy compression */ 108139212Sgibbs EIT_ENCRYPT /* Engine type: encryption */ 108239212Sgibbs} ei_type; 108339212Sgibbs 108439212Sgibbstypedef enum { 108539212Sgibbs EAD_VUNIQUE, /* Engine algorithm ID: vendor unique */ 108639212Sgibbs EAD_LZ1V1, /* Engine algorithm ID: LZ1 var.1 */ 108739212Sgibbs EAD_LZ2V1, /* Engine algorithm ID: LZ2 var.1 */ 108853258Sken EAD_LZ2V2 /* Engine algorithm ID: LZ2 var.2 */ 108939212Sgibbs} ei_algo; 109039212Sgibbs 109139212Sgibbsstruct ccb_eng_inq { 109239212Sgibbs struct ccb_hdr ccb_h; 109339212Sgibbs u_int16_t eng_num; /* The engine number for this inquiry */ 109439212Sgibbs ei_type eng_type; /* Returned engine type */ 109539212Sgibbs ei_algo eng_algo; /* Returned engine algorithm type */ 109639212Sgibbs u_int32_t eng_memeory; /* Returned engine memory size */ 109739212Sgibbs}; 109839212Sgibbs 109939212Sgibbsstruct ccb_eng_exec { /* This structure must match SCSIIO size */ 110039212Sgibbs struct ccb_hdr ccb_h; 110139212Sgibbs u_int8_t *pdrv_ptr; /* Ptr used by the peripheral driver */ 110239212Sgibbs u_int8_t *req_map; /* Ptr for mapping info on the req. */ 110339212Sgibbs u_int8_t *data_ptr; /* Pointer to the data buf/SG list */ 110439212Sgibbs u_int32_t dxfer_len; /* Data transfer length */ 110539212Sgibbs u_int8_t *engdata_ptr; /* Pointer to the engine buffer data */ 110639212Sgibbs u_int16_t sglist_cnt; /* Num of scatter gather list entries */ 110739212Sgibbs u_int32_t dmax_len; /* Destination data maximum length */ 110839212Sgibbs u_int32_t dest_len; /* Destination data length */ 110939212Sgibbs int32_t src_resid; /* Source residual length: 2's comp */ 111039212Sgibbs u_int32_t timeout; /* Timeout value */ 111139212Sgibbs u_int16_t eng_num; /* Engine number for this request */ 111239212Sgibbs u_int16_t vu_flags; /* Vendor Unique flags */ 111339212Sgibbs}; 111439212Sgibbs 111539212Sgibbs/* 111639212Sgibbs * Definitions for the timeout field in the SCSI I/O CCB. 111739212Sgibbs */ 111839212Sgibbs#define CAM_TIME_DEFAULT 0x00000000 /* Use SIM default value */ 111939212Sgibbs#define CAM_TIME_INFINITY 0xFFFFFFFF /* Infinite timeout */ 112039212Sgibbs 112139212Sgibbs#define CAM_SUCCESS 0 /* For signaling general success */ 112239212Sgibbs#define CAM_FAILURE 1 /* For signaling general failure */ 112339212Sgibbs 112439212Sgibbs#define CAM_FALSE 0 112539212Sgibbs#define CAM_TRUE 1 112639212Sgibbs 112739212Sgibbs#define XPT_CCB_INVALID -1 /* for signaling a bad CCB to free */ 112839212Sgibbs 112939212Sgibbs/* 1130223081Sgibbs * CCB for working with advanced device information. This operates in a fashion 1131216088Sken * similar to XPT_GDEV_TYPE. Specify the target in ccb_h, the buffer 1132216088Sken * type requested, and provide a buffer size/buffer to write to. If the 1133223081Sgibbs * buffer is too small, provsiz will be larger than bufsiz. 1134216088Sken */ 1135223081Sgibbsstruct ccb_dev_advinfo { 1136216088Sken struct ccb_hdr ccb_h; 1137216088Sken uint32_t flags; 1138223081Sgibbs#define CDAI_FLAG_STORE 0x1 /* If set, action becomes store */ 1139216088Sken uint32_t buftype; /* IN: Type of data being requested */ 1140216088Sken /* NB: buftype is interpreted on a per-transport basis */ 1141223081Sgibbs#define CDAI_TYPE_SCSI_DEVID 1 1142223081Sgibbs#define CDAI_TYPE_SERIAL_NUM 2 1143223081Sgibbs#define CDAI_TYPE_PHYS_PATH 3 1144247111Smav#define CDAI_TYPE_RCAPLONG 4 1145216088Sken off_t bufsiz; /* IN: Size of external buffer */ 1146216088Sken#define CAM_SCSI_DEVID_MAXLEN 65536 /* length in buffer is an uint16_t */ 1147216088Sken off_t provsiz; /* OUT: Size required/used */ 1148216088Sken uint8_t *buf; /* IN/OUT: Buffer for requested data */ 1149216088Sken}; 1150216088Sken 1151216088Sken/* 115239212Sgibbs * Union of all CCB types for kernel space allocation. This union should 115339212Sgibbs * never be used for manipulating CCBs - its only use is for the allocation 115439212Sgibbs * and deallocation of raw CCB space and is the return type of xpt_ccb_alloc 115539212Sgibbs * and the argument to xpt_ccb_free. 115639212Sgibbs */ 115739212Sgibbsunion ccb { 115839212Sgibbs struct ccb_hdr ccb_h; /* For convenience */ 115939212Sgibbs struct ccb_scsiio csio; 116039212Sgibbs struct ccb_getdev cgd; 116139212Sgibbs struct ccb_getdevlist cgdl; 116239212Sgibbs struct ccb_pathinq cpi; 116339212Sgibbs struct ccb_relsim crs; 116439212Sgibbs struct ccb_setasync csa; 116539212Sgibbs struct ccb_setdev csd; 116647412Sgibbs struct ccb_pathstats cpis; 116747412Sgibbs struct ccb_getdevstats cgds; 116839212Sgibbs struct ccb_dev_match cdm; 116939212Sgibbs struct ccb_trans_settings cts; 117039212Sgibbs struct ccb_calc_geometry ccg; 1171196008Smjacob struct ccb_sim_knob knob; 117239212Sgibbs struct ccb_abort cab; 117339212Sgibbs struct ccb_resetbus crb; 117439212Sgibbs struct ccb_resetdev crd; 117539212Sgibbs struct ccb_termio tio; 117639212Sgibbs struct ccb_accept_tio atio; 117739212Sgibbs struct ccb_scsiio ctio; 117839212Sgibbs struct ccb_en_lun cel; 117939212Sgibbs struct ccb_immed_notify cin; 118039212Sgibbs struct ccb_notify_ack cna; 1181196008Smjacob struct ccb_immediate_notify cin1; 1182196008Smjacob struct ccb_notify_acknowledge cna2; 118339212Sgibbs struct ccb_eng_inq cei; 118439212Sgibbs struct ccb_eng_exec cee; 1185216088Sken struct ccb_smpio smpio; 118639212Sgibbs struct ccb_rescan crcn; 118739212Sgibbs struct ccb_debug cdbg; 1188195534Sscottl struct ccb_ataio ataio; 1189223081Sgibbs struct ccb_dev_advinfo cdai; 119039212Sgibbs}; 119139212Sgibbs 119239212Sgibbs__BEGIN_DECLS 119339212Sgibbsstatic __inline void 119439212Sgibbscam_fill_csio(struct ccb_scsiio *csio, u_int32_t retries, 119539212Sgibbs void (*cbfcnp)(struct cam_periph *, union ccb *), 119639212Sgibbs u_int32_t flags, u_int8_t tag_action, 119739212Sgibbs u_int8_t *data_ptr, u_int32_t dxfer_len, 119839212Sgibbs u_int8_t sense_len, u_int8_t cdb_len, 119939212Sgibbs u_int32_t timeout); 120039212Sgibbs 120139212Sgibbsstatic __inline void 120239212Sgibbscam_fill_ctio(struct ccb_scsiio *csio, u_int32_t retries, 120339212Sgibbs void (*cbfcnp)(struct cam_periph *, union ccb *), 120439212Sgibbs u_int32_t flags, u_int tag_action, u_int tag_id, 120539212Sgibbs u_int init_id, u_int scsi_status, u_int8_t *data_ptr, 120639212Sgibbs u_int32_t dxfer_len, u_int32_t timeout); 1207195534Sscottl 120839212Sgibbsstatic __inline void 1209195534Sscottlcam_fill_ataio(struct ccb_ataio *ataio, u_int32_t retries, 1210195534Sscottl void (*cbfcnp)(struct cam_periph *, union ccb *), 1211195534Sscottl u_int32_t flags, u_int tag_action, 1212195534Sscottl u_int8_t *data_ptr, u_int32_t dxfer_len, 1213195534Sscottl u_int32_t timeout); 1214195534Sscottl 1215195534Sscottlstatic __inline void 1216216088Skencam_fill_smpio(struct ccb_smpio *smpio, uint32_t retries, 1217216088Sken void (*cbfcnp)(struct cam_periph *, union ccb *), uint32_t flags, 1218216088Sken uint8_t *smp_request, int smp_request_len, 1219216088Sken uint8_t *smp_response, int smp_response_len, 1220216088Sken uint32_t timeout); 1221216088Sken 1222216088Skenstatic __inline void 122339212Sgibbscam_fill_csio(struct ccb_scsiio *csio, u_int32_t retries, 122439212Sgibbs void (*cbfcnp)(struct cam_periph *, union ccb *), 122539212Sgibbs u_int32_t flags, u_int8_t tag_action, 122639212Sgibbs u_int8_t *data_ptr, u_int32_t dxfer_len, 122739212Sgibbs u_int8_t sense_len, u_int8_t cdb_len, 122839212Sgibbs u_int32_t timeout) 122939212Sgibbs{ 123039212Sgibbs csio->ccb_h.func_code = XPT_SCSI_IO; 123139212Sgibbs csio->ccb_h.flags = flags; 123239212Sgibbs csio->ccb_h.retry_count = retries; 123339212Sgibbs csio->ccb_h.cbfcnp = cbfcnp; 123439212Sgibbs csio->ccb_h.timeout = timeout; 123539212Sgibbs csio->data_ptr = data_ptr; 123639212Sgibbs csio->dxfer_len = dxfer_len; 123739212Sgibbs csio->sense_len = sense_len; 123839212Sgibbs csio->cdb_len = cdb_len; 123939212Sgibbs csio->tag_action = tag_action; 124039212Sgibbs} 124139212Sgibbs 124239212Sgibbsstatic __inline void 124339212Sgibbscam_fill_ctio(struct ccb_scsiio *csio, u_int32_t retries, 124439212Sgibbs void (*cbfcnp)(struct cam_periph *, union ccb *), 124539212Sgibbs u_int32_t flags, u_int tag_action, u_int tag_id, 124639212Sgibbs u_int init_id, u_int scsi_status, u_int8_t *data_ptr, 124739212Sgibbs u_int32_t dxfer_len, u_int32_t timeout) 124839212Sgibbs{ 124939212Sgibbs csio->ccb_h.func_code = XPT_CONT_TARGET_IO; 125039212Sgibbs csio->ccb_h.flags = flags; 125139212Sgibbs csio->ccb_h.retry_count = retries; 125239212Sgibbs csio->ccb_h.cbfcnp = cbfcnp; 125339212Sgibbs csio->ccb_h.timeout = timeout; 125439212Sgibbs csio->data_ptr = data_ptr; 125539212Sgibbs csio->dxfer_len = dxfer_len; 125639212Sgibbs csio->scsi_status = scsi_status; 125739212Sgibbs csio->tag_action = tag_action; 125839212Sgibbs csio->tag_id = tag_id; 125939212Sgibbs csio->init_id = init_id; 126039212Sgibbs} 126139212Sgibbs 1262195534Sscottlstatic __inline void 1263195534Sscottlcam_fill_ataio(struct ccb_ataio *ataio, u_int32_t retries, 1264195534Sscottl void (*cbfcnp)(struct cam_periph *, union ccb *), 1265195534Sscottl u_int32_t flags, u_int tag_action, 1266195534Sscottl u_int8_t *data_ptr, u_int32_t dxfer_len, 1267195534Sscottl u_int32_t timeout) 1268195534Sscottl{ 1269195534Sscottl ataio->ccb_h.func_code = XPT_ATA_IO; 1270195534Sscottl ataio->ccb_h.flags = flags; 1271195534Sscottl ataio->ccb_h.retry_count = retries; 1272195534Sscottl ataio->ccb_h.cbfcnp = cbfcnp; 1273195534Sscottl ataio->ccb_h.timeout = timeout; 1274195534Sscottl ataio->data_ptr = data_ptr; 1275195534Sscottl ataio->dxfer_len = dxfer_len; 1276195534Sscottl ataio->tag_action = tag_action; 1277195534Sscottl} 1278195534Sscottl 1279216088Skenstatic __inline void 1280216088Skencam_fill_smpio(struct ccb_smpio *smpio, uint32_t retries, 1281216088Sken void (*cbfcnp)(struct cam_periph *, union ccb *), uint32_t flags, 1282216088Sken uint8_t *smp_request, int smp_request_len, 1283216088Sken uint8_t *smp_response, int smp_response_len, 1284216088Sken uint32_t timeout) 1285216088Sken{ 1286216088Sken#ifdef _KERNEL 1287216088Sken KASSERT((flags & CAM_DIR_MASK) == CAM_DIR_BOTH, 1288216088Sken ("direction != CAM_DIR_BOTH")); 1289216088Sken KASSERT((smp_request != NULL) && (smp_response != NULL), 1290216088Sken ("need valid request and response buffers")); 1291216088Sken KASSERT((smp_request_len != 0) && (smp_response_len != 0), 1292216088Sken ("need non-zero request and response lengths")); 1293216088Sken#endif /*_KERNEL*/ 1294216088Sken smpio->ccb_h.func_code = XPT_SMP_IO; 1295216088Sken smpio->ccb_h.flags = flags; 1296216088Sken smpio->ccb_h.retry_count = retries; 1297216088Sken smpio->ccb_h.cbfcnp = cbfcnp; 1298216088Sken smpio->ccb_h.timeout = timeout; 1299216088Sken smpio->smp_request = smp_request; 1300216088Sken smpio->smp_request_len = smp_request_len; 1301216088Sken smpio->smp_response = smp_response; 1302216088Sken smpio->smp_response_len = smp_response_len; 1303216088Sken} 1304216088Sken 1305255542Smavstatic __inline void 1306255542Smavcam_set_ccbstatus(union ccb *ccb, cam_status status) 1307255542Smav{ 1308255542Smav ccb->ccb_h.status &= ~CAM_STATUS_MASK; 1309255542Smav ccb->ccb_h.status |= status; 1310255542Smav} 1311255542Smav 1312255542Smavstatic __inline cam_status 1313255542Smavcam_ccb_status(union ccb *ccb) 1314255542Smav{ 1315255542Smav return ((cam_status)(ccb->ccb_h.status & CAM_STATUS_MASK)); 1316255542Smav} 1317255542Smav 1318116350Snjlvoid cam_calc_geometry(struct ccb_calc_geometry *ccg, int extended); 1319116350Snjl 132039212Sgibbs__END_DECLS 132139212Sgibbs 132239212Sgibbs#endif /* _CAM_CAM_CCB_H */ 1323