iPXE
fcp.h
Go to the documentation of this file.
1 #ifndef _IPXE_FCP_H
2 #define _IPXE_FCP_H
3 
4 /**
5  * @file
6  *
7  * Fibre Channel Protocol
8  *
9  */
10 
11 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
12 FILE_SECBOOT ( PERMITTED );
13 
14 #include <stdint.h>
15 #include <ipxe/fc.h>
16 #include <ipxe/fcels.h>
17 #include <ipxe/scsi.h>
18 
19 /** An FCP command IU */
20 struct fcp_cmnd {
21  /** SCSI LUN */
22  struct scsi_lun lun;
23  /** Command reference number */
25  /** Priority and task attributes */
27  /** Task management flags */
29  /** Direction */
31  /** SCSI CDB */
32  union scsi_cdb cdb;
33  /** Data length */
35 } __attribute__ (( packed ));
36 
37 /** Command includes data-out */
38 #define FCP_CMND_WRDATA 0x01
39 
40 /** Command includes data-in */
41 #define FCP_CMND_RDDATA 0x02
42 
43 /** FCP tag magic marker */
44 #define FCP_TAG_MAGIC 0x18ae0000
45 
46 /** An FCP transfer ready IU */
47 struct fcp_xfer_rdy {
48  /** Relative offset of data */
50  /** Burst length */
52  /** Reserved */
54 } __attribute__ (( packed ));
55 
56 /** An FCP response IU */
57 struct fcp_rsp {
58  /** Reserved */
60  /** Retry delay timer */
62  /** Flags */
64  /** SCSI status code */
66  /** Residual data count */
68  /** Sense data length */
70  /** Response data length */
72 } __attribute__ (( packed ));
73 
74 /** Response length field is valid */
75 #define FCP_RSP_RESPONSE_LEN_VALID 0x01
76 
77 /** Sense length field is valid */
78 #define FCP_RSP_SENSE_LEN_VALID 0x02
79 
80 /** Residual represents overrun */
81 #define FCP_RSP_RESIDUAL_OVERRUN 0x04
82 
83 /** Residual represents underrun */
84 #define FCP_RSP_RESIDUAL_UNDERRUN 0x08
85 
86 /**
87  * Get response data portion of FCP response
88  *
89  * @v rsp FCP response
90  * @ret response_data Response data, or NULL if not present
91  */
92 static inline void * fcp_rsp_response_data ( struct fcp_rsp *rsp ) {
93  return ( ( rsp->flags & FCP_RSP_RESPONSE_LEN_VALID ) ?
94  ( ( ( void * ) rsp ) + sizeof ( *rsp ) ) : NULL );
95 }
96 
97 /**
98  * Get length of response data portion of FCP response
99  *
100  * @v rsp FCP response
101  * @ret response_data_len Response data length
102  */
103 static inline size_t fcp_rsp_response_data_len ( struct fcp_rsp *rsp ) {
104  return ( ( rsp->flags & FCP_RSP_RESPONSE_LEN_VALID ) ?
105  ntohl ( rsp->response_len ) : 0 );
106 }
107 
108 /**
109  * Get sense data portion of FCP response
110  *
111  * @v rsp FCP response
112  * @ret sense_data Sense data, or NULL if not present
113  */
114 static inline void * fcp_rsp_sense_data ( struct fcp_rsp *rsp ) {
115  return ( ( rsp->flags & FCP_RSP_SENSE_LEN_VALID ) ?
116  ( ( ( void * ) rsp ) + sizeof ( *rsp ) +
118 }
119 
120 /**
121  * Get length of sense data portion of FCP response
122  *
123  * @v rsp FCP response
124  * @ret sense_data_len Sense data length
125  */
126 static inline size_t fcp_rsp_sense_data_len ( struct fcp_rsp *rsp ) {
127  return ( ( rsp->flags & FCP_RSP_SENSE_LEN_VALID ) ?
128  ntohl ( rsp->sense_len ) : 0 );
129 }
130 
131 /** An FCP PRLI service parameter page */
133  /** Flags */
135 } __attribute__ (( packed ));
136 
137 /** Write FCP_XFER_RDY disabled */
138 #define FCP_PRLI_NO_WRITE_RDY 0x0001
139 
140 /** Read FCP_XFER_RDY disabled */
141 #define FCP_PRLI_NO_READ_RDY 0x0002
142 
143 /** Has target functionality */
144 #define FCP_PRLI_TARGET 0x0010
145 
146 /** Has initiator functionality */
147 #define FCP_PRLI_INITIATOR 0x0020
148 
149 /** Data overlay allowed */
150 #define FCP_PRLI_OVERLAY 0x0040
151 
152 /** Confirm completion allowed */
153 #define FCP_PRLI_CONF 0x0080
154 
155 /** Retransmission supported */
156 #define FCP_PRLI_RETRY 0x0100
157 
158 /** Task retry identification */
159 #define FCP_PRLI_TASK_RETRY 0x0200
160 
161 /** REC ELS supported */
162 #define FCP_PRLI_REC 0x0400
163 
164 /** Enhanced discovery supported */
165 #define FCP_PRLI_ENH_DISC 0x0800
166 
167 /** An FCP device description */
169  /** Fibre Channel WWN */
170  struct fc_name wwn;
171  /** SCSI LUN */
172  struct scsi_lun lun;
173 };
174 
175 #endif /* _IPXE_FCP_H */
#define __attribute__(x)
Definition: compiler.h:10
unsigned short uint16_t
Definition: stdint.h:11
uint8_t status
SCSI status code.
Definition: fcp.h:65
An FCP transfer ready IU.
Definition: fcp.h:47
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
union scsi_cdb cdb
SCSI CDB.
Definition: fcp.h:32
uint8_t reserved[8]
Reserved.
Definition: fcp.h:59
An FCP command IU.
Definition: fcp.h:20
uint32_t residual
Residual data count.
Definition: fcp.h:67
#define ntohl(value)
Definition: byteswap.h:135
uint32_t offset
Relative offset of data.
Definition: fcp.h:49
struct fc_name wwn
Fibre Channel WWN.
Definition: fcp.h:170
uint16_t retry_delay
Retry delay timer.
Definition: fcp.h:61
uint32_t reserved
Reserved.
Definition: fcp.h:53
static void * fcp_rsp_sense_data(struct fcp_rsp *rsp)
Get sense data portion of FCP response.
Definition: fcp.h:114
uint32_t flags
Flags.
Definition: fcp.h:134
uint8_t flags
Task management flags.
Definition: fcp.h:28
static void * fcp_rsp_response_data(struct fcp_rsp *rsp)
Get response data portion of FCP response.
Definition: fcp.h:92
struct scsi_lun lun
SCSI LUN.
Definition: fcp.h:22
uint64_t rsp
Definition: librm.h:153
static size_t fcp_rsp_response_data_len(struct fcp_rsp *rsp)
Get length of response data portion of FCP response.
Definition: fcp.h:103
uint32_t response_len
Response data length.
Definition: fcp.h:71
uint8_t flags
Flags.
Definition: fcp.h:63
unsigned char uint8_t
Definition: stdint.h:10
Fibre Channel.
uint8_t ref
Command reference number.
Definition: fcp.h:24
#define FCP_RSP_RESPONSE_LEN_VALID
Response length field is valid.
Definition: fcp.h:75
unsigned int uint32_t
Definition: stdint.h:12
An FCP device description.
Definition: fcp.h:168
A SCSI Command Data Block.
Definition: scsi.h:207
A Fibre Channel name.
Definition: fc.h:30
SCSI devices.
struct scsi_lun lun
SCSI LUN.
Definition: fcp.h:172
An FCP PRLI service parameter page.
Definition: fcp.h:132
uint8_t priority
Priority and task attributes.
Definition: fcp.h:26
uint32_t len
Data length.
Definition: fcp.h:34
A SCSI LUN.
Definition: scsi.h:236
#define FCP_RSP_SENSE_LEN_VALID
Sense length field is valid.
Definition: fcp.h:78
An FCP response IU.
Definition: fcp.h:57
uint32_t len
Burst length.
Definition: fcp.h:51
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322
uint8_t dirn
Direction.
Definition: fcp.h:30
FILE_SECBOOT(PERMITTED)
static size_t fcp_rsp_sense_data_len(struct fcp_rsp *rsp)
Get length of sense data portion of FCP response.
Definition: fcp.h:126
Fibre Channel Extended Link Services.
uint32_t sense_len
Sense data length.
Definition: fcp.h:69