ctl_io.h revision 269298
1139825Simp/*- 21541Srgrimes * Copyright (c) 2003 Silicon Graphics International Corp. 3174167Srwatson * All rights reserved. 4174167Srwatson * 5174167Srwatson * Redistribution and use in source and binary forms, with or without 61541Srgrimes * modification, are permitted provided that the following conditions 71541Srgrimes * are met: 81541Srgrimes * 1. Redistributions of source code must retain the above copyright 91541Srgrimes * notice, this list of conditions, and the following disclaimer, 101541Srgrimes * without modification. 111541Srgrimes * 2. Redistributions in binary form must reproduce at minimum a disclaimer 121541Srgrimes * substantially similar to the "NO WARRANTY" disclaimer below 131541Srgrimes * ("Disclaimer") and any redistribution must be conditioned upon 141541Srgrimes * including a substantially similar Disclaimer requirement for further 151541Srgrimes * binary redistribution. 161541Srgrimes * 171541Srgrimes * NO WARRANTY 181541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 191541Srgrimes * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 201541Srgrimes * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 211541Srgrimes * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 221541Srgrimes * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 231541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 241541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 251541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 261541Srgrimes * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 271541Srgrimes * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 281541Srgrimes * POSSIBILITY OF SUCH DAMAGES. 291541Srgrimes * 301541Srgrimes * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl_io.h#5 $ 311541Srgrimes * $FreeBSD: stable/10/sys/cam/ctl/ctl_io.h 269298 2014-07-30 07:21:30Z mav $ 3250477Speter */ 331541Srgrimes/* 341541Srgrimes * CAM Target Layer data movement structures/interface. 352165Spaul * 362165Spaul * Author: Ken Merry <ken@FreeBSD.org> 372165Spaul */ 381541Srgrimes 3955205Speter#ifndef _CTL_IO_H_ 401541Srgrimes#define _CTL_IO_H_ 4118207Sbde 421541Srgrimes#ifdef _CTL_C 431541Srgrimes#define EXTERN(__var,__val) __var = __val 441541Srgrimes#else 451541Srgrimes#define EXTERN(__var,__val) extern __var 4692047Sdd#endif 4781202Sjhb 4876166Smarkm#define CTL_MAX_CDBLEN 32 4911913Sphk/* 5012685Speter * Uncomment this next line to enable printing out times for I/Os 5112685Speter * that take longer than CTL_TIME_IO_SECS seconds to get to the datamove 5212685Speter * and/or done stage. 5312685Speter */ 5455205Speter#define CTL_TIME_IO 5534924Sbde#ifdef CTL_TIME_IO 561541Srgrimes#define CTL_TIME_IO_DEFAULT_SECS 90 5734924SbdeEXTERN(int ctl_time_io_secs, CTL_TIME_IO_DEFAULT_SECS); 5834924Sbde#endif 591541Srgrimes 6034924Sbde/* 61174167Srwatson * Uncomment these next two lines to enable the CTL I/O delay feature. You 62174167Srwatson * can delay I/O at two different points -- datamove and done. This is 63174167Srwatson * useful for diagnosing abort conditions (for hosts that send an abort on a 641541Srgrimes * timeout), and for determining how long a host's timeout is. 651541Srgrimes */ 6669896Smckusick#define CTL_IO_DELAY 6769896Smckusick#define CTL_TIMER_BYTES sizeof(struct callout) 68147188Sgad 69147188Sgadtypedef enum { 70147188Sgad CTL_STATUS_NONE, /* No status */ 71147188Sgad CTL_SUCCESS, /* Transaction completed successfully */ 72147188Sgad CTL_CMD_TIMEOUT, /* Command timed out, shouldn't happen here */ 73147188Sgad CTL_SEL_TIMEOUT, /* Selection timeout, shouldn't happen here */ 74147188Sgad CTL_ERROR, /* General CTL error XXX expand on this? */ 75147188Sgad CTL_SCSI_ERROR, /* SCSI error, look at status byte/sense data */ 76130825Sgad CTL_CMD_ABORTED, /* Command aborted, don't return status */ 77147188Sgad CTL_STATUS_MASK = 0xfff,/* Mask off any status flags */ 78147188Sgad CTL_AUTOSENSE = 0x1000 /* Autosense performed */ 79147188Sgad} ctl_io_status; 80147188Sgad 81147188Sgad/* 82147188Sgad * WARNING: Keep the data in/out/none flags where they are. They're used 83147188Sgad * in conjuction with ctl_cmd_flags. See comment above ctl_cmd_flags 84147188Sgad * definition in ctl_private.h. 8511865Sphk */ 86193255Srwatsontypedef enum { 87147188Sgad CTL_FLAG_NONE = 0x00000000, /* no flags */ 88195843Sbrooks CTL_FLAG_DATA_IN = 0x00000001, /* DATA IN */ 89130825Sgad CTL_FLAG_DATA_OUT = 0x00000002, /* DATA OUT */ 90207152Skib CTL_FLAG_DATA_NONE = 0x00000003, /* no data */ 91130825Sgad CTL_FLAG_DATA_MASK = 0x00000003, 92130825Sgad CTL_FLAG_KDPTR_SGLIST = 0x00000008, /* kern_data_ptr is S/G list*/ 93130825Sgad CTL_FLAG_EDPTR_SGLIST = 0x00000010, /* ext_data_ptr is S/G list */ 94207152Skib CTL_FLAG_DO_AUTOSENSE = 0x00000020, /* grab sense info */ 95130825Sgad CTL_FLAG_USER_REQ = 0x00000040, /* request came from userland */ 9669896Smckusick CTL_FLAG_CONTROL_DEV = 0x00000080, /* processor device */ 97104387Sjhb CTL_FLAG_ALLOCATED = 0x00000100, /* data space allocated */ 98154535Sjulian CTL_FLAG_BLOCKED = 0x00000200, /* on the blocked queue */ 9981759Speter CTL_FLAG_ABORT_STATUS = 0x00000400, /* return TASK ABORTED status */ 100130726Sgad CTL_FLAG_ABORT = 0x00000800, /* this I/O should be aborted */ 101195843Sbrooks CTL_FLAG_DMA_INPROG = 0x00001000, /* DMA in progress */ 10281759Speter CTL_FLAG_NO_DATASYNC = 0x00002000, /* don't cache flush data */ 10369896Smckusick CTL_FLAG_DELAY_DONE = 0x00004000, /* delay injection done */ 104195843Sbrooks CTL_FLAG_INT_COPY = 0x00008000, /* internal copy, no done call*/ 105195843Sbrooks CTL_FLAG_SENT_2OTHER_SC = 0x00010000, 106195843Sbrooks CTL_FLAG_FROM_OTHER_SC = 0x00020000, 107195843Sbrooks CTL_FLAG_IS_WAS_ON_RTR = 0x00040000, /* Don't rerun cmd on failover*/ 108195843Sbrooks CTL_FLAG_BUS_ADDR = 0x00080000, /* ctl_sglist contains BUS 109195843Sbrooks addresses, not virtual ones*/ 11011865Sphk CTL_FLAG_IO_CONT = 0x00100000, /* Continue I/O instead of 11169896Smckusick completing */ 11272415Sphk CTL_FLAG_AUTO_MIRROR = 0x00200000, /* Automatically use memory 11369896Smckusick from the RC cache mirrored 11469896Smckusick address area. */ 11569896Smckusick#if 0 11669896Smckusick CTL_FLAG_ALREADY_DONE = 0x00200000 /* I/O already completed */ 11769896Smckusick#endif 11869896Smckusick CTL_FLAG_NO_DATAMOVE = 0x00400000, 11969896Smckusick CTL_FLAG_DMA_QUEUED = 0x00800000, /* DMA queued but not started*/ 12069896Smckusick CTL_FLAG_STATUS_QUEUED = 0x01000000, /* Status queued but not sent*/ 12169896Smckusick 12269896Smckusick CTL_FLAG_REDIR_DONE = 0x02000000, /* Redirection has already 12369896Smckusick been done. */ 12469896Smckusick CTL_FLAG_FAILOVER = 0x04000000, /* Killed by a failover */ 12569896Smckusick CTL_FLAG_IO_ACTIVE = 0x08000000, /* I/O active on this SC */ 12669896Smckusick CTL_FLAG_RDMA_MASK = CTL_FLAG_NO_DATASYNC | CTL_FLAG_BUS_ADDR | 12769896Smckusick CTL_FLAG_AUTO_MIRROR | CTL_FLAG_REDIR_DONE 128130726Sgad /* Flags we care about for 129130640Sphk remote DMA */ 13069896Smckusick} ctl_io_flags; 13169896Smckusick 13269896Smckusick 13369896Smckusickstruct ctl_lba_len { 13469896Smckusick uint64_t lba; 13569896Smckusick uint32_t len; 13669896Smckusick}; 13769896Smckusick 13869896Smckusickstruct ctl_lba_len_flags { 13969896Smckusick uint64_t lba; 140130726Sgad uint32_t len; 141195843Sbrooks uint32_t flags; 14269896Smckusick#define CTL_LLF_READ 0x10000000 14369896Smckusick#define CTL_LLF_WRITE 0x20000000 14469896Smckusick#define CTL_LLF_VERIFY 0x40000000 14569896Smckusick#define CTL_LLF_COMPARE 0x80000000 14669896Smckusick}; 14769896Smckusick 14869896Smckusickstruct ctl_ptr_len_flags { 14969896Smckusick uint8_t *ptr; 15069896Smckusick uint32_t len; 15169896Smckusick uint32_t flags; 15269896Smckusick}; 15369896Smckusick 154147188Sgadunion ctl_priv { 15569896Smckusick uint8_t bytes[sizeof(uint64_t) * 2]; 15669896Smckusick uint64_t integer; 15769896Smckusick void *ptr; 15869896Smckusick}; 15969896Smckusick 16069896Smckusick/* 16169896Smckusick * Number of CTL private areas. 162124829Sgrehan */ 16369896Smckusick#define CTL_NUM_PRIV 6 16469896Smckusick 16569896Smckusick/* 16669896Smckusick * Which private area are we using for a particular piece of data? 167154535Sjulian */ 16869896Smckusick#define CTL_PRIV_LUN 0 /* CTL LUN pointer goes here */ 16981759Speter#define CTL_PRIV_LBA_LEN 1 /* Decoded LBA/len for read/write*/ 170104387Sjhb#define CTL_PRIV_MODEPAGE 1 /* Modepage info for config write */ 17181759Speter#define CTL_PRIV_BACKEND 2 /* Reserved for block, RAIDCore */ 172130726Sgad#define CTL_PRIV_BACKEND_LUN 3 /* Backend LUN pointer */ 173147188Sgad#define CTL_PRIV_FRONTEND 4 /* LSI driver, ioctl front end */ 174147188Sgad#define CTL_PRIV_USER 5 /* Userland use */ 175147188Sgad 176147188Sgad#define CTL_INVALID_PORTNAME 0xFF 177147188Sgad#define CTL_UNMAPPED_IID 0xFF 178130726Sgad/* 179147188Sgad * XXX KDM this size is for the port_priv variable in struct ctl_io_hdr 180193255Srwatson * below. This should be defined in terms of the size of struct 181147188Sgad * ctlfe_lun_cmd_info at the moment: 182147188Sgad * struct ctlfe_lun_cmd_info { 183147188Sgad * int cur_transfer_index; 184147188Sgad * ctlfe_cmd_flags flags; 18569896Smckusick * bus_dma_segment_t cam_sglist[32]; 186147188Sgad * }; 187147188Sgad * 18883366Sjulian * This isn't really the way I'd prefer to do it, but it does make some 18983366Sjulian * sense, AS LONG AS we can guarantee that there will always only be one 190132014Salfred * outstanding DMA request per ctl_io. If that assumption isn't valid, 191147188Sgad * then we've got problems. 192147188Sgad * 193147188Sgad * At some point it may be nice switch CTL over to using CCBs for 194147188Sgad * everything. At that point we can probably use the ATIO/CTIO model, so 195147188Sgad * that multiple simultaneous DMAs per command will just work. 196147188Sgad * 197147188Sgad * Also note that the current size, 600, is appropriate for 64-bit 198147188Sgad * architectures, but is overkill for 32-bit architectures. Need a way to 199147188Sgad * figure out the size at compile time, or just get rid of this altogether. 20011865Sphk */ 20192719Salfred#define CTL_PORT_PRIV_SIZE 600 202147188Sgad 203147188Sgadstruct ctl_sg_entry { 204147188Sgad void *addr; 20511865Sphk size_t len; 206172207Sjeff}; 207172207Sjeff 208172207Sjeffstruct ctl_id { 209172207Sjeff uint32_t id; 210172207Sjeff uint64_t wwid[2]; 211172207Sjeff}; 21269896Smckusick 21369896Smckusicktypedef enum { 21469896Smckusick CTL_IO_NONE, 215104387Sjhb CTL_IO_SCSI, 21611865Sphk CTL_IO_TASK, 21711865Sphk} ctl_io_type; 218137920Sdas 219137920Sdasstruct ctl_nexus { 220137920Sdas struct ctl_id initid; /* Initiator ID */ 2211541Srgrimes uint32_t targ_port; /* Target port, filled in by PORT */ 22283421Sobrien struct ctl_id targ_target; /* Destination target */ 22383366Sjulian uint32_t targ_lun; /* Destination lun */ 22483366Sjulian uint32_t targ_mapped_lun; /* Destination lun CTL-wide */ 2251541Srgrimes}; 2261541Srgrimes 227174167Srwatsontypedef enum { 228176124Smarcus CTL_MSG_SERIALIZE, 229174167Srwatson CTL_MSG_R2R, 230174167Srwatson CTL_MSG_FINISH_IO, 231174167Srwatson CTL_MSG_BAD_JUJU, 232174167Srwatson CTL_MSG_MANAGE_TASKS, 233174167Srwatson CTL_MSG_PERS_ACTION, 234174167Srwatson CTL_MSG_SYNC_FE, 235174167Srwatson CTL_MSG_APS_LOCK, 236174167Srwatson CTL_MSG_DATAMOVE, 237174167Srwatson CTL_MSG_DATAMOVE_DONE 238174167Srwatson} ctl_msg_type; 239175514Srwatson 240180059Sjhbstruct ctl_scsiio; 241181905Sed 242174167Srwatson#define CTL_NUM_SG_ENTRIES 9 243174167Srwatson 244174167Srwatsonstruct ctl_io_hdr { 245174167Srwatson uint32_t version; /* interface version XXX */ 246174167Srwatson ctl_io_type io_type; /* task I/O, SCSI I/O, etc. */ 247174167Srwatson ctl_msg_type msg_type; 248174167Srwatson struct ctl_nexus nexus; /* Initiator, port, target, lun */ 249174167Srwatson uint32_t iid_indx; /* the index into the iid mapping */ 250174167Srwatson uint32_t flags; /* transaction flags */ 251174167Srwatson uint32_t status; /* transaction status */ 252174167Srwatson uint32_t port_status; /* trans status, set by PORT, 0 = good*/ 253174167Srwatson uint32_t timeout; /* timeout in ms */ 254174167Srwatson uint32_t retries; /* retry count */ 255176124Smarcus#ifdef CTL_IO_DELAY 256176124Smarcus uint8_t timer_bytes[CTL_TIMER_BYTES]; /* timer kludge */ 257176124Smarcus#endif /* CTL_IO_DELAY */ 258176124Smarcus#ifdef CTL_TIME_IO 259174167Srwatson time_t start_time; /* I/O start time */ 260174167Srwatson struct bintime start_bt; /* Timer start ticks */ 261174167Srwatson struct bintime dma_start_bt; /* DMA start ticks */ 262174167Srwatson struct bintime dma_bt; /* DMA total ticks */ 263174167Srwatson uint32_t num_dmas; /* Number of DMAs */ 264174167Srwatson#endif /* CTL_TIME_IO */ 265174167Srwatson union ctl_io *original_sc; 266174167Srwatson union ctl_io *serializing_sc; 267174167Srwatson void *pool; /* I/O pool */ 268185548Speter union ctl_priv ctl_private[CTL_NUM_PRIV];/* CTL private area */ 269185548Speter uint8_t port_priv[CTL_PORT_PRIV_SIZE];/* PORT private area*/ 270185548Speter struct ctl_sg_entry remote_sglist[CTL_NUM_SG_ENTRIES]; 271185548Speter struct ctl_sg_entry remote_dma_sglist[CTL_NUM_SG_ENTRIES]; 272185548Speter struct ctl_sg_entry local_sglist[CTL_NUM_SG_ENTRIES]; 273185548Speter struct ctl_sg_entry local_dma_sglist[CTL_NUM_SG_ENTRIES]; 274185548Speter STAILQ_ENTRY(ctl_io_hdr) links; /* linked list pointer */ 275185548Speter TAILQ_ENTRY(ctl_io_hdr) ooa_links; 276185548Speter TAILQ_ENTRY(ctl_io_hdr) blocked_links; 277185548Speter}; 278185548Speter 279185548Spetertypedef enum { 280174167Srwatson CTL_TAG_UNTAGGED, 281174167Srwatson CTL_TAG_SIMPLE, 282174167Srwatson CTL_TAG_ORDERED, 283174167Srwatson CTL_TAG_HEAD_OF_QUEUE, 284174167Srwatson CTL_TAG_ACA 285185548Speter} ctl_tag_type; 286174167Srwatson 287174167Srwatsonunion ctl_io; 288174167Srwatson 289174167Srwatson/* 290174167Srwatson * SCSI passthrough I/O structure for the CAM Target Layer. Note 291185548Speter * that some of these fields are here for completeness, but they aren't 292174167Srwatson * used in the CTL implementation. e.g., timeout and retries won't be 293174167Srwatson * used. 294174167Srwatson * 295174167Srwatson * Note: Make sure the io_hdr is *always* the first element in this 296185548Speter * structure. 297185548Speter */ 298185548Speterstruct ctl_scsiio { 299185548Speter struct ctl_io_hdr io_hdr; /* common to all I/O types */ 300185548Speter 301185548Speter /* 302185548Speter * The ext_* fields are generally intended for frontend use; CTL itself 303185548Speter * doesn't modify or use them. 304185548Speter */ 305185548Speter uint32_t ext_sg_entries; /* 0 = no S/G list, > 0 = num entries */ 306185548Speter uint8_t *ext_data_ptr; /* data buffer or S/G list */ 307185554Speter uint32_t ext_data_len; /* Data transfer length */ 308185548Speter uint32_t ext_data_filled; /* Amount of data filled so far */ 309185548Speter 310185548Speter /* 311185548Speter * The number of scatter/gather entries in the list pointed to 312185548Speter * by kern_data_ptr. 0 means there is no list, just a data pointer. 313185548Speter */ 314185548Speter uint32_t kern_sg_entries; 315185548Speter 316185548Speter uint32_t rem_sg_entries; /* Unused. */ 317185548Speter 318185548Speter /* 319174167Srwatson * The data pointer or a pointer to the scatter/gather list. 320174167Srwatson */ 321174167Srwatson uint8_t *kern_data_ptr; 322174167Srwatson 323174167Srwatson /* 324174167Srwatson * Length of the data buffer or scatter/gather list. It's also 325174167Srwatson * the length of this particular piece of the data transfer, 326174167Srwatson * ie. number of bytes expected to be transferred by the current 327174167Srwatson * invocation of frontend's datamove() callback. It's always 328174167Srwatson * less than or equal to kern_total_len. 329174167Srwatson */ 330195840Sjhb uint32_t kern_data_len; 331174167Srwatson 332174167Srwatson /* 333174167Srwatson * Total length of data to be transferred during this particular 334174167Srwatson * SCSI command, as decoded from SCSI CDB. 335174167Srwatson */ 336174167Srwatson uint32_t kern_total_len; 337174167Srwatson 338174167Srwatson /* 339208587Sattilio * Amount of data left after the current data transfer. 340174167Srwatson */ 341185548Speter uint32_t kern_data_resid; 342185548Speter 343185548Speter /* 344185548Speter * Byte offset of this transfer, equal to the amount of data 345185548Speter * already transferred for this SCSI command during previous 346185548Speter * datamove() invocations. 347185548Speter */ 348185548Speter uint32_t kern_rel_offset; 349174167Srwatson 350174167Srwatson struct scsi_sense_data sense_data; /* sense data */ 351185548Speter uint8_t sense_len; /* Returned sense length */ 352185548Speter uint8_t scsi_status; /* SCSI status byte */ 353174167Srwatson uint8_t sense_residual; /* Unused. */ 354174167Srwatson uint32_t residual; /* data residual length */ 355174167Srwatson uint32_t tag_num; /* tag number */ 356174167Srwatson ctl_tag_type tag_type; /* simple, ordered, head of queue,etc.*/ 357174167Srwatson uint8_t cdb_len; /* CDB length */ 358174167Srwatson uint8_t cdb[CTL_MAX_CDBLEN]; /* CDB */ 359174167Srwatson int (*be_move_done)(union ctl_io *io); /* called by fe */ 360174167Srwatson int (*io_cont)(union ctl_io *io); /* to continue processing */ 361184492Speter}; 362185548Speter 363184492Spetertypedef enum { 364184492Speter CTL_TASK_ABORT_TASK, 365174167Srwatson CTL_TASK_ABORT_TASK_SET, 366174167Srwatson CTL_TASK_CLEAR_ACA, 367185548Speter CTL_TASK_CLEAR_TASK_SET, 368185548Speter CTL_TASK_I_T_NEXUS_RESET, 369185548Speter CTL_TASK_LUN_RESET, 370185548Speter CTL_TASK_TARGET_RESET, 371185548Speter CTL_TASK_BUS_RESET, 372185548Speter CTL_TASK_PORT_LOGIN, 373185548Speter CTL_TASK_PORT_LOGOUT 374185548Speter} ctl_task_type; 375185548Speter 376185548Speter/* 377185548Speter * Task management I/O structure. Aborts, bus resets, etc., are sent using 378185548Speter * this structure. 379185548Speter * 380185548Speter * Note: Make sure the io_hdr is *always* the first element in this 381185548Speter * structure. 382185548Speter */ 383185548Speterstruct ctl_taskio { 384185548Speter struct ctl_io_hdr io_hdr; /* common to all I/O types */ 385185548Speter ctl_task_type task_action; /* Target Reset, Abort, etc. */ 386185548Speter uint32_t tag_num; /* tag number */ 387185548Speter ctl_tag_type tag_type; /* simple, ordered, etc. */ 388185548Speter}; 389185548Speter 390185548Spetertypedef enum { 391174197Srwatson CTL_PR_REG_KEY, 392174197Srwatson CTL_PR_UNREG_KEY, 393174197Srwatson CTL_PR_PREEMPT, 394174197Srwatson CTL_PR_CLEAR, 395174197Srwatson CTL_PR_RESERVE, 396174197Srwatson CTL_PR_RELEASE 397174197Srwatson} ctl_pr_action; 398174197Srwatson 399174197Srwatson/* 400174197Srwatson * The PR info is specifically for sending Persistent Reserve actions 401174197Srwatson * to the other SC which it must also act on. 402185548Speter * 403185548Speter * Note: Make sure the io_hdr is *always* the first element in this 404185548Speter * structure. 405185548Speter */ 406174197Srwatsonstruct ctl_pr_info { 407174197Srwatson ctl_pr_action action; 408174197Srwatson uint8_t sa_res_key[8]; 409174197Srwatson uint8_t res_type; 410185548Speter uint32_t residx; 411174197Srwatson}; 412174197Srwatson 41337689Sdfrstruct ctl_ha_msg_hdr { 414 ctl_msg_type msg_type; 415 union ctl_io *original_sc; 416 union ctl_io *serializing_sc; 417 struct ctl_nexus nexus; /* Initiator, port, target, lun */ 418 uint32_t status; /* transaction status */ 419 TAILQ_ENTRY(ctl_ha_msg_hdr) links; 420}; 421 422#define CTL_HA_MAX_SG_ENTRIES 16 423 424/* 425 * Used for CTL_MSG_APS_LOCK. 426 */ 427struct ctl_ha_msg_aps { 428 struct ctl_ha_msg_hdr hdr; 429 uint8_t lock_flag; 430}; 431 432/* 433 * Used for CTL_MSG_PERS_ACTION. 434 */ 435struct ctl_ha_msg_pr { 436 struct ctl_ha_msg_hdr hdr; 437 struct ctl_pr_info pr_info; 438}; 439 440/* 441 * The S/G handling here is a little different than the standard ctl_scsiio 442 * structure, because we can't pass data by reference in between controllers. 443 * The S/G list in the ctl_scsiio struct is normally passed in the 444 * kern_data_ptr field. So kern_sg_entries here will always be non-zero, 445 * even if there is only one entry. 446 * 447 * Used for CTL_MSG_DATAMOVE. 448 */ 449struct ctl_ha_msg_dt { 450 struct ctl_ha_msg_hdr hdr; 451 ctl_io_flags flags; /* Only I/O flags are used here */ 452 uint32_t sg_sequence; /* S/G portion number */ 453 uint8_t sg_last; /* last S/G batch = 1 */ 454 uint32_t sent_sg_entries; /* previous S/G count */ 455 uint32_t cur_sg_entries; /* current S/G entries */ 456 uint32_t kern_sg_entries; /* total S/G entries */ 457 uint32_t kern_data_len; /* Length of this S/G list */ 458 uint32_t kern_total_len; /* Total length of this 459 transaction */ 460 uint32_t kern_data_resid; /* Length left to transfer 461 after this*/ 462 uint32_t kern_rel_offset; /* Byte Offset of this 463 transfer */ 464 struct ctl_sg_entry sg_list[CTL_HA_MAX_SG_ENTRIES]; 465}; 466 467/* 468 * Used for CTL_MSG_SERIALIZE, CTL_MSG_FINISH_IO, CTL_MSG_BAD_JUJU. 469 */ 470struct ctl_ha_msg_scsi { 471 struct ctl_ha_msg_hdr hdr; 472 uint8_t cdb[CTL_MAX_CDBLEN]; /* CDB */ 473 uint32_t tag_num; /* tag number */ 474 ctl_tag_type tag_type; /* simple, ordered, etc. */ 475 uint8_t scsi_status; /* SCSI status byte */ 476 struct scsi_sense_data sense_data; /* sense data */ 477 uint8_t sense_len; /* Returned sense length */ 478 uint8_t sense_residual; /* sense residual length */ 479 uint32_t residual; /* data residual length */ 480 uint32_t fetd_status; /* trans status, set by FETD, 481 0 = good*/ 482 struct ctl_lba_len lbalen; /* used for stats */ 483}; 484 485/* 486 * Used for CTL_MSG_MANAGE_TASKS. 487 */ 488struct ctl_ha_msg_task { 489 struct ctl_ha_msg_hdr hdr; 490 ctl_task_type task_action; /* Target Reset, Abort, etc. */ 491 uint32_t tag_num; /* tag number */ 492 ctl_tag_type tag_type; /* simple, ordered, etc. */ 493}; 494 495union ctl_ha_msg { 496 struct ctl_ha_msg_hdr hdr; 497 struct ctl_ha_msg_task task; 498 struct ctl_ha_msg_scsi scsi; 499 struct ctl_ha_msg_dt dt; 500 struct ctl_ha_msg_pr pr; 501 struct ctl_ha_msg_aps aps; 502}; 503 504 505struct ctl_prio { 506 struct ctl_io_hdr io_hdr; 507 struct ctl_ha_msg_pr pr_msg; 508}; 509 510 511 512union ctl_io { 513 struct ctl_io_hdr io_hdr; /* common to all I/O types */ 514 struct ctl_scsiio scsiio; /* Normal SCSI commands */ 515 struct ctl_taskio taskio; /* SCSI task management/reset */ 516 struct ctl_prio presio; /* update per. res info on other SC */ 517}; 518 519#ifdef _KERNEL 520 521union ctl_io *ctl_alloc_io(void *pool_ref); 522void ctl_free_io(union ctl_io *io); 523void ctl_zero_io(union ctl_io *io); 524void ctl_copy_io(union ctl_io *src, union ctl_io *dest); 525 526#endif /* _KERNEL */ 527 528#endif /* _CTL_IO_H_ */ 529 530/* 531 * vim: ts=8 532 */ 533