isp_stds.h revision 196008
1/* $FreeBSD: head/sys/dev/isp/isp_stds.h 196008 2009-08-01 01:04:26Z mjacob $ */ 2/*- 3 * Copyright (c) 1997-2009 by Matthew Jacob 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 */ 29/* 30 * Structures that derive directly from public standards. 31 */ 32#ifndef _ISP_STDS_H 33#define _ISP_STDS_H 34 35/* 36 * FC Frame Header 37 * 38 * Source: dpANS-X3.xxx-199x, section 18 (AKA FC-PH-2) 39 * 40 */ 41typedef struct { 42 uint8_t r_ctl; 43 uint8_t d_id[3]; 44 uint8_t cs_ctl; 45 uint8_t s_id[3]; 46 uint8_t type; 47 uint8_t f_ctl[3]; 48 uint8_t seq_id; 49 uint8_t df_ctl; 50 uint16_t seq_cnt; 51 uint16_t ox_id; 52 uint16_t rx_id; 53 uint32_t parameter; 54} fc_hdr_t; 55 56/* 57 * FCP_CMND_IU Payload 58 * 59 * Source: NICTS T10, Project 1144D, Revision 07a, Section 9 (AKA fcp2-r07a) 60 * 61 * Notes: 62 * When additional cdb length is defined in fcp_cmnd_alen_datadir, 63 * bits 2..7, the actual cdb length is 16 + ((fcp_cmnd_alen_datadir>>2)*4), 64 * with the datalength following in MSB format just after. 65 */ 66typedef struct { 67 uint8_t fcp_cmnd_lun[8]; 68 uint8_t fcp_cmnd_crn; 69 uint8_t fcp_cmnd_task_attribute; 70 uint8_t fcp_cmnd_task_management; 71 uint8_t fcp_cmnd_alen_datadir; 72 union { 73 struct { 74 uint8_t fcp_cmnd_cdb[16]; 75 uint32_t fcp_cmnd_dl; 76 } sf; 77 struct { 78 uint8_t fcp_cmnd_cdb[1]; 79 } lf; 80 } cdb_dl; 81} fcp_cmnd_iu_t; 82 83 84#define FCP_CMND_TASK_ATTR_SIMPLE 0x00 85#define FCP_CMND_TASK_ATTR_HEAD 0x01 86#define FCP_CMND_TASK_ATTR_ORDERED 0x02 87#define FCP_CMND_TASK_ATTR_ACA 0x04 88#define FCP_CMND_TASK_ATTR_UNTAGGED 0x05 89#define FCP_CMND_TASK_ATTR_MASK 0x07 90 91#define FCP_CMND_ADDTL_CDBLEN_SHIFT 2 92 93#define FCP_CMND_DATA_WRITE 0x01 94#define FCP_CMND_DATA_READ 0x02 95 96#define FCP_CMND_DATA_DIR_MASK 0x03 97 98#define FCP_CMND_TMF_CLEAR_ACA 0x40 99#define FCP_CMND_TMF_TGT_RESET 0x20 100#define FCP_CMND_TMF_LUN_RESET 0x10 101#define FCP_CMND_TMF_CLEAR_TASK_SET 0x04 102#define FCP_CMND_TMF_ABORT_TASK_SET 0x02 103 104/* 105 * Basic CT IU Header 106 * 107 * Source: X3.288-199x Generic Services 2 Rev 5.3 (FC-GS-2) Section 4.3.1 108 */ 109 110typedef struct { 111 uint8_t ct_revision; 112 uint8_t ct_in_id[3]; 113 uint8_t ct_fcs_type; 114 uint8_t ct_fcs_subtype; 115 uint8_t ct_options; 116 uint8_t ct_reserved0; 117 uint16_t ct_cmd_resp; 118 uint16_t ct_bcnt_resid; 119 uint8_t ct_reserved1; 120 uint8_t ct_reason; 121 uint8_t ct_explanation; 122 uint8_t ct_vunique; 123} ct_hdr_t; 124#define CT_REVISION 1 125#define CT_FC_TYPE_FC 0xFC 126#define CT_FC_SUBTYPE_NS 0x02 127 128/* 129 * RFT_ID Requet CT_IU 130 * 131 * Source: NCITS xxx-200x Generic Services- 5 Rev 8.5 Section 5.2.5.30 132 */ 133typedef struct { 134 ct_hdr_t rftid_hdr; 135 uint8_t rftid_reserved; 136 uint8_t rftid_portid[3]; 137 uint32_t rftid_fc4types[8]; 138} rft_id_t; 139 140/* 141 * FCP Response IU Bits of interest 142 * Source: NCITS T10, Project 1144D, Revision 08 (aka FCP2r08) 143 */ 144#define FCP_CONF_REQ 0x10 145#define FCP_RESID_UNDERFLOW 0x08 146#define FCP_RESID_OVERFLOW 0x04 147#define FCP_SNSLEN_VALID 0x02 148#define FCP_RSPLEN_VALID 0x01 149 150/* 151 * FCP Response Code Definitions 152 * Source: NCITS T10, Project 1144D, Revision 08 (aka FCP2r08) 153 */ 154#define FCP_RSPNS_CODE_OFFSET 3 155 156#define FCP_RSPNS_TMF_DONE 0 157#define FCP_RSPNS_DLBRSTX 1 158#define FCP_RSPNS_BADCMND 2 159#define FCP_RSPNS_EROFS 3 160#define FCP_RSPNS_TMF_REJECT 4 161#define FCP_RSPNS_TMF_FAILED 5 162 163 164/* unconverted miscellany */ 165/* 166 * Basic FC Link Service defines 167 */ 168/* 169 * These are in the R_CTL field. 170 */ 171#define ABTS 0x81 172#define BA_ACC 0x84 /* of ABORT SEQUENCE */ 173#define BA_RJT 0x85 /* of ABORT SEQUENCE */ 174 175/* 176 * Link Service Accept/Reject 177 */ 178#define LS_ACC 0x8002 179#define LS_RJT 0x8001 180 181/* 182 * FC ELS Codes- bits 31-24 of the first payload word of an ELS frame. 183 */ 184#define PLOGI 0x03 185#define FLOGI 0x04 186#define LOGO 0x05 187#define ABTX 0x06 188#define PRLI 0x20 189#define PRLO 0x21 190#define SCN 0x22 191#define TPRLO 0x24 192#define PDISC 0x50 193#define ADISC 0x52 194#define RNC 0x53 195 196/* 197 * FC4 defines 198 */ 199#define FC4_IP 5 /* ISO/EEC 8802-2 LLC/SNAP */ 200#define FC4_SCSI 8 /* SCSI-3 via Fibre Channel Protocol (FCP) */ 201#define FC4_FC_SVC 0x20 /* Fibre Channel Services */ 202 203#ifndef MSG_ABORT 204#define MSG_ABORT 0x06 205#endif 206#ifndef MSG_BUS_DEV_RESET 207#define MSG_BUS_DEV_RESET 0x0c 208#endif 209#ifndef MSG_ABORT_TAG 210#define MSG_ABORT_TAG 0x0d 211#endif 212#ifndef MSG_CLEAR_QUEUE 213#define MSG_CLEAR_QUEUE 0x0e 214#endif 215#ifndef MSG_REL_RECOVERY 216#define MSG_REL_RECOVERY 0x10 217#endif 218#ifndef MSG_TERM_IO_PROC 219#define MSG_TERM_IO_PROC 0x11 220#endif 221#ifndef MSG_LUN_RESET 222#define MSG_LUN_RESET 0x17 223#endif 224 225#endif /* _ISP_STDS_H */ 226