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.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 the CAM system.
    3  *
    4  * Copyright (c) 1997 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: releng/8.2/sys/cam/cam.h 203889 2010-02-14 19:38:27Z mav $
   29  */
   30 
   31 #ifndef _CAM_CAM_H
   32 #define _CAM_CAM_H 1
   33 
   34 #ifdef _KERNEL
   35 #include <opt_cam.h>
   36 #endif
   37 
   38 #include <sys/cdefs.h>
   39 
   40 typedef u_int path_id_t;
   41 typedef u_int target_id_t;
   42 typedef u_int lun_id_t;
   43 
   44 #define CAM_XPT_PATH_ID ((path_id_t)~0)
   45 #define CAM_BUS_WILDCARD ((path_id_t)~0)
   46 #define CAM_TARGET_WILDCARD ((target_id_t)~0)
   47 #define CAM_LUN_WILDCARD ((lun_id_t)~0)
   48 
   49 /*
   50  * Maximum length for a CAM CDB.  
   51  */
   52 #define CAM_MAX_CDBLEN 16
   53 
   54 /*
   55  * Definition of a CAM peripheral driver entry.  Peripheral drivers instantiate
   56  * one of these for each device they wish to communicate with and pass it into
   57  * the xpt layer when they wish to schedule work on that device via the
   58  * xpt_schedule API.
   59  */
   60 struct cam_periph;
   61 
   62 /*
   63  * Priority information for a CAM structure. 
   64  */
   65 typedef enum {
   66     CAM_RL_HOST,
   67     CAM_RL_BUS,
   68     CAM_RL_XPT,
   69     CAM_RL_DEV,
   70     CAM_RL_NORMAL,
   71     CAM_RL_VALUES
   72 } cam_rl;
   73 /*
   74  * The generation number is incremented everytime a new entry is entered into
   75  * the queue giving round robin per priority level scheduling.
   76  */
   77 typedef struct {
   78         u_int32_t priority;
   79 #define CAM_PRIORITY_HOST       ((CAM_RL_HOST << 8) + 0x80)
   80 #define CAM_PRIORITY_BUS        ((CAM_RL_BUS << 8) + 0x80)
   81 #define CAM_PRIORITY_XPT        ((CAM_RL_XPT << 8) + 0x80)
   82 #define CAM_PRIORITY_DEV        ((CAM_RL_DEV << 8) + 0x80)
   83 #define CAM_PRIORITY_NORMAL     ((CAM_RL_NORMAL << 8) + 0x80)
   84 #define CAM_PRIORITY_NONE       (u_int32_t)-1
   85 #define CAM_PRIORITY_TO_RL(x)   ((x) >> 8)
   86         u_int32_t generation;
   87         int       index;
   88 #define CAM_UNQUEUED_INDEX      -1
   89 #define CAM_ACTIVE_INDEX        -2      
   90 #define CAM_DONEQ_INDEX         -3      
   91 } cam_pinfo;
   92 
   93 /*
   94  * Macro to compare two generation numbers.  It is used like this:  
   95  *
   96  *      if (GENERATIONCMP(a, >=, b))
   97  *              ...;
   98  *
   99  * GERERATIONCMP uses modular arithmetic to guard against wraps
  100  * wraps in the generation number.
  101  */
  102 #define GENERATIONCMP(x, op, y) ((int32_t)((x) - (y)) op 0)
  103 
  104 /* CAM flags XXX Move to cam_periph.h ??? */
  105 typedef enum {
  106         CAM_FLAG_NONE           = 0x00,
  107         CAM_EXPECT_INQ_CHANGE   = 0x01,
  108         CAM_RETRY_SELTO         = 0x02 /* Retry Selection Timeouts */
  109 } cam_flags;
  110 
  111 /* CAM  Status field values */
  112 typedef enum {
  113         CAM_REQ_INPROG,         /* CCB request is in progress */
  114         CAM_REQ_CMP,            /* CCB request completed without error */
  115         CAM_REQ_ABORTED,        /* CCB request aborted by the host */
  116         CAM_UA_ABORT,           /* Unable to abort CCB request */
  117         CAM_REQ_CMP_ERR,        /* CCB request completed with an error */
  118         CAM_BUSY,               /* CAM subsystem is busy */
  119         CAM_REQ_INVALID,        /* CCB request was invalid */
  120         CAM_PATH_INVALID,       /* Supplied Path ID is invalid */
  121         CAM_DEV_NOT_THERE,      /* SCSI Device Not Installed/there */
  122         CAM_UA_TERMIO,          /* Unable to terminate I/O CCB request */
  123         CAM_SEL_TIMEOUT,        /* Target Selection Timeout */
  124         CAM_CMD_TIMEOUT,        /* Command timeout */
  125         CAM_SCSI_STATUS_ERROR,  /* SCSI error, look at error code in CCB */
  126         CAM_MSG_REJECT_REC,     /* Message Reject Received */
  127         CAM_SCSI_BUS_RESET,     /* SCSI Bus Reset Sent/Received */
  128         CAM_UNCOR_PARITY,       /* Uncorrectable parity error occurred */
  129         CAM_AUTOSENSE_FAIL = 0x10,/* Autosense: request sense cmd fail */
  130         CAM_NO_HBA,             /* No HBA Detected error */
  131         CAM_DATA_RUN_ERR,       /* Data Overrun error */
  132         CAM_UNEXP_BUSFREE,      /* Unexpected Bus Free */
  133         CAM_SEQUENCE_FAIL,      /* Target Bus Phase Sequence Failure */
  134         CAM_CCB_LEN_ERR,        /* CCB length supplied is inadequate */
  135         CAM_PROVIDE_FAIL,       /* Unable to provide requested capability */
  136         CAM_BDR_SENT,           /* A SCSI BDR msg was sent to target */
  137         CAM_REQ_TERMIO,         /* CCB request terminated by the host */
  138         CAM_UNREC_HBA_ERROR,    /* Unrecoverable Host Bus Adapter Error */
  139         CAM_REQ_TOO_BIG,        /* The request was too large for this host */
  140         CAM_REQUEUE_REQ,        /*
  141                                  * This request should be requeued to preserve
  142                                  * transaction ordering.  This typically occurs
  143                                  * when the SIM recognizes an error that should
  144                                  * freeze the queue and must place additional
  145                                  * requests for the target at the sim level
  146                                  * back into the XPT queue.
  147                                  */
  148         CAM_ATA_STATUS_ERROR,   /* ATA error, look at error code in CCB */
  149         CAM_SCSI_IT_NEXUS_LOST, /* Initiator/Target Nexus lost. */
  150         CAM_IDE = 0x33,         /* Initiator Detected Error */
  151         CAM_RESRC_UNAVAIL,      /* Resource Unavailable */
  152         CAM_UNACKED_EVENT,      /* Unacknowledged Event by Host */
  153         CAM_MESSAGE_RECV,       /* Message Received in Host Target Mode */
  154         CAM_INVALID_CDB,        /* Invalid CDB received in Host Target Mode */
  155         CAM_LUN_INVALID,        /* Lun supplied is invalid */
  156         CAM_TID_INVALID,        /* Target ID supplied is invalid */
  157         CAM_FUNC_NOTAVAIL,      /* The requested function is not available */
  158         CAM_NO_NEXUS,           /* Nexus is not established */
  159         CAM_IID_INVALID,        /* The initiator ID is invalid */
  160         CAM_CDB_RECVD,          /* The SCSI CDB has been received */
  161         CAM_LUN_ALRDY_ENA,      /* The LUN is already enabled for target mode */
  162         CAM_SCSI_BUSY,          /* SCSI Bus Busy */
  163 
  164         CAM_DEV_QFRZN = 0x40,   /* The DEV queue is frozen w/this err */
  165 
  166                                 /* Autosense data valid for target */
  167         CAM_AUTOSNS_VALID = 0x80,
  168         CAM_RELEASE_SIMQ = 0x100,/* SIM ready to take more commands */
  169         CAM_SIM_QUEUED   = 0x200,/* SIM has this command in it's queue */
  170 
  171         CAM_STATUS_MASK = 0x3F, /* Mask bits for just the status # */
  172 
  173                                 /* Target Specific Adjunct Status */
  174         CAM_SENT_SENSE = 0x40000000     /* sent sense with status */
  175 } cam_status;
  176 
  177 typedef enum {
  178         CAM_ESF_NONE            = 0x00,
  179         CAM_ESF_COMMAND         = 0x01,
  180         CAM_ESF_CAM_STATUS      = 0x02,
  181         CAM_ESF_PROTO_STATUS    = 0x04,
  182         CAM_ESF_ALL             = 0xff
  183 } cam_error_string_flags;
  184 
  185 typedef enum {
  186         CAM_EPF_NONE            = 0x00,
  187         CAM_EPF_MINIMAL         = 0x01,
  188         CAM_EPF_NORMAL          = 0x02,
  189         CAM_EPF_ALL             = 0x03,
  190         CAM_EPF_LEVEL_MASK      = 0x0f
  191         /* All bits above bit 3 are protocol-specific */
  192 } cam_error_proto_flags;
  193 
  194 typedef enum {
  195         CAM_ESF_PRINT_NONE      = 0x00,
  196         CAM_ESF_PRINT_STATUS    = 0x10,
  197         CAM_ESF_PRINT_SENSE     = 0x20
  198 } cam_error_scsi_flags;
  199 
  200 typedef enum {
  201         CAM_EAF_PRINT_NONE      = 0x00,
  202         CAM_EAF_PRINT_STATUS    = 0x10,
  203         CAM_EAF_PRINT_RESULT    = 0x20
  204 } cam_error_ata_flags;
  205 
  206 struct cam_status_entry
  207 {
  208         cam_status  status_code;
  209         const char *status_text;
  210 };
  211 
  212 extern const struct cam_status_entry cam_status_table[];
  213 extern const int num_cam_status_entries;
  214 union ccb;
  215 
  216 #ifdef SYSCTL_DECL      /* from sysctl.h */
  217 SYSCTL_DECL(_kern_cam);
  218 #endif
  219 
  220 __BEGIN_DECLS
  221 typedef int (cam_quirkmatch_t)(caddr_t, caddr_t);
  222 
  223 caddr_t cam_quirkmatch(caddr_t target, caddr_t quirk_table, int num_entries,
  224                        int entry_size, cam_quirkmatch_t *comp_func);
  225 
  226 void    cam_strvis(u_int8_t *dst, const u_int8_t *src, int srclen, int dstlen);
  227 
  228 int     cam_strmatch(const u_int8_t *str, const u_int8_t *pattern, int str_len);
  229 const struct cam_status_entry*
  230         cam_fetch_status_entry(cam_status status);
  231 #ifdef _KERNEL
  232 char *  cam_error_string(union ccb *ccb, char *str, int str_len,
  233                          cam_error_string_flags flags,
  234                          cam_error_proto_flags proto_flags);
  235 void    cam_error_print(union ccb *ccb, cam_error_string_flags flags,
  236                         cam_error_proto_flags proto_flags);
  237 #else /* _KERNEL */
  238 struct cam_device;
  239 
  240 char *  cam_error_string(struct cam_device *device, union ccb *ccb, char *str,
  241                          int str_len, cam_error_string_flags flags,
  242                          cam_error_proto_flags proto_flags);
  243 void    cam_error_print(struct cam_device *device, union ccb *ccb,
  244                         cam_error_string_flags flags,
  245                         cam_error_proto_flags proto_flags, FILE *ofile);
  246 #endif /* _KERNEL */
  247 __END_DECLS
  248 
  249 #ifdef _KERNEL
  250 static __inline void cam_init_pinfo(cam_pinfo *pinfo);
  251 
  252 static __inline void cam_init_pinfo(cam_pinfo *pinfo)
  253 {
  254         pinfo->priority = CAM_PRIORITY_NONE;    
  255         pinfo->index = CAM_UNQUEUED_INDEX;
  256 }
  257 #endif
  258 
  259 #endif /* _CAM_CAM_H */

Cache object: cef68baaf41b2617d50a6c71dece4ab1


[ 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.