1fcf3ce44SJohn Forte /* 2fcf3ce44SJohn Forte * CDDL HEADER START 3fcf3ce44SJohn Forte * 4fcf3ce44SJohn Forte * The contents of this file are subject to the terms of the 5fcf3ce44SJohn Forte * Common Development and Distribution License (the "License"). 6fcf3ce44SJohn Forte * You may not use this file except in compliance with the License. 7fcf3ce44SJohn Forte * 8fcf3ce44SJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9fcf3ce44SJohn Forte * or http://www.opensolaris.org/os/licensing. 10fcf3ce44SJohn Forte * See the License for the specific language governing permissions 11fcf3ce44SJohn Forte * and limitations under the License. 12fcf3ce44SJohn Forte * 13fcf3ce44SJohn Forte * When distributing Covered Code, include this CDDL HEADER in each 14fcf3ce44SJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15fcf3ce44SJohn Forte * If applicable, add the following below this CDDL HEADER, with the 16fcf3ce44SJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying 17fcf3ce44SJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner] 18fcf3ce44SJohn Forte * 19fcf3ce44SJohn Forte * CDDL HEADER END 20fcf3ce44SJohn Forte */ 21fcf3ce44SJohn Forte /* 22*7ff83669SZhong Wang * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23fcf3ce44SJohn Forte * Use is subject to license terms. 24fcf3ce44SJohn Forte */ 25fcf3ce44SJohn Forte 26fcf3ce44SJohn Forte #ifndef _FCP_H 27fcf3ce44SJohn Forte #define _FCP_H 28fcf3ce44SJohn Forte 29fcf3ce44SJohn Forte /* 30fcf3ce44SJohn Forte * Frame format and protocol definitions for transferring 31fcf3ce44SJohn Forte * commands and data between a SCSI initiator and target 32fcf3ce44SJohn Forte * using an FC4 serial link interface. 33fcf3ce44SJohn Forte * 34fcf3ce44SJohn Forte * this file originally taken from fc4/fcp.h 35fcf3ce44SJohn Forte */ 36fcf3ce44SJohn Forte 37fcf3ce44SJohn Forte #ifdef __cplusplus 38fcf3ce44SJohn Forte extern "C" { 39fcf3ce44SJohn Forte #endif 40fcf3ce44SJohn Forte 41fcf3ce44SJohn Forte #include <sys/types.h> 42fcf3ce44SJohn Forte 43fcf3ce44SJohn Forte 44fcf3ce44SJohn Forte /* 45fcf3ce44SJohn Forte * FCP Device Data Frame Information Categories 46fcf3ce44SJohn Forte */ 47fcf3ce44SJohn Forte #define FCP_SCSI_DATA 0x01 /* frame contains SCSI data */ 48fcf3ce44SJohn Forte #define FCP_SCSI_CMD 0x02 /* frame contains SCSI command */ 49fcf3ce44SJohn Forte #define FCP_SCSI_RSP 0x03 /* frame contains SCSI response */ 50fcf3ce44SJohn Forte #define FCP_SCSI_XFER_RDY 0x05 /* frame contains xfer rdy block */ 51fcf3ce44SJohn Forte 52fcf3ce44SJohn Forte /* 53fcf3ce44SJohn Forte * fcp SCSI control structure 54fcf3ce44SJohn Forte */ 55fcf3ce44SJohn Forte typedef struct fcp_cntl { 56fcf3ce44SJohn Forte 57fcf3ce44SJohn Forte uchar_t cntl_reserved_0; /* reserved */ 58fcf3ce44SJohn Forte 59fcf3ce44SJohn Forte #if defined(_BIT_FIELDS_HTOL) 60fcf3ce44SJohn Forte 61fcf3ce44SJohn Forte uchar_t cntl_reserved_1 : 5, /* reserved */ 62fcf3ce44SJohn Forte cntl_qtype : 3; /* tagged queueing type */ 63fcf3ce44SJohn Forte 64fcf3ce44SJohn Forte uchar_t cntl_kill_tsk : 1, /* terminate task */ 65fcf3ce44SJohn Forte cntl_clr_aca : 1, /* clear aca */ 66fcf3ce44SJohn Forte cntl_reset_tgt : 1, /* reset target */ 67fcf3ce44SJohn Forte cntl_reset_lun : 1, /* reset lun */ 68fcf3ce44SJohn Forte cntl_reserved_2 : 1, /* reserved */ 69fcf3ce44SJohn Forte cntl_clr_tsk : 1, /* clear task set */ 70fcf3ce44SJohn Forte cntl_abort_tsk : 1, /* abort task set */ 71fcf3ce44SJohn Forte cntl_reserved_3 : 1; /* reserved */ 72fcf3ce44SJohn Forte 73fcf3ce44SJohn Forte uchar_t cntl_reserved_4 : 6, /* reserved */ 74fcf3ce44SJohn Forte cntl_read_data : 1, /* initiator read */ 75fcf3ce44SJohn Forte cntl_write_data : 1; /* initiator write */ 76fcf3ce44SJohn Forte 77fcf3ce44SJohn Forte #elif defined(_BIT_FIELDS_LTOH) 78fcf3ce44SJohn Forte 79fcf3ce44SJohn Forte uchar_t cntl_qtype : 3, /* tagged queueing type */ 80fcf3ce44SJohn Forte cntl_reserved_1 : 5; /* reserved */ 81fcf3ce44SJohn Forte 82fcf3ce44SJohn Forte uchar_t cntl_reserved_3 : 1, /* reserved */ 83fcf3ce44SJohn Forte cntl_abort_tsk : 1, /* abort task set */ 84fcf3ce44SJohn Forte cntl_clr_tsk : 1, /* clear task set */ 85fcf3ce44SJohn Forte cntl_reserved_2 : 1, /* reserved */ 86fcf3ce44SJohn Forte cntl_reset_lun : 1, /* reset lun */ 87fcf3ce44SJohn Forte cntl_reset_tgt : 1, /* reset target */ 88fcf3ce44SJohn Forte cntl_clr_aca : 1, /* clear aca */ 89fcf3ce44SJohn Forte cntl_kill_tsk : 1; /* terminate task */ 90fcf3ce44SJohn Forte 91fcf3ce44SJohn Forte uchar_t cntl_write_data : 1, /* initiator write */ 92fcf3ce44SJohn Forte cntl_read_data : 1, /* initiator read */ 93fcf3ce44SJohn Forte cntl_reserved_4 : 6; /* reserved */ 94fcf3ce44SJohn Forte 95fcf3ce44SJohn Forte #else 96fcf3ce44SJohn Forte #error one of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined 97fcf3ce44SJohn Forte #endif 98fcf3ce44SJohn Forte 99fcf3ce44SJohn Forte } fcp_cntl_t; 100fcf3ce44SJohn Forte 101fcf3ce44SJohn Forte /* 102fcf3ce44SJohn Forte * fcp SCSI control tagged queueing types - cntl_qtype 103fcf3ce44SJohn Forte */ 104fcf3ce44SJohn Forte #define FCP_QTYPE_SIMPLE 0 /* simple queueing */ 105fcf3ce44SJohn Forte #define FCP_QTYPE_HEAD_OF_Q 1 /* head of queue */ 106fcf3ce44SJohn Forte #define FCP_QTYPE_ORDERED 2 /* ordered queueing */ 107fcf3ce44SJohn Forte #define FCP_QTYPE_ACA_Q_TAG 4 /* ACA queueing */ 108fcf3ce44SJohn Forte #define FCP_QTYPE_UNTAGGED 5 /* Untagged */ 109fcf3ce44SJohn Forte 110fcf3ce44SJohn Forte /* 111fcf3ce44SJohn Forte * fcp SCSI entity address 112fcf3ce44SJohn Forte * 113fcf3ce44SJohn Forte * ent_addr_0 is always the first and highest layer of 114fcf3ce44SJohn Forte * the hierarchy. The depth of the hierarchy of addressing, 115fcf3ce44SJohn Forte * up to a maximum of four layers, is arbitrary and 116fcf3ce44SJohn Forte * device-dependent. 117fcf3ce44SJohn Forte */ 118fcf3ce44SJohn Forte typedef struct fcp_ent_addr { 119fcf3ce44SJohn Forte ushort_t ent_addr_0; /* entity address 0 */ 120fcf3ce44SJohn Forte ushort_t ent_addr_1; /* entity address 1 */ 121fcf3ce44SJohn Forte ushort_t ent_addr_2; /* entity address 2 */ 122fcf3ce44SJohn Forte ushort_t ent_addr_3; /* entity address 3 */ 123fcf3ce44SJohn Forte } fcp_ent_addr_t; 124fcf3ce44SJohn Forte 125fcf3ce44SJohn Forte /* 126fcf3ce44SJohn Forte * maximum size of SCSI cdb in fcp SCSI command 127fcf3ce44SJohn Forte */ 128fcf3ce44SJohn Forte #define FCP_CDB_SIZE 16 129fcf3ce44SJohn Forte #define FCP_LUN_SIZE 8 130fcf3ce44SJohn Forte #define FCP_LUN_HEADER 8 131fcf3ce44SJohn Forte 132fcf3ce44SJohn Forte /* 133fcf3ce44SJohn Forte * FCP SCSI command payload 134fcf3ce44SJohn Forte */ 135fcf3ce44SJohn Forte typedef struct fcp_cmd { 136fcf3ce44SJohn Forte fcp_ent_addr_t fcp_ent_addr; /* entity address */ 137fcf3ce44SJohn Forte fcp_cntl_t fcp_cntl; /* SCSI options */ 138fcf3ce44SJohn Forte uchar_t fcp_cdb[FCP_CDB_SIZE]; /* SCSI cdb */ 139fcf3ce44SJohn Forte int fcp_data_len; /* data length */ 140fcf3ce44SJohn Forte } fcp_cmd_t; 141fcf3ce44SJohn Forte 142fcf3ce44SJohn Forte /* 143fcf3ce44SJohn Forte * fcp SCSI status 144fcf3ce44SJohn Forte */ 145fcf3ce44SJohn Forte typedef struct fcp_status { 146fcf3ce44SJohn Forte ushort_t reserved_0; /* reserved */ 147fcf3ce44SJohn Forte 148fcf3ce44SJohn Forte #if defined(_BIT_FIELDS_HTOL) 149fcf3ce44SJohn Forte 150fcf3ce44SJohn Forte uchar_t reserved_1 : 4, /* reserved */ 151fcf3ce44SJohn Forte resid_under : 1, /* resid non-zero */ 152fcf3ce44SJohn Forte resid_over : 1, /* resid non-zero */ 153fcf3ce44SJohn Forte sense_len_set : 1, /* sense_len non-zero */ 154fcf3ce44SJohn Forte rsp_len_set : 1; /* response_len non-zero */ 155fcf3ce44SJohn Forte 156fcf3ce44SJohn Forte #elif defined(_BIT_FIELDS_LTOH) 157fcf3ce44SJohn Forte 158fcf3ce44SJohn Forte uchar_t rsp_len_set : 1, /* response_len non-zero */ 159fcf3ce44SJohn Forte sense_len_set : 1, /* sense_len non-zero */ 160fcf3ce44SJohn Forte resid_over : 1, /* resid non-zero */ 161fcf3ce44SJohn Forte resid_under : 1, /* resid non-zero */ 162fcf3ce44SJohn Forte reserved_1 : 4; /* reserved */ 163fcf3ce44SJohn Forte 164fcf3ce44SJohn Forte #endif 165fcf3ce44SJohn Forte uchar_t scsi_status; /* status of cmd */ 166fcf3ce44SJohn Forte } fcp_status_t; 167fcf3ce44SJohn Forte 168fcf3ce44SJohn Forte /* 169fcf3ce44SJohn Forte * fcp SCSI response payload 170fcf3ce44SJohn Forte */ 171fcf3ce44SJohn Forte typedef struct fcp_rsp { 172fcf3ce44SJohn Forte uint32_t reserved_0; /* reserved */ 173fcf3ce44SJohn Forte uint32_t reserved_1; /* reserved */ 174fcf3ce44SJohn Forte union { 175fcf3ce44SJohn Forte fcp_status_t fcp_status; /* command status */ 176fcf3ce44SJohn Forte uint32_t i_fcp_status; 177fcf3ce44SJohn Forte } fcp_u; 178fcf3ce44SJohn Forte uint32_t fcp_resid; /* resid of operation */ 179fcf3ce44SJohn Forte uint32_t fcp_sense_len; /* sense data length */ 180fcf3ce44SJohn Forte uint32_t fcp_response_len; /* response data length */ 181fcf3ce44SJohn Forte /* 182fcf3ce44SJohn Forte * 'm' bytes of scsi response info follow 183fcf3ce44SJohn Forte * 'n' bytes of scsi sense info follow 184fcf3ce44SJohn Forte */ 185fcf3ce44SJohn Forte } fcp_rsp_t; 186fcf3ce44SJohn Forte 187fcf3ce44SJohn Forte /* MAde 256 for sonoma as it wants to give tons of sense info */ 188fcf3ce44SJohn Forte #define FCP_MAX_RSP_IU_SIZE 256 189fcf3ce44SJohn Forte 190fcf3ce44SJohn Forte /* 191fcf3ce44SJohn Forte * fcp rsp_info field format 192fcf3ce44SJohn Forte */ 193fcf3ce44SJohn Forte struct fcp_rsp_info { 194fcf3ce44SJohn Forte uchar_t resvd1; 195fcf3ce44SJohn Forte uchar_t resvd2; 196fcf3ce44SJohn Forte uchar_t resvd3; 197fcf3ce44SJohn Forte uchar_t rsp_code; 198fcf3ce44SJohn Forte uchar_t resvd4; 199fcf3ce44SJohn Forte uchar_t resvd5; 200fcf3ce44SJohn Forte uchar_t resvd6; 201fcf3ce44SJohn Forte uchar_t resvd7; 202fcf3ce44SJohn Forte }; 203fcf3ce44SJohn Forte 204fcf3ce44SJohn Forte /* 205fcf3ce44SJohn Forte * rsp_code definitions 206fcf3ce44SJohn Forte */ 207fcf3ce44SJohn Forte #define FCP_NO_FAILURE 0x0 208fcf3ce44SJohn Forte #define FCP_DL_LEN_MISMATCH 0x1 209fcf3ce44SJohn Forte #define FCP_CMND_INVALID 0x2 210fcf3ce44SJohn Forte #define FCP_DATA_RO_MISMATCH 0x3 211fcf3ce44SJohn Forte #define FCP_TASK_MGMT_NOT_SUPPTD 0x4 212fcf3ce44SJohn Forte #define FCP_TASK_MGMT_FAILED 0x5 213fcf3ce44SJohn Forte 214fcf3ce44SJohn Forte #ifdef THIS_NEEDED_YET 215fcf3ce44SJohn Forte 216fcf3ce44SJohn Forte /* 217fcf3ce44SJohn Forte * fcp scsi_xfer_rdy payload 218fcf3ce44SJohn Forte */ 219fcf3ce44SJohn Forte typedef struct fcp_xfer_rdy { 220fcf3ce44SJohn Forte ulong64_t fcp_seq_offset; /* relative offset */ 221fcf3ce44SJohn Forte ulong64_t fcp_burst_len; /* buffer space */ 222fcf3ce44SJohn Forte ulong64_t reserved; /* reserved */ 223fcf3ce44SJohn Forte } fcp_xfer_rdy_t; 224fcf3ce44SJohn Forte 225fcf3ce44SJohn Forte #endif /* THIS_NEEDED_YET */ 226fcf3ce44SJohn Forte 227fcf3ce44SJohn Forte /* 228fcf3ce44SJohn Forte * fcp PRLI payload 229fcf3ce44SJohn Forte */ 230fcf3ce44SJohn Forte struct fcp_prli { 231fcf3ce44SJohn Forte uchar_t type; 232fcf3ce44SJohn Forte uchar_t resvd1; /* rsvd by std */ 233fcf3ce44SJohn Forte 234fcf3ce44SJohn Forte #if defined(_BIT_FIELDS_HTOL) 235fcf3ce44SJohn Forte 236fcf3ce44SJohn Forte uint16_t orig_process_assoc_valid : 1, 237fcf3ce44SJohn Forte resp_process_assoc_valid : 1, 238fcf3ce44SJohn Forte establish_image_pair : 1, 239fcf3ce44SJohn Forte resvd2 : 13; /* rsvd by std */ 240fcf3ce44SJohn Forte 241fcf3ce44SJohn Forte #elif defined(_BIT_FIELDS_LTOH) 242fcf3ce44SJohn Forte 243fcf3ce44SJohn Forte uint16_t resvd2 : 13, /* rsvd by std */ 244fcf3ce44SJohn Forte establish_image_pair : 1, 245fcf3ce44SJohn Forte resp_process_assoc_valid : 1, 246fcf3ce44SJohn Forte orig_process_assoc_valid : 1; 247fcf3ce44SJohn Forte 248fcf3ce44SJohn Forte #endif 249fcf3ce44SJohn Forte 250fcf3ce44SJohn Forte uint32_t orig_process_associator; 251fcf3ce44SJohn Forte uint32_t resp_process_associator; 252fcf3ce44SJohn Forte 253fcf3ce44SJohn Forte #if defined(_BIT_FIELDS_HTOL) 254fcf3ce44SJohn Forte 255fcf3ce44SJohn Forte uint32_t resvd3 : 23, /* rsvd by std */ 256fcf3ce44SJohn Forte retry : 1, 257fcf3ce44SJohn Forte confirmed_compl_allowed : 1, 258fcf3ce44SJohn Forte data_overlay_allowed : 1, 259fcf3ce44SJohn Forte initiator_fn : 1, 260fcf3ce44SJohn Forte target_fn : 1, 261fcf3ce44SJohn Forte obsolete_2 : 1, 262fcf3ce44SJohn Forte obsolete_1 : 1, 263fcf3ce44SJohn Forte read_xfer_rdy_disabled : 1, 264fcf3ce44SJohn Forte write_xfer_rdy_disabled : 1; 265fcf3ce44SJohn Forte 266fcf3ce44SJohn Forte #elif defined(_BIT_FIELDS_LTOH) 267fcf3ce44SJohn Forte 268fcf3ce44SJohn Forte uint32_t write_xfer_rdy_disabled : 1, 269fcf3ce44SJohn Forte read_xfer_rdy_disabled : 1, 270fcf3ce44SJohn Forte obsolete_1 : 1, 271fcf3ce44SJohn Forte obsolete_2 : 1, 272fcf3ce44SJohn Forte target_fn : 1, 273fcf3ce44SJohn Forte initiator_fn : 1, 274fcf3ce44SJohn Forte data_overlay_allowed : 1, 275fcf3ce44SJohn Forte confirmed_compl_allowed : 1, 276fcf3ce44SJohn Forte retry : 1, 277fcf3ce44SJohn Forte resvd3 : 23; /* rsvd by std */ 278fcf3ce44SJohn Forte 279fcf3ce44SJohn Forte #endif 280fcf3ce44SJohn Forte 281fcf3ce44SJohn Forte }; 282fcf3ce44SJohn Forte 283fcf3ce44SJohn Forte /* 284fcf3ce44SJohn Forte * fcp PRLI ACC payload 285fcf3ce44SJohn Forte */ 286fcf3ce44SJohn Forte struct fcp_prli_acc { 287fcf3ce44SJohn Forte uchar_t type; 288*7ff83669SZhong Wang uchar_t resvd1; /* type code extension */ 289*7ff83669SZhong Wang 290*7ff83669SZhong Wang #if defined(_BIT_FIELDS_HTOL) 291*7ff83669SZhong Wang uint16_t orig_process_assoc_valid : 1, 292*7ff83669SZhong Wang resp_process_assoc_valid : 1, 293*7ff83669SZhong Wang image_pair_established : 1, 294*7ff83669SZhong Wang resvd2 : 1, 295*7ff83669SZhong Wang accept_response_code : 4, 296*7ff83669SZhong Wang resvd3 : 8; 297*7ff83669SZhong Wang #elif defined(_BIT_FIELDS_LTOH) 298*7ff83669SZhong Wang uint16_t resvd3 : 8, 299*7ff83669SZhong Wang accept_response_code : 4, 300*7ff83669SZhong Wang resvd2 : 1, 301*7ff83669SZhong Wang image_pair_established : 1, 302*7ff83669SZhong Wang resp_process_assoc_valid : 1, 303*7ff83669SZhong Wang orig_process_assoc_valid : 1; 304*7ff83669SZhong Wang #endif 305fcf3ce44SJohn Forte 306fcf3ce44SJohn Forte uint32_t orig_process_associator; 307fcf3ce44SJohn Forte uint32_t resp_process_associator; 308fcf3ce44SJohn Forte 309*7ff83669SZhong Wang #if defined(_BIT_FIELDS_HTOL) 310*7ff83669SZhong Wang uint32_t resvd4 : 26, 311*7ff83669SZhong Wang initiator_fn : 1, 312*7ff83669SZhong Wang target_fn : 1, 313*7ff83669SZhong Wang cmd_data_mixed : 1, 314*7ff83669SZhong Wang data_resp_mixed : 1, 315*7ff83669SZhong Wang read_xfer_rdy_disabled : 1, 316*7ff83669SZhong Wang write_xfer_rdy_disabled : 1; 317*7ff83669SZhong Wang #elif defined(_BIT_FIELDS_LTOH) 318*7ff83669SZhong Wang uint32_t write_xfer_rdy_disabled : 1, 319*7ff83669SZhong Wang read_xfer_rdy_disabled : 1, 320*7ff83669SZhong Wang data_resp_mixed : 1, 321*7ff83669SZhong Wang cmd_data_mixed : 1, 322*7ff83669SZhong Wang target_fn : 1, 323*7ff83669SZhong Wang initiator_fn : 1, 324*7ff83669SZhong Wang resvd4 : 26; 325*7ff83669SZhong Wang #endif 326fcf3ce44SJohn Forte }; 327fcf3ce44SJohn Forte 328fcf3ce44SJohn Forte #define FC_UB_FCP_CDB_FLAG 0x0001 /* UB has valid cdb */ 329fcf3ce44SJohn Forte #define FC_UB_FCP_PORT_LOGOUT 0x0002 /* Port logout UB */ 330fcf3ce44SJohn Forte #define FC_UB_FCP_ABORT_TASK 0x0004 /* Abort task UB */ 331fcf3ce44SJohn Forte #define FC_UB_FCP_BUS_RESET 0x0008 /* Bus reset UB */ 332fcf3ce44SJohn Forte #define FC_UB_FCP_CMD_DONE 0x8000 /* Work on this UB is done */ 333fcf3ce44SJohn Forte 334fcf3ce44SJohn Forte #define FC_UB_FCP_OOB_CMD (FC_UB_FCP_PORT_LOGOUT | FC_UB_FCP_ABORT_TASK \ 335fcf3ce44SJohn Forte | FC_UB_FCP_BUS_RESET) /* Out-of-band traget cmds */ 336fcf3ce44SJohn Forte 337fcf3ce44SJohn Forte 338fcf3ce44SJohn Forte #if !defined(__lint) 339fcf3ce44SJohn Forte _NOTE(SCHEME_PROTECTS_DATA("Unshared Data", 340fcf3ce44SJohn Forte fcp_cmd 341fcf3ce44SJohn Forte fcp_rsp 342fcf3ce44SJohn Forte fcp_prli)) 343fcf3ce44SJohn Forte #endif /* __lint */ 344fcf3ce44SJohn Forte 345fcf3ce44SJohn Forte /* 346fcf3ce44SJohn Forte * FC4 type setttings for Name Server registration. 347fcf3ce44SJohn Forte */ 348fcf3ce44SJohn Forte #define FC4_TYPE_WORD_POS(x) ((uchar_t)(x) >> 5) 349fcf3ce44SJohn Forte #define FC4_TYPE_BIT_POS(x) ((uchar_t)(x) & 0x1F) 350fcf3ce44SJohn Forte 351fcf3ce44SJohn Forte #ifdef __cplusplus 352fcf3ce44SJohn Forte } 353fcf3ce44SJohn Forte #endif 354fcf3ce44SJohn Forte 355fcf3ce44SJohn Forte #endif /* _FCP_H */ 356