1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright (c) 1995,1997-1998 by Sun Microsystems, Inc. 24 * All rights reserved. 25 */ 26 27 #ifndef _SYS_FC4_FCP_H 28 #define _SYS_FC4_FCP_H 29 30 /* 31 * Frame format and protocol definitions for transferring 32 * commands and data between a SCSI initiator and target 33 * using an FC4 serial link interface. 34 */ 35 36 #ifdef __cplusplus 37 extern "C" { 38 #endif 39 40 41 /* 42 * FCP Device Data Frame Information Categories 43 */ 44 #define FCP_SCSI_DATA 0x01 /* frame contains SCSI data */ 45 #define FCP_SCSI_CMD 0x02 /* frame contains SCSI command */ 46 #define FCP_SCSI_RSP 0x03 /* frame contains SCSI response */ 47 #define FCP_SCSI_XFER_RDY 0x05 /* frame contains xfer rdy block */ 48 49 50 /* 51 * FCP SCSI Control structure 52 */ 53 typedef struct fcp_cntl { 54 uchar_t cntl_reserved_0; /* reserved */ 55 uchar_t cntl_reserved_1 : 5, /* reserved */ 56 cntl_qtype : 3; /* tagged queueing type */ 57 uchar_t cntl_kill_tsk : 1, /* terminate task */ 58 cntl_clr_aca : 1, /* clear aca */ 59 cntl_reset : 1, /* reset */ 60 cntl_reserved_2 : 2, /* reserved */ 61 cntl_clr_tsk : 1, /* clear task set */ 62 cntl_abort_tsk : 1, /* abort task set */ 63 cntl_reserved_3 : 1; /* reserved */ 64 uchar_t cntl_reserved_4 : 6, /* reserved */ 65 cntl_read_data : 1, /* initiator read */ 66 cntl_write_data : 1; /* initiator write */ 67 } fcp_cntl_t; 68 69 /* 70 * FCP SCSI Control Tagged Queueing types - cntl_qtype 71 */ 72 #define FCP_QTYPE_SIMPLE 0 /* simple queueing */ 73 #define FCP_QTYPE_HEAD_OF_Q 1 /* head of queue */ 74 #define FCP_QTYPE_ORDERED 2 /* ordered queueing */ 75 #define FCP_QTYPE_ACA_Q_TAG 4 /* ACA queueing */ 76 #define FCP_QTYPE_UNTAGGED 5 /* Untagged */ 77 78 79 /* 80 * FCP SCSI Entity Address 81 * 82 * ent_addr_0 is always the first and highest layer of 83 * the hierarchy. The depth of the hierarchy of addressing, 84 * up to a maximum of four layers, is arbitrary and 85 * device-dependent. 86 */ 87 typedef struct fcp_ent_addr { 88 ushort_t ent_addr_0; /* entity address 0 */ 89 ushort_t ent_addr_1; /* entity address 1 */ 90 ushort_t ent_addr_2; /* entity address 2 */ 91 ushort_t ent_addr_3; /* entity address 3 */ 92 } fcp_ent_addr_t; 93 94 95 /* 96 * Maximum size of SCSI cdb in FCP SCSI command 97 */ 98 #define FCP_CDB_SIZE 16 99 #define FCP_LUN_SIZE 8 100 101 /* 102 * FCP SCSI command payload 103 */ 104 typedef struct fcp_cmd { 105 fcp_ent_addr_t fcp_ent_addr; /* entity address */ 106 fcp_cntl_t fcp_cntl; /* SCSI options */ 107 uchar_t fcp_cdb[FCP_CDB_SIZE]; /* SCSI cdb */ 108 int fcp_data_len; /* data length */ 109 } fcp_cmd_t; 110 111 112 /* 113 * FCP SCSI status 114 */ 115 typedef struct fcp_status { 116 ushort_t reserved_0; /* reserved */ 117 uchar_t reserved_1 : 4, /* reserved */ 118 resid_under : 1, /* resid non-zero */ 119 resid_over : 1, /* resid non-zero */ 120 sense_len_set : 1, /* sense_len non-zero */ 121 rsp_len_set : 1; /* response_len non-zero */ 122 uchar_t scsi_status; /* status of cmd */ 123 } fcp_status_t; 124 125 #define resid_len_set resid_over /* for pln */ 126 127 128 /* 129 * FCP SCSI Response Payload 130 */ 131 typedef struct fcp_rsp { 132 uint_t reserved_0; /* reserved */ 133 uint_t reserved_1; /* reserved */ 134 union { 135 fcp_status_t fcp_status; /* command status */ 136 uint_t i_fcp_status; 137 }fcp_u; 138 uint_t fcp_resid; /* resid of operation */ 139 uint_t fcp_sense_len; /* sense data length */ 140 uint_t fcp_response_len; /* response data length */ 141 /* 142 * 'm' bytes of scsi response info follow 143 * 'n' bytes of scsi sense info follow 144 */ 145 } fcp_rsp_t; 146 147 #define FCP_MAX_RSP_IU_SIZE 256 148 149 /* 150 * FCP RSP_INFO field format 151 */ 152 153 struct fcp_rsp_info { 154 uchar_t resvd1; 155 uchar_t resvd2; 156 uchar_t resvd3; 157 uchar_t rsp_code; 158 uchar_t resvd4; 159 uchar_t resvd5; 160 uchar_t resvd6; 161 uchar_t resvd7; 162 }; 163 164 /* RSP_CODE definitions */ 165 166 #define FCP_NO_FAILURE 0x0 167 #define FCP_DL_LEN_MISMATCH 0x1 168 #define FCP_CMND_INVALID 0x2 169 #define FCP_DATA_RO_MISMATCH 0x3 170 #define FCP_TASK_MGMT_NOT_SUPPTD 0x4 171 #define FCP_TASK_MGMT_FAILED 0x5 172 173 174 /* 175 * FCP SCSI_ XFER_RDY Payload 176 */ 177 typedef struct fcp_xfer_rdy { 178 ulong_t fcp_seq_offset; /* relative offset */ 179 ulong_t fcp_burst_len; /* buffer space */ 180 ulong_t reserved; /* reserved */ 181 } fcp_xfer_rdy_t; 182 183 /* 184 * FCP PRLI Payload 185 */ 186 187 struct fcp_prli { 188 uchar_t type; 189 uchar_t resvd1; 190 uint_t orig_process_assoc_valid:1; 191 uint_t resp_process_assoc_valid:1; 192 uint_t establish_image_pair:1; 193 uint_t resvd2:13; 194 uint_t orig_process_associator; 195 uint_t resp_process_associator; 196 uint_t resvd3:25; 197 uint_t data_overlay_allowed:1; 198 uint_t initiator_fn:1; 199 uint_t target_fn:1; 200 uint_t cmd_data_mixed:1; 201 uint_t data_resp_mixed:1; 202 uint_t read_xfer_rdy_disabled:1; 203 uint_t write_xfer_rdy_disabled:1; 204 }; 205 206 /* 207 * FCP PRLI ACC Payload 208 */ 209 210 struct fcp_prli_acc { 211 uchar_t type; 212 uchar_t resvd1; 213 uint_t orig_process_assoc_valid:1; 214 uint_t resp_process_assoc_valid:1; 215 uint_t image_pair_establsihed:1; 216 uint_t resvd2:1; 217 uint_t accept_response_code:4; 218 uint_t resvd3:8; 219 uint_t orig_process_associator; 220 uint_t resp_process_associator; 221 uint_t resvd4:26; 222 uint_t initiator_fn:1; 223 uint_t target_fn:1; 224 uint_t cmd_data_mixed:1; 225 uint_t data_resp_mixed:1; 226 uint_t read_xfer_rdy_disabled:1; 227 uint_t write_xfer_rdy_disabled:1; 228 }; 229 230 231 #ifdef __cplusplus 232 } 233 #endif 234 235 #endif /* _SYS_FC4_FCP_H */ 236