Print this page
5007142 Add ntohll and htonll to sys/byteorder.h
6717509 Need to use bswap/bswapq for byte swap of 64-bit integer on x32/x64
PSARC 2008/474


  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 /*
  23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 #ifndef _T10_SPC_H
  28 #define _T10_SPC_H
  29 
  30 #pragma ident   "%Z%%M% %I%     %E% SMI"
  31 
  32 #ifdef __cplusplus
  33 extern "C" {
  34 #endif
  35 
  36 /*
  37  * []------------------------------------------------------------------[]
  38  * | SPC-3                                                              |
  39  * []------------------------------------------------------------------[]
  40  */
  41 
  42 /*
  43  * FIXED_SENSE_ADDL_INFO_LEN is the length of INFORMATION field
  44  * in fixed format sense data
  45  */
  46 #define FIXED_SENSE_ADDL_INFO_LEN 0xFFFFFFFF
  47 #define INFORMATION_SENSE_DESCR sizeof (struct scsi_information_sense_descr)
  48 


  49 #include <sys/scsi/generic/inquiry.h>
  50 #include <sys/scsi/generic/mode.h>
  51 
  52 /*
  53  * SPC Command Functions
  54  */
  55 void spc_tur(struct t10_cmd *cmd, uint8_t *cdb, size_t cdb_len);
  56 void spc_request_sense(struct t10_cmd *cmd, uint8_t *cdb, size_t cdb_len);
  57 void spc_unsupported(struct t10_cmd *cmd, uint8_t *cdb, size_t cdb_len);
  58 void spc_inquiry(t10_cmd_t *cmd, uint8_t *cdb, size_t cdb_len);
  59 void spc_mselect(t10_cmd_t *cmd, uint8_t *cdb, size_t cdb_len);
  60 void spc_mselect_data(t10_cmd_t *cmd, emul_handle_t id, size_t offset,
  61     char *data, size_t data_len);
  62 void spc_report_luns(t10_cmd_t *cmd, uint8_t *cdb, size_t cdb_len);
  63 void spc_report_tpgs(t10_cmd_t *cmd, uint8_t *cdb, size_t cdb_len);
  64 void spc_msense(t10_cmd_t *cmd, uint8_t *cdb, size_t cdb_len);
  65 void spc_startstop(t10_cmd_t *cmd, uint8_t *cdb, size_t cdb_len);
  66 void spc_send_diag(t10_cmd_t *cmd, uint8_t *cdb, size_t cdb_len);
  67 
  68 /*
  69  * SPC Support Functions
  70  */
  71 void spc_cmd_offline(t10_cmd_t *cmd, uint8_t *cdb, size_t cdb_len);
  72 void spc_sense_create(struct t10_cmd *cmd, int sense_key, int addl_sense_len);
  73 void spc_sense_ascq(struct t10_cmd *cmd, int asc, int ascq);
  74 void spc_sense_info(t10_cmd_t *cmd, uint64_t info);
  75 void spc_sense_flags(t10_cmd_t *cmd, int flags);
  76 void spc_sense_raw(t10_cmd_t *cmd, uchar_t *sense_buf, size_t sense_len);
  77 Boolean_t spc_decode_lu_addr(uint8_t *buf, int len, uint32_t *val);
  78 Boolean_t spc_encode_lu_addr(uint8_t *buf, int select_field, uint32_t lun);
  79 
  80 /*
  81  * SPC flags to use when setting various sense code flags
  82  */
  83 #define SPC_SENSE_EOM   0x01
  84 #define SPC_SENSE_FM    0x02
  85 #define SPC_SENSE_ILI   0x04
  86 
  87 #ifdef _BIG_ENDIAN
  88 #define htonll(x)   (x)
  89 #define ntohll(x)   (x)
  90 #else
  91 #define htonll(x)   ((((unsigned long long)htonl(x & 0xffffffff)) << 32) + \
  92                     htonl(x >> 32))
  93 #define ntohll(x)   ((((unsigned long long)ntohl(x)) << 32) + ntohl(x >> 32))
  94 #endif
  95 
  96 /*
  97  * []------------------------------------------------------------------[]
  98  * | SPC-3, revision 21c -- ASC/ASCQ values                             |
  99  * | The full tables can be found in Appendix D (numerical order) or    |
 100  * | section 4.5.6 (alphabetical order). There are close to fifteen     |
 101  * | pages of values which will not be included here. Only those used   |
 102  * | by the code.                                                       |
 103  * []------------------------------------------------------------------[]
 104  */
 105 #define SPC_ASC_FM_DETECTED     0x00 /* file-mark detected */
 106 #define SPC_ASCQ_FM_DETECTED    0x01
 107 
 108 #define SPC_ASC_EOP             0x00 /* end-of-partition/medium detected */
 109 #define SPC_ASCQ_EOP            0x02
 110 
 111 #define SPC_ASC_IN_PROG         0x04
 112 #define SPC_ASCQ_IN_PROG        0x07
 113 
 114 #define SPC_ASC_WRITE_ERROR     0x0c
 115 #define SPC_ASCQ_WRITE_ERROR    0x00




  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 /*
  23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 #ifndef _T10_SPC_H
  28 #define _T10_SPC_H
  29 


  30 #ifdef __cplusplus
  31 extern "C" {
  32 #endif
  33 
  34 /*
  35  * []------------------------------------------------------------------[]
  36  * | SPC-3                                                              |
  37  * []------------------------------------------------------------------[]
  38  */
  39 
  40 /*
  41  * FIXED_SENSE_ADDL_INFO_LEN is the length of INFORMATION field
  42  * in fixed format sense data
  43  */
  44 #define FIXED_SENSE_ADDL_INFO_LEN 0xFFFFFFFF
  45 #define INFORMATION_SENSE_DESCR sizeof (struct scsi_information_sense_descr)
  46 
  47 #include <sys/types.h>
  48 #include <netinet/in.h>
  49 #include <sys/scsi/generic/inquiry.h>
  50 #include <sys/scsi/generic/mode.h>
  51 
  52 /*
  53  * SPC Command Functions
  54  */
  55 void spc_tur(struct t10_cmd *cmd, uint8_t *cdb, size_t cdb_len);
  56 void spc_request_sense(struct t10_cmd *cmd, uint8_t *cdb, size_t cdb_len);
  57 void spc_unsupported(struct t10_cmd *cmd, uint8_t *cdb, size_t cdb_len);
  58 void spc_inquiry(t10_cmd_t *cmd, uint8_t *cdb, size_t cdb_len);
  59 void spc_mselect(t10_cmd_t *cmd, uint8_t *cdb, size_t cdb_len);
  60 void spc_mselect_data(t10_cmd_t *cmd, emul_handle_t id, size_t offset,
  61     char *data, size_t data_len);
  62 void spc_report_luns(t10_cmd_t *cmd, uint8_t *cdb, size_t cdb_len);
  63 void spc_report_tpgs(t10_cmd_t *cmd, uint8_t *cdb, size_t cdb_len);
  64 void spc_msense(t10_cmd_t *cmd, uint8_t *cdb, size_t cdb_len);
  65 void spc_startstop(t10_cmd_t *cmd, uint8_t *cdb, size_t cdb_len);
  66 void spc_send_diag(t10_cmd_t *cmd, uint8_t *cdb, size_t cdb_len);
  67 
  68 /*
  69  * SPC Support Functions
  70  */
  71 void spc_cmd_offline(t10_cmd_t *cmd, uint8_t *cdb, size_t cdb_len);
  72 void spc_sense_create(struct t10_cmd *cmd, int sense_key, int addl_sense_len);
  73 void spc_sense_ascq(struct t10_cmd *cmd, int asc, int ascq);
  74 void spc_sense_info(t10_cmd_t *cmd, uint64_t info);
  75 void spc_sense_flags(t10_cmd_t *cmd, int flags);
  76 void spc_sense_raw(t10_cmd_t *cmd, uchar_t *sense_buf, size_t sense_len);
  77 Boolean_t spc_decode_lu_addr(uint8_t *buf, int len, uint32_t *val);
  78 Boolean_t spc_encode_lu_addr(uint8_t *buf, int select_field, uint32_t lun);
  79 
  80 /*
  81  * SPC flags to use when setting various sense code flags
  82  */
  83 #define SPC_SENSE_EOM   0x01
  84 #define SPC_SENSE_FM    0x02
  85 #define SPC_SENSE_ILI   0x04
  86 









  87 /*
  88  * []------------------------------------------------------------------[]
  89  * | SPC-3, revision 21c -- ASC/ASCQ values                             |
  90  * | The full tables can be found in Appendix D (numerical order) or    |
  91  * | section 4.5.6 (alphabetical order). There are close to fifteen     |
  92  * | pages of values which will not be included here. Only those used   |
  93  * | by the code.                                                       |
  94  * []------------------------------------------------------------------[]
  95  */
  96 #define SPC_ASC_FM_DETECTED     0x00 /* file-mark detected */
  97 #define SPC_ASCQ_FM_DETECTED    0x01
  98 
  99 #define SPC_ASC_EOP             0x00 /* end-of-partition/medium detected */
 100 #define SPC_ASCQ_EOP            0x02
 101 
 102 #define SPC_ASC_IN_PROG         0x04
 103 #define SPC_ASCQ_IN_PROG        0x07
 104 
 105 #define SPC_ASC_WRITE_ERROR     0x0c
 106 #define SPC_ASCQ_WRITE_ERROR    0x00