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