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