1*a61127c2SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 2f032c2f7SRobert Love /* 3f032c2f7SRobert Love * Copyright(c) 2007 Intel Corporation. All rights reserved. 4f032c2f7SRobert Love * 5f032c2f7SRobert Love * Maintained at www.Open-FCoE.org 6f032c2f7SRobert Love */ 7f032c2f7SRobert Love 8f032c2f7SRobert Love #ifndef _FC_FCP_H_ 9f032c2f7SRobert Love #define _FC_FCP_H_ 10f032c2f7SRobert Love 11e35fa8c2SAndy Grover #include <scsi/scsi.h> 12e35fa8c2SAndy Grover 13f032c2f7SRobert Love /* 14f032c2f7SRobert Love * Fibre Channel Protocol for SCSI. 15f032c2f7SRobert Love * From T10 FCP-3, T10 project 1560-D Rev 4, Sept. 13, 2005. 16f032c2f7SRobert Love */ 17f032c2f7SRobert Love 18f032c2f7SRobert Love /* 19f032c2f7SRobert Love * fc/fs.h defines FC_TYPE_FCP. 20f032c2f7SRobert Love */ 21f032c2f7SRobert Love 22f032c2f7SRobert Love /* 23f032c2f7SRobert Love * Service parameter page parameters (word 3 bits) for Process Login. 24f032c2f7SRobert Love */ 25f032c2f7SRobert Love #define FCP_SPPF_TASK_RETRY_ID 0x0200 /* task retry ID requested */ 26f032c2f7SRobert Love #define FCP_SPPF_RETRY 0x0100 /* retry supported */ 27f032c2f7SRobert Love #define FCP_SPPF_CONF_COMPL 0x0080 /* confirmed completion allowed */ 28f032c2f7SRobert Love #define FCP_SPPF_OVLY_ALLOW 0x0040 /* data overlay allowed */ 29f032c2f7SRobert Love #define FCP_SPPF_INIT_FCN 0x0020 /* initiator function */ 30f032c2f7SRobert Love #define FCP_SPPF_TARG_FCN 0x0010 /* target function */ 31f032c2f7SRobert Love #define FCP_SPPF_RD_XRDY_DIS 0x0002 /* disable XFER_RDY for reads */ 32f032c2f7SRobert Love #define FCP_SPPF_WR_XRDY_DIS 0x0001 /* disable XFER_RDY for writes */ 33f032c2f7SRobert Love 34f032c2f7SRobert Love /* 35f032c2f7SRobert Love * FCP_CMND IU Payload. 36f032c2f7SRobert Love */ 37f032c2f7SRobert Love struct fcp_cmnd { 38e35fa8c2SAndy Grover struct scsi_lun fc_lun; /* logical unit number */ 39b595076aSUwe Kleine-König __u8 fc_cmdref; /* command reference number */ 40f032c2f7SRobert Love __u8 fc_pri_ta; /* priority and task attribute */ 41f032c2f7SRobert Love __u8 fc_tm_flags; /* task management flags */ 42f032c2f7SRobert Love __u8 fc_flags; /* additional len & flags */ 43f032c2f7SRobert Love __u8 fc_cdb[16]; /* base CDB */ 44f032c2f7SRobert Love __be32 fc_dl; /* data length (must follow fc_cdb) */ 45f032c2f7SRobert Love }; 46f032c2f7SRobert Love 47f032c2f7SRobert Love #define FCP_CMND_LEN 32 /* expected length of structure */ 48f032c2f7SRobert Love 49f032c2f7SRobert Love struct fcp_cmnd32 { 50e35fa8c2SAndy Grover struct scsi_lun fc_lun; /* logical unit number */ 51b595076aSUwe Kleine-König __u8 fc_cmdref; /* command reference number */ 52f032c2f7SRobert Love __u8 fc_pri_ta; /* priority and task attribute */ 53f032c2f7SRobert Love __u8 fc_tm_flags; /* task management flags */ 54f032c2f7SRobert Love __u8 fc_flags; /* additional len & flags */ 55f032c2f7SRobert Love __u8 fc_cdb[32]; /* base CDB */ 56f032c2f7SRobert Love __be32 fc_dl; /* data length (must follow fc_cdb) */ 57f032c2f7SRobert Love }; 58f032c2f7SRobert Love 59f032c2f7SRobert Love #define FCP_CMND32_LEN 48 /* expected length of structure */ 60f032c2f7SRobert Love #define FCP_CMND32_ADD_LEN (16 / 4) /* Additional cdb length */ 61f032c2f7SRobert Love 62f032c2f7SRobert Love /* 63f032c2f7SRobert Love * fc_pri_ta. 64f032c2f7SRobert Love */ 65f032c2f7SRobert Love #define FCP_PTA_SIMPLE 0 /* simple task attribute */ 66f032c2f7SRobert Love #define FCP_PTA_HEADQ 1 /* head of queue task attribute */ 67f032c2f7SRobert Love #define FCP_PTA_ORDERED 2 /* ordered task attribute */ 6825985edcSLucas De Marchi #define FCP_PTA_ACA 4 /* auto. contingent allegiance */ 694dc7ccf7SJoe Eykholt #define FCP_PTA_MASK 7 /* mask for task attribute field */ 70f032c2f7SRobert Love #define FCP_PRI_SHIFT 3 /* priority field starts in bit 3 */ 71f032c2f7SRobert Love #define FCP_PRI_RESVD_MASK 0x80 /* reserved bits in priority field */ 72f032c2f7SRobert Love 73f032c2f7SRobert Love /* 74f032c2f7SRobert Love * fc_tm_flags - task management flags field. 75f032c2f7SRobert Love */ 76f032c2f7SRobert Love #define FCP_TMF_CLR_ACA 0x40 /* clear ACA condition */ 770a55256dSChristof Schmitt #define FCP_TMF_TGT_RESET 0x20 /* target reset task management, 780a55256dSChristof Schmitt deprecated as of FCP-3 */ 79f032c2f7SRobert Love #define FCP_TMF_LUN_RESET 0x10 /* logical unit reset task management */ 80f032c2f7SRobert Love #define FCP_TMF_CLR_TASK_SET 0x04 /* clear task set */ 81f032c2f7SRobert Love #define FCP_TMF_ABT_TASK_SET 0x02 /* abort task set */ 82f032c2f7SRobert Love 83f032c2f7SRobert Love /* 84f032c2f7SRobert Love * fc_flags. 85f032c2f7SRobert Love * Bits 7:2 are the additional FCP_CDB length / 4. 86f032c2f7SRobert Love */ 87f032c2f7SRobert Love #define FCP_CFL_LEN_MASK 0xfc /* mask for additional length */ 88f032c2f7SRobert Love #define FCP_CFL_LEN_SHIFT 2 /* shift bits for additional length */ 89f032c2f7SRobert Love #define FCP_CFL_RDDATA 0x02 /* read data */ 90f032c2f7SRobert Love #define FCP_CFL_WRDATA 0x01 /* write data */ 91f032c2f7SRobert Love 92f032c2f7SRobert Love /* 93f032c2f7SRobert Love * FCP_TXRDY IU - transfer ready payload. 94f032c2f7SRobert Love */ 95f032c2f7SRobert Love struct fcp_txrdy { 96f032c2f7SRobert Love __be32 ft_data_ro; /* data relative offset */ 97f032c2f7SRobert Love __be32 ft_burst_len; /* burst length */ 98f032c2f7SRobert Love __u8 _ft_resvd[4]; /* reserved */ 99f032c2f7SRobert Love }; 100f032c2f7SRobert Love 101f032c2f7SRobert Love #define FCP_TXRDY_LEN 12 /* expected length of structure */ 102f032c2f7SRobert Love 103f032c2f7SRobert Love /* 104f032c2f7SRobert Love * FCP_RESP IU - response payload. 105f032c2f7SRobert Love * 106f032c2f7SRobert Love * The response payload comes in three parts: the flags/status, the 107f032c2f7SRobert Love * sense/response lengths and the sense data/response info section. 108f032c2f7SRobert Love * 109f032c2f7SRobert Love * From FCP3r04, note 6 of section 9.5.13: 110f032c2f7SRobert Love * 111f032c2f7SRobert Love * Some early implementations presented the FCP_RSP IU without the FCP_RESID, 112f032c2f7SRobert Love * FCP_SNS_LEN, and FCP_RSP_LEN fields if the FCP_RESID_UNDER, FCP_RESID_OVER, 113f032c2f7SRobert Love * FCP_SNS_LEN_VALID, and FCP_RSP_LEN_VALID bits were all set to zero. This 114f032c2f7SRobert Love * non-standard behavior should be tolerated. 115f032c2f7SRobert Love * 116f032c2f7SRobert Love * All response frames will always contain the fcp_resp template. Some 117f032c2f7SRobert Love * will also include the fcp_resp_len template. 1183b64b188SYi Zou * 1193b64b188SYi Zou * From Table 23, the FCP_RSP_INFO can either be 4 bytes or 8 bytes, both 1203b64b188SYi Zou * are valid length. 121f032c2f7SRobert Love */ 122f032c2f7SRobert Love struct fcp_resp { 123f032c2f7SRobert Love __u8 _fr_resvd[8]; /* reserved */ 124f032c2f7SRobert Love __be16 fr_retry_delay; /* retry delay timer */ 125f032c2f7SRobert Love __u8 fr_flags; /* flags */ 126f032c2f7SRobert Love __u8 fr_status; /* SCSI status code */ 127f032c2f7SRobert Love }; 128f032c2f7SRobert Love 129f032c2f7SRobert Love #define FCP_RESP_LEN 12 /* expected length of structure */ 130f032c2f7SRobert Love 131f032c2f7SRobert Love struct fcp_resp_ext { 132f032c2f7SRobert Love __be32 fr_resid; /* Residual value */ 133f032c2f7SRobert Love __be32 fr_sns_len; /* SCSI Sense length */ 134f032c2f7SRobert Love __be32 fr_rsp_len; /* Response Info length */ 135f032c2f7SRobert Love 136f032c2f7SRobert Love /* 137f032c2f7SRobert Love * Optionally followed by RSP info and/or SNS info and/or 138f032c2f7SRobert Love * bidirectional read residual length, if any. 139f032c2f7SRobert Love */ 140f032c2f7SRobert Love }; 141f032c2f7SRobert Love 142f032c2f7SRobert Love #define FCP_RESP_EXT_LEN 12 /* expected length of the structure */ 143f032c2f7SRobert Love 144f032c2f7SRobert Love struct fcp_resp_rsp_info { 145f032c2f7SRobert Love __u8 _fr_resvd[3]; /* reserved */ 146f032c2f7SRobert Love __u8 rsp_code; /* Response Info Code */ 147f032c2f7SRobert Love __u8 _fr_resvd2[4]; /* reserved */ 148f032c2f7SRobert Love }; 149f032c2f7SRobert Love 1503b64b188SYi Zou #define FCP_RESP_RSP_INFO_LEN4 4 /* without reserved field */ 1513b64b188SYi Zou #define FCP_RESP_RSP_INFO_LEN8 8 /* with reserved field */ 1523b64b188SYi Zou 153f032c2f7SRobert Love struct fcp_resp_with_ext { 154f032c2f7SRobert Love struct fcp_resp resp; 155f032c2f7SRobert Love struct fcp_resp_ext ext; 156f032c2f7SRobert Love }; 157f032c2f7SRobert Love 158f032c2f7SRobert Love #define FCP_RESP_WITH_EXT (FCP_RESP_LEN + FCP_RESP_EXT_LEN) 159f032c2f7SRobert Love 160f032c2f7SRobert Love /* 161f032c2f7SRobert Love * fr_flags. 162f032c2f7SRobert Love */ 163f032c2f7SRobert Love #define FCP_BIDI_RSP 0x80 /* bidirectional read response */ 164f032c2f7SRobert Love #define FCP_BIDI_READ_UNDER 0x40 /* bidir. read less than requested */ 165f032c2f7SRobert Love #define FCP_BIDI_READ_OVER 0x20 /* DL insufficient for full transfer */ 166f032c2f7SRobert Love #define FCP_CONF_REQ 0x10 /* confirmation requested */ 167f032c2f7SRobert Love #define FCP_RESID_UNDER 0x08 /* transfer shorter than expected */ 168f032c2f7SRobert Love #define FCP_RESID_OVER 0x04 /* DL insufficient for full transfer */ 169f032c2f7SRobert Love #define FCP_SNS_LEN_VAL 0x02 /* SNS_LEN field is valid */ 170f032c2f7SRobert Love #define FCP_RSP_LEN_VAL 0x01 /* RSP_LEN field is valid */ 171f032c2f7SRobert Love 172f032c2f7SRobert Love /* 173f032c2f7SRobert Love * rsp_codes 174f032c2f7SRobert Love */ 175f032c2f7SRobert Love enum fcp_resp_rsp_codes { 176f032c2f7SRobert Love FCP_TMF_CMPL = 0, 177f032c2f7SRobert Love FCP_DATA_LEN_INVALID = 1, 178f032c2f7SRobert Love FCP_CMND_FIELDS_INVALID = 2, 179f032c2f7SRobert Love FCP_DATA_PARAM_MISMATCH = 3, 180f032c2f7SRobert Love FCP_TMF_REJECTED = 4, 181f032c2f7SRobert Love FCP_TMF_FAILED = 5, 182f032c2f7SRobert Love FCP_TMF_INVALID_LUN = 9, 183f032c2f7SRobert Love }; 184f032c2f7SRobert Love 185f032c2f7SRobert Love /* 186f032c2f7SRobert Love * FCP SRR Link Service request - Sequence Retransmission Request. 187f032c2f7SRobert Love */ 188f032c2f7SRobert Love struct fcp_srr { 189f032c2f7SRobert Love __u8 srr_op; /* opcode ELS_SRR */ 190f032c2f7SRobert Love __u8 srr_resvd[3]; /* opcode / reserved - must be zero */ 191f032c2f7SRobert Love __be16 srr_ox_id; /* OX_ID of failed command */ 192f032c2f7SRobert Love __be16 srr_rx_id; /* RX_ID of failed command */ 193f032c2f7SRobert Love __be32 srr_rel_off; /* relative offset */ 194f032c2f7SRobert Love __u8 srr_r_ctl; /* r_ctl for the information unit */ 195f032c2f7SRobert Love __u8 srr_resvd2[3]; /* reserved */ 196f032c2f7SRobert Love }; 197f032c2f7SRobert Love 198ab593b18SJoe Eykholt /* 199ab593b18SJoe Eykholt * Feature bits in name server FC-4 Features object. 200ab593b18SJoe Eykholt */ 201ab593b18SJoe Eykholt #define FCP_FEAT_TARG (1 << 0) /* target function supported */ 202ab593b18SJoe Eykholt #define FCP_FEAT_INIT (1 << 1) /* initiator function supported */ 203ab593b18SJoe Eykholt 204f032c2f7SRobert Love #endif /* _FC_FCP_H_ */ 205