1/* 2 * Copyright(c) 2007 Intel Corporation. All rights reserved. 3 * 4 * This program is free software; you can redistribute it and/or modify it 5 * under the terms and conditions of the GNU General Public License, 6 * version 2, as published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope it will be useful, but WITHOUT 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 * more details. 12 * 13 * You should have received a copy of the GNU General Public License along with 14 * this program; if not, write to the Free Software Foundation, Inc., 15 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 16 * 17 * Maintained at www.Open-FCoE.org 18 */ 19 20#ifndef _FC_FCP_H_ 21#define _FC_FCP_H_ 22 23/* 24 * Fibre Channel Protocol for SCSI. 25 * From T10 FCP-3, T10 project 1560-D Rev 4, Sept. 13, 2005. 26 */ 27 28/* 29 * fc/fs.h defines FC_TYPE_FCP. 30 */ 31 32/* 33 * Service parameter page parameters (word 3 bits) for Process Login. 34 */ 35#define FCP_SPPF_TASK_RETRY_ID 0x0200 /* task retry ID requested */ 36#define FCP_SPPF_RETRY 0x0100 /* retry supported */ 37#define FCP_SPPF_CONF_COMPL 0x0080 /* confirmed completion allowed */ 38#define FCP_SPPF_OVLY_ALLOW 0x0040 /* data overlay allowed */ 39#define FCP_SPPF_INIT_FCN 0x0020 /* initiator function */ 40#define FCP_SPPF_TARG_FCN 0x0010 /* target function */ 41#define FCP_SPPF_RD_XRDY_DIS 0x0002 /* disable XFER_RDY for reads */ 42#define FCP_SPPF_WR_XRDY_DIS 0x0001 /* disable XFER_RDY for writes */ 43 44/* 45 * FCP_CMND IU Payload. 46 */ 47struct fcp_cmnd { 48 __u8 fc_lun[8]; /* logical unit number */ 49 __u8 fc_cmdref; /* commmand reference number */ 50 __u8 fc_pri_ta; /* priority and task attribute */ 51 __u8 fc_tm_flags; /* task management flags */ 52 __u8 fc_flags; /* additional len & flags */ 53 __u8 fc_cdb[16]; /* base CDB */ 54 __be32 fc_dl; /* data length (must follow fc_cdb) */ 55}; 56 57#define FCP_CMND_LEN 32 /* expected length of structure */ 58 59struct fcp_cmnd32 { 60 __u8 fc_lun[8]; /* logical unit number */ 61 __u8 fc_cmdref; /* commmand reference number */ 62 __u8 fc_pri_ta; /* priority and task attribute */ 63 __u8 fc_tm_flags; /* task management flags */ 64 __u8 fc_flags; /* additional len & flags */ 65 __u8 fc_cdb[32]; /* base CDB */ 66 __be32 fc_dl; /* data length (must follow fc_cdb) */ 67}; 68 69#define FCP_CMND32_LEN 48 /* expected length of structure */ 70#define FCP_CMND32_ADD_LEN (16 / 4) /* Additional cdb length */ 71 72/* 73 * fc_pri_ta. 74 */ 75#define FCP_PTA_SIMPLE 0 /* simple task attribute */ 76#define FCP_PTA_HEADQ 1 /* head of queue task attribute */ 77#define FCP_PTA_ORDERED 2 /* ordered task attribute */ 78#define FCP_PTA_ACA 4 /* auto. contigent allegiance */ 79#define FCP_PRI_SHIFT 3 /* priority field starts in bit 3 */ 80#define FCP_PRI_RESVD_MASK 0x80 /* reserved bits in priority field */ 81 82/* 83 * fc_tm_flags - task management flags field. 84 */ 85#define FCP_TMF_CLR_ACA 0x40 /* clear ACA condition */ 86#define FCP_TMF_LUN_RESET 0x10 /* logical unit reset task management */ 87#define FCP_TMF_CLR_TASK_SET 0x04 /* clear task set */ 88#define FCP_TMF_ABT_TASK_SET 0x02 /* abort task set */ 89 90/* 91 * fc_flags. 92 * Bits 7:2 are the additional FCP_CDB length / 4. 93 */ 94#define FCP_CFL_LEN_MASK 0xfc /* mask for additional length */ 95#define FCP_CFL_LEN_SHIFT 2 /* shift bits for additional length */ 96#define FCP_CFL_RDDATA 0x02 /* read data */ 97#define FCP_CFL_WRDATA 0x01 /* write data */ 98 99/* 100 * FCP_TXRDY IU - transfer ready payload. 101 */ 102struct fcp_txrdy { 103 __be32 ft_data_ro; /* data relative offset */ 104 __be32 ft_burst_len; /* burst length */ 105 __u8 _ft_resvd[4]; /* reserved */ 106}; 107 108#define FCP_TXRDY_LEN 12 /* expected length of structure */ 109 110/* 111 * FCP_RESP IU - response payload. 112 * 113 * The response payload comes in three parts: the flags/status, the 114 * sense/response lengths and the sense data/response info section. 115 * 116 * From FCP3r04, note 6 of section 9.5.13: 117 * 118 * Some early implementations presented the FCP_RSP IU without the FCP_RESID, 119 * FCP_SNS_LEN, and FCP_RSP_LEN fields if the FCP_RESID_UNDER, FCP_RESID_OVER, 120 * FCP_SNS_LEN_VALID, and FCP_RSP_LEN_VALID bits were all set to zero. This 121 * non-standard behavior should be tolerated. 122 * 123 * All response frames will always contain the fcp_resp template. Some 124 * will also include the fcp_resp_len template. 125 */ 126struct fcp_resp { 127 __u8 _fr_resvd[8]; /* reserved */ 128 __be16 fr_retry_delay; /* retry delay timer */ 129 __u8 fr_flags; /* flags */ 130 __u8 fr_status; /* SCSI status code */ 131}; 132 133#define FCP_RESP_LEN 12 /* expected length of structure */ 134 135struct fcp_resp_ext { 136 __be32 fr_resid; /* Residual value */ 137 __be32 fr_sns_len; /* SCSI Sense length */ 138 __be32 fr_rsp_len; /* Response Info length */ 139 140 /* 141 * Optionally followed by RSP info and/or SNS info and/or 142 * bidirectional read residual length, if any. 143 */ 144}; 145 146#define FCP_RESP_EXT_LEN 12 /* expected length of the structure */ 147 148struct fcp_resp_rsp_info { 149 __u8 _fr_resvd[3]; /* reserved */ 150 __u8 rsp_code; /* Response Info Code */ 151 __u8 _fr_resvd2[4]; /* reserved */ 152}; 153 154struct fcp_resp_with_ext { 155 struct fcp_resp resp; 156 struct fcp_resp_ext ext; 157}; 158 159#define FCP_RESP_WITH_EXT (FCP_RESP_LEN + FCP_RESP_EXT_LEN) 160 161/* 162 * fr_flags. 163 */ 164#define FCP_BIDI_RSP 0x80 /* bidirectional read response */ 165#define FCP_BIDI_READ_UNDER 0x40 /* bidir. read less than requested */ 166#define FCP_BIDI_READ_OVER 0x20 /* DL insufficient for full transfer */ 167#define FCP_CONF_REQ 0x10 /* confirmation requested */ 168#define FCP_RESID_UNDER 0x08 /* transfer shorter than expected */ 169#define FCP_RESID_OVER 0x04 /* DL insufficient for full transfer */ 170#define FCP_SNS_LEN_VAL 0x02 /* SNS_LEN field is valid */ 171#define FCP_RSP_LEN_VAL 0x01 /* RSP_LEN field is valid */ 172 173/* 174 * rsp_codes 175 */ 176enum fcp_resp_rsp_codes { 177 FCP_TMF_CMPL = 0, 178 FCP_DATA_LEN_INVALID = 1, 179 FCP_CMND_FIELDS_INVALID = 2, 180 FCP_DATA_PARAM_MISMATCH = 3, 181 FCP_TMF_REJECTED = 4, 182 FCP_TMF_FAILED = 5, 183 FCP_TMF_INVALID_LUN = 9, 184}; 185 186/* 187 * FCP SRR Link Service request - Sequence Retransmission Request. 188 */ 189struct fcp_srr { 190 __u8 srr_op; /* opcode ELS_SRR */ 191 __u8 srr_resvd[3]; /* opcode / reserved - must be zero */ 192 __be16 srr_ox_id; /* OX_ID of failed command */ 193 __be16 srr_rx_id; /* RX_ID of failed command */ 194 __be32 srr_rel_off; /* relative offset */ 195 __u8 srr_r_ctl; /* r_ctl for the information unit */ 196 __u8 srr_resvd2[3]; /* reserved */ 197}; 198 199#endif /* _FC_FCP_H_ */ 200