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
11FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
12FILE_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 */
20struct 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 */
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 */
48 /** Relative offset of data */
50 /** Burst length */
52 /** Reserved */
54} __attribute__ (( packed ));
55
56/** An FCP response IU */
57struct 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 */
92static 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 */
103static 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 */
114static 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 */
126static 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 NULL
NULL pointer (VOID *)
Definition Base.h:322
unsigned short uint16_t
Definition stdint.h:11
unsigned int uint32_t
Definition stdint.h:12
unsigned char uint8_t
Definition stdint.h:10
Fibre Channel.
Fibre Channel Extended Link Services.
#define FCP_RSP_RESPONSE_LEN_VALID
Response length field is valid.
Definition fcp.h:75
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
#define FCP_RSP_SENSE_LEN_VALID
Sense length field is valid.
Definition fcp.h:78
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
static void * fcp_rsp_sense_data(struct fcp_rsp *rsp)
Get sense data portion of FCP response.
Definition fcp.h:114
static void * fcp_rsp_response_data(struct fcp_rsp *rsp)
Get response data portion of FCP response.
Definition fcp.h:92
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
#define ntohl(value)
Definition byteswap.h:135
#define __attribute__(x)
Definition compiler.h:10
uint64_t rsp
Definition librm.h:18
SCSI devices.
A Fibre Channel name.
Definition fc.h:30
An FCP command IU.
Definition fcp.h:20
uint8_t flags
Task management flags.
Definition fcp.h:28
uint32_t len
Data length.
Definition fcp.h:34
uint8_t ref
Command reference number.
Definition fcp.h:24
union scsi_cdb cdb
SCSI CDB.
Definition fcp.h:32
uint8_t dirn
Direction.
Definition fcp.h:30
uint8_t priority
Priority and task attributes.
Definition fcp.h:26
struct scsi_lun lun
SCSI LUN.
Definition fcp.h:22
An FCP device description.
Definition fcp.h:168
struct fc_name wwn
Fibre Channel WWN.
Definition fcp.h:170
struct scsi_lun lun
SCSI LUN.
Definition fcp.h:172
An FCP PRLI service parameter page.
Definition fcp.h:132
uint32_t flags
Flags.
Definition fcp.h:134
An FCP response IU.
Definition fcp.h:57
uint8_t flags
Flags.
Definition fcp.h:63
uint32_t sense_len
Sense data length.
Definition fcp.h:69
uint32_t response_len
Response data length.
Definition fcp.h:71
uint8_t reserved[8]
Reserved.
Definition fcp.h:59
uint32_t residual
Residual data count.
Definition fcp.h:67
uint8_t status
SCSI status code.
Definition fcp.h:65
uint16_t retry_delay
Retry delay timer.
Definition fcp.h:61
An FCP transfer ready IU.
Definition fcp.h:47
uint32_t reserved
Reserved.
Definition fcp.h:53
uint32_t offset
Relative offset of data.
Definition fcp.h:49
uint32_t len
Burst length.
Definition fcp.h:51
A SCSI LUN.
Definition scsi.h:236
A SCSI Command Data Block.
Definition scsi.h:207