diff options
Diffstat (limited to 'freebsd/sys/cam/cam.h')
-rw-r--r-- | freebsd/sys/cam/cam.h | 267 |
1 files changed, 200 insertions, 67 deletions
diff --git a/freebsd/sys/cam/cam.h b/freebsd/sys/cam/cam.h index ba0e43c7..5eb0a776 100644 --- a/freebsd/sys/cam/cam.h +++ b/freebsd/sys/cam/cam.h @@ -43,12 +43,18 @@ typedef u_int path_id_t; typedef u_int target_id_t; -typedef u_int lun_id_t; +typedef u_int64_t lun_id_t; #define CAM_XPT_PATH_ID ((path_id_t)~0) #define CAM_BUS_WILDCARD ((path_id_t)~0) #define CAM_TARGET_WILDCARD ((target_id_t)~0) -#define CAM_LUN_WILDCARD ((lun_id_t)~0) +#define CAM_LUN_WILDCARD (~(u_int)0) + +#define CAM_EXTLUN_BYTE_SWIZZLE(lun) ( \ + ((((u_int64_t)lun) & 0xffff000000000000L) >> 48) | \ + ((((u_int64_t)lun) & 0x0000ffff00000000L) >> 16) | \ + ((((u_int64_t)lun) & 0x00000000ffff0000L) << 16) | \ + ((((u_int64_t)lun) & 0x000000000000ffffL) << 48)) /* * Maximum length for a CAM CDB. @@ -75,7 +81,7 @@ typedef enum { CAM_RL_VALUES } cam_rl; /* - * The generation number is incremented everytime a new entry is entered into + * The generation number is incremented every time a new entry is entered into * the queue giving round robin per priority level scheduling. */ typedef struct { @@ -116,7 +122,7 @@ typedef enum { enum { SF_RETRY_UA = 0x01, /* Retry UNIT ATTENTION conditions. */ SF_NO_PRINT = 0x02, /* Never print error status. */ - SF_QUIET_IR = 0x04, /* Be quiet about Illegal Request reponses */ + SF_QUIET_IR = 0x04, /* Be quiet about Illegal Request responses */ SF_PRINT_ALWAYS = 0x08, /* Always print error status. */ SF_NO_RECOVERY = 0x10, /* Don't do active error recovery. */ SF_NO_RETRY = 0x20, /* Don't do any retries. */ @@ -125,69 +131,184 @@ enum { /* CAM Status field values */ typedef enum { - CAM_REQ_INPROG, /* CCB request is in progress */ - CAM_REQ_CMP, /* CCB request completed without error */ - CAM_REQ_ABORTED, /* CCB request aborted by the host */ - CAM_UA_ABORT, /* Unable to abort CCB request */ - CAM_REQ_CMP_ERR, /* CCB request completed with an error */ - CAM_BUSY, /* CAM subsystem is busy */ - CAM_REQ_INVALID, /* CCB request was invalid */ - CAM_PATH_INVALID, /* Supplied Path ID is invalid */ - CAM_DEV_NOT_THERE, /* SCSI Device Not Installed/there */ - CAM_UA_TERMIO, /* Unable to terminate I/O CCB request */ - CAM_SEL_TIMEOUT, /* Target Selection Timeout */ - CAM_CMD_TIMEOUT, /* Command timeout */ - CAM_SCSI_STATUS_ERROR, /* SCSI error, look at error code in CCB */ - CAM_MSG_REJECT_REC, /* Message Reject Received */ - CAM_SCSI_BUS_RESET, /* SCSI Bus Reset Sent/Received */ - CAM_UNCOR_PARITY, /* Uncorrectable parity error occurred */ - CAM_AUTOSENSE_FAIL = 0x10,/* Autosense: request sense cmd fail */ - CAM_NO_HBA, /* No HBA Detected error */ - CAM_DATA_RUN_ERR, /* Data Overrun error */ - CAM_UNEXP_BUSFREE, /* Unexpected Bus Free */ - CAM_SEQUENCE_FAIL, /* Target Bus Phase Sequence Failure */ - CAM_CCB_LEN_ERR, /* CCB length supplied is inadequate */ - CAM_PROVIDE_FAIL, /* Unable to provide requested capability */ - CAM_BDR_SENT, /* A SCSI BDR msg was sent to target */ - CAM_REQ_TERMIO, /* CCB request terminated by the host */ - CAM_UNREC_HBA_ERROR, /* Unrecoverable Host Bus Adapter Error */ - CAM_REQ_TOO_BIG, /* The request was too large for this host */ - CAM_REQUEUE_REQ, /* - * This request should be requeued to preserve - * transaction ordering. This typically occurs - * when the SIM recognizes an error that should - * freeze the queue and must place additional - * requests for the target at the sim level - * back into the XPT queue. - */ - CAM_ATA_STATUS_ERROR, /* ATA error, look at error code in CCB */ - CAM_SCSI_IT_NEXUS_LOST, /* Initiator/Target Nexus lost. */ - CAM_SMP_STATUS_ERROR, /* SMP error, look at error code in CCB */ - CAM_IDE = 0x33, /* Initiator Detected Error */ - CAM_RESRC_UNAVAIL, /* Resource Unavailable */ - CAM_UNACKED_EVENT, /* Unacknowledged Event by Host */ - CAM_MESSAGE_RECV, /* Message Received in Host Target Mode */ - CAM_INVALID_CDB, /* Invalid CDB received in Host Target Mode */ - CAM_LUN_INVALID, /* Lun supplied is invalid */ - CAM_TID_INVALID, /* Target ID supplied is invalid */ - CAM_FUNC_NOTAVAIL, /* The requested function is not available */ - CAM_NO_NEXUS, /* Nexus is not established */ - CAM_IID_INVALID, /* The initiator ID is invalid */ - CAM_CDB_RECVD, /* The SCSI CDB has been received */ - CAM_LUN_ALRDY_ENA, /* The LUN is already enabled for target mode */ - CAM_SCSI_BUSY, /* SCSI Bus Busy */ - - CAM_DEV_QFRZN = 0x40, /* The DEV queue is frozen w/this err */ - - /* Autosense data valid for target */ - CAM_AUTOSNS_VALID = 0x80, - CAM_RELEASE_SIMQ = 0x100,/* SIM ready to take more commands */ - CAM_SIM_QUEUED = 0x200,/* SIM has this command in it's queue */ - - CAM_STATUS_MASK = 0x3F, /* Mask bits for just the status # */ - - /* Target Specific Adjunct Status */ - CAM_SENT_SENSE = 0x40000000 /* sent sense with status */ + /* CCB request is in progress */ + CAM_REQ_INPROG = 0x00, + + /* CCB request completed without error */ + CAM_REQ_CMP = 0x01, + + /* CCB request aborted by the host */ + CAM_REQ_ABORTED = 0x02, + + /* Unable to abort CCB request */ + CAM_UA_ABORT = 0x03, + + /* CCB request completed with an error */ + CAM_REQ_CMP_ERR = 0x04, + + /* CAM subsystem is busy */ + CAM_BUSY = 0x05, + + /* CCB request was invalid */ + CAM_REQ_INVALID = 0x06, + + /* Supplied Path ID is invalid */ + CAM_PATH_INVALID = 0x07, + + /* SCSI Device Not Installed/there */ + CAM_DEV_NOT_THERE = 0x08, + + /* Unable to terminate I/O CCB request */ + CAM_UA_TERMIO = 0x09, + + /* Target Selection Timeout */ + CAM_SEL_TIMEOUT = 0x0a, + + /* Command timeout */ + CAM_CMD_TIMEOUT = 0x0b, + + /* SCSI error, look at error code in CCB */ + CAM_SCSI_STATUS_ERROR = 0x0c, + + /* Message Reject Received */ + CAM_MSG_REJECT_REC = 0x0d, + + /* SCSI Bus Reset Sent/Received */ + CAM_SCSI_BUS_RESET = 0x0e, + + /* Uncorrectable parity error occurred */ + CAM_UNCOR_PARITY = 0x0f, + + /* Autosense: request sense cmd fail */ + CAM_AUTOSENSE_FAIL = 0x10, + + /* No HBA Detected error */ + CAM_NO_HBA = 0x11, + + /* Data Overrun error */ + CAM_DATA_RUN_ERR = 0x12, + + /* Unexpected Bus Free */ + CAM_UNEXP_BUSFREE = 0x13, + + /* Target Bus Phase Sequence Failure */ + CAM_SEQUENCE_FAIL = 0x14, + + /* CCB length supplied is inadequate */ + CAM_CCB_LEN_ERR = 0x15, + + /* Unable to provide requested capability*/ + CAM_PROVIDE_FAIL = 0x16, + + /* A SCSI BDR msg was sent to target */ + CAM_BDR_SENT = 0x17, + + /* CCB request terminated by the host */ + CAM_REQ_TERMIO = 0x18, + + /* Unrecoverable Host Bus Adapter Error */ + CAM_UNREC_HBA_ERROR = 0x19, + + /* Request was too large for this host */ + CAM_REQ_TOO_BIG = 0x1a, + + /* + * This request should be requeued to preserve + * transaction ordering. This typically occurs + * when the SIM recognizes an error that should + * freeze the queue and must place additional + * requests for the target at the sim level + * back into the XPT queue. + */ + CAM_REQUEUE_REQ = 0x1b, + + /* ATA error, look at error code in CCB */ + CAM_ATA_STATUS_ERROR = 0x1c, + + /* Initiator/Target Nexus lost. */ + CAM_SCSI_IT_NEXUS_LOST = 0x1d, + + /* SMP error, look at error code in CCB */ + CAM_SMP_STATUS_ERROR = 0x1e, + + /* + * Command completed without error but exceeded the soft + * timeout threshold. + */ + CAM_REQ_SOFTTIMEOUT = 0x1f, + + /* + * 0x20 - 0x32 are unassigned + */ + + /* Initiator Detected Error */ + CAM_IDE = 0x33, + + /* Resource Unavailable */ + CAM_RESRC_UNAVAIL = 0x34, + + /* Unacknowledged Event by Host */ + CAM_UNACKED_EVENT = 0x35, + + /* Message Received in Host Target Mode */ + CAM_MESSAGE_RECV = 0x36, + + /* Invalid CDB received in Host Target Mode */ + CAM_INVALID_CDB = 0x37, + + /* Lun supplied is invalid */ + CAM_LUN_INVALID = 0x38, + + /* Target ID supplied is invalid */ + CAM_TID_INVALID = 0x39, + + /* The requested function is not available */ + CAM_FUNC_NOTAVAIL = 0x3a, + + /* Nexus is not established */ + CAM_NO_NEXUS = 0x3b, + + /* The initiator ID is invalid */ + CAM_IID_INVALID = 0x3c, + + /* The SCSI CDB has been received */ + CAM_CDB_RECVD = 0x3d, + + /* The LUN is already enabled for target mode */ + CAM_LUN_ALRDY_ENA = 0x3e, + + /* SCSI Bus Busy */ + CAM_SCSI_BUSY = 0x3f, + + + /* + * Flags + */ + + /* The DEV queue is frozen w/this err */ + CAM_DEV_QFRZN = 0x40, + + /* Autosense data valid for target */ + CAM_AUTOSNS_VALID = 0x80, + + /* SIM ready to take more commands */ + CAM_RELEASE_SIMQ = 0x100, + + /* SIM has this command in it's queue */ + CAM_SIM_QUEUED = 0x200, + + /* Quality of service data is valid */ + CAM_QOS_VALID = 0x400, + + /* Mask bits for just the status # */ + CAM_STATUS_MASK = 0x3F, + + /* + * Target Specific Adjunct Status + */ + + /* sent sense with status */ + CAM_SENT_SENSE = 0x40000000 } cam_status; typedef enum { @@ -225,6 +346,15 @@ typedef enum { CAM_EAF_PRINT_RESULT = 0x20 } cam_error_ata_flags; +typedef enum { + CAM_STRVIS_FLAG_NONE = 0x00, + CAM_STRVIS_FLAG_NONASCII_MASK = 0x03, + CAM_STRVIS_FLAG_NONASCII_TRIM = 0x00, + CAM_STRVIS_FLAG_NONASCII_RAW = 0x01, + CAM_STRVIS_FLAG_NONASCII_SPC = 0x02, + CAM_STRVIS_FLAG_NONASCII_ESC = 0x03 +} cam_strvis_flags; + struct cam_status_entry { cam_status status_code; @@ -237,6 +367,7 @@ extern const int num_cam_status_entries; extern int cam_sort_io_queues; #endif union ccb; +struct sbuf; #ifdef SYSCTL_DECL /* from sysctl.h */ SYSCTL_DECL(_kern_cam); @@ -249,6 +380,8 @@ caddr_t cam_quirkmatch(caddr_t target, caddr_t quirk_table, int num_entries, int entry_size, cam_quirkmatch_t *comp_func); void cam_strvis(u_int8_t *dst, const u_int8_t *src, int srclen, int dstlen); +void cam_strvis_sbuf(struct sbuf *sb, const u_int8_t *src, int srclen, + uint32_t flags); int cam_strmatch(const u_int8_t *str, const u_int8_t *pattern, int str_len); const struct cam_status_entry* |