The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/cam/cam_ccb.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Data structures and definitions for CAM Control Blocks (CCBs).
    3  *
    4  * Copyright (c) 1997, 1998 Justin T. Gibbs.
    5  * All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions, and the following disclaimer,
   12  *    without modification, immediately at the beginning of the file.
   13  * 2. The name of the author may not be used to endorse or promote products
   14  *    derived from this software without specific prior written permission.
   15  *
   16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   19  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
   20  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   26  * SUCH DAMAGE.
   27  *
   28  * $FreeBSD$
   29  */
   30 
   31 #ifndef _CAM_CAM_CCB_H
   32 #define _CAM_CAM_CCB_H 1
   33 
   34 #include <sys/queue.h>
   35 #include <sys/cdefs.h>
   36 #include <sys/time.h>
   37 #ifndef KERNEL
   38 #include <sys/callout.h>
   39 #endif
   40 #include <cam/cam_debug.h>
   41 #include <cam/scsi/scsi_all.h>
   42 
   43 
   44 /* General allocation length definitions for CCB structures */
   45 #define IOCDBLEN        CAM_MAX_CDBLEN  /* Space for CDB bytes/pointer */
   46 #define VUHBALEN        14              /* Vendor Unique HBA length */
   47 #define SIM_IDLEN       16              /* ASCII string len for SIM ID */
   48 #define HBA_IDLEN       16              /* ASCII string len for HBA ID */
   49 #define DEV_IDLEN       16              /* ASCII string len for device names */
   50 #define CCB_PERIPH_PRIV_SIZE    2       /* size of peripheral private area */
   51 #define CCB_SIM_PRIV_SIZE       2       /* size of sim private area */
   52 
   53 /* Struct definitions for CAM control blocks */
   54 
   55 /* Common CCB header */
   56 /* CAM CCB flags */
   57 typedef enum {
   58         CAM_CDB_POINTER         = 0x00000001,/* The CDB field is a pointer    */
   59         CAM_QUEUE_ENABLE        = 0x00000002,/* SIM queue actions are enabled */
   60         CAM_CDB_LINKED          = 0x00000004,/* CCB contains a linked CDB     */
   61         CAM_SCATTER_VALID       = 0x00000010,/* Scatter/gather list is valid  */
   62         CAM_DIS_AUTOSENSE       = 0x00000020,/* Disable autosense feature     */
   63         CAM_DIR_RESV            = 0x00000000,/* Data direction (00:reserved)  */
   64         CAM_DIR_IN              = 0x00000040,/* Data direction (01:DATA IN)   */
   65         CAM_DIR_OUT             = 0x00000080,/* Data direction (10:DATA OUT)  */
   66         CAM_DIR_NONE            = 0x000000C0,/* Data direction (11:no data)   */
   67         CAM_DIR_MASK            = 0x000000C0,/* Data direction Mask           */
   68         CAM_SOFT_RST_OP         = 0x00000100,/* Use Soft reset alternative    */
   69         CAM_ENG_SYNC            = 0x00000200,/* Flush resid bytes on complete */
   70         CAM_DEV_QFRZDIS         = 0x00000400,/* Disable DEV Q freezing        */
   71         CAM_DEV_QFREEZE         = 0x00000800,/* Freeze DEV Q on execution     */
   72         CAM_HIGH_POWER          = 0x00001000,/* Command takes a lot of power  */
   73         CAM_SENSE_PTR           = 0x00002000,/* Sense data is a pointer       */
   74         CAM_SENSE_PHYS          = 0x00004000,/* Sense pointer is physical addr*/
   75         CAM_TAG_ACTION_VALID    = 0x00008000,/* Use the tag action in this ccb*/
   76         CAM_PASS_ERR_RECOVER    = 0x00010000,/* Pass driver does err. recovery*/
   77         CAM_DIS_DISCONNECT      = 0x00020000,/* Disable disconnect            */
   78         CAM_SG_LIST_PHYS        = 0x00040000,/* SG list has physical addrs.   */
   79         CAM_MSG_BUF_PHYS        = 0x00080000,/* Message buffer ptr is physical*/
   80         CAM_SNS_BUF_PHYS        = 0x00100000,/* Autosense data ptr is physical*/
   81         CAM_DATA_PHYS           = 0x00200000,/* SG/Buffer data ptrs are phys. */
   82         CAM_CDB_PHYS            = 0x00400000,/* CDB poiner is physical        */
   83         CAM_ENG_SGLIST          = 0x00800000,/* SG list is for the HBA engine */
   84 
   85 /* Phase cognizant mode flags */
   86         CAM_DIS_AUTOSRP         = 0x01000000,/* Diable autosave/restore ptrs  */
   87         CAM_DIS_AUTODISC        = 0x02000000,/* Disable auto disconnect       */
   88         CAM_TGT_CCB_AVAIL       = 0x04000000,/* Target CCB available          */
   89         CAM_TGT_PHASE_MODE      = 0x08000000,/* The SIM runs in phase mode    */
   90         CAM_MSGB_VALID          = 0x20000000,/* Message buffer valid          */
   91         CAM_STATUS_VALID        = 0x40000000,/* Status buffer valid           */
   92         CAM_DATAB_VALID         = 0x80000000,/* Data buffer valid             */
   93         
   94 /* Host target Mode flags */
   95         CAM_TERM_IO             = 0x20000000,/* Terminate I/O Message sup.    */
   96         CAM_DISCONNECT          = 0x40000000,/* Disconnects are mandatory     */
   97         CAM_SEND_STATUS         = 0x80000000,/* Send status after data phase  */
   98 } ccb_flags;
   99 
  100 /* XPT Opcodes for xpt_action */
  101 typedef enum {
  102 /* Function code flags are bits greater than 0xff */
  103         XPT_FC_QUEUED           = 0x100,
  104                                 /* Non-immediate function code */
  105         XPT_FC_USER_CCB         = 0x200,
  106         XPT_FC_XPT_ONLY         = 0x400,
  107                                 /* Only for the transport layer device */
  108 /* Common function commands: 0x00->0x0F */
  109         XPT_NOOP                = 0x00,
  110                                 /* Execute Nothing */
  111         XPT_SCSI_IO             = 0x01 | XPT_FC_QUEUED,
  112                                 /* Execute the requested I/O operation */
  113         XPT_GDEV_TYPE           = 0x02,
  114                                 /* Get type information for specified device */
  115         XPT_GDEVLIST            = 0x03,
  116                                 /* Get a list of peripheral devices */
  117         XPT_PATH_INQ            = 0x04,
  118                                 /* Path routing inquiry */
  119         XPT_REL_SIMQ            = 0x05,
  120                                 /* Release a frozen SIM queue */
  121         XPT_SASYNC_CB           = 0x06,
  122                                 /* Set Asynchronous Callback Parameters */
  123         XPT_SDEV_TYPE           = 0x07,
  124                                 /* Set device type information */
  125         XPT_SCAN_BUS            = 0x08 | XPT_FC_QUEUED | XPT_FC_USER_CCB
  126                                        | XPT_FC_XPT_ONLY,
  127                                 /* (Re)Scan the SCSI Bus */
  128         XPT_DEV_MATCH           = 0x09 | XPT_FC_XPT_ONLY,
  129                                 /* Get EDT entries matching the given pattern */
  130         XPT_DEBUG               = 0x0a,
  131                                 /* Turn on debugging for a bus, target or lun */
  132         XPT_PATH_STATS          = 0x0b,
  133                                 /* Path statistics (error counts, etc.) */
  134         XPT_GDEV_STATS          = 0x0c,
  135                                 /* Device statistics (error counts, etc.) */
  136 /* SCSI Control Functions: 0x10->0x1F */
  137         XPT_ABORT               = 0x10,
  138                                 /* Abort the specified CCB */
  139         XPT_RESET_BUS           = 0x11 | XPT_FC_XPT_ONLY,
  140                                 /* Reset the specified SCSI bus */
  141         XPT_RESET_DEV           = 0x12 | XPT_FC_QUEUED,
  142                                 /* Bus Device Reset the specified SCSI device */
  143         XPT_TERM_IO             = 0x13,
  144                                 /* Terminate the I/O process */
  145         XPT_SCAN_LUN            = 0x14 | XPT_FC_QUEUED | XPT_FC_USER_CCB
  146                                        | XPT_FC_XPT_ONLY,
  147                                 /* Scan Logical Unit */
  148         XPT_GET_TRAN_SETTINGS   = 0x15,
  149                                 /*
  150                                  * Get default/user transfer settings
  151                                  * for the target
  152                                  */
  153         XPT_SET_TRAN_SETTINGS   = 0x16,
  154                                 /*
  155                                  * Set transfer rate/width
  156                                  * negotiation settings
  157                                  */
  158         XPT_CALC_GEOMETRY       = 0x17,
  159                                 /*
  160                                  * Calculate the geometry parameters for
  161                                  * a device give the sector size and
  162                                  * volume size.
  163                                  */
  164 
  165 /* HBA engine commands 0x20->0x2F */
  166         XPT_ENG_INQ             = 0x20 | XPT_FC_XPT_ONLY,
  167                                 /* HBA engine feature inquiry */
  168         XPT_ENG_EXEC            = 0x21 | XPT_FC_QUEUED | XPT_FC_XPT_ONLY,
  169                                 /* HBA execute engine request */
  170 
  171 /* Target mode commands: 0x30->0x3F */
  172         XPT_EN_LUN              = 0x30,
  173                                 /* Enable LUN as a target */
  174         XPT_TARGET_IO           = 0x31 | XPT_FC_QUEUED,
  175                                 /* Execute target I/O request */
  176         XPT_ACCEPT_TARGET_IO    = 0x32 | XPT_FC_QUEUED | XPT_FC_USER_CCB,
  177                                 /* Accept Host Target Mode CDB */
  178         XPT_CONT_TARGET_IO      = 0x33 | XPT_FC_QUEUED,
  179                                 /* Continue Host Target I/O Connection */
  180         XPT_IMMED_NOTIFY        = 0x34 | XPT_FC_QUEUED | XPT_FC_USER_CCB,
  181                                 /* Notify Host Target driver of event */
  182         XPT_NOTIFY_ACK          = 0x35,
  183                                 /* Acknowledgement of event */
  184 
  185 /* Vendor Unique codes: 0x80->0x8F */
  186         XPT_VUNIQUE             = 0x80
  187 } xpt_opcode;
  188 
  189 #define XPT_FC_GROUP_MASK               0xF0
  190 #define XPT_FC_GROUP(op) ((op) & XPT_FC_GROUP_MASK)
  191 #define XPT_FC_GROUP_COMMON             0x00
  192 #define XPT_FC_GROUP_SCSI_CONTROL       0x10
  193 #define XPT_FC_GROUP_HBA_ENGINE 0x20
  194 #define XPT_FC_GROUP_TMODE              0x30
  195 #define XPT_FC_GROUP_VENDOR_UNIQUE      0x80
  196 
  197 typedef union {
  198         LIST_ENTRY(ccb_hdr) le;
  199         SLIST_ENTRY(ccb_hdr) sle;
  200         TAILQ_ENTRY(ccb_hdr) tqe;
  201         STAILQ_ENTRY(ccb_hdr) stqe;
  202 } camq_entry;
  203 
  204 typedef union {
  205         void            *ptr;
  206         u_long          field;
  207         u_int8_t        bytes[sizeof(void *) > sizeof(u_long)
  208                               ? sizeof(void *) : sizeof(u_long)];
  209 } ccb_priv_entry;
  210 
  211 typedef union {
  212         ccb_priv_entry  entries[CCB_PERIPH_PRIV_SIZE];
  213         u_int8_t        bytes[CCB_PERIPH_PRIV_SIZE * sizeof(ccb_priv_entry)];
  214 } ccb_ppriv_area;
  215 
  216 typedef union {
  217         ccb_priv_entry  entries[CCB_SIM_PRIV_SIZE];
  218         u_int8_t        bytes[CCB_SIM_PRIV_SIZE * sizeof(ccb_priv_entry)];
  219 } ccb_spriv_area;
  220 
  221 struct ccb_hdr {
  222         cam_pinfo       pinfo;  /* Info for priority scheduling */
  223         camq_entry      xpt_links;      /* For chaining in the XPT layer */     
  224         camq_entry      sim_links;      /* For chaining in the SIM layer */     
  225         camq_entry      periph_links;/* For chaining in the type driver */
  226         u_int32_t       retry_count;
  227                                 /* Callback on completion function */
  228         void            (*cbfcnp)(struct cam_periph *, union ccb *);
  229         xpt_opcode      func_code;      /* XPT function code */
  230         u_int32_t       status; /* Status returned by CAM subsystem */
  231                                 /* Compiled path for this ccb */
  232         struct          cam_path *path;
  233         path_id_t       path_id;        /* Path ID for the request */
  234         target_id_t     target_id;      /* Target device ID */
  235         lun_id_t        target_lun;     /* Target LUN number */
  236         u_int32_t       flags;
  237         ccb_ppriv_area  periph_priv;
  238         ccb_spriv_area  sim_priv;
  239         u_int32_t       timeout;        /* Timeout value */
  240                                         /* Callout handle used for timeouts */
  241         struct          callout_handle timeout_ch;
  242 };
  243 
  244 /* Get Device Information CCB */
  245 struct ccb_getdev {
  246         struct    ccb_hdr ccb_h;
  247         struct    scsi_inquiry_data inq_data;
  248         u_int8_t  serial_num[252];
  249         u_int8_t  serial_num_len;
  250         u_int8_t  pd_type;      /* returned peripheral device type */
  251 /*
  252  * GARBAGE COLLECT
  253  * Moved to ccb_getdevstats but left here for binary compatibility.
  254  * Remove during next bump in CAM major version.
  255  */
  256         int       dev_openings; /* Space left for more work on device*/ 
  257         int       dev_active;   /* Transactions running on the device */
  258         int       devq_openings;/* Space left for more queued work */
  259         int       devq_queued;  /* Transactions queued to be sent */
  260         int       held;         /*
  261                                  * CCBs held by peripheral drivers
  262                                  * for this device
  263                                  */
  264         int       maxtags;      /*
  265                                  * Boundary conditions for number of
  266                                  * tagged operations
  267                                  */
  268         int       mintags;
  269 };
  270 
  271 /* Device Statistics CCB */
  272 struct ccb_getdevstats {
  273         struct  ccb_hdr ccb_h;
  274         int     dev_openings;   /* Space left for more work on device*/ 
  275         int     dev_active;     /* Transactions running on the device */
  276         int     devq_openings;  /* Space left for more queued work */
  277         int     devq_queued;    /* Transactions queued to be sent */
  278         int     held;           /*
  279                                  * CCBs held by peripheral drivers
  280                                  * for this device
  281                                  */
  282         int     maxtags;        /*
  283                                  * Boundary conditions for number of
  284                                  * tagged operations
  285                                  */
  286         int     mintags;
  287         struct  timeval last_reset;     /* Time of last bus reset/loop init */
  288 };
  289 
  290 typedef enum {
  291         CAM_GDEVLIST_LAST_DEVICE,
  292         CAM_GDEVLIST_LIST_CHANGED,
  293         CAM_GDEVLIST_MORE_DEVS,
  294         CAM_GDEVLIST_ERROR
  295 } ccb_getdevlist_status_e;
  296 
  297 struct ccb_getdevlist {
  298         struct ccb_hdr          ccb_h;
  299         char                    periph_name[DEV_IDLEN];
  300         u_int32_t               unit_number;
  301         unsigned int            generation;
  302         u_int32_t               index;
  303         ccb_getdevlist_status_e status;
  304 };
  305 
  306 typedef enum {
  307         PERIPH_MATCH_NONE       = 0x000,
  308         PERIPH_MATCH_PATH       = 0x001,
  309         PERIPH_MATCH_TARGET     = 0x002,
  310         PERIPH_MATCH_LUN        = 0x004,
  311         PERIPH_MATCH_NAME       = 0x008,
  312         PERIPH_MATCH_UNIT       = 0x010,
  313         PERIPH_MATCH_ANY        = 0x01f
  314 } periph_pattern_flags;
  315 
  316 struct periph_match_pattern {
  317         char                    periph_name[DEV_IDLEN];
  318         u_int32_t               unit_number;
  319         path_id_t               path_id;
  320         target_id_t             target_id;
  321         lun_id_t                target_lun;
  322         periph_pattern_flags    flags;
  323 };
  324 
  325 typedef enum {
  326         DEV_MATCH_NONE          = 0x000,
  327         DEV_MATCH_PATH          = 0x001,
  328         DEV_MATCH_TARGET        = 0x002,
  329         DEV_MATCH_LUN           = 0x004,
  330         DEV_MATCH_INQUIRY       = 0x008,
  331         DEV_MATCH_ANY           = 0x00f
  332 } dev_pattern_flags;
  333 
  334 struct device_match_pattern {
  335         path_id_t                               path_id;
  336         target_id_t                             target_id;
  337         lun_id_t                                target_lun;
  338         struct scsi_static_inquiry_pattern      inq_pat;
  339         dev_pattern_flags                       flags;
  340 };
  341 
  342 typedef enum {
  343         BUS_MATCH_NONE          = 0x000,
  344         BUS_MATCH_PATH          = 0x001,
  345         BUS_MATCH_NAME          = 0x002,
  346         BUS_MATCH_UNIT          = 0x004,
  347         BUS_MATCH_BUS_ID        = 0x008,
  348         BUS_MATCH_ANY           = 0x00f
  349 } bus_pattern_flags;
  350 
  351 struct bus_match_pattern {
  352         path_id_t               path_id;
  353         char                    dev_name[DEV_IDLEN];
  354         u_int32_t               unit_number;
  355         u_int32_t               bus_id;
  356         bus_pattern_flags       flags;
  357 };
  358 
  359 union match_pattern {
  360         struct periph_match_pattern     periph_pattern;
  361         struct device_match_pattern     device_pattern;
  362         struct bus_match_pattern        bus_pattern;
  363 };
  364 
  365 typedef enum {
  366         DEV_MATCH_PERIPH,
  367         DEV_MATCH_DEVICE,
  368         DEV_MATCH_BUS
  369 } dev_match_type;
  370 
  371 struct dev_match_pattern {
  372         dev_match_type          type;
  373         union match_pattern     pattern;
  374 };
  375 
  376 struct periph_match_result {
  377         char                    periph_name[DEV_IDLEN];
  378         u_int32_t               unit_number;
  379         path_id_t               path_id;
  380         target_id_t             target_id;
  381         lun_id_t                target_lun;
  382 };
  383 
  384 typedef enum {
  385         DEV_RESULT_NOFLAG               = 0x00,
  386         DEV_RESULT_UNCONFIGURED         = 0x01
  387 } dev_result_flags;
  388 
  389 struct device_match_result {
  390         path_id_t                       path_id;
  391         target_id_t                     target_id;
  392         lun_id_t                        target_lun;
  393         struct scsi_inquiry_data        inq_data;
  394         dev_result_flags                flags;
  395 };
  396 
  397 struct bus_match_result {
  398         path_id_t       path_id;
  399         char            dev_name[DEV_IDLEN];
  400         u_int32_t       unit_number;
  401         u_int32_t       bus_id;
  402 };
  403 
  404 union match_result {
  405         struct periph_match_result      periph_result;
  406         struct device_match_result      device_result;
  407         struct bus_match_result         bus_result;
  408 };
  409 
  410 struct dev_match_result {
  411         dev_match_type          type;
  412         union match_result      result;
  413 };
  414 
  415 typedef enum {
  416         CAM_DEV_MATCH_LAST,
  417         CAM_DEV_MATCH_MORE,
  418         CAM_DEV_MATCH_LIST_CHANGED,
  419         CAM_DEV_MATCH_SIZE_ERROR,
  420         CAM_DEV_MATCH_ERROR
  421 } ccb_dev_match_status;
  422 
  423 typedef enum {
  424         CAM_DEV_POS_NONE        = 0x000,
  425         CAM_DEV_POS_BUS         = 0x001,
  426         CAM_DEV_POS_TARGET      = 0x002,
  427         CAM_DEV_POS_DEVICE      = 0x004,
  428         CAM_DEV_POS_PERIPH      = 0x008,
  429         CAM_DEV_POS_PDPTR       = 0x010,
  430         CAM_DEV_POS_TYPEMASK    = 0xf00,
  431         CAM_DEV_POS_EDT         = 0x100,
  432         CAM_DEV_POS_PDRV        = 0x200
  433 } dev_pos_type;
  434 
  435 struct ccb_dm_cookie {
  436         void    *bus;
  437         void    *target;        
  438         void    *device;
  439         void    *periph;
  440         void    *pdrv;
  441 };
  442 
  443 struct ccb_dev_position {
  444         u_int                   generations[4];
  445 #define CAM_BUS_GENERATION      0x00
  446 #define CAM_TARGET_GENERATION   0x01
  447 #define CAM_DEV_GENERATION      0x02
  448 #define CAM_PERIPH_GENERATION   0x03
  449         dev_pos_type            position_type;
  450         struct ccb_dm_cookie    cookie;
  451 };
  452 
  453 struct ccb_dev_match {
  454         struct ccb_hdr                  ccb_h;
  455         ccb_dev_match_status            status;
  456         u_int32_t                       num_patterns;
  457         u_int32_t                       pattern_buf_len;
  458         struct dev_match_pattern        *patterns;
  459         u_int32_t                       num_matches;
  460         u_int32_t                       match_buf_len;
  461         struct dev_match_result         *matches;
  462         struct ccb_dev_position         pos;
  463 };
  464 
  465 /*
  466  * Definitions for the path inquiry CCB fields.
  467  */
  468 #define CAM_VERSION     0x11    /* Hex value for current version */
  469 
  470 typedef enum {
  471         PI_MDP_ABLE     = 0x80, /* Supports MDP message */
  472         PI_WIDE_32      = 0x40, /* Supports 32 bit wide SCSI */
  473         PI_WIDE_16      = 0x20, /* Supports 16 bit wide SCSI */
  474         PI_SDTR_ABLE    = 0x10, /* Supports SDTR message */
  475         PI_LINKED_CDB   = 0x08, /* Supports linked CDBs */
  476         PI_TAG_ABLE     = 0x02, /* Supports tag queue messages */
  477         PI_SOFT_RST     = 0x01, /* Supports soft reset alternative */
  478 } pi_inqflag;
  479 
  480 typedef enum {
  481         PIT_PROCESSOR   = 0x80, /* Target mode processor mode */
  482         PIT_PHASE       = 0x40, /* Target mode phase cog. mode */
  483         PIT_DISCONNECT  = 0x20, /* Disconnects supported in target mode */
  484         PIT_TERM_IO     = 0x10, /* Terminate I/O message supported in TM */
  485         PIT_GRP_6       = 0x08, /* Group 6 commands supported */
  486         PIT_GRP_7       = 0x04, /* Group 7 commands supported */
  487 } pi_tmflag;
  488 
  489 typedef enum {
  490         PIM_SCANHILO    = 0x80, /* Bus scans from high ID to low ID */
  491         PIM_NOREMOVE    = 0x40, /* Removeable devices not included in scan */
  492         PIM_NOINITIATOR = 0x20, /* Initiator role not supported. */
  493         PIM_NOBUSRESET  = 0x10, /* User has disabled initial BUS RESET */
  494 } pi_miscflag;
  495 
  496 /* Path Inquiry CCB */
  497 struct ccb_pathinq {
  498         struct      ccb_hdr ccb_h;
  499         u_int8_t    version_num;        /* Version number for the SIM/HBA */
  500         u_int8_t    hba_inquiry;        /* Mimic of INQ byte 7 for the HBA */
  501         u_int8_t    target_sprt;        /* Flags for target mode support */
  502         u_int8_t    hba_misc;           /* Misc HBA features */
  503         u_int16_t   hba_eng_cnt;        /* HBA engine count */
  504                                         /* Vendor Unique capabilities */
  505         u_int8_t    vuhba_flags[VUHBALEN];
  506         u_int32_t   max_target;         /* Maximum supported Target */
  507         u_int32_t   max_lun;            /* Maximum supported Lun */
  508         u_int32_t   async_flags;        /* Installed Async handlers */
  509         path_id_t   hpath_id;           /* Highest Path ID in the subsystem */
  510         target_id_t initiator_id;       /* ID of the HBA on the SCSI bus */
  511         char        sim_vid[SIM_IDLEN]; /* Vendor ID of the SIM */
  512         char        hba_vid[HBA_IDLEN]; /* Vendor ID of the HBA */
  513         char        dev_name[DEV_IDLEN];/* Device name for SIM */
  514         u_int32_t   unit_number;        /* Unit number for SIM */
  515         u_int32_t   bus_id;             /* Bus ID for SIM */
  516         u_int32_t   base_transfer_speed;/* Base bus speed in KB/sec */
  517 };
  518 
  519 /* Path Statistics CCB */
  520 struct ccb_pathstats {
  521         struct  ccb_hdr ccb_h;
  522         struct  timeval last_reset;     /* Time of last bus reset/loop init */
  523 };
  524 
  525 typedef union {
  526         u_int8_t *sense_ptr;            /*
  527                                          * Pointer to storage
  528                                          * for sense information
  529                                          */
  530                                         /* Storage Area for sense information */
  531         struct   scsi_sense_data sense_buf;
  532 } sense_t;
  533 
  534 typedef union {
  535         u_int8_t  *cdb_ptr;             /* Pointer to the CDB bytes to send */
  536                                         /* Area for the CDB send */
  537         u_int8_t  cdb_bytes[IOCDBLEN];
  538 } cdb_t;
  539 
  540 /*
  541  * SCSI I/O Request CCB used for the XPT_SCSI_IO and XPT_CONT_TARGET_IO
  542  * function codes.
  543  */
  544 struct ccb_scsiio {
  545         struct     ccb_hdr ccb_h;
  546         union      ccb *next_ccb;       /* Ptr for next CCB for action */
  547         u_int8_t   *req_map;            /* Ptr to mapping info */
  548         u_int8_t   *data_ptr;           /* Ptr to the data buf/SG list */
  549         u_int32_t  dxfer_len;           /* Data transfer length */
  550                                         /* Autosense storage */ 
  551         struct     scsi_sense_data sense_data;
  552         u_int8_t   sense_len;           /* Number of bytes to autosense */
  553         u_int8_t   cdb_len;             /* Number of bytes for the CDB */
  554         u_int16_t  sglist_cnt;          /* Number of SG list entries */
  555         u_int8_t   scsi_status;         /* Returned SCSI status */
  556         u_int8_t   sense_resid;         /* Autosense resid length: 2's comp */
  557         u_int32_t  resid;               /* Transfer residual length: 2's comp */
  558         cdb_t      cdb_io;              /* Union for CDB bytes/pointer */
  559         u_int8_t   *msg_ptr;            /* Pointer to the message buffer */
  560         u_int16_t  msg_len;             /* Number of bytes for the Message */
  561         u_int8_t   tag_action;          /* What to do for tag queueing */
  562         /*
  563          * The tag action should be either the define below (to send a
  564          * non-tagged transaction) or one of the defined scsi tag messages
  565          * from scsi_message.h.
  566          */
  567 #define         CAM_TAG_ACTION_NONE     0x00
  568         u_int8_t   tag_id;              /* tag id from initator (target mode) */
  569         u_int8_t   init_id;             /* initiator id of who selected */
  570 };
  571 
  572 struct ccb_accept_tio {
  573         struct     ccb_hdr ccb_h;
  574         cdb_t      cdb_io;              /* Union for CDB bytes/pointer */
  575         u_int8_t   cdb_len;             /* Number of bytes for the CDB */
  576         u_int8_t   tag_action;          /* What to do for tag queueing */
  577         u_int8_t   tag_id;              /* tag id from initator (target mode) */
  578         u_int8_t   init_id;             /* initiator id of who selected */
  579 };
  580 
  581 /* Release SIM Queue */
  582 struct ccb_relsim {
  583         struct ccb_hdr ccb_h;
  584         u_int32_t      release_flags;
  585 #define RELSIM_ADJUST_OPENINGS          0x01
  586 #define RELSIM_RELEASE_AFTER_TIMEOUT    0x02
  587 #define RELSIM_RELEASE_AFTER_CMDCMPLT   0x04
  588 #define RELSIM_RELEASE_AFTER_QEMPTY     0x08
  589         u_int32_t      openings;
  590         u_int32_t      release_timeout;
  591         u_int32_t      qfrozen_cnt;
  592 };
  593 
  594 /*
  595  * Definitions for the asynchronous callback CCB fields.
  596  */
  597 typedef enum {
  598         AC_GETDEV_CHANGED       = 0x800,/* Getdev info might have changed */
  599         AC_INQ_CHANGED          = 0x400,/* Inquiry info might have changed */
  600         AC_TRANSFER_NEG         = 0x200,/* New transfer settings in effect */
  601         AC_LOST_DEVICE          = 0x100,/* A device went away */
  602         AC_FOUND_DEVICE         = 0x080,/* A new device was found */
  603         AC_PATH_DEREGISTERED    = 0x040,/* A path has de-registered */
  604         AC_PATH_REGISTERED      = 0x020,/* A new path has been registered */
  605         AC_SENT_BDR             = 0x010,/* A BDR message was sent to target */
  606         AC_SCSI_AEN             = 0x008,/* A SCSI AEN has been received */
  607         AC_UNSOL_RESEL          = 0x002,/* Unsolicited reselection occurred */
  608         AC_BUS_RESET            = 0x001 /* A SCSI bus reset occurred */
  609 } ac_code;
  610 
  611 typedef void ac_callback_t (void *softc, u_int32_t code,
  612                             struct cam_path *path, void *args);
  613 
  614 /* Set Asynchronous Callback CCB */
  615 struct ccb_setasync {
  616         struct ccb_hdr   ccb_h;
  617         u_int32_t        event_enable;  /* Async Event enables */       
  618         ac_callback_t   *callback;
  619         void            *callback_arg;
  620 };
  621 
  622 /* Set Device Type CCB */
  623 struct ccb_setdev {
  624         struct     ccb_hdr ccb_h;
  625         u_int8_t   dev_type;    /* Value for dev type field in EDT */
  626 };
  627 
  628 /* SCSI Control Functions */
  629 
  630 /* Abort XPT request CCB */
  631 struct ccb_abort {
  632         struct  ccb_hdr ccb_h;
  633         union   ccb *abort_ccb; /* Pointer to CCB to abort */
  634 };
  635 
  636 /* Reset SCSI Bus CCB */
  637 struct ccb_resetbus {
  638         struct  ccb_hdr ccb_h;
  639 };
  640 
  641 /* Reset SCSI Device CCB */
  642 struct ccb_resetdev {
  643         struct  ccb_hdr ccb_h;
  644 };
  645 
  646 /* Terminate I/O Process Request CCB */
  647 struct ccb_termio {
  648         struct  ccb_hdr ccb_h;
  649         union   ccb *termio_ccb;        /* Pointer to CCB to terminate */
  650 };
  651 
  652 /* Get/Set transfer rate/width/disconnection/tag queueing settings */
  653 struct ccb_trans_settings {
  654         struct  ccb_hdr ccb_h;
  655         u_int   valid;  /* Which fields to honor */
  656 #define CCB_TRANS_SYNC_RATE_VALID       0x01
  657 #define CCB_TRANS_SYNC_OFFSET_VALID     0x02
  658 #define CCB_TRANS_BUS_WIDTH_VALID       0x04
  659 #define CCB_TRANS_DISC_VALID            0x08
  660 #define CCB_TRANS_TQ_VALID              0x10
  661         u_int   flags;
  662 #define CCB_TRANS_CURRENT_SETTINGS      0x01
  663 #define CCB_TRANS_USER_SETTINGS         0x02
  664 #define CCB_TRANS_DISC_ENB              0x04
  665 #define CCB_TRANS_TAG_ENB               0x08
  666         u_int   sync_period;
  667         u_int   sync_offset;
  668         u_int   bus_width;
  669 };
  670 
  671 /*
  672  * Calculate the geometry parameters for a device
  673  * give the block size and volume size in blocks.
  674  */
  675 struct ccb_calc_geometry {
  676         struct    ccb_hdr ccb_h;
  677         u_int32_t block_size;
  678         u_int32_t volume_size;
  679         u_int16_t cylinders;            
  680         u_int8_t  heads;
  681         u_int8_t  secs_per_track;
  682 };
  683 
  684 /*
  685  * Rescan the given bus, or bus/target/lun
  686  */
  687 struct ccb_rescan {
  688         struct  ccb_hdr ccb_h;
  689         cam_flags       flags;
  690 };
  691 
  692 /*
  693  * Turn on debugging for the given bus, bus/target, or bus/target/lun.
  694  */
  695 struct ccb_debug {
  696         struct  ccb_hdr ccb_h;
  697         cam_debug_flags flags;
  698 };
  699 
  700 /* Target mode structures. */
  701 
  702 struct ccb_en_lun {
  703         struct    ccb_hdr ccb_h;
  704         u_int16_t grp6_len;             /* Group 6 VU CDB length */
  705         u_int16_t grp7_len;             /* Group 7 VU CDB length */
  706         u_int8_t  enable;
  707 };
  708 
  709 struct ccb_immed_notify {
  710         struct    ccb_hdr ccb_h;
  711         struct    scsi_sense_data sense_data;
  712         u_int8_t  sense_len;            /* Number of bytes in sese buffer */
  713         u_int8_t  initiator_id;         /* Id of initiator that selected */
  714         u_int16_t seq_id;               /* Sequence Identifier */
  715         u_int8_t  message_code;         /* Message Code */
  716         u_int8_t  message_args[7];      /* Message Arguments */
  717 };
  718 
  719 struct ccb_notify_ack {
  720         struct    ccb_hdr ccb_h;
  721         u_int16_t seq_id;               /* Sequence identifier */
  722         u_int8_t  event;                /* Event flags */
  723 };
  724 
  725 /* HBA engine structures. */
  726 
  727 typedef enum {
  728         EIT_BUFFER,     /* Engine type: buffer memory */
  729         EIT_LOSSLESS,   /* Engine type: lossless compression */
  730         EIT_LOSSY,      /* Engine type: lossy compression */
  731         EIT_ENCRYPT     /* Engine type: encryption */
  732 } ei_type;
  733 
  734 typedef enum {
  735         EAD_VUNIQUE,    /* Engine algorithm ID: vendor unique */
  736         EAD_LZ1V1,      /* Engine algorithm ID: LZ1 var.1 */
  737         EAD_LZ2V1,      /* Engine algorithm ID: LZ2 var.1 */
  738         EAD_LZ2V2,      /* Engine algorithm ID: LZ2 var.2 */
  739 } ei_algo;
  740 
  741 struct ccb_eng_inq {
  742         struct    ccb_hdr ccb_h;
  743         u_int16_t eng_num;      /* The engine number for this inquiry */
  744         ei_type   eng_type;     /* Returned engine type */
  745         ei_algo   eng_algo;     /* Returned engine algorithm type */
  746         u_int32_t eng_memeory;  /* Returned engine memory size */
  747 };
  748 
  749 struct ccb_eng_exec {   /* This structure must match SCSIIO size */
  750         struct    ccb_hdr ccb_h;
  751         u_int8_t  *pdrv_ptr;    /* Ptr used by the peripheral driver */
  752         u_int8_t  *req_map;     /* Ptr for mapping info on the req. */
  753         u_int8_t  *data_ptr;    /* Pointer to the data buf/SG list */
  754         u_int32_t dxfer_len;    /* Data transfer length */
  755         u_int8_t  *engdata_ptr; /* Pointer to the engine buffer data */
  756         u_int16_t sglist_cnt;   /* Num of scatter gather list entries */
  757         u_int32_t dmax_len;     /* Destination data maximum length */
  758         u_int32_t dest_len;     /* Destination data length */
  759         int32_t   src_resid;    /* Source residual length: 2's comp */
  760         u_int32_t timeout;      /* Timeout value */
  761         u_int16_t eng_num;      /* Engine number for this request */
  762         u_int16_t vu_flags;     /* Vendor Unique flags */
  763 };
  764 
  765 /*
  766  * Definitions for the timeout field in the SCSI I/O CCB.
  767  */
  768 #define CAM_TIME_DEFAULT        0x00000000      /* Use SIM default value */
  769 #define CAM_TIME_INFINITY       0xFFFFFFFF      /* Infinite timeout */
  770 
  771 #define CAM_SUCCESS     0       /* For signaling general success */
  772 #define CAM_FAILURE     1       /* For signaling general failure */
  773 
  774 #define CAM_FALSE       0
  775 #define CAM_TRUE        1
  776 
  777 #define XPT_CCB_INVALID -1      /* for signaling a bad CCB to free */
  778 
  779 /*
  780  * Union of all CCB types for kernel space allocation.  This union should
  781  * never be used for manipulating CCBs - its only use is for the allocation
  782  * and deallocation of raw CCB space and is the return type of xpt_ccb_alloc
  783  * and the argument to xpt_ccb_free.
  784  */
  785 union ccb {
  786         struct  ccb_hdr                 ccb_h;  /* For convenience */
  787         struct  ccb_scsiio              csio;
  788         struct  ccb_getdev              cgd;
  789         struct  ccb_getdevlist          cgdl;
  790         struct  ccb_pathinq             cpi;
  791         struct  ccb_relsim              crs;
  792         struct  ccb_setasync            csa;
  793         struct  ccb_setdev              csd;
  794         struct  ccb_pathstats           cpis;
  795         struct  ccb_getdevstats         cgds;
  796         struct  ccb_dev_match           cdm;
  797         struct  ccb_trans_settings      cts;
  798         struct  ccb_calc_geometry       ccg;    
  799         struct  ccb_abort               cab;
  800         struct  ccb_resetbus            crb;
  801         struct  ccb_resetdev            crd;
  802         struct  ccb_termio              tio;
  803         struct  ccb_accept_tio          atio;
  804         struct  ccb_scsiio              ctio;
  805         struct  ccb_en_lun              cel;
  806         struct  ccb_immed_notify        cin;
  807         struct  ccb_notify_ack          cna;
  808         struct  ccb_eng_inq             cei;
  809         struct  ccb_eng_exec            cee;
  810         struct  ccb_rescan              crcn;
  811         struct  ccb_debug               cdbg;
  812 };
  813 
  814 __BEGIN_DECLS
  815 static __inline void
  816 cam_fill_csio(struct ccb_scsiio *csio, u_int32_t retries,
  817               void (*cbfcnp)(struct cam_periph *, union ccb *),
  818               u_int32_t flags, u_int8_t tag_action,
  819               u_int8_t *data_ptr, u_int32_t dxfer_len,
  820               u_int8_t sense_len, u_int8_t cdb_len,
  821               u_int32_t timeout);
  822 
  823 static __inline void
  824 cam_fill_ctio(struct ccb_scsiio *csio, u_int32_t retries,
  825               void (*cbfcnp)(struct cam_periph *, union ccb *),
  826               u_int32_t flags, u_int tag_action, u_int tag_id,
  827               u_int init_id, u_int scsi_status, u_int8_t *data_ptr,
  828               u_int32_t dxfer_len, u_int32_t timeout);
  829         
  830 static __inline void
  831 cam_fill_csio(struct ccb_scsiio *csio, u_int32_t retries,
  832               void (*cbfcnp)(struct cam_periph *, union ccb *),
  833               u_int32_t flags, u_int8_t tag_action,
  834               u_int8_t *data_ptr, u_int32_t dxfer_len,
  835               u_int8_t sense_len, u_int8_t cdb_len,
  836               u_int32_t timeout)
  837 {
  838         csio->ccb_h.func_code = XPT_SCSI_IO;
  839         csio->ccb_h.flags = flags;
  840         csio->ccb_h.retry_count = retries;      
  841         csio->ccb_h.cbfcnp = cbfcnp;
  842         csio->ccb_h.timeout = timeout;
  843         csio->data_ptr = data_ptr;
  844         csio->dxfer_len = dxfer_len;
  845         csio->sense_len = sense_len;
  846         csio->cdb_len = cdb_len;
  847         csio->tag_action = tag_action;
  848 }
  849 
  850 static __inline void
  851 cam_fill_ctio(struct ccb_scsiio *csio, u_int32_t retries,
  852               void (*cbfcnp)(struct cam_periph *, union ccb *),
  853               u_int32_t flags, u_int tag_action, u_int tag_id,
  854               u_int init_id, u_int scsi_status, u_int8_t *data_ptr,
  855               u_int32_t dxfer_len, u_int32_t timeout)
  856 {
  857         csio->ccb_h.func_code = XPT_CONT_TARGET_IO;
  858         csio->ccb_h.flags = flags;
  859         csio->ccb_h.retry_count = retries;      
  860         csio->ccb_h.cbfcnp = cbfcnp;
  861         csio->ccb_h.timeout = timeout;
  862         csio->data_ptr = data_ptr;
  863         csio->dxfer_len = dxfer_len;
  864         csio->scsi_status = scsi_status;
  865         csio->tag_action = tag_action;
  866         csio->tag_id = tag_id;
  867         csio->init_id = init_id;
  868 }
  869 
  870 __END_DECLS
  871 
  872 #endif /* _CAM_CAM_CCB_H */

Cache object: 90a0514a0067cbe30df04ca44979829c


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.