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