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