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