iPXE
fcp.h
Go to the documentation of this file.
00001 #ifndef _IPXE_FCP_H
00002 #define _IPXE_FCP_H
00003 
00004 /**
00005  * @file
00006  *
00007  * Fibre Channel Protocol
00008  *
00009  */
00010 
00011 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00012 
00013 #include <stdint.h>
00014 #include <ipxe/fc.h>
00015 #include <ipxe/fcels.h>
00016 #include <ipxe/scsi.h>
00017 
00018 /** An FCP command IU */
00019 struct fcp_cmnd {
00020         /** SCSI LUN */
00021         struct scsi_lun lun;
00022         /** Command reference number */
00023         uint8_t ref;
00024         /** Priority and task attributes */
00025         uint8_t priority;
00026         /** Task management flags */
00027         uint8_t flags;
00028         /** Direction */
00029         uint8_t dirn;
00030         /** SCSI CDB */
00031         union scsi_cdb cdb;
00032         /** Data length */
00033         uint32_t len;
00034 } __attribute__ (( packed ));
00035 
00036 /** Command includes data-out */
00037 #define FCP_CMND_WRDATA 0x01
00038 
00039 /** Command includes data-in */
00040 #define FCP_CMND_RDDATA 0x02
00041 
00042 /** FCP tag magic marker */
00043 #define FCP_TAG_MAGIC 0x18ae0000
00044 
00045 /** An FCP transfer ready IU */
00046 struct fcp_xfer_rdy {
00047         /** Relative offset of data */
00048         uint32_t offset;
00049         /** Burst length */
00050         uint32_t len;
00051         /** Reserved */
00052         uint32_t reserved;
00053 } __attribute__ (( packed ));
00054 
00055 /** An FCP response IU */
00056 struct fcp_rsp {
00057         /** Reserved */
00058         uint8_t reserved[8];
00059         /** Retry delay timer */
00060         uint16_t retry_delay;
00061         /** Flags */
00062         uint8_t flags;
00063         /** SCSI status code */
00064         uint8_t status;
00065         /** Residual data count */
00066         uint32_t residual;
00067         /** Sense data length */
00068         uint32_t sense_len;
00069         /** Response data length */
00070         uint32_t response_len;
00071 } __attribute__ (( packed ));
00072 
00073 /** Response length field is valid */
00074 #define FCP_RSP_RESPONSE_LEN_VALID 0x01
00075 
00076 /** Sense length field is valid */
00077 #define FCP_RSP_SENSE_LEN_VALID 0x02
00078 
00079 /** Residual represents overrun */
00080 #define FCP_RSP_RESIDUAL_OVERRUN 0x04
00081 
00082 /** Residual represents underrun */
00083 #define FCP_RSP_RESIDUAL_UNDERRUN 0x08
00084 
00085 /**
00086  * Get response data portion of FCP response
00087  *
00088  * @v rsp                       FCP response
00089  * @ret response_data           Response data, or NULL if not present
00090  */
00091 static inline void * fcp_rsp_response_data ( struct fcp_rsp *rsp ) {
00092         return ( ( rsp->flags & FCP_RSP_RESPONSE_LEN_VALID ) ?
00093                  ( ( ( void * ) rsp ) + sizeof ( *rsp ) ) : NULL );
00094 }
00095 
00096 /**
00097  * Get length of response data portion of FCP response
00098  *
00099  * @v rsp                       FCP response
00100  * @ret response_data_len       Response data length
00101  */
00102 static inline size_t fcp_rsp_response_data_len ( struct fcp_rsp *rsp ) {
00103         return ( ( rsp->flags & FCP_RSP_RESPONSE_LEN_VALID ) ?
00104                  ntohl ( rsp->response_len ) : 0 );
00105 }
00106 
00107 /**
00108  * Get sense data portion of FCP response
00109  *
00110  * @v rsp                       FCP response
00111  * @ret sense_data              Sense data, or NULL if not present
00112  */
00113 static inline void * fcp_rsp_sense_data ( struct fcp_rsp *rsp ) {
00114         return ( ( rsp->flags & FCP_RSP_SENSE_LEN_VALID ) ?
00115                  ( ( ( void * ) rsp ) + sizeof ( *rsp ) +
00116                    fcp_rsp_response_data_len ( rsp ) ) : NULL );
00117 }
00118 
00119 /**
00120  * Get length of sense data portion of FCP response
00121  *
00122  * @v rsp                       FCP response
00123  * @ret sense_data_len          Sense data length
00124  */
00125 static inline size_t fcp_rsp_sense_data_len ( struct fcp_rsp *rsp ) {
00126         return ( ( rsp->flags & FCP_RSP_SENSE_LEN_VALID ) ?
00127                  ntohl ( rsp->sense_len ) : 0 );
00128 }
00129 
00130 /** An FCP PRLI service parameter page */
00131 struct fcp_prli_service_parameters {
00132         /** Flags */
00133         uint32_t flags;
00134 } __attribute__ (( packed ));
00135 
00136 /** Write FCP_XFER_RDY disabled */
00137 #define FCP_PRLI_NO_WRITE_RDY 0x0001
00138 
00139 /** Read FCP_XFER_RDY disabled */
00140 #define FCP_PRLI_NO_READ_RDY 0x0002
00141 
00142 /** Has target functionality */
00143 #define FCP_PRLI_TARGET 0x0010
00144 
00145 /** Has initiator functionality */
00146 #define FCP_PRLI_INITIATOR 0x0020
00147 
00148 /** Data overlay allowed */
00149 #define FCP_PRLI_OVERLAY 0x0040
00150 
00151 /** Confirm completion allowed */
00152 #define FCP_PRLI_CONF 0x0080
00153 
00154 /** Retransmission supported */
00155 #define FCP_PRLI_RETRY 0x0100
00156 
00157 /** Task retry identification */
00158 #define FCP_PRLI_TASK_RETRY 0x0200
00159 
00160 /** REC ELS supported */
00161 #define FCP_PRLI_REC 0x0400
00162 
00163 /** Enhanced discovery supported */
00164 #define FCP_PRLI_ENH_DISC 0x0800
00165 
00166 #endif /* _IPXE_FCP_H */