4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 #ifndef _SYS_SCSI_SCSI_PKT_H
  27 #define _SYS_SCSI_SCSI_PKT_H
  28 
  29 #include <sys/scsi/scsi_types.h>
  30 
  31 #ifdef  __cplusplus
  32 extern "C" {
  33 #endif
  34 
  35 #ifdef  _KERNEL
  36 /*
  37  * SCSI packet definition.
  38  *
  39  *      This structure defines the packet which is allocated by a library
  40  *      function and handed to a target driver. The target driver fills
  41  *      in some information, and passes it to the library for transport
  42  *      to an addressed SCSI device. The host adapter found by
  43  *      the library fills in some other information as the command is
 
  89          * permitted.
  90          */
  91         /* HBA driver only, iff scsi_hba_pkt_alloc(9F)|tran_seup_pkt(9E) used */
  92         uint_t  pkt_cdblen;             /* length of pkt_cdbp */
  93         uint_t  pkt_tgtlen;             /* length of pkt_private */
  94         uint_t  pkt_scblen;             /* lenght of pkt_scbp */
  95 
  96         /* HBA driver only, iff tran_seup_pkt(9E) used */
  97         ddi_dma_handle_t pkt_handle;    /* private */
  98         uint_t  pkt_numcookies;         /* number of DMA cookies */
  99         off_t   pkt_dma_offset;         /* private */
 100         size_t  pkt_dma_len;            /* private */
 101         uint_t  pkt_dma_flags;          /* DMA flags */
 102         ddi_dma_cookie_t *pkt_cookies;  /* array of DMA cookies */
 103 
 104         /* private: iff scsi_pkt_allocated_correctly() */
 105         int     pkt_path_instance;      /* pHCI transport path */
 106 
 107         /* stage-temporary: iff scsi_pkt_allocated_correctly() */
 108         void    *pkt_stmp;              /* temporary for current pkt stage */
 109 
 110 #ifdef  SCSI_SIZE_CLEAN_VERIFY
 111         /*
 112          * Must be last: Building a driver with-and-without
 113          * -DSCSI_SIZE_CLEAN_VERIFY, and checking driver modules for
 114          * differences with a tools like 'wsdiff' allows a developer to verify
 115          * that their driver has no dependencies on scsi*(9S) size.
 116          */
 117         int                     i_pkt_pad[8];
 118 #endif  /* SCSI_SIZE_CLEAN_VERIFY */
 119 };
 120 #endif  /* _KERNEL */
 121 
 122 /*
 123  * Definitions for the pkt_flags field.
 124  */
 125 
 126 /*
 127  * Following defines are generic.
 128  */
 
 
 166  * pkg_flag for TLR
 167  */
 168 #define FLAG_TLR                0x00080000
 169 
 170 
 171 /*
 172  * Following define is for scsi_vhci.
 173  *   NOQUEUE            If pHCI cannot transport the command to the device,
 174  *                      do not queue the pkt in pHCI. Return immediately with
 175  *                      TRAN_BUSY.
 176  *   PATH_INSTANCE      Select specific path (pkt_path_instance).
 177  *                      We need both a pkt_path_instance field and flag bit so
 178  *                      that a retry after a path failure, which sets
 179  *                      pkt_path_instance to failed path, does not select the
 180  *                      failed path.
 181  */
 182 #define FLAG_NOQUEUE            0x80000000
 183 #define FLAG_PKT_PATH_INSTANCE  0x40000000      /* Tell vhci the path to use */
 184 #define FLAG_PKT_COMP_CALLED    0x20000000      /* Set once pkt_comp called */
 185 
 186 /*
 187  * Definitions for the pkt_reason field.
 188  */
 189 
 190 /*
 191  * Following defines are generic.
 192  */
 193 #define CMD_CMPLT       0       /* no transport errors- normal completion */
 194 #define CMD_INCOMPLETE  1       /* transport stopped with not normal state */
 195 #define CMD_DMA_DERR    2       /* dma direction error occurred */
 196 #define CMD_TRAN_ERR    3       /* unspecified transport error */
 197 #define CMD_RESET       4       /* Target completed hard reset sequence */
 198 #define CMD_ABORTED     5       /* Command transport aborted on request */
 199 #define CMD_TIMEOUT     6       /* Command timed out */
 200 #define CMD_DATA_OVR    7       /* Data Overrun */
 201 #define CMD_CMD_OVR     8       /* Command Overrun */
 202 #define CMD_STS_OVR     9       /* Status Overrun */
 203 #define CMD_TERMINATED  22      /* Command transport terminated on request */
 204 #define CMD_TLR_OFF     23      /* don't support TLR */
 205 
  
 | 
 
 
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  *
  25  * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
  26  */
  27 
  28 #ifndef _SYS_SCSI_SCSI_PKT_H
  29 #define _SYS_SCSI_SCSI_PKT_H
  30 
  31 #include <sys/scsi/scsi_types.h>
  32 
  33 #ifdef  __cplusplus
  34 extern "C" {
  35 #endif
  36 
  37 #ifdef  _KERNEL
  38 /*
  39  * SCSI packet definition.
  40  *
  41  *      This structure defines the packet which is allocated by a library
  42  *      function and handed to a target driver. The target driver fills
  43  *      in some information, and passes it to the library for transport
  44  *      to an addressed SCSI device. The host adapter found by
  45  *      the library fills in some other information as the command is
 
  91          * permitted.
  92          */
  93         /* HBA driver only, iff scsi_hba_pkt_alloc(9F)|tran_seup_pkt(9E) used */
  94         uint_t  pkt_cdblen;             /* length of pkt_cdbp */
  95         uint_t  pkt_tgtlen;             /* length of pkt_private */
  96         uint_t  pkt_scblen;             /* lenght of pkt_scbp */
  97 
  98         /* HBA driver only, iff tran_seup_pkt(9E) used */
  99         ddi_dma_handle_t pkt_handle;    /* private */
 100         uint_t  pkt_numcookies;         /* number of DMA cookies */
 101         off_t   pkt_dma_offset;         /* private */
 102         size_t  pkt_dma_len;            /* private */
 103         uint_t  pkt_dma_flags;          /* DMA flags */
 104         ddi_dma_cookie_t *pkt_cookies;  /* array of DMA cookies */
 105 
 106         /* private: iff scsi_pkt_allocated_correctly() */
 107         int     pkt_path_instance;      /* pHCI transport path */
 108 
 109         /* stage-temporary: iff scsi_pkt_allocated_correctly() */
 110         void    *pkt_stmp;              /* temporary for current pkt stage */
 111         hrtime_t pkt_start;
 112         hrtime_t pkt_stop;
 113 
 114 #ifdef  SCSI_SIZE_CLEAN_VERIFY
 115         /*
 116          * Must be last: Building a driver with-and-without
 117          * -DSCSI_SIZE_CLEAN_VERIFY, and checking driver modules for
 118          * differences with a tools like 'wsdiff' allows a developer to verify
 119          * that their driver has no dependencies on scsi*(9S) size.
 120          */
 121         int                     i_pkt_pad[8];
 122 #endif  /* SCSI_SIZE_CLEAN_VERIFY */
 123 };
 124 #endif  /* _KERNEL */
 125 
 126 /*
 127  * Definitions for the pkt_flags field.
 128  */
 129 
 130 /*
 131  * Following defines are generic.
 132  */
 
 
 170  * pkg_flag for TLR
 171  */
 172 #define FLAG_TLR                0x00080000
 173 
 174 
 175 /*
 176  * Following define is for scsi_vhci.
 177  *   NOQUEUE            If pHCI cannot transport the command to the device,
 178  *                      do not queue the pkt in pHCI. Return immediately with
 179  *                      TRAN_BUSY.
 180  *   PATH_INSTANCE      Select specific path (pkt_path_instance).
 181  *                      We need both a pkt_path_instance field and flag bit so
 182  *                      that a retry after a path failure, which sets
 183  *                      pkt_path_instance to failed path, does not select the
 184  *                      failed path.
 185  */
 186 #define FLAG_NOQUEUE            0x80000000
 187 #define FLAG_PKT_PATH_INSTANCE  0x40000000      /* Tell vhci the path to use */
 188 #define FLAG_PKT_COMP_CALLED    0x20000000      /* Set once pkt_comp called */
 189 
 190 /* Extended flags. */
 191 #define FLAG_PKT_BUSY           0x04000000      /* Reject packet immediately. */
 192 #define FLAG_PKT_TIMEOUT        0x08000000      /* Timed-out packet. */
 193 
 194 /*
 195  * Definitions for the pkt_reason field.
 196  */
 197 
 198 /*
 199  * Following defines are generic.
 200  */
 201 #define CMD_CMPLT       0       /* no transport errors- normal completion */
 202 #define CMD_INCOMPLETE  1       /* transport stopped with not normal state */
 203 #define CMD_DMA_DERR    2       /* dma direction error occurred */
 204 #define CMD_TRAN_ERR    3       /* unspecified transport error */
 205 #define CMD_RESET       4       /* Target completed hard reset sequence */
 206 #define CMD_ABORTED     5       /* Command transport aborted on request */
 207 #define CMD_TIMEOUT     6       /* Command timed out */
 208 #define CMD_DATA_OVR    7       /* Data Overrun */
 209 #define CMD_CMD_OVR     8       /* Command Overrun */
 210 #define CMD_STS_OVR     9       /* Status Overrun */
 211 #define CMD_TERMINATED  22      /* Command transport terminated on request */
 212 #define CMD_TLR_OFF     23      /* don't support TLR */
 213 
  
 |