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: stable/10/sys/cam/cam_ccb.h 312850 2017-01-26 21:35:58Z mav $ 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 */ 66246713Skib CAM_DATA_ISPHYS = 0x00000010,/* 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 */ 73246713Skib CAM_DATA_VADDR = 0x00000000,/* Data type (000:Virtual) */ 74246713Skib CAM_DATA_PADDR = 0x00000010,/* Data type (001:Physical) */ 75246713Skib CAM_DATA_SG = 0x00040000,/* Data type (010:sglist) */ 76246713Skib CAM_DATA_SG_PADDR = 0x00040010,/* Data type (011:sglist phys) */ 77246713Skib CAM_DATA_BIO = 0x00200000,/* Data type (100:bio) */ 78246713Skib 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 9439212Sgibbs/* Phase cognizant mode flags */ 9558111Sn_hibma CAM_DIS_AUTOSRP = 0x01000000,/* Disable autosave/restore ptrs */ 9639212Sgibbs CAM_DIS_AUTODISC = 0x02000000,/* Disable auto disconnect */ 9739212Sgibbs CAM_TGT_CCB_AVAIL = 0x04000000,/* Target CCB available */ 9839212Sgibbs CAM_TGT_PHASE_MODE = 0x08000000,/* The SIM runs in phase mode */ 9956145Smjacob CAM_MSGB_VALID = 0x10000000,/* Message buffer valid */ 10056145Smjacob CAM_STATUS_VALID = 0x20000000,/* Status buffer valid */ 10156145Smjacob CAM_DATAB_VALID = 0x40000000,/* Data buffer valid */ 102248520Skib 10339212Sgibbs/* Host target Mode flags */ 10456145Smjacob CAM_SEND_SENSE = 0x08000000,/* Send sense data with status */ 10556145Smjacob CAM_TERM_IO = 0x10000000,/* Terminate I/O Message sup. */ 10656145Smjacob CAM_DISCONNECT = 0x20000000,/* Disconnects are mandatory */ 107260387Sscottl CAM_SEND_STATUS = 0x40000000,/* Send status after data phase */ 108260387Sscottl 109260387Sscottl CAM_UNLOCKED = 0x80000000 /* Call callback without lock. */ 11039212Sgibbs} ccb_flags; 11139212Sgibbs 112255870Sscottltypedef enum { 113255870Sscottl CAM_EXTLUN_VALID = 0x00000001,/* 64bit lun field is valid */ 114292348Sken CAM_USER_DATA_ADDR = 0x00000002,/* Userspace data pointers */ 115292348Sken CAM_SG_FORMAT_IOVEC = 0x00000004,/* iovec instead of busdma S/G*/ 116292348Sken CAM_UNMAPPED_BUF = 0x00000008 /* use unmapped I/O */ 117255870Sscottl} ccb_xflags; 118255870Sscottl 11939212Sgibbs/* XPT Opcodes for xpt_action */ 12039212Sgibbstypedef enum { 12146581Sken/* Function code flags are bits greater than 0xff */ 12246581Sken XPT_FC_QUEUED = 0x100, 12346581Sken /* Non-immediate function code */ 12446581Sken XPT_FC_USER_CCB = 0x200, 12546581Sken XPT_FC_XPT_ONLY = 0x400, 12646581Sken /* Only for the transport layer device */ 12749925Sgibbs XPT_FC_DEV_QUEUED = 0x800 | XPT_FC_QUEUED, 12849925Sgibbs /* Passes through the device queues */ 12939212Sgibbs/* Common function commands: 0x00->0x0F */ 13046581Sken XPT_NOOP = 0x00, 13146581Sken /* Execute Nothing */ 13249925Sgibbs XPT_SCSI_IO = 0x01 | XPT_FC_DEV_QUEUED, 13346581Sken /* Execute the requested I/O operation */ 13446581Sken XPT_GDEV_TYPE = 0x02, 13546581Sken /* Get type information for specified device */ 13646581Sken XPT_GDEVLIST = 0x03, 13746581Sken /* Get a list of peripheral devices */ 13846581Sken XPT_PATH_INQ = 0x04, 13946581Sken /* Path routing inquiry */ 14046581Sken XPT_REL_SIMQ = 0x05, 141203108Smav /* Release a frozen device queue */ 14246581Sken XPT_SASYNC_CB = 0x06, 14346581Sken /* Set Asynchronous Callback Parameters */ 14446581Sken XPT_SDEV_TYPE = 0x07, 14546581Sken /* Set device type information */ 14646581Sken XPT_SCAN_BUS = 0x08 | XPT_FC_QUEUED | XPT_FC_USER_CCB 14746581Sken | XPT_FC_XPT_ONLY, 14846581Sken /* (Re)Scan the SCSI Bus */ 14946581Sken XPT_DEV_MATCH = 0x09 | XPT_FC_XPT_ONLY, 15046581Sken /* Get EDT entries matching the given pattern */ 15146581Sken XPT_DEBUG = 0x0a, 15246581Sken /* Turn on debugging for a bus, target or lun */ 15347412Sgibbs XPT_PATH_STATS = 0x0b, 15447412Sgibbs /* Path statistics (error counts, etc.) */ 15547412Sgibbs XPT_GDEV_STATS = 0x0c, 15647412Sgibbs /* Device statistics (error counts, etc.) */ 157223081Sgibbs XPT_DEV_ADVINFO = 0x0e, 158223081Sgibbs /* Get/Set Device advanced information */ 159260387Sscottl XPT_ASYNC = 0x0f | XPT_FC_QUEUED | XPT_FC_USER_CCB 160260387Sscottl | XPT_FC_XPT_ONLY, 161260387Sscottl /* Asynchronous event */ 16239212Sgibbs/* SCSI Control Functions: 0x10->0x1F */ 16346581Sken XPT_ABORT = 0x10, 16446581Sken /* Abort the specified CCB */ 16546581Sken XPT_RESET_BUS = 0x11 | XPT_FC_XPT_ONLY, 16646581Sken /* Reset the specified SCSI bus */ 16749925Sgibbs XPT_RESET_DEV = 0x12 | XPT_FC_DEV_QUEUED, 16846581Sken /* Bus Device Reset the specified SCSI device */ 16946581Sken XPT_TERM_IO = 0x13, 17046581Sken /* Terminate the I/O process */ 17146581Sken XPT_SCAN_LUN = 0x14 | XPT_FC_QUEUED | XPT_FC_USER_CCB 17246581Sken | XPT_FC_XPT_ONLY, 17346581Sken /* Scan Logical Unit */ 17446581Sken XPT_GET_TRAN_SETTINGS = 0x15, 17546581Sken /* 17639212Sgibbs * Get default/user transfer settings 17739212Sgibbs * for the target 17839212Sgibbs */ 17946581Sken XPT_SET_TRAN_SETTINGS = 0x16, 18046581Sken /* 18139212Sgibbs * Set transfer rate/width 18239212Sgibbs * negotiation settings 18339212Sgibbs */ 18446581Sken XPT_CALC_GEOMETRY = 0x17, 18546581Sken /* 18639212Sgibbs * Calculate the geometry parameters for 18739212Sgibbs * a device give the sector size and 18839212Sgibbs * volume size. 18939212Sgibbs */ 190195534Sscottl XPT_ATA_IO = 0x18 | XPT_FC_DEV_QUEUED, 191195534Sscottl /* Execute the requested ATA I/O operation */ 19239212Sgibbs 193196008Smjacob XPT_GET_SIM_KNOB = 0x18, 194196008Smjacob /* 195196008Smjacob * Get SIM specific knob values. 196196008Smjacob */ 197196008Smjacob 198196008Smjacob XPT_SET_SIM_KNOB = 0x19, 199196008Smjacob /* 200196008Smjacob * Set SIM specific knob values. 201196008Smjacob */ 202208582Smjacob 203216088Sken XPT_SMP_IO = 0x1b | XPT_FC_DEV_QUEUED, 204216088Sken /* Serial Management Protocol */ 205216088Sken 206208582Smjacob XPT_SCAN_TGT = 0x1E | XPT_FC_QUEUED | XPT_FC_USER_CCB 207208582Smjacob | XPT_FC_XPT_ONLY, 208208582Smjacob /* Scan Target */ 209208582Smjacob 21039212Sgibbs/* HBA engine commands 0x20->0x2F */ 21146581Sken XPT_ENG_INQ = 0x20 | XPT_FC_XPT_ONLY, 21246581Sken /* HBA engine feature inquiry */ 21374840Sken XPT_ENG_EXEC = 0x21 | XPT_FC_DEV_QUEUED, 21446581Sken /* HBA execute engine request */ 21539212Sgibbs 21639212Sgibbs/* Target mode commands: 0x30->0x3F */ 21746581Sken XPT_EN_LUN = 0x30, 21846581Sken /* Enable LUN as a target */ 21949925Sgibbs XPT_TARGET_IO = 0x31 | XPT_FC_DEV_QUEUED, 22046581Sken /* Execute target I/O request */ 22146581Sken XPT_ACCEPT_TARGET_IO = 0x32 | XPT_FC_QUEUED | XPT_FC_USER_CCB, 22246581Sken /* Accept Host Target Mode CDB */ 22349925Sgibbs XPT_CONT_TARGET_IO = 0x33 | XPT_FC_DEV_QUEUED, 22446581Sken /* Continue Host Target I/O Connection */ 22546581Sken XPT_IMMED_NOTIFY = 0x34 | XPT_FC_QUEUED | XPT_FC_USER_CCB, 226196008Smjacob /* Notify Host Target driver of event (obsolete) */ 227196008Smjacob XPT_NOTIFY_ACK = 0x35, 228196008Smjacob /* Acknowledgement of event (obsolete) */ 229196008Smjacob XPT_IMMEDIATE_NOTIFY = 0x36 | XPT_FC_QUEUED | XPT_FC_USER_CCB, 23046581Sken /* Notify Host Target driver of event */ 231196008Smjacob XPT_NOTIFY_ACKNOWLEDGE = 0x37 | XPT_FC_QUEUED | XPT_FC_USER_CCB, 23246581Sken /* Acknowledgement of event */ 233302376Struckman XPT_REPROBE_LUN = 0x38 | XPT_FC_QUEUED | XPT_FC_USER_CCB, 234302376Struckman /* Query device capacity and notify GEOM */ 23539212Sgibbs 23639212Sgibbs/* Vendor Unique codes: 0x80->0x8F */ 23746581Sken XPT_VUNIQUE = 0x80 23839212Sgibbs} xpt_opcode; 23939212Sgibbs 24046581Sken#define XPT_FC_GROUP_MASK 0xF0 24146581Sken#define XPT_FC_GROUP(op) ((op) & XPT_FC_GROUP_MASK) 24246581Sken#define XPT_FC_GROUP_COMMON 0x00 24346581Sken#define XPT_FC_GROUP_SCSI_CONTROL 0x10 24449925Sgibbs#define XPT_FC_GROUP_HBA_ENGINE 0x20 24546581Sken#define XPT_FC_GROUP_TMODE 0x30 24646581Sken#define XPT_FC_GROUP_VENDOR_UNIQUE 0x80 24744499Sgibbs 24849925Sgibbs#define XPT_FC_IS_DEV_QUEUED(ccb) \ 24949925Sgibbs (((ccb)->ccb_h.func_code & XPT_FC_DEV_QUEUED) == XPT_FC_DEV_QUEUED) 25049925Sgibbs#define XPT_FC_IS_QUEUED(ccb) \ 25149925Sgibbs (((ccb)->ccb_h.func_code & XPT_FC_QUEUED) != 0) 25274840Sken 25374840Skentypedef enum { 25474840Sken PROTO_UNKNOWN, 25574840Sken PROTO_UNSPECIFIED, 25674840Sken PROTO_SCSI, /* Small Computer System Interface */ 25774840Sken PROTO_ATA, /* AT Attachment */ 25874840Sken PROTO_ATAPI, /* AT Attachment Packetized Interface */ 259195534Sscottl PROTO_SATAPM, /* SATA Port Multiplier */ 260235897Smav PROTO_SEMB, /* SATA Enclosure Management Bridge */ 26174840Sken} cam_proto; 26274840Sken 26374840Skentypedef enum { 26474840Sken XPORT_UNKNOWN, 26574840Sken XPORT_UNSPECIFIED, 26674840Sken XPORT_SPI, /* SCSI Parallel Interface */ 26774840Sken XPORT_FC, /* Fiber Channel */ 26874840Sken XPORT_SSA, /* Serial Storage Architecture */ 26974840Sken XPORT_USB, /* Universal Serial Bus */ 27074840Sken XPORT_PPB, /* Parallel Port Bus */ 271154593Smjacob XPORT_ATA, /* AT Attachment */ 272154593Smjacob XPORT_SAS, /* Serial Attached SCSI */ 273195534Sscottl XPORT_SATA, /* Serial AT Attachment */ 274196352Smav XPORT_ISCSI, /* iSCSI */ 275255915Snwhitehorn XPORT_SRP, /* SCSI RDMA Protocol */ 27674840Sken} cam_xport; 27774840Sken 278220644Smav#define XPORT_IS_ATA(t) ((t) == XPORT_ATA || (t) == XPORT_SATA) 279220644Smav#define XPORT_IS_SCSI(t) ((t) != XPORT_UNKNOWN && \ 280220644Smav (t) != XPORT_UNSPECIFIED && \ 281220644Smav !XPORT_IS_ATA(t)) 282220644Smav#define XPORT_DEVSTAT_TYPE(t) (XPORT_IS_ATA(t) ? DEVSTAT_TYPE_IF_IDE : \ 283220644Smav XPORT_IS_SCSI(t) ? DEVSTAT_TYPE_IF_SCSI : \ 284220644Smav DEVSTAT_TYPE_IF_OTHER) 285220644Smav 286154593Smjacob#define PROTO_VERSION_UNKNOWN (UINT_MAX - 1) 287154593Smjacob#define PROTO_VERSION_UNSPECIFIED UINT_MAX 288154593Smjacob#define XPORT_VERSION_UNKNOWN (UINT_MAX - 1) 289154593Smjacob#define XPORT_VERSION_UNSPECIFIED UINT_MAX 29074840Sken 29139212Sgibbstypedef union { 29260938Sjake LIST_ENTRY(ccb_hdr) le; 29360938Sjake SLIST_ENTRY(ccb_hdr) sle; 29460938Sjake TAILQ_ENTRY(ccb_hdr) tqe; 29560938Sjake STAILQ_ENTRY(ccb_hdr) stqe; 29639212Sgibbs} camq_entry; 29739212Sgibbs 29839212Sgibbstypedef union { 29939212Sgibbs void *ptr; 30039212Sgibbs u_long field; 301168752Sscottl u_int8_t bytes[sizeof(uintptr_t)]; 30239212Sgibbs} ccb_priv_entry; 30339212Sgibbs 30439212Sgibbstypedef union { 30539212Sgibbs ccb_priv_entry entries[CCB_PERIPH_PRIV_SIZE]; 30639212Sgibbs u_int8_t bytes[CCB_PERIPH_PRIV_SIZE * sizeof(ccb_priv_entry)]; 30739212Sgibbs} ccb_ppriv_area; 30839212Sgibbs 30939212Sgibbstypedef union { 31039212Sgibbs ccb_priv_entry entries[CCB_SIM_PRIV_SIZE]; 31139212Sgibbs u_int8_t bytes[CCB_SIM_PRIV_SIZE * sizeof(ccb_priv_entry)]; 31239212Sgibbs} ccb_spriv_area; 31339212Sgibbs 314255870Sscottltypedef struct { 315255870Sscottl struct timeval *etime; 316255870Sscottl uintptr_t sim_data; 317255870Sscottl uintptr_t periph_data; 318255870Sscottl} ccb_qos_area; 319255870Sscottl 32039212Sgibbsstruct ccb_hdr { 321130200Sscottl cam_pinfo pinfo; /* Info for priority scheduling */ 32239212Sgibbs camq_entry xpt_links; /* For chaining in the XPT layer */ 32339212Sgibbs camq_entry sim_links; /* For chaining in the SIM layer */ 324130200Sscottl camq_entry periph_links; /* For chaining in the type driver */ 32539212Sgibbs u_int32_t retry_count; 32639212Sgibbs void (*cbfcnp)(struct cam_periph *, union ccb *); 327130200Sscottl /* Callback on completion function */ 32839212Sgibbs xpt_opcode func_code; /* XPT function code */ 329130200Sscottl u_int32_t status; /* Status returned by CAM subsystem */ 330130200Sscottl struct cam_path *path; /* Compiled path for this ccb */ 33139212Sgibbs path_id_t path_id; /* Path ID for the request */ 33239212Sgibbs target_id_t target_id; /* Target device ID */ 33339212Sgibbs lun_id_t target_lun; /* Target LUN number */ 334255870Sscottl lun64_id_t ext_lun; /* 64bit extended/multi-level LUNs */ 335130200Sscottl u_int32_t flags; /* ccb_flags */ 336255870Sscottl u_int32_t xflags; /* Extended flags */ 33739212Sgibbs ccb_ppriv_area periph_priv; 33839212Sgibbs ccb_spriv_area sim_priv; 339255870Sscottl ccb_qos_area qos; 340255870Sscottl u_int32_t timeout; /* Hard timeout value in mseconds */ 341255870Sscottl struct timeval softtimeout; /* Soft timeout value in sec + usec */ 34239212Sgibbs}; 34339212Sgibbs 34439212Sgibbs/* Get Device Information CCB */ 34539212Sgibbsstruct ccb_getdev { 34639212Sgibbs struct ccb_hdr ccb_h; 347195534Sscottl cam_proto protocol; 34856145Smjacob struct scsi_inquiry_data inq_data; 349195534Sscottl struct ata_params ident_data; 35039212Sgibbs u_int8_t serial_num[252]; 351199178Smav u_int8_t inq_flags; 35239212Sgibbs u_int8_t serial_num_len; 35339212Sgibbs}; 35439212Sgibbs 35547412Sgibbs/* Device Statistics CCB */ 35647412Sgibbsstruct ccb_getdevstats { 35747412Sgibbs struct ccb_hdr ccb_h; 35847412Sgibbs int dev_openings; /* Space left for more work on device*/ 35947412Sgibbs int dev_active; /* Transactions running on the device */ 360273078Smav int allocated; /* CCBs allocated for the device */ 361273078Smav int queued; /* CCBs queued to be sent to the device */ 36247412Sgibbs int held; /* 36347412Sgibbs * CCBs held by peripheral drivers 36447412Sgibbs * for this device 36547412Sgibbs */ 36647434Sgibbs int maxtags; /* 36747434Sgibbs * Boundary conditions for number of 36847434Sgibbs * tagged operations 36947434Sgibbs */ 37047434Sgibbs int mintags; 37147412Sgibbs struct timeval last_reset; /* Time of last bus reset/loop init */ 37247412Sgibbs}; 37339212Sgibbs 37439212Sgibbstypedef enum { 37539212Sgibbs CAM_GDEVLIST_LAST_DEVICE, 37639212Sgibbs CAM_GDEVLIST_LIST_CHANGED, 37739212Sgibbs CAM_GDEVLIST_MORE_DEVS, 37839212Sgibbs CAM_GDEVLIST_ERROR 37939212Sgibbs} ccb_getdevlist_status_e; 38039212Sgibbs 38139212Sgibbsstruct ccb_getdevlist { 38239212Sgibbs struct ccb_hdr ccb_h; 38339212Sgibbs char periph_name[DEV_IDLEN]; 38439212Sgibbs u_int32_t unit_number; 38539212Sgibbs unsigned int generation; 38639212Sgibbs u_int32_t index; 38739212Sgibbs ccb_getdevlist_status_e status; 38839212Sgibbs}; 38939212Sgibbs 39039212Sgibbstypedef enum { 39139212Sgibbs PERIPH_MATCH_NONE = 0x000, 39239212Sgibbs PERIPH_MATCH_PATH = 0x001, 39339212Sgibbs PERIPH_MATCH_TARGET = 0x002, 39439212Sgibbs PERIPH_MATCH_LUN = 0x004, 39539212Sgibbs PERIPH_MATCH_NAME = 0x008, 39639212Sgibbs PERIPH_MATCH_UNIT = 0x010, 39739212Sgibbs PERIPH_MATCH_ANY = 0x01f 39839212Sgibbs} periph_pattern_flags; 39939212Sgibbs 40039212Sgibbsstruct periph_match_pattern { 40139212Sgibbs char periph_name[DEV_IDLEN]; 40239212Sgibbs u_int32_t unit_number; 40339212Sgibbs path_id_t path_id; 40439212Sgibbs target_id_t target_id; 40539212Sgibbs lun_id_t target_lun; 40639212Sgibbs periph_pattern_flags flags; 40739212Sgibbs}; 40839212Sgibbs 40939212Sgibbstypedef enum { 41039212Sgibbs DEV_MATCH_NONE = 0x000, 41139212Sgibbs DEV_MATCH_PATH = 0x001, 41239212Sgibbs DEV_MATCH_TARGET = 0x002, 41339212Sgibbs DEV_MATCH_LUN = 0x004, 41439212Sgibbs DEV_MATCH_INQUIRY = 0x008, 415223081Sgibbs DEV_MATCH_DEVID = 0x010, 41639212Sgibbs DEV_MATCH_ANY = 0x00f 41739212Sgibbs} dev_pattern_flags; 41839212Sgibbs 419223081Sgibbsstruct device_id_match_pattern { 420223081Sgibbs uint8_t id_len; 421223081Sgibbs uint8_t id[256]; 422223081Sgibbs}; 423223081Sgibbs 42439212Sgibbsstruct device_match_pattern { 425223081Sgibbs path_id_t path_id; 426223081Sgibbs target_id_t target_id; 427223081Sgibbs lun_id_t target_lun; 428223081Sgibbs dev_pattern_flags flags; 429223081Sgibbs union { 430223081Sgibbs struct scsi_static_inquiry_pattern inq_pat; 431223081Sgibbs struct device_id_match_pattern devid_pat; 432223081Sgibbs } data; 43339212Sgibbs}; 43439212Sgibbs 43539212Sgibbstypedef enum { 43639212Sgibbs BUS_MATCH_NONE = 0x000, 43739212Sgibbs BUS_MATCH_PATH = 0x001, 43839212Sgibbs BUS_MATCH_NAME = 0x002, 43939212Sgibbs BUS_MATCH_UNIT = 0x004, 44039212Sgibbs BUS_MATCH_BUS_ID = 0x008, 44139212Sgibbs BUS_MATCH_ANY = 0x00f 44239212Sgibbs} bus_pattern_flags; 44339212Sgibbs 44439212Sgibbsstruct bus_match_pattern { 44539212Sgibbs path_id_t path_id; 44639212Sgibbs char dev_name[DEV_IDLEN]; 44739212Sgibbs u_int32_t unit_number; 44839212Sgibbs u_int32_t bus_id; 44939212Sgibbs bus_pattern_flags flags; 45039212Sgibbs}; 45139212Sgibbs 45239212Sgibbsunion match_pattern { 45339212Sgibbs struct periph_match_pattern periph_pattern; 45439212Sgibbs struct device_match_pattern device_pattern; 45539212Sgibbs struct bus_match_pattern bus_pattern; 45639212Sgibbs}; 45739212Sgibbs 45839212Sgibbstypedef enum { 45939212Sgibbs DEV_MATCH_PERIPH, 46039212Sgibbs DEV_MATCH_DEVICE, 46139212Sgibbs DEV_MATCH_BUS 46239212Sgibbs} dev_match_type; 46339212Sgibbs 46439212Sgibbsstruct dev_match_pattern { 46539212Sgibbs dev_match_type type; 46639212Sgibbs union match_pattern pattern; 46739212Sgibbs}; 46839212Sgibbs 46939212Sgibbsstruct periph_match_result { 47039212Sgibbs char periph_name[DEV_IDLEN]; 47139212Sgibbs u_int32_t unit_number; 47239212Sgibbs path_id_t path_id; 47339212Sgibbs target_id_t target_id; 47439212Sgibbs lun_id_t target_lun; 47539212Sgibbs}; 47639212Sgibbs 47746581Skentypedef enum { 47846581Sken DEV_RESULT_NOFLAG = 0x00, 47946581Sken DEV_RESULT_UNCONFIGURED = 0x01 48046581Sken} dev_result_flags; 48146581Sken 48239212Sgibbsstruct device_match_result { 48339212Sgibbs path_id_t path_id; 48439212Sgibbs target_id_t target_id; 48539212Sgibbs lun_id_t target_lun; 486195534Sscottl cam_proto protocol; 48739212Sgibbs struct scsi_inquiry_data inq_data; 488195534Sscottl struct ata_params ident_data; 48946581Sken dev_result_flags flags; 49039212Sgibbs}; 49139212Sgibbs 49239212Sgibbsstruct bus_match_result { 49339212Sgibbs path_id_t path_id; 49439212Sgibbs char dev_name[DEV_IDLEN]; 49539212Sgibbs u_int32_t unit_number; 49639212Sgibbs u_int32_t bus_id; 49739212Sgibbs}; 49839212Sgibbs 49939212Sgibbsunion match_result { 50039212Sgibbs struct periph_match_result periph_result; 50139212Sgibbs struct device_match_result device_result; 50239212Sgibbs struct bus_match_result bus_result; 50339212Sgibbs}; 50439212Sgibbs 50539212Sgibbsstruct dev_match_result { 50639212Sgibbs dev_match_type type; 50739212Sgibbs union match_result result; 50839212Sgibbs}; 50939212Sgibbs 51039212Sgibbstypedef enum { 51139212Sgibbs CAM_DEV_MATCH_LAST, 51239212Sgibbs CAM_DEV_MATCH_MORE, 51339212Sgibbs CAM_DEV_MATCH_LIST_CHANGED, 51439212Sgibbs CAM_DEV_MATCH_SIZE_ERROR, 51539212Sgibbs CAM_DEV_MATCH_ERROR 51639212Sgibbs} ccb_dev_match_status; 51739212Sgibbs 51839212Sgibbstypedef enum { 51939212Sgibbs CAM_DEV_POS_NONE = 0x000, 52039212Sgibbs CAM_DEV_POS_BUS = 0x001, 52139212Sgibbs CAM_DEV_POS_TARGET = 0x002, 52239212Sgibbs CAM_DEV_POS_DEVICE = 0x004, 52339212Sgibbs CAM_DEV_POS_PERIPH = 0x008, 52439212Sgibbs CAM_DEV_POS_PDPTR = 0x010, 52539212Sgibbs CAM_DEV_POS_TYPEMASK = 0xf00, 52639212Sgibbs CAM_DEV_POS_EDT = 0x100, 52739212Sgibbs CAM_DEV_POS_PDRV = 0x200 52839212Sgibbs} dev_pos_type; 52939212Sgibbs 53039212Sgibbsstruct ccb_dm_cookie { 53139212Sgibbs void *bus; 53239212Sgibbs void *target; 53339212Sgibbs void *device; 53439212Sgibbs void *periph; 53539212Sgibbs void *pdrv; 53639212Sgibbs}; 53739212Sgibbs 53839212Sgibbsstruct ccb_dev_position { 53939212Sgibbs u_int generations[4]; 54039212Sgibbs#define CAM_BUS_GENERATION 0x00 54139212Sgibbs#define CAM_TARGET_GENERATION 0x01 54239212Sgibbs#define CAM_DEV_GENERATION 0x02 54339212Sgibbs#define CAM_PERIPH_GENERATION 0x03 54439212Sgibbs dev_pos_type position_type; 54539212Sgibbs struct ccb_dm_cookie cookie; 54639212Sgibbs}; 54739212Sgibbs 54839212Sgibbsstruct ccb_dev_match { 54939212Sgibbs struct ccb_hdr ccb_h; 55039212Sgibbs ccb_dev_match_status status; 55139212Sgibbs u_int32_t num_patterns; 55239212Sgibbs u_int32_t pattern_buf_len; 55339212Sgibbs struct dev_match_pattern *patterns; 55439212Sgibbs u_int32_t num_matches; 55539212Sgibbs u_int32_t match_buf_len; 55639212Sgibbs struct dev_match_result *matches; 55739212Sgibbs struct ccb_dev_position pos; 55839212Sgibbs}; 55939212Sgibbs 56039212Sgibbs/* 56139212Sgibbs * Definitions for the path inquiry CCB fields. 56239212Sgibbs */ 563255870Sscottl#define CAM_VERSION 0x18 /* Hex value for current version */ 56439212Sgibbs 56539212Sgibbstypedef enum { 56639212Sgibbs PI_MDP_ABLE = 0x80, /* Supports MDP message */ 56739212Sgibbs PI_WIDE_32 = 0x40, /* Supports 32 bit wide SCSI */ 56839212Sgibbs PI_WIDE_16 = 0x20, /* Supports 16 bit wide SCSI */ 56939212Sgibbs PI_SDTR_ABLE = 0x10, /* Supports SDTR message */ 57039212Sgibbs PI_LINKED_CDB = 0x08, /* Supports linked CDBs */ 571195534Sscottl PI_SATAPM = 0x04, /* Supports SATA PM */ 57239212Sgibbs PI_TAG_ABLE = 0x02, /* Supports tag queue messages */ 57353258Sken PI_SOFT_RST = 0x01 /* Supports soft reset alternative */ 57439212Sgibbs} pi_inqflag; 57539212Sgibbs 57639212Sgibbstypedef enum { 57739212Sgibbs PIT_PROCESSOR = 0x80, /* Target mode processor mode */ 57839212Sgibbs PIT_PHASE = 0x40, /* Target mode phase cog. mode */ 57939212Sgibbs PIT_DISCONNECT = 0x20, /* Disconnects supported in target mode */ 58039212Sgibbs PIT_TERM_IO = 0x10, /* Terminate I/O message supported in TM */ 58139212Sgibbs PIT_GRP_6 = 0x08, /* Group 6 commands supported */ 58253258Sken PIT_GRP_7 = 0x04 /* Group 7 commands supported */ 58339212Sgibbs} pi_tmflag; 58439212Sgibbs 58539212Sgibbstypedef enum { 586255870Sscottl PIM_EXTLUNS = 0x100,/* 64bit extended LUNs supported */ 58739212Sgibbs PIM_SCANHILO = 0x80, /* Bus scans from high ID to low ID */ 58839212Sgibbs PIM_NOREMOVE = 0x40, /* Removeable devices not included in scan */ 58941644Sgibbs PIM_NOINITIATOR = 0x20, /* Initiator role not supported. */ 590118105Snjl PIM_NOBUSRESET = 0x10, /* User has disabled initial BUS RESET */ 591159311Smjacob PIM_NO_6_BYTE = 0x08, /* Do not send 6-byte commands */ 592248519Skib PIM_SEQSCAN = 0x04, /* Do bus scans sequentially, not in parallel */ 593248519Skib PIM_UNMAPPED = 0x02, 594253549Sken PIM_NOSCAN = 0x01 /* SIM does its own scanning */ 59539212Sgibbs} pi_miscflag; 59639212Sgibbs 59739212Sgibbs/* Path Inquiry CCB */ 59874840Skenstruct ccb_pathinq_settings_spi { 59974840Sken u_int8_t ppr_options; 60074840Sken}; 601196008Smjacob 60277708Smjacobstruct ccb_pathinq_settings_fc { 60377708Smjacob u_int64_t wwnn; /* world wide node name */ 60477708Smjacob u_int64_t wwpn; /* world wide port name */ 60577708Smjacob u_int32_t port; /* 24 bit port id, if known */ 60677708Smjacob u_int32_t bitrate; /* Mbps */ 60777708Smjacob}; 608196008Smjacob 609154593Smjacobstruct ccb_pathinq_settings_sas { 610154593Smjacob u_int32_t bitrate; /* Mbps */ 611154593Smjacob}; 61277708Smjacob#define PATHINQ_SETTINGS_SIZE 128 61374840Sken 61439212Sgibbsstruct ccb_pathinq { 61539212Sgibbs struct ccb_hdr ccb_h; 61639212Sgibbs u_int8_t version_num; /* Version number for the SIM/HBA */ 61739212Sgibbs u_int8_t hba_inquiry; /* Mimic of INQ byte 7 for the HBA */ 618255870Sscottl u_int16_t target_sprt; /* Flags for target mode support */ 619255870Sscottl u_int32_t hba_misc; /* Misc HBA features */ 62039212Sgibbs u_int16_t hba_eng_cnt; /* HBA engine count */ 62139212Sgibbs /* Vendor Unique capabilities */ 62239212Sgibbs u_int8_t vuhba_flags[VUHBALEN]; 62339212Sgibbs u_int32_t max_target; /* Maximum supported Target */ 62439212Sgibbs u_int32_t max_lun; /* Maximum supported Lun */ 62539212Sgibbs u_int32_t async_flags; /* Installed Async handlers */ 62639212Sgibbs path_id_t hpath_id; /* Highest Path ID in the subsystem */ 62739212Sgibbs target_id_t initiator_id; /* ID of the HBA on the SCSI bus */ 62839212Sgibbs char sim_vid[SIM_IDLEN]; /* Vendor ID of the SIM */ 62939212Sgibbs char hba_vid[HBA_IDLEN]; /* Vendor ID of the HBA */ 63039212Sgibbs char dev_name[DEV_IDLEN];/* Device name for SIM */ 63139212Sgibbs u_int32_t unit_number; /* Unit number for SIM */ 63239212Sgibbs u_int32_t bus_id; /* Bus ID for SIM */ 63346581Sken u_int32_t base_transfer_speed;/* Base bus speed in KB/sec */ 63474840Sken cam_proto protocol; 63574840Sken u_int protocol_version; 63674840Sken cam_xport transport; 63774840Sken u_int transport_version; 63874840Sken union { 63974840Sken struct ccb_pathinq_settings_spi spi; 64077708Smjacob struct ccb_pathinq_settings_fc fc; 641154593Smjacob struct ccb_pathinq_settings_sas sas; 64277708Smjacob char ccb_pathinq_settings_opaque[PATHINQ_SETTINGS_SIZE]; 64374840Sken } xport_specific; 644195534Sscottl u_int maxio; /* Max supported I/O size, in bytes. */ 645210471Smav u_int16_t hba_vendor; /* HBA vendor ID */ 646210471Smav u_int16_t hba_device; /* HBA device ID */ 647210471Smav u_int16_t hba_subvendor; /* HBA subvendor ID */ 648210471Smav u_int16_t hba_subdevice; /* HBA subdevice ID */ 64939212Sgibbs}; 65039212Sgibbs 65147412Sgibbs/* Path Statistics CCB */ 65247412Sgibbsstruct ccb_pathstats { 65347412Sgibbs struct ccb_hdr ccb_h; 65447412Sgibbs struct timeval last_reset; /* Time of last bus reset/loop init */ 65547412Sgibbs}; 65647412Sgibbs 657216088Skentypedef enum { 658216088Sken SMP_FLAG_NONE = 0x00, 659216088Sken SMP_FLAG_REQ_SG = 0x01, 660216088Sken SMP_FLAG_RSP_SG = 0x02 661216088Sken} ccb_smp_pass_flags; 662216088Sken 663216088Sken/* 664216088Sken * Serial Management Protocol CCB 665216088Sken * XXX Currently the semantics for this CCB are that it is executed either 666216088Sken * by the addressed device, or that device's parent (i.e. an expander for 667216088Sken * any device on an expander) if the addressed device doesn't support SMP. 668216088Sken * Later, once we have the ability to probe SMP-only devices and put them 669216088Sken * in CAM's topology, the CCB will only be executed by the addressed device 670216088Sken * if possible. 671216088Sken */ 672216088Skenstruct ccb_smpio { 673216088Sken struct ccb_hdr ccb_h; 674216088Sken uint8_t *smp_request; 675216088Sken int smp_request_len; 676216088Sken uint16_t smp_request_sglist_cnt; 677216088Sken uint8_t *smp_response; 678216088Sken int smp_response_len; 679216088Sken uint16_t smp_response_sglist_cnt; 680216088Sken ccb_smp_pass_flags flags; 681216088Sken}; 682216088Sken 68339212Sgibbstypedef union { 68439212Sgibbs u_int8_t *sense_ptr; /* 68539212Sgibbs * Pointer to storage 68639212Sgibbs * for sense information 68739212Sgibbs */ 68839212Sgibbs /* Storage Area for sense information */ 68939212Sgibbs struct scsi_sense_data sense_buf; 69039212Sgibbs} sense_t; 69139212Sgibbs 69239212Sgibbstypedef union { 69339212Sgibbs u_int8_t *cdb_ptr; /* Pointer to the CDB bytes to send */ 69439212Sgibbs /* Area for the CDB send */ 69539212Sgibbs u_int8_t cdb_bytes[IOCDBLEN]; 69639212Sgibbs} cdb_t; 69739212Sgibbs 69839212Sgibbs/* 69939212Sgibbs * SCSI I/O Request CCB used for the XPT_SCSI_IO and XPT_CONT_TARGET_IO 70039212Sgibbs * function codes. 70139212Sgibbs */ 70239212Sgibbsstruct ccb_scsiio { 70339212Sgibbs struct ccb_hdr ccb_h; 70439212Sgibbs union ccb *next_ccb; /* Ptr for next CCB for action */ 70539212Sgibbs u_int8_t *req_map; /* Ptr to mapping info */ 70639212Sgibbs u_int8_t *data_ptr; /* Ptr to the data buf/SG list */ 70739212Sgibbs u_int32_t dxfer_len; /* Data transfer length */ 70839212Sgibbs /* Autosense storage */ 70939212Sgibbs struct scsi_sense_data sense_data; 71039212Sgibbs u_int8_t sense_len; /* Number of bytes to autosense */ 71139212Sgibbs u_int8_t cdb_len; /* Number of bytes for the CDB */ 71239212Sgibbs u_int16_t sglist_cnt; /* Number of SG list entries */ 71339212Sgibbs u_int8_t scsi_status; /* Returned SCSI status */ 71439212Sgibbs u_int8_t sense_resid; /* Autosense resid length: 2's comp */ 71539212Sgibbs u_int32_t resid; /* Transfer residual length: 2's comp */ 71639212Sgibbs cdb_t cdb_io; /* Union for CDB bytes/pointer */ 71739212Sgibbs u_int8_t *msg_ptr; /* Pointer to the message buffer */ 71839212Sgibbs u_int16_t msg_len; /* Number of bytes for the Message */ 71939212Sgibbs u_int8_t tag_action; /* What to do for tag queueing */ 72040417Sgibbs /* 72140417Sgibbs * The tag action should be either the define below (to send a 72240417Sgibbs * non-tagged transaction) or one of the defined scsi tag messages 72340417Sgibbs * from scsi_message.h. 72440417Sgibbs */ 72540417Sgibbs#define CAM_TAG_ACTION_NONE 0x00 72649925Sgibbs u_int tag_id; /* tag id from initator (target mode) */ 72749925Sgibbs u_int init_id; /* initiator id of who selected */ 72839212Sgibbs}; 72939212Sgibbs 730312850Smavstatic __inline uint8_t * 731312850Smavscsiio_cdb_ptr(struct ccb_scsiio *ccb) 732312850Smav{ 733312850Smav return ((ccb->ccb_h.flags & CAM_CDB_POINTER) ? 734312850Smav ccb->cdb_io.cdb_ptr : ccb->cdb_io.cdb_bytes); 735312850Smav} 736312850Smav 737195534Sscottl/* 738195534Sscottl * ATA I/O Request CCB used for the XPT_ATA_IO function code. 739195534Sscottl */ 740195534Sscottlstruct ccb_ataio { 741195534Sscottl struct ccb_hdr ccb_h; 742195534Sscottl union ccb *next_ccb; /* Ptr for next CCB for action */ 743195534Sscottl struct ata_cmd cmd; /* ATA command register set */ 744195534Sscottl struct ata_res res; /* ATA result register set */ 745195534Sscottl u_int8_t *data_ptr; /* Ptr to the data buf/SG list */ 746195534Sscottl u_int32_t dxfer_len; /* Data transfer length */ 747195534Sscottl u_int32_t resid; /* Transfer residual length: 2's comp */ 748195534Sscottl u_int8_t tag_action; /* What to do for tag queueing */ 749195534Sscottl /* 750195534Sscottl * The tag action should be either the define below (to send a 751195534Sscottl * non-tagged transaction) or one of the defined scsi tag messages 752195534Sscottl * from scsi_message.h. 753195534Sscottl */ 754195534Sscottl#define CAM_TAG_ACTION_NONE 0x00 755195534Sscottl u_int tag_id; /* tag id from initator (target mode) */ 756195534Sscottl u_int init_id; /* initiator id of who selected */ 757195534Sscottl}; 758195534Sscottl 75939212Sgibbsstruct ccb_accept_tio { 76039212Sgibbs struct ccb_hdr ccb_h; 76139212Sgibbs cdb_t cdb_io; /* Union for CDB bytes/pointer */ 76239212Sgibbs u_int8_t cdb_len; /* Number of bytes for the CDB */ 76339212Sgibbs u_int8_t tag_action; /* What to do for tag queueing */ 76456145Smjacob u_int8_t sense_len; /* Number of bytes of Sense Data */ 76555328Smjacob u_int tag_id; /* tag id from initator (target mode) */ 76655328Smjacob u_int init_id; /* initiator id of who selected */ 76756145Smjacob struct scsi_sense_data sense_data; 76839212Sgibbs}; 76939212Sgibbs 770312845Smavstatic __inline uint8_t * 771312845Smavatio_cdb_ptr(struct ccb_accept_tio *ccb) 772312845Smav{ 773312845Smav return ((ccb->ccb_h.flags & CAM_CDB_POINTER) ? 774312845Smav ccb->cdb_io.cdb_ptr : ccb->cdb_io.cdb_bytes); 775312845Smav} 776312845Smav 77739212Sgibbs/* Release SIM Queue */ 77839212Sgibbsstruct ccb_relsim { 77939212Sgibbs struct ccb_hdr ccb_h; 78039212Sgibbs u_int32_t release_flags; 78139212Sgibbs#define RELSIM_ADJUST_OPENINGS 0x01 78239212Sgibbs#define RELSIM_RELEASE_AFTER_TIMEOUT 0x02 78339212Sgibbs#define RELSIM_RELEASE_AFTER_CMDCMPLT 0x04 78439212Sgibbs#define RELSIM_RELEASE_AFTER_QEMPTY 0x08 78539212Sgibbs u_int32_t openings; 786203108Smav u_int32_t release_timeout; /* Abstract argument. */ 78739212Sgibbs u_int32_t qfrozen_cnt; 78839212Sgibbs}; 78939212Sgibbs 79039212Sgibbs/* 79139212Sgibbs * Definitions for the asynchronous callback CCB fields. 79239212Sgibbs */ 79339212Sgibbstypedef enum { 794238886Smav AC_UNIT_ATTENTION = 0x4000,/* Device reported UNIT ATTENTION */ 795223081Sgibbs AC_ADVINFO_CHANGED = 0x2000,/* Advance info might have changes */ 796196008Smjacob AC_CONTRACT = 0x1000,/* A contractual callback */ 79739212Sgibbs AC_GETDEV_CHANGED = 0x800,/* Getdev info might have changed */ 79839212Sgibbs AC_INQ_CHANGED = 0x400,/* Inquiry info might have changed */ 79939212Sgibbs AC_TRANSFER_NEG = 0x200,/* New transfer settings in effect */ 80039212Sgibbs AC_LOST_DEVICE = 0x100,/* A device went away */ 80139212Sgibbs AC_FOUND_DEVICE = 0x080,/* A new device was found */ 80239212Sgibbs AC_PATH_DEREGISTERED = 0x040,/* A path has de-registered */ 80339212Sgibbs AC_PATH_REGISTERED = 0x020,/* A new path has been registered */ 80439212Sgibbs AC_SENT_BDR = 0x010,/* A BDR message was sent to target */ 80539212Sgibbs AC_SCSI_AEN = 0x008,/* A SCSI AEN has been received */ 80639212Sgibbs AC_UNSOL_RESEL = 0x002,/* Unsolicited reselection occurred */ 80739212Sgibbs AC_BUS_RESET = 0x001 /* A SCSI bus reset occurred */ 80839212Sgibbs} ac_code; 80939212Sgibbs 81039212Sgibbstypedef void ac_callback_t (void *softc, u_int32_t code, 81139212Sgibbs struct cam_path *path, void *args); 81239212Sgibbs 813196008Smjacob/* 814196008Smjacob * Generic Asynchronous callbacks. 815196008Smjacob * 816196008Smjacob * Generic arguments passed bac which are then interpreted between a per-system 817196008Smjacob * contract number. 818196008Smjacob */ 819196008Smjacob#define AC_CONTRACT_DATA_MAX (128 - sizeof (u_int64_t)) 820196008Smjacobstruct ac_contract { 821196008Smjacob u_int64_t contract_number; 822196008Smjacob u_int8_t contract_data[AC_CONTRACT_DATA_MAX]; 823196008Smjacob}; 824196008Smjacob 825196008Smjacob#define AC_CONTRACT_DEV_CHG 1 826196008Smjacobstruct ac_device_changed { 827196008Smjacob u_int64_t wwpn; 828196008Smjacob u_int32_t port; 829196008Smjacob target_id_t target; 830196008Smjacob u_int8_t arrived; 831196008Smjacob}; 832196008Smjacob 83339212Sgibbs/* Set Asynchronous Callback CCB */ 83439212Sgibbsstruct ccb_setasync { 83539212Sgibbs struct ccb_hdr ccb_h; 83639212Sgibbs u_int32_t event_enable; /* Async Event enables */ 83739212Sgibbs ac_callback_t *callback; 83839212Sgibbs void *callback_arg; 83939212Sgibbs}; 84039212Sgibbs 84139212Sgibbs/* Set Device Type CCB */ 84239212Sgibbsstruct ccb_setdev { 84339212Sgibbs struct ccb_hdr ccb_h; 84439212Sgibbs u_int8_t dev_type; /* Value for dev type field in EDT */ 84539212Sgibbs}; 84639212Sgibbs 84739212Sgibbs/* SCSI Control Functions */ 84839212Sgibbs 84939212Sgibbs/* Abort XPT request CCB */ 85039212Sgibbsstruct ccb_abort { 85139212Sgibbs struct ccb_hdr ccb_h; 85239212Sgibbs union ccb *abort_ccb; /* Pointer to CCB to abort */ 85339212Sgibbs}; 85439212Sgibbs 85539212Sgibbs/* Reset SCSI Bus CCB */ 85639212Sgibbsstruct ccb_resetbus { 85739212Sgibbs struct ccb_hdr ccb_h; 85839212Sgibbs}; 85939212Sgibbs 86039212Sgibbs/* Reset SCSI Device CCB */ 86139212Sgibbsstruct ccb_resetdev { 86239212Sgibbs struct ccb_hdr ccb_h; 86339212Sgibbs}; 86439212Sgibbs 86539212Sgibbs/* Terminate I/O Process Request CCB */ 86639212Sgibbsstruct ccb_termio { 86739212Sgibbs struct ccb_hdr ccb_h; 86839212Sgibbs union ccb *termio_ccb; /* Pointer to CCB to terminate */ 86939212Sgibbs}; 87039212Sgibbs 87174840Skentypedef enum { 87274840Sken CTS_TYPE_CURRENT_SETTINGS, 87374840Sken CTS_TYPE_USER_SETTINGS 87474840Sken} cts_type; 87574840Sken 87674840Skenstruct ccb_trans_settings_scsi 87774840Sken{ 87839212Sgibbs u_int valid; /* Which fields to honor */ 87974840Sken#define CTS_SCSI_VALID_TQ 0x01 88039212Sgibbs u_int flags; 88174840Sken#define CTS_SCSI_FLAGS_TAG_ENB 0x01 88274840Sken}; 88374840Sken 884236437Smavstruct ccb_trans_settings_ata 885236437Smav{ 886236437Smav u_int valid; /* Which fields to honor */ 887236437Smav#define CTS_ATA_VALID_TQ 0x01 888236437Smav u_int flags; 889236437Smav#define CTS_ATA_FLAGS_TAG_ENB 0x01 890236437Smav}; 891236437Smav 89274840Skenstruct ccb_trans_settings_spi 89374840Sken{ 89474840Sken u_int valid; /* Which fields to honor */ 89574840Sken#define CTS_SPI_VALID_SYNC_RATE 0x01 89674840Sken#define CTS_SPI_VALID_SYNC_OFFSET 0x02 89774840Sken#define CTS_SPI_VALID_BUS_WIDTH 0x04 89874840Sken#define CTS_SPI_VALID_DISC 0x08 89974840Sken#define CTS_SPI_VALID_PPR_OPTIONS 0x10 90074840Sken u_int flags; 90174840Sken#define CTS_SPI_FLAGS_DISC_ENB 0x01 90239212Sgibbs u_int sync_period; 90339212Sgibbs u_int sync_offset; 90439212Sgibbs u_int bus_width; 90574840Sken u_int ppr_options; 90639212Sgibbs}; 90739212Sgibbs 90878709Smjacobstruct ccb_trans_settings_fc { 90978709Smjacob u_int valid; /* Which fields to honor */ 91078709Smjacob#define CTS_FC_VALID_WWNN 0x8000 91178709Smjacob#define CTS_FC_VALID_WWPN 0x4000 91278709Smjacob#define CTS_FC_VALID_PORT 0x2000 91378709Smjacob#define CTS_FC_VALID_SPEED 0x1000 91478709Smjacob u_int64_t wwnn; /* world wide node name */ 91578709Smjacob u_int64_t wwpn; /* world wide port name */ 91678709Smjacob u_int32_t port; /* 24 bit port id, if known */ 91778709Smjacob u_int32_t bitrate; /* Mbps */ 91878709Smjacob}; 91978709Smjacob 920154593Smjacobstruct ccb_trans_settings_sas { 921154593Smjacob u_int valid; /* Which fields to honor */ 922154593Smjacob#define CTS_SAS_VALID_SPEED 0x1000 923154593Smjacob u_int32_t bitrate; /* Mbps */ 924154593Smjacob}; 925154593Smjacob 926236437Smavstruct ccb_trans_settings_pata { 927198708Smav u_int valid; /* Which fields to honor */ 928198708Smav#define CTS_ATA_VALID_MODE 0x01 929199747Smav#define CTS_ATA_VALID_BYTECOUNT 0x02 930203376Smav#define CTS_ATA_VALID_ATAPI 0x20 931249199Smarius#define CTS_ATA_VALID_CAPS 0x40 932199821Smav int mode; /* Mode */ 933198708Smav u_int bytecount; /* Length of PIO transaction */ 934203376Smav u_int atapi; /* Length of ATAPI CDB */ 935249199Smarius u_int caps; /* Device and host SATA caps. */ 936249199Smarius#define CTS_ATA_CAPS_H 0x0000ffff 937249199Smarius#define CTS_ATA_CAPS_H_DMA48 0x00000001 /* 48-bit DMA */ 938249199Smarius#define CTS_ATA_CAPS_D 0xffff0000 939198708Smav}; 940198708Smav 941195534Sscottlstruct ccb_trans_settings_sata { 942195534Sscottl u_int valid; /* Which fields to honor */ 943199747Smav#define CTS_SATA_VALID_MODE 0x01 944199747Smav#define CTS_SATA_VALID_BYTECOUNT 0x02 945199747Smav#define CTS_SATA_VALID_REVISION 0x04 946199747Smav#define CTS_SATA_VALID_PM 0x08 947199747Smav#define CTS_SATA_VALID_TAGS 0x10 948203376Smav#define CTS_SATA_VALID_ATAPI 0x20 949207499Smav#define CTS_SATA_VALID_CAPS 0x40 950199821Smav int mode; /* Legacy PATA mode */ 951199747Smav u_int bytecount; /* Length of PIO transaction */ 952199821Smav int revision; /* SATA revision */ 953195534Sscottl u_int pm_present; /* PM is present (XPT->SIM) */ 954199747Smav u_int tags; /* Number of allowed tags */ 955203376Smav u_int atapi; /* Length of ATAPI CDB */ 956207499Smav u_int caps; /* Device and host SATA caps. */ 957207499Smav#define CTS_SATA_CAPS_H 0x0000ffff 958207499Smav#define CTS_SATA_CAPS_H_PMREQ 0x00000001 959207499Smav#define CTS_SATA_CAPS_H_APST 0x00000002 960207499Smav#define CTS_SATA_CAPS_H_DMAAA 0x00000010 /* Auto-activation */ 961220602Smav#define CTS_SATA_CAPS_H_AN 0x00000020 /* Async. notification */ 962207499Smav#define CTS_SATA_CAPS_D 0xffff0000 963207499Smav#define CTS_SATA_CAPS_D_PMREQ 0x00010000 964207499Smav#define CTS_SATA_CAPS_D_APST 0x00020000 965195534Sscottl}; 966154593Smjacob 96774840Sken/* Get/Set transfer rate/width/disconnection/tag queueing settings */ 96874840Skenstruct ccb_trans_settings { 96974840Sken struct ccb_hdr ccb_h; 97074840Sken cts_type type; /* Current or User settings */ 97174840Sken cam_proto protocol; 97274840Sken u_int protocol_version; 97374840Sken cam_xport transport; 97474840Sken u_int transport_version; 97574840Sken union { 97674840Sken u_int valid; /* Which fields to honor */ 977236437Smav struct ccb_trans_settings_ata ata; 97874840Sken struct ccb_trans_settings_scsi scsi; 97974840Sken } proto_specific; 98074840Sken union { 98174840Sken u_int valid; /* Which fields to honor */ 98274840Sken struct ccb_trans_settings_spi spi; 98378709Smjacob struct ccb_trans_settings_fc fc; 984154593Smjacob struct ccb_trans_settings_sas sas; 985236437Smav struct ccb_trans_settings_pata ata; 986195534Sscottl struct ccb_trans_settings_sata sata; 98774840Sken } xport_specific; 98874840Sken}; 98974840Sken 99074840Sken 99139212Sgibbs/* 99239212Sgibbs * Calculate the geometry parameters for a device 99339212Sgibbs * give the block size and volume size in blocks. 99439212Sgibbs */ 99539212Sgibbsstruct ccb_calc_geometry { 99639212Sgibbs struct ccb_hdr ccb_h; 99739212Sgibbs u_int32_t block_size; 998114261Sken u_int64_t volume_size; 999114261Sken u_int32_t cylinders; 100039212Sgibbs u_int8_t heads; 100139212Sgibbs u_int8_t secs_per_track; 100239212Sgibbs}; 100339212Sgibbs 100439212Sgibbs/* 1005196008Smjacob * Set or get SIM (and transport) specific knobs 1006196008Smjacob */ 1007196008Smjacob 1008196008Smjacob#define KNOB_VALID_ADDRESS 0x1 1009196008Smjacob#define KNOB_VALID_ROLE 0x2 1010196008Smjacob 1011196008Smjacob 1012196008Smjacob#define KNOB_ROLE_NONE 0x0 1013196008Smjacob#define KNOB_ROLE_INITIATOR 0x1 1014196008Smjacob#define KNOB_ROLE_TARGET 0x2 1015196008Smjacob#define KNOB_ROLE_BOTH 0x3 1016196008Smjacob 1017196008Smjacobstruct ccb_sim_knob_settings_spi { 1018196008Smjacob u_int valid; 1019196008Smjacob u_int initiator_id; 1020196008Smjacob u_int role; 1021196008Smjacob}; 1022196008Smjacob 1023196008Smjacobstruct ccb_sim_knob_settings_fc { 1024196008Smjacob u_int valid; 1025196008Smjacob u_int64_t wwnn; /* world wide node name */ 1026196008Smjacob u_int64_t wwpn; /* world wide port name */ 1027196008Smjacob u_int role; 1028196008Smjacob}; 1029196008Smjacob 1030196008Smjacobstruct ccb_sim_knob_settings_sas { 1031196008Smjacob u_int valid; 1032196008Smjacob u_int64_t wwnn; /* world wide node name */ 1033196008Smjacob u_int role; 1034196008Smjacob}; 1035196008Smjacob#define KNOB_SETTINGS_SIZE 128 1036196008Smjacob 1037196008Smjacobstruct ccb_sim_knob { 1038196008Smjacob struct ccb_hdr ccb_h; 1039196008Smjacob union { 1040196008Smjacob u_int valid; /* Which fields to honor */ 1041196008Smjacob struct ccb_sim_knob_settings_spi spi; 1042196008Smjacob struct ccb_sim_knob_settings_fc fc; 1043196008Smjacob struct ccb_sim_knob_settings_sas sas; 1044196008Smjacob char pad[KNOB_SETTINGS_SIZE]; 1045196008Smjacob } xport_specific; 1046196008Smjacob}; 1047196008Smjacob 1048196008Smjacob/* 104939212Sgibbs * Rescan the given bus, or bus/target/lun 105039212Sgibbs */ 105139212Sgibbsstruct ccb_rescan { 105239212Sgibbs struct ccb_hdr ccb_h; 105339212Sgibbs cam_flags flags; 105439212Sgibbs}; 105539212Sgibbs 105639212Sgibbs/* 105739212Sgibbs * Turn on debugging for the given bus, bus/target, or bus/target/lun. 105839212Sgibbs */ 105939212Sgibbsstruct ccb_debug { 106039212Sgibbs struct ccb_hdr ccb_h; 106139212Sgibbs cam_debug_flags flags; 106239212Sgibbs}; 106339212Sgibbs 106439212Sgibbs/* Target mode structures. */ 106539212Sgibbs 106639212Sgibbsstruct ccb_en_lun { 106739212Sgibbs struct ccb_hdr ccb_h; 106839212Sgibbs u_int16_t grp6_len; /* Group 6 VU CDB length */ 106939212Sgibbs u_int16_t grp7_len; /* Group 7 VU CDB length */ 107039212Sgibbs u_int8_t enable; 107139212Sgibbs}; 107239212Sgibbs 1073196008Smjacob/* old, barely used immediate notify, binary compatibility */ 107439212Sgibbsstruct ccb_immed_notify { 107539212Sgibbs struct ccb_hdr ccb_h; 107639212Sgibbs struct scsi_sense_data sense_data; 107756145Smjacob u_int8_t sense_len; /* Number of bytes in sense buffer */ 107839212Sgibbs u_int8_t initiator_id; /* Id of initiator that selected */ 107939212Sgibbs u_int8_t message_args[7]; /* Message Arguments */ 108039212Sgibbs}; 108139212Sgibbs 108239212Sgibbsstruct ccb_notify_ack { 108339212Sgibbs struct ccb_hdr ccb_h; 108439212Sgibbs u_int16_t seq_id; /* Sequence identifier */ 108539212Sgibbs u_int8_t event; /* Event flags */ 108639212Sgibbs}; 108739212Sgibbs 1088196008Smjacobstruct ccb_immediate_notify { 1089196008Smjacob struct ccb_hdr ccb_h; 1090196008Smjacob u_int tag_id; /* Tag for immediate notify */ 1091196008Smjacob u_int seq_id; /* Tag for target of notify */ 1092196008Smjacob u_int initiator_id; /* Initiator Identifier */ 1093196008Smjacob u_int arg; /* Function specific */ 1094196008Smjacob}; 1095196008Smjacob 1096196008Smjacobstruct ccb_notify_acknowledge { 1097196008Smjacob struct ccb_hdr ccb_h; 1098196008Smjacob u_int tag_id; /* Tag for immediate notify */ 1099196008Smjacob u_int seq_id; /* Tar for target of notify */ 1100196008Smjacob u_int initiator_id; /* Initiator Identifier */ 1101304417Smav u_int arg; /* Response information */ 1102304417Smav /* 1103304417Smav * Lower byte of arg is one of RESPONSE CODE values defined below 1104304417Smav * (subset of response codes from SPL-4 and FCP-4 specifications), 1105304417Smav * upper 3 bytes is code-specific ADDITIONAL RESPONSE INFORMATION. 1106304417Smav */ 1107304417Smav#define CAM_RSP_TMF_COMPLETE 0x00 1108304417Smav#define CAM_RSP_TMF_REJECTED 0x04 1109304417Smav#define CAM_RSP_TMF_FAILED 0x05 1110304417Smav#define CAM_RSP_TMF_SUCCEEDED 0x08 1111304417Smav#define CAM_RSP_TMF_INCORRECT_LUN 0x09 1112196008Smjacob}; 1113196008Smjacob 111439212Sgibbs/* HBA engine structures. */ 111539212Sgibbs 111639212Sgibbstypedef enum { 111739212Sgibbs EIT_BUFFER, /* Engine type: buffer memory */ 111839212Sgibbs EIT_LOSSLESS, /* Engine type: lossless compression */ 111939212Sgibbs EIT_LOSSY, /* Engine type: lossy compression */ 112039212Sgibbs EIT_ENCRYPT /* Engine type: encryption */ 112139212Sgibbs} ei_type; 112239212Sgibbs 112339212Sgibbstypedef enum { 112439212Sgibbs EAD_VUNIQUE, /* Engine algorithm ID: vendor unique */ 112539212Sgibbs EAD_LZ1V1, /* Engine algorithm ID: LZ1 var.1 */ 112639212Sgibbs EAD_LZ2V1, /* Engine algorithm ID: LZ2 var.1 */ 112753258Sken EAD_LZ2V2 /* Engine algorithm ID: LZ2 var.2 */ 112839212Sgibbs} ei_algo; 112939212Sgibbs 113039212Sgibbsstruct ccb_eng_inq { 113139212Sgibbs struct ccb_hdr ccb_h; 113239212Sgibbs u_int16_t eng_num; /* The engine number for this inquiry */ 113339212Sgibbs ei_type eng_type; /* Returned engine type */ 113439212Sgibbs ei_algo eng_algo; /* Returned engine algorithm type */ 113539212Sgibbs u_int32_t eng_memeory; /* Returned engine memory size */ 113639212Sgibbs}; 113739212Sgibbs 113839212Sgibbsstruct ccb_eng_exec { /* This structure must match SCSIIO size */ 113939212Sgibbs struct ccb_hdr ccb_h; 114039212Sgibbs u_int8_t *pdrv_ptr; /* Ptr used by the peripheral driver */ 114139212Sgibbs u_int8_t *req_map; /* Ptr for mapping info on the req. */ 114239212Sgibbs u_int8_t *data_ptr; /* Pointer to the data buf/SG list */ 114339212Sgibbs u_int32_t dxfer_len; /* Data transfer length */ 114439212Sgibbs u_int8_t *engdata_ptr; /* Pointer to the engine buffer data */ 114539212Sgibbs u_int16_t sglist_cnt; /* Num of scatter gather list entries */ 114639212Sgibbs u_int32_t dmax_len; /* Destination data maximum length */ 114739212Sgibbs u_int32_t dest_len; /* Destination data length */ 114839212Sgibbs int32_t src_resid; /* Source residual length: 2's comp */ 114939212Sgibbs u_int32_t timeout; /* Timeout value */ 115039212Sgibbs u_int16_t eng_num; /* Engine number for this request */ 115139212Sgibbs u_int16_t vu_flags; /* Vendor Unique flags */ 115239212Sgibbs}; 115339212Sgibbs 115439212Sgibbs/* 115539212Sgibbs * Definitions for the timeout field in the SCSI I/O CCB. 115639212Sgibbs */ 115739212Sgibbs#define CAM_TIME_DEFAULT 0x00000000 /* Use SIM default value */ 115839212Sgibbs#define CAM_TIME_INFINITY 0xFFFFFFFF /* Infinite timeout */ 115939212Sgibbs 116039212Sgibbs#define CAM_SUCCESS 0 /* For signaling general success */ 116139212Sgibbs#define CAM_FAILURE 1 /* For signaling general failure */ 116239212Sgibbs 116339212Sgibbs#define CAM_FALSE 0 116439212Sgibbs#define CAM_TRUE 1 116539212Sgibbs 116639212Sgibbs#define XPT_CCB_INVALID -1 /* for signaling a bad CCB to free */ 116739212Sgibbs 116839212Sgibbs/* 1169223081Sgibbs * CCB for working with advanced device information. This operates in a fashion 1170216088Sken * similar to XPT_GDEV_TYPE. Specify the target in ccb_h, the buffer 1171216088Sken * type requested, and provide a buffer size/buffer to write to. If the 1172223081Sgibbs * buffer is too small, provsiz will be larger than bufsiz. 1173216088Sken */ 1174223081Sgibbsstruct ccb_dev_advinfo { 1175216088Sken struct ccb_hdr ccb_h; 1176216088Sken uint32_t flags; 1177279329Sken#define CDAI_FLAG_NONE 0x0 /* No flags set */ 1178223081Sgibbs#define CDAI_FLAG_STORE 0x1 /* If set, action becomes store */ 1179216088Sken uint32_t buftype; /* IN: Type of data being requested */ 1180216088Sken /* NB: buftype is interpreted on a per-transport basis */ 1181223081Sgibbs#define CDAI_TYPE_SCSI_DEVID 1 1182223081Sgibbs#define CDAI_TYPE_SERIAL_NUM 2 1183223081Sgibbs#define CDAI_TYPE_PHYS_PATH 3 1184230590Sken#define CDAI_TYPE_RCAPLONG 4 1185278974Sken#define CDAI_TYPE_EXT_INQ 5 1186216088Sken off_t bufsiz; /* IN: Size of external buffer */ 1187216088Sken#define CAM_SCSI_DEVID_MAXLEN 65536 /* length in buffer is an uint16_t */ 1188216088Sken off_t provsiz; /* OUT: Size required/used */ 1189216088Sken uint8_t *buf; /* IN/OUT: Buffer for requested data */ 1190216088Sken}; 1191216088Sken 1192216088Sken/* 1193260387Sscottl * CCB for sending async events 1194260387Sscottl */ 1195260387Sscottlstruct ccb_async { 1196260387Sscottl struct ccb_hdr ccb_h; 1197260387Sscottl uint32_t async_code; 1198260387Sscottl off_t async_arg_size; 1199260387Sscottl void *async_arg_ptr; 1200260387Sscottl}; 1201260387Sscottl 1202260387Sscottl/* 120339212Sgibbs * Union of all CCB types for kernel space allocation. This union should 120439212Sgibbs * never be used for manipulating CCBs - its only use is for the allocation 120539212Sgibbs * and deallocation of raw CCB space and is the return type of xpt_ccb_alloc 120639212Sgibbs * and the argument to xpt_ccb_free. 120739212Sgibbs */ 120839212Sgibbsunion ccb { 120939212Sgibbs struct ccb_hdr ccb_h; /* For convenience */ 121039212Sgibbs struct ccb_scsiio csio; 121139212Sgibbs struct ccb_getdev cgd; 121239212Sgibbs struct ccb_getdevlist cgdl; 121339212Sgibbs struct ccb_pathinq cpi; 121439212Sgibbs struct ccb_relsim crs; 121539212Sgibbs struct ccb_setasync csa; 121639212Sgibbs struct ccb_setdev csd; 121747412Sgibbs struct ccb_pathstats cpis; 121847412Sgibbs struct ccb_getdevstats cgds; 121939212Sgibbs struct ccb_dev_match cdm; 122039212Sgibbs struct ccb_trans_settings cts; 122139212Sgibbs struct ccb_calc_geometry ccg; 1222196008Smjacob struct ccb_sim_knob knob; 122339212Sgibbs struct ccb_abort cab; 122439212Sgibbs struct ccb_resetbus crb; 122539212Sgibbs struct ccb_resetdev crd; 122639212Sgibbs struct ccb_termio tio; 122739212Sgibbs struct ccb_accept_tio atio; 122839212Sgibbs struct ccb_scsiio ctio; 122939212Sgibbs struct ccb_en_lun cel; 123039212Sgibbs struct ccb_immed_notify cin; 123139212Sgibbs struct ccb_notify_ack cna; 1232196008Smjacob struct ccb_immediate_notify cin1; 1233196008Smjacob struct ccb_notify_acknowledge cna2; 123439212Sgibbs struct ccb_eng_inq cei; 123539212Sgibbs struct ccb_eng_exec cee; 1236216088Sken struct ccb_smpio smpio; 123739212Sgibbs struct ccb_rescan crcn; 123839212Sgibbs struct ccb_debug cdbg; 1239195534Sscottl struct ccb_ataio ataio; 1240223081Sgibbs struct ccb_dev_advinfo cdai; 1241260387Sscottl struct ccb_async casync; 124239212Sgibbs}; 124339212Sgibbs 1244302377Struckman#define CCB_CLEAR_ALL_EXCEPT_HDR(ccbp) \ 1245302377Struckman bzero((char *)(ccbp) + sizeof((ccbp)->ccb_h), \ 1246302377Struckman sizeof(*(ccbp)) - sizeof((ccbp)->ccb_h)) 1247302377Struckman 124839212Sgibbs__BEGIN_DECLS 124939212Sgibbsstatic __inline void 125039212Sgibbscam_fill_csio(struct ccb_scsiio *csio, u_int32_t retries, 125139212Sgibbs void (*cbfcnp)(struct cam_periph *, union ccb *), 125239212Sgibbs u_int32_t flags, u_int8_t tag_action, 125339212Sgibbs u_int8_t *data_ptr, u_int32_t dxfer_len, 125439212Sgibbs u_int8_t sense_len, u_int8_t cdb_len, 125539212Sgibbs u_int32_t timeout); 125639212Sgibbs 125739212Sgibbsstatic __inline void 125839212Sgibbscam_fill_ctio(struct ccb_scsiio *csio, u_int32_t retries, 125939212Sgibbs void (*cbfcnp)(struct cam_periph *, union ccb *), 126039212Sgibbs u_int32_t flags, u_int tag_action, u_int tag_id, 126139212Sgibbs u_int init_id, u_int scsi_status, u_int8_t *data_ptr, 126239212Sgibbs u_int32_t dxfer_len, u_int32_t timeout); 1263195534Sscottl 126439212Sgibbsstatic __inline void 1265195534Sscottlcam_fill_ataio(struct ccb_ataio *ataio, u_int32_t retries, 1266195534Sscottl void (*cbfcnp)(struct cam_periph *, union ccb *), 1267195534Sscottl u_int32_t flags, u_int tag_action, 1268195534Sscottl u_int8_t *data_ptr, u_int32_t dxfer_len, 1269195534Sscottl u_int32_t timeout); 1270195534Sscottl 1271195534Sscottlstatic __inline void 1272216088Skencam_fill_smpio(struct ccb_smpio *smpio, uint32_t retries, 1273216088Sken void (*cbfcnp)(struct cam_periph *, union ccb *), uint32_t flags, 1274216088Sken uint8_t *smp_request, int smp_request_len, 1275216088Sken uint8_t *smp_response, int smp_response_len, 1276216088Sken uint32_t timeout); 1277216088Sken 1278216088Skenstatic __inline void 127939212Sgibbscam_fill_csio(struct ccb_scsiio *csio, u_int32_t retries, 128039212Sgibbs void (*cbfcnp)(struct cam_periph *, union ccb *), 128139212Sgibbs u_int32_t flags, u_int8_t tag_action, 128239212Sgibbs u_int8_t *data_ptr, u_int32_t dxfer_len, 128339212Sgibbs u_int8_t sense_len, u_int8_t cdb_len, 128439212Sgibbs u_int32_t timeout) 128539212Sgibbs{ 128639212Sgibbs csio->ccb_h.func_code = XPT_SCSI_IO; 128739212Sgibbs csio->ccb_h.flags = flags; 1288255915Snwhitehorn csio->ccb_h.xflags = 0; 128939212Sgibbs csio->ccb_h.retry_count = retries; 129039212Sgibbs csio->ccb_h.cbfcnp = cbfcnp; 129139212Sgibbs csio->ccb_h.timeout = timeout; 129239212Sgibbs csio->data_ptr = data_ptr; 129339212Sgibbs csio->dxfer_len = dxfer_len; 129439212Sgibbs csio->sense_len = sense_len; 129539212Sgibbs csio->cdb_len = cdb_len; 129639212Sgibbs csio->tag_action = tag_action; 129739212Sgibbs} 129839212Sgibbs 129939212Sgibbsstatic __inline void 130039212Sgibbscam_fill_ctio(struct ccb_scsiio *csio, u_int32_t retries, 130139212Sgibbs void (*cbfcnp)(struct cam_periph *, union ccb *), 130239212Sgibbs u_int32_t flags, u_int tag_action, u_int tag_id, 130339212Sgibbs u_int init_id, u_int scsi_status, u_int8_t *data_ptr, 130439212Sgibbs u_int32_t dxfer_len, u_int32_t timeout) 130539212Sgibbs{ 130639212Sgibbs csio->ccb_h.func_code = XPT_CONT_TARGET_IO; 130739212Sgibbs csio->ccb_h.flags = flags; 1308255915Snwhitehorn csio->ccb_h.xflags = 0; 130939212Sgibbs csio->ccb_h.retry_count = retries; 131039212Sgibbs csio->ccb_h.cbfcnp = cbfcnp; 131139212Sgibbs csio->ccb_h.timeout = timeout; 131239212Sgibbs csio->data_ptr = data_ptr; 131339212Sgibbs csio->dxfer_len = dxfer_len; 131439212Sgibbs csio->scsi_status = scsi_status; 131539212Sgibbs csio->tag_action = tag_action; 131639212Sgibbs csio->tag_id = tag_id; 131739212Sgibbs csio->init_id = init_id; 131839212Sgibbs} 131939212Sgibbs 1320195534Sscottlstatic __inline void 1321195534Sscottlcam_fill_ataio(struct ccb_ataio *ataio, u_int32_t retries, 1322195534Sscottl void (*cbfcnp)(struct cam_periph *, union ccb *), 1323195534Sscottl u_int32_t flags, u_int tag_action, 1324195534Sscottl u_int8_t *data_ptr, u_int32_t dxfer_len, 1325195534Sscottl u_int32_t timeout) 1326195534Sscottl{ 1327195534Sscottl ataio->ccb_h.func_code = XPT_ATA_IO; 1328195534Sscottl ataio->ccb_h.flags = flags; 1329195534Sscottl ataio->ccb_h.retry_count = retries; 1330195534Sscottl ataio->ccb_h.cbfcnp = cbfcnp; 1331195534Sscottl ataio->ccb_h.timeout = timeout; 1332195534Sscottl ataio->data_ptr = data_ptr; 1333195534Sscottl ataio->dxfer_len = dxfer_len; 1334195534Sscottl ataio->tag_action = tag_action; 1335195534Sscottl} 1336195534Sscottl 1337216088Skenstatic __inline void 1338216088Skencam_fill_smpio(struct ccb_smpio *smpio, uint32_t retries, 1339216088Sken void (*cbfcnp)(struct cam_periph *, union ccb *), uint32_t flags, 1340216088Sken uint8_t *smp_request, int smp_request_len, 1341216088Sken uint8_t *smp_response, int smp_response_len, 1342216088Sken uint32_t timeout) 1343216088Sken{ 1344216088Sken#ifdef _KERNEL 1345216088Sken KASSERT((flags & CAM_DIR_MASK) == CAM_DIR_BOTH, 1346216088Sken ("direction != CAM_DIR_BOTH")); 1347216088Sken KASSERT((smp_request != NULL) && (smp_response != NULL), 1348216088Sken ("need valid request and response buffers")); 1349216088Sken KASSERT((smp_request_len != 0) && (smp_response_len != 0), 1350216088Sken ("need non-zero request and response lengths")); 1351216088Sken#endif /*_KERNEL*/ 1352216088Sken smpio->ccb_h.func_code = XPT_SMP_IO; 1353216088Sken smpio->ccb_h.flags = flags; 1354216088Sken smpio->ccb_h.retry_count = retries; 1355216088Sken smpio->ccb_h.cbfcnp = cbfcnp; 1356216088Sken smpio->ccb_h.timeout = timeout; 1357216088Sken smpio->smp_request = smp_request; 1358216088Sken smpio->smp_request_len = smp_request_len; 1359216088Sken smpio->smp_response = smp_response; 1360216088Sken smpio->smp_response_len = smp_response_len; 1361216088Sken} 1362216088Sken 1363252382Sscottlstatic __inline void 1364252382Sscottlcam_set_ccbstatus(union ccb *ccb, cam_status status) 1365252382Sscottl{ 1366252382Sscottl ccb->ccb_h.status &= ~CAM_STATUS_MASK; 1367252382Sscottl ccb->ccb_h.status |= status; 1368252382Sscottl} 1369252382Sscottl 1370252382Sscottlstatic __inline cam_status 1371252382Sscottlcam_ccb_status(union ccb *ccb) 1372252382Sscottl{ 1373252684Sjkim return ((cam_status)(ccb->ccb_h.status & CAM_STATUS_MASK)); 1374252382Sscottl} 1375252382Sscottl 1376116350Snjlvoid cam_calc_geometry(struct ccb_calc_geometry *ccg, int extended); 1377116350Snjl 137839212Sgibbs__END_DECLS 137939212Sgibbs 138039212Sgibbs#endif /* _CAM_CAM_CCB_H */ 1381