|
@@ -0,0 +1,452 @@
|
|
1
|
+#ifndef _IPXE_FCELS_H
|
|
2
|
+#define _IPXE_FCELS_H
|
|
3
|
+
|
|
4
|
+/**
|
|
5
|
+ * @file
|
|
6
|
+ *
|
|
7
|
+ * Fibre Channel Extended Link Services
|
|
8
|
+ *
|
|
9
|
+ */
|
|
10
|
+
|
|
11
|
+FILE_LICENCE ( GPL2_OR_LATER );
|
|
12
|
+
|
|
13
|
+#include <stdint.h>
|
|
14
|
+#include <ipxe/fc.h>
|
|
15
|
+#include <ipxe/tables.h>
|
|
16
|
+#include <ipxe/refcnt.h>
|
|
17
|
+#include <ipxe/list.h>
|
|
18
|
+#include <ipxe/process.h>
|
|
19
|
+#include <ipxe/interface.h>
|
|
20
|
+
|
|
21
|
+/** Fibre Channel ELS frame common parameters */
|
|
22
|
+struct fc_els_frame_common {
|
|
23
|
+ /** ELS command code */
|
|
24
|
+ uint8_t command;
|
|
25
|
+ /** Reserved */
|
|
26
|
+ uint8_t reserved[3];
|
|
27
|
+} __attribute__ (( packed ));
|
|
28
|
+
|
|
29
|
+/** Fibre Channel ELS command codes */
|
|
30
|
+enum fc_els_command_code {
|
|
31
|
+ FC_ELS_LS_RJT = 0x01, /**< Link Service Reject */
|
|
32
|
+ FC_ELS_LS_ACC = 0x02, /**< Link Service Accept */
|
|
33
|
+ FC_ELS_PLOGI = 0x03, /**< Port Login */
|
|
34
|
+ FC_ELS_FLOGI = 0x04, /**< Fabric Login */
|
|
35
|
+ FC_ELS_LOGO = 0x05, /**< Logout */
|
|
36
|
+ FC_ELS_RTV = 0x0e, /**< Read Timeout Value */
|
|
37
|
+ FC_ELS_PRLI = 0x20, /**< Process Login */
|
|
38
|
+ FC_ELS_PRLO = 0x21, /**< Process Logout */
|
|
39
|
+};
|
|
40
|
+
|
|
41
|
+/** A Fibre Channel LS_RJT frame */
|
|
42
|
+struct fc_ls_rjt_frame {
|
|
43
|
+ /** ELS command code */
|
|
44
|
+ uint8_t command;
|
|
45
|
+ /** Reserved */
|
|
46
|
+ uint8_t reserved[4];
|
|
47
|
+ /** Reason code */
|
|
48
|
+ uint8_t reason;
|
|
49
|
+ /** Reason code explanation */
|
|
50
|
+ uint8_t explanation;
|
|
51
|
+ /** Vendor unique */
|
|
52
|
+ uint8_t vendor;
|
|
53
|
+} __attribute__ (( packed ));
|
|
54
|
+
|
|
55
|
+/** Fibre Channel ELS rejection reason codes */
|
|
56
|
+enum fc_els_reject_reason {
|
|
57
|
+ /** Invalid ELS command code */
|
|
58
|
+ FC_ELS_RJT_INVALID_COMMAND = 0x01,
|
|
59
|
+ /** Logical error */
|
|
60
|
+ FC_ELS_RJT_ILLOGICAL = 0x03,
|
|
61
|
+ /** Logical busy */
|
|
62
|
+ FC_ELS_RJT_BUSY = 0x05,
|
|
63
|
+ /** Protocol error */
|
|
64
|
+ FC_ELS_RJT_PROTOCOL = 0x07,
|
|
65
|
+ /** Unable to perform command request */
|
|
66
|
+ FC_ELS_RJT_UNABLE = 0x09,
|
|
67
|
+ /** Command not supported */
|
|
68
|
+ FC_ELS_RJT_UNSUPPORTED = 0x0b,
|
|
69
|
+ /** Command already in progress */
|
|
70
|
+ FC_ELS_RJT_IN_PROGRESS = 0x0e,
|
|
71
|
+};
|
|
72
|
+
|
|
73
|
+/** Fibre Channel "common" service parameters */
|
|
74
|
+struct fc_login_common {
|
|
75
|
+ /** Login version */
|
|
76
|
+ uint16_t version;
|
|
77
|
+ /** Buffer-to-buffer credit */
|
|
78
|
+ uint16_t credit;
|
|
79
|
+ /** Flags */
|
|
80
|
+ uint16_t flags;
|
|
81
|
+ /** Receive size */
|
|
82
|
+ uint16_t mtu;
|
|
83
|
+ /** "Common"?! */
|
|
84
|
+ union {
|
|
85
|
+ struct {
|
|
86
|
+ /** Maximum number of concurrent sequences */
|
|
87
|
+ uint16_t max_seq;
|
|
88
|
+ /** Relative offset by info category */
|
|
89
|
+ uint16_t rel_offs;
|
|
90
|
+ } plogi;
|
|
91
|
+ struct {
|
|
92
|
+ /** Resource allocation timeout value */
|
|
93
|
+ uint32_t r_a_tov;
|
|
94
|
+ } flogi;
|
|
95
|
+ } u;
|
|
96
|
+ /** Error detection timeout value */
|
|
97
|
+ uint32_t e_d_tov;
|
|
98
|
+} __attribute__ (( packed ));
|
|
99
|
+
|
|
100
|
+/** Fibre Channel default login version */
|
|
101
|
+#define FC_LOGIN_VERSION 0x2020
|
|
102
|
+
|
|
103
|
+/** Fibre Channel default buffer-to-buffer credit */
|
|
104
|
+#define FC_LOGIN_DEFAULT_B2B 10
|
|
105
|
+
|
|
106
|
+/** Continuously increasing relative offset */
|
|
107
|
+#define FC_LOGIN_CONTINUOUS_OFFSET 0x8000
|
|
108
|
+
|
|
109
|
+/** Clean address */
|
|
110
|
+#define FC_LOGIN_CLEAN 0x8000
|
|
111
|
+
|
|
112
|
+/** Multiple N_Port_ID support */
|
|
113
|
+#define FC_LOGIN_MULTI_N 0x8000
|
|
114
|
+
|
|
115
|
+/** Random relative offset */
|
|
116
|
+#define FC_LOGIN_RANDOM_OFFSET 0x4000
|
|
117
|
+
|
|
118
|
+/** Virtual fabrics */
|
|
119
|
+#define FC_LOGIN_VIRTUAL 0x4000
|
|
120
|
+
|
|
121
|
+/** Vendor version level */
|
|
122
|
+#define FC_LOGIN_VENDOR 0x2000
|
|
123
|
+
|
|
124
|
+/** Multiple N_Port_ID support */
|
|
125
|
+#define FC_LOGIN_MULTI_F 0x2000
|
|
126
|
+
|
|
127
|
+/** Forwarder port */
|
|
128
|
+#define FC_LOGIN_F_PORT 0x1000
|
|
129
|
+
|
|
130
|
+/** Alternative credit management */
|
|
131
|
+#define FC_LOGIN_ALT_CREDIT 0x0800
|
|
132
|
+
|
|
133
|
+/** Name server session started */
|
|
134
|
+#define FC_LOGIN_NSS_STARTED 0x0800
|
|
135
|
+
|
|
136
|
+/** Begin name server session */
|
|
137
|
+#define FC_LOGIN_NSS_BEGIN 0x0400
|
|
138
|
+
|
|
139
|
+/** 1ns error detection timer resolution */
|
|
140
|
+#define FC_LOGIN_HIRES_E_D_TOV 0x0400
|
|
141
|
+
|
|
142
|
+/** Broadcast supported */
|
|
143
|
+#define FC_LOGIN_BROADCAST 0x0100
|
|
144
|
+
|
|
145
|
+/** Query buffer conditions */
|
|
146
|
+#define FC_LOGIN_QUERY_BUF 0x0040
|
|
147
|
+
|
|
148
|
+/** Security */
|
|
149
|
+#define FC_LOGIN_SECURITY 0x0020
|
|
150
|
+
|
|
151
|
+/** Clock sync primitive capable */
|
|
152
|
+#define FC_LOGIN_CLOCK_SYNC 0x0010
|
|
153
|
+
|
|
154
|
+/** Short R_T timeout */
|
|
155
|
+#define FC_LOGIN_SHORT_R_T_TOV 0x0008
|
|
156
|
+
|
|
157
|
+/** Dynamic half duplex */
|
|
158
|
+#define FC_LOGIN_DHD 0x0004
|
|
159
|
+
|
|
160
|
+/** Continuously increasing sequence count */
|
|
161
|
+#define FC_LOGIN_CONTINUOUS_SEQ 0x0002
|
|
162
|
+
|
|
163
|
+/** Payload */
|
|
164
|
+#define FC_LOGIN_PAYLOAD 0x0001
|
|
165
|
+
|
|
166
|
+/** Fibre Channel default MTU */
|
|
167
|
+#define FC_LOGIN_DEFAULT_MTU 1452
|
|
168
|
+
|
|
169
|
+/** Default maximum number of concurrent sequences */
|
|
170
|
+#define FC_LOGIN_DEFAULT_MAX_SEQ 255
|
|
171
|
+
|
|
172
|
+/** Default relative offset by info category */
|
|
173
|
+#define FC_LOGIN_DEFAULT_REL_OFFS 0x1f
|
|
174
|
+
|
|
175
|
+/** Default E_D timeout value */
|
|
176
|
+#define FC_LOGIN_DEFAULT_E_D_TOV 2000
|
|
177
|
+
|
|
178
|
+/** Fibre Channel class-specific login parameters */
|
|
179
|
+struct fc_login_class {
|
|
180
|
+ /** Flags */
|
|
181
|
+ uint16_t flags;
|
|
182
|
+ /** Initiator flags */
|
|
183
|
+ uint16_t init_flags;
|
|
184
|
+ /** Recipient flags */
|
|
185
|
+ uint16_t recip_flags;
|
|
186
|
+ /** Receive data field size */
|
|
187
|
+ uint16_t mtu;
|
|
188
|
+ /** Maximum number of concurrent sequences */
|
|
189
|
+ uint16_t max_seq;
|
|
190
|
+ /** End-to-end credit */
|
|
191
|
+ uint16_t credit;
|
|
192
|
+ /** Reserved */
|
|
193
|
+ uint8_t reserved0;
|
|
194
|
+ /** Maximum number of open sequences per exchange */
|
|
195
|
+ uint8_t max_seq_per_xchg;
|
|
196
|
+ /** Reserved */
|
|
197
|
+ uint8_t reserved1[2];
|
|
198
|
+} __attribute__ (( packed ));
|
|
199
|
+
|
|
200
|
+/** Class valid */
|
|
201
|
+#define FC_LOGIN_CLASS_VALID 0x8000
|
|
202
|
+
|
|
203
|
+/** Sequential delivery requested */
|
|
204
|
+#define FC_LOGIN_CLASS_SEQUENTIAL 0x0800
|
|
205
|
+
|
|
206
|
+/** A Fibre Channel FLOGI/PLOGI frame */
|
|
207
|
+struct fc_login_frame {
|
|
208
|
+ /** ELS command code */
|
|
209
|
+ uint8_t command;
|
|
210
|
+ /** Reserved */
|
|
211
|
+ uint8_t reserved[3];
|
|
212
|
+ /** Common service parameters */
|
|
213
|
+ struct fc_login_common common;
|
|
214
|
+ /** Port name */
|
|
215
|
+ struct fc_name port_wwn;
|
|
216
|
+ /** Node name */
|
|
217
|
+ struct fc_name node_wwn;
|
|
218
|
+ /** Class 1 service parameters */
|
|
219
|
+ struct fc_login_class class1;
|
|
220
|
+ /** Class 2 service parameters */
|
|
221
|
+ struct fc_login_class class2;
|
|
222
|
+ /** Class 3 service parameters */
|
|
223
|
+ struct fc_login_class class3;
|
|
224
|
+ /** Class 4 service parameters */
|
|
225
|
+ struct fc_login_class class4;
|
|
226
|
+ /** Vendor version level */
|
|
227
|
+ uint8_t vendor_version[16];
|
|
228
|
+} __attribute__ (( packed ));
|
|
229
|
+
|
|
230
|
+/** A Fibre Channel LOGO request frame */
|
|
231
|
+struct fc_logout_request_frame {
|
|
232
|
+ /** ELS command code */
|
|
233
|
+ uint8_t command;
|
|
234
|
+ /** Reserved */
|
|
235
|
+ uint8_t reserved[4];
|
|
236
|
+ /** Port ID */
|
|
237
|
+ struct fc_port_id port_id;
|
|
238
|
+ /** Port name */
|
|
239
|
+ struct fc_name port_wwn;
|
|
240
|
+} __attribute__ (( packed ));
|
|
241
|
+
|
|
242
|
+/** A Fibre Channel LOGO response frame */
|
|
243
|
+struct fc_logout_response_frame {
|
|
244
|
+ /** ELS command code */
|
|
245
|
+ uint8_t command;
|
|
246
|
+ /** Reserved */
|
|
247
|
+ uint8_t reserved[3];
|
|
248
|
+} __attribute__ (( packed ));
|
|
249
|
+
|
|
250
|
+/** A Fibre Channel PRLI service parameter page */
|
|
251
|
+struct fc_prli_page {
|
|
252
|
+ /** Type code */
|
|
253
|
+ uint8_t type;
|
|
254
|
+ /** Type code extension */
|
|
255
|
+ uint8_t type_ext;
|
|
256
|
+ /** Flags and response code */
|
|
257
|
+ uint16_t flags;
|
|
258
|
+ /** Reserved */
|
|
259
|
+ uint32_t reserved[2];
|
|
260
|
+} __attribute__ (( packed ));
|
|
261
|
+
|
|
262
|
+/** Establish image pair */
|
|
263
|
+#define FC_PRLI_ESTABLISH 0x2000
|
|
264
|
+
|
|
265
|
+/** Response code mask */
|
|
266
|
+#define FC_PRLI_RESPONSE_MASK 0x0f00
|
|
267
|
+
|
|
268
|
+/** Request was executed successfully */
|
|
269
|
+#define FC_PRLI_RESPONSE_SUCCESS 0x0100
|
|
270
|
+
|
|
271
|
+/** A Fibre Channel PRLI frame */
|
|
272
|
+struct fc_prli_frame {
|
|
273
|
+ /** ELS command code */
|
|
274
|
+ uint8_t command;
|
|
275
|
+ /** Page length */
|
|
276
|
+ uint8_t page_len;
|
|
277
|
+ /** Payload length */
|
|
278
|
+ uint16_t len;
|
|
279
|
+ /** Service parameter page */
|
|
280
|
+ struct fc_prli_page page;
|
|
281
|
+} __attribute__ (( packed ));
|
|
282
|
+
|
|
283
|
+/** A Fibre Channel RTV request frame */
|
|
284
|
+struct fc_rtv_request_frame {
|
|
285
|
+ /** ELS command code */
|
|
286
|
+ uint8_t command;
|
|
287
|
+ /** Reserved */
|
|
288
|
+ uint8_t reserved[3];
|
|
289
|
+} __attribute__ (( packed ));
|
|
290
|
+
|
|
291
|
+/** A Fibre Channel RTV response frame */
|
|
292
|
+struct fc_rtv_response_frame {
|
|
293
|
+ /** ELS command code */
|
|
294
|
+ uint8_t command;
|
|
295
|
+ /** Reserved */
|
|
296
|
+ uint8_t reserved0[3];
|
|
297
|
+ /** Resource allocation timeout value */
|
|
298
|
+ uint32_t r_a_tov;
|
|
299
|
+ /** Error detection timeout value */
|
|
300
|
+ uint32_t e_d_tov;
|
|
301
|
+ /** Timeout qualifier */
|
|
302
|
+ uint16_t flags;
|
|
303
|
+ /** Reserved */
|
|
304
|
+ uint16_t reserved1;
|
|
305
|
+} __attribute__ (( packed ));
|
|
306
|
+
|
|
307
|
+/** 1ns error detection timer resolution */
|
|
308
|
+#define FC_RTV_HIRES_E_D_TOV 0x0400
|
|
309
|
+
|
|
310
|
+/** Short R_T timeout */
|
|
311
|
+#define FC_RTV_SHORT_R_T_TOV 0x0008
|
|
312
|
+
|
|
313
|
+/** A Fibre Channel extended link services transaction */
|
|
314
|
+struct fc_els {
|
|
315
|
+ /** Reference count */
|
|
316
|
+ struct refcnt refcnt;
|
|
317
|
+ /** Job control interface */
|
|
318
|
+ struct interface job;
|
|
319
|
+ /** Fibre Channel exchange */
|
|
320
|
+ struct interface xchg;
|
|
321
|
+ /** Request sending process */
|
|
322
|
+ struct process process;
|
|
323
|
+
|
|
324
|
+ /** Fibre Channel port */
|
|
325
|
+ struct fc_port *port;
|
|
326
|
+ /** Local port ID */
|
|
327
|
+ struct fc_port_id port_id;
|
|
328
|
+ /** Peer port ID */
|
|
329
|
+ struct fc_port_id peer_port_id;
|
|
330
|
+ /** ELS handler, if known */
|
|
331
|
+ struct fc_els_handler *handler;
|
|
332
|
+ /** Flags */
|
|
333
|
+ unsigned int flags;
|
|
334
|
+};
|
|
335
|
+
|
|
336
|
+/** Fibre Channel extended link services transaction flags */
|
|
337
|
+enum fc_els_flags {
|
|
338
|
+ /** ELS transaction is a request */
|
|
339
|
+ FC_ELS_REQUEST = 0x0001,
|
|
340
|
+};
|
|
341
|
+
|
|
342
|
+/** A Fibre Channel extended link services handler */
|
|
343
|
+struct fc_els_handler {
|
|
344
|
+ /** Name */
|
|
345
|
+ const char *name;
|
|
346
|
+ /** Transmit ELS request frame
|
|
347
|
+ *
|
|
348
|
+ * @v els Fibre Channel ELS transaction
|
|
349
|
+ * @ret rc Return status code
|
|
350
|
+ */
|
|
351
|
+ int ( * tx_request ) ( struct fc_els *els );
|
|
352
|
+ /** Transmit ELS response frame
|
|
353
|
+ *
|
|
354
|
+ * @v els Fibre Channel ELS transaction
|
|
355
|
+ * @ret rc Return status code
|
|
356
|
+ */
|
|
357
|
+ int ( * tx_response ) ( struct fc_els *els );
|
|
358
|
+ /** Receive ELS request frame
|
|
359
|
+ *
|
|
360
|
+ * @v els Fibre Channel ELS transaction
|
|
361
|
+ * @v data ELS frame
|
|
362
|
+ * @v len Length of ELS frame
|
|
363
|
+ * @ret rc Return status code
|
|
364
|
+ */
|
|
365
|
+ int ( * rx_request ) ( struct fc_els *els, const void *data,
|
|
366
|
+ size_t len );
|
|
367
|
+ /** Receive ELS response frame
|
|
368
|
+ *
|
|
369
|
+ * @v els Fibre Channel ELS transaction
|
|
370
|
+ * @v data ELS frame
|
|
371
|
+ * @v len Length of ELS frame
|
|
372
|
+ * @ret rc Return status code
|
|
373
|
+ */
|
|
374
|
+ int ( * rx_response ) ( struct fc_els *els, const void *data,
|
|
375
|
+ size_t len );
|
|
376
|
+ /** Detect ELS request frame
|
|
377
|
+ *
|
|
378
|
+ * @v els Fibre Channel ELS transaction
|
|
379
|
+ * @v data ELS frame
|
|
380
|
+ * @v len Length of ELS frame
|
|
381
|
+ * @ret rc Return status code
|
|
382
|
+ */
|
|
383
|
+ int ( * detect ) ( struct fc_els *els, const void *data, size_t len );
|
|
384
|
+};
|
|
385
|
+
|
|
386
|
+/** Fibre Channel ELS handler table */
|
|
387
|
+#define FC_ELS_HANDLERS __table ( struct fc_els_handler, "fc_els_handlers" )
|
|
388
|
+
|
|
389
|
+/** Declare a Fibre Channel ELS handler */
|
|
390
|
+#define __fc_els_handler __table_entry ( FC_ELS_HANDLERS, 01 )
|
|
391
|
+
|
|
392
|
+/** A Fibre Channel ELS PRLI descriptor */
|
|
393
|
+struct fc_els_prli_descriptor {
|
|
394
|
+ /** Upper-layer protocol type */
|
|
395
|
+ unsigned int type;
|
|
396
|
+ /** Service parameter length */
|
|
397
|
+ size_t param_len;
|
|
398
|
+ /** Fibre Channel ELS handler */
|
|
399
|
+ struct fc_els_handler *handler;
|
|
400
|
+};
|
|
401
|
+
|
|
402
|
+/** Fibre Channel ELS PRLI descriptor table */
|
|
403
|
+#define FC_ELS_PRLI_DESCRIPTORS \
|
|
404
|
+ __table ( struct fc_els_prli_descriptor, "fc_els_prli_descriptors" )
|
|
405
|
+
|
|
406
|
+/** Declare a Fibre Channel ELS PRLI descriptor */
|
|
407
|
+#define __fc_els_prli_descriptor __table_entry ( FC_ELS_PRLI_DESCRIPTORS, 01 )
|
|
408
|
+
|
|
409
|
+/**
|
|
410
|
+ * Check if Fibre Channel ELS transaction is a request
|
|
411
|
+ *
|
|
412
|
+ * @v els Fibre Channel ELS transaction
|
|
413
|
+ * @ret is_request ELS transaction is a request
|
|
414
|
+ */
|
|
415
|
+static inline int fc_els_is_request ( struct fc_els *els ) {
|
|
416
|
+ return ( els->flags & FC_ELS_REQUEST );
|
|
417
|
+}
|
|
418
|
+
|
|
419
|
+/**
|
|
420
|
+ * Calculate ELS command to transmit
|
|
421
|
+ *
|
|
422
|
+ * @v els Fibre Channel ELS transaction
|
|
423
|
+ * @v request_command Command for requests
|
|
424
|
+ * @v command Command to transmit
|
|
425
|
+ */
|
|
426
|
+static inline unsigned int fc_els_tx_command ( struct fc_els *els,
|
|
427
|
+ unsigned int request_command ) {
|
|
428
|
+ return ( fc_els_is_request ( els ) ? request_command : FC_ELS_LS_ACC );
|
|
429
|
+}
|
|
430
|
+
|
|
431
|
+extern int fc_els_tx ( struct fc_els *els, const void *data, size_t len );
|
|
432
|
+extern int fc_els_request ( struct interface *job, struct fc_port *port,
|
|
433
|
+ struct fc_port_id *peer_port_id,
|
|
434
|
+ struct fc_els_handler *handler );
|
|
435
|
+extern int fc_els_flogi ( struct interface *parent, struct fc_port *port );
|
|
436
|
+extern int fc_els_plogi ( struct interface *parent, struct fc_port *port,
|
|
437
|
+ struct fc_port_id *peer_port_id );
|
|
438
|
+extern int fc_els_logo ( struct interface *parent, struct fc_port *port,
|
|
439
|
+ struct fc_port_id *peer_port_id );
|
|
440
|
+extern int fc_els_prli ( struct interface *parent, struct fc_port *port,
|
|
441
|
+ struct fc_port_id *peer_port_id, unsigned int type );
|
|
442
|
+extern int fc_els_prli_tx ( struct fc_els *els,
|
|
443
|
+ struct fc_els_prli_descriptor *descriptor,
|
|
444
|
+ void *param );
|
|
445
|
+extern int fc_els_prli_rx ( struct fc_els *els,
|
|
446
|
+ struct fc_els_prli_descriptor *descriptor,
|
|
447
|
+ const void *data, size_t len );
|
|
448
|
+extern int fc_els_prli_detect ( struct fc_els *els __unused,
|
|
449
|
+ struct fc_els_prli_descriptor *descriptor,
|
|
450
|
+ const void *data, size_t len );
|
|
451
|
+
|
|
452
|
+#endif /* _IPXE_FCELS_H */
|