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