Browse Source

[fcp] Add support for the Fibre Channel Protocol

The Fibre Channel Protocol provides a mechanism for transporting SCSI
commands via a Fibre Channel fabric.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 14 years ago
parent
commit
d2a2618d76
6 changed files with 1181 additions and 0 deletions
  1. 7
    0
      src/config/config_fc.c
  2. 1
    0
      src/config/defaults/pcbios.h
  3. 1
    0
      src/config/general.h
  4. 1
    0
      src/include/ipxe/errfile.h
  5. 166
    0
      src/include/ipxe/fcp.h
  6. 1005
    0
      src/net/fcp.c

+ 7
- 0
src/config/config_fc.c View File

@@ -22,3 +22,10 @@ FILE_LICENCE ( GPL2_OR_LATER );
22 22
 #ifdef FCMGMT_CMD
23 23
 REQUIRE_OBJECT ( fcmgmt_cmd );
24 24
 #endif
25
+
26
+/*
27
+ * Drag in Fibre Channel-specific protocols
28
+ */
29
+#ifdef SANBOOT_PROTO_FCP
30
+REQUIRE_OBJECT ( fcp );
31
+#endif

+ 1
- 0
src/config/defaults/pcbios.h View File

@@ -33,5 +33,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
33 33
 #define	SANBOOT_PROTO_ISCSI	/* iSCSI protocol */
34 34
 #define	SANBOOT_PROTO_AOE	/* AoE protocol */
35 35
 #define	SANBOOT_PROTO_IB_SRP	/* Infiniband SCSI RDMA protocol */
36
+#define	SANBOOT_PROTO_FCP	/* Fibre Channel protocol */
36 37
 
37 38
 #endif /* CONFIG_DEFAULTS_PCBIOS_H */

+ 1
- 0
src/config/general.h View File

@@ -68,6 +68,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
68 68
 //#undef	SANBOOT_PROTO_ISCSI	/* iSCSI protocol */
69 69
 //#undef	SANBOOT_PROTO_AOE	/* AoE protocol */
70 70
 //#undef	SANBOOT_PROTO_IB_SRP	/* Infiniband SCSI RDMA protocol */
71
+//#undef	SANBOOT_PROTO_FCP	/* Fibre Channel protocol */
71 72
 
72 73
 /*
73 74
  * 802.11 cryptosystems and handshaking protocols

+ 1
- 0
src/include/ipxe/errfile.h View File

@@ -186,6 +186,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
186 186
 #define ERRFILE_eth_slow		( ERRFILE_NET | 0x002a0000 )
187 187
 #define ERRFILE_fc			( ERRFILE_NET | 0x002b0000 )
188 188
 #define ERRFILE_fcels			( ERRFILE_NET | 0x002c0000 )
189
+#define ERRFILE_fcp			( ERRFILE_NET | 0x002d0000 )
189 190
 
190 191
 #define ERRFILE_image		      ( ERRFILE_IMAGE | 0x00000000 )
191 192
 #define ERRFILE_elf		      ( ERRFILE_IMAGE | 0x00010000 )

+ 166
- 0
src/include/ipxe/fcp.h View File

@@ -0,0 +1,166 @@
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 );
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 */
23
+	uint8_t ref;
24
+	/** Priority and task attributes */
25
+	uint8_t priority;
26
+	/** Task management flags */
27
+	uint8_t flags;
28
+	/** Direction */
29
+	uint8_t dirn;
30
+	/** SCSI CDB */
31
+	union scsi_cdb cdb;
32
+	/** Data length */
33
+	uint32_t len;
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 */
48
+	uint32_t offset;
49
+	/** Burst length */
50
+	uint32_t len;
51
+	/** Reserved */
52
+	uint32_t reserved;
53
+} __attribute__ (( packed ));
54
+
55
+/** An FCP response IU */
56
+struct fcp_rsp {
57
+	/** Reserved */
58
+	uint8_t reserved[8];
59
+	/** Retry delay timer */
60
+	uint16_t retry_delay;
61
+	/** Flags */
62
+	uint8_t flags;
63
+	/** SCSI status code */
64
+	uint8_t status;
65
+	/** Residual data count */
66
+	uint32_t residual;
67
+	/** Sense data length */
68
+	uint32_t sense_len;
69
+	/** Response data length */
70
+	uint32_t response_len;
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 ) +
116
+		   fcp_rsp_response_data_len ( rsp ) ) : NULL );
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 */
131
+struct fcp_prli_service_parameters {
132
+	/** Flags */
133
+	uint32_t 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 */

+ 1005
- 0
src/net/fcp.c
File diff suppressed because it is too large
View File


Loading…
Cancel
Save