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