5 * Copyright (C) 2010 Michael Brown <mbrown@fensystems.co.uk>.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or any later version.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 #include <ipxe/fcels.h>
26 #include <ipxe/fcoe.h>
28 /** A FIP frame header */
40 /** Descriptor list length in 32-bit words */
44 } __attribute__ (( packed ));
46 /** FIP frame version */
47 #define FIP_VERSION 0x10
49 /** FIP protocol code */
51 FIP_CODE_DISCOVERY = 0x0001, /**< Discovery */
52 FIP_CODE_ELS = 0x0002, /**< Extended link services */
53 FIP_CODE_MAINTAIN = 0x0003, /**< Maintain virtual links */
54 FIP_CODE_VLAN = 0x0004, /**< VLAN */
57 /** FIP protocol subcode for discovery */
58 enum fip_discovery_subcode {
59 FIP_DISCOVERY_SOLICIT = 0x01, /**< Discovery solicitation */
60 FIP_DISCOVERY_ADVERTISE = 0x02, /**< Discovery advertisement */
63 /** FIP protocol subcode for extended link services */
64 enum fip_els_subcode {
65 FIP_ELS_REQUEST = 0x01, /**< ELS request */
66 FIP_ELS_RESPONSE = 0x02, /**< ELS response */
69 /** FIP protocol subcode for keep alive / clear links */
70 enum fip_vitality_subcode {
71 FIP_MAINTAIN_KEEP_ALIVE = 0x01, /**< Keep alive */
72 FIP_MAINTAIN_CLEAR_LINKS = 0x02,/**< Clear virtual links */
75 /** FIP protocol subcode for VLAN */
76 enum fip_vlan_subcode {
77 FIP_VLAN_REQUEST = 0x01, /**< VLAN request */
78 FIP_VLAN_NOTIFY = 0x02, /**< VLAN notification */
83 FIP_FP = 0x8000, /**< Fabric-provided MAC address */
84 FIP_SP = 0x4000, /**< Server-provided MAC address */
85 FIP_A = 0x0004, /**< Available for login */
86 FIP_S = 0x0002, /**< Solicited */
87 FIP_F = 0x0001, /**< Forwarder */
90 /** FIP descriptor common fields */
94 /** Length in 32-bit words */
98 } __attribute__ (( packed ));
100 /** FIP descriptor types */
102 FIP_RESERVED = 0x00, /**< Reserved */
103 FIP_PRIORITY = 0x01, /**< Priority */
104 FIP_MAC_ADDRESS = 0x02, /**< MAC address */
105 FIP_FC_MAP = 0x03, /**< FC-MAP */
106 FIP_NAME_ID = 0x04, /**< Name identifier */
107 FIP_FABRIC = 0x05, /**< Fabric */
108 FIP_MAX_FCOE_SIZE = 0x06, /**< Max FCoE size */
109 FIP_FLOGI = 0x07, /**< FLOGI */
110 FIP_NPIV_FDISC = 0x08, /**< NPIV FDISC */
111 FIP_LOGO = 0x09, /**< LOGO */
112 FIP_ELP = 0x0a, /**< ELP */
113 FIP_VX_PORT_ID = 0x0b, /**< Vx port identification */
114 FIP_FKA_ADV_P = 0x0c, /**< FKA ADV period */
115 FIP_VENDOR_ID = 0x0d, /**< Vendor ID */
116 FIP_VLAN = 0x0e, /**< VLAN */
117 FIP_NUM_DESCRIPTOR_TYPES
120 /** FIP descriptor type is critical */
121 #define FIP_IS_CRITICAL( type ) ( (type) <= 0x7f )
123 /** A FIP priority descriptor */
124 struct fip_priority {
127 /** Length in 32-bit words */
133 * A higher value indicates a lower priority.
136 } __attribute__ (( packed ));
138 /** Default FIP priority */
139 #define FIP_DEFAULT_PRIORITY 128
141 /** Lowest FIP priority */
142 #define FIP_LOWEST_PRIORITY 255
144 /** A FIP MAC address descriptor */
145 struct fip_mac_address {
148 /** Length in 32-bit words */
151 uint8_t mac[ETH_ALEN];
152 } __attribute__ (( packed ));
154 /** A FIP FC-MAP descriptor */
158 /** Length in 32-bit words */
164 } __attribute__ (( packed ));
166 /** A FIP name identifier descriptor */
170 /** Length in 32-bit words */
174 /** Name identifier */
176 } __attribute__ (( packed ));
178 /** A FIP fabric descriptor */
182 /** Length in 32-bit words */
184 /** Virtual Fabric ID, if any */
192 } __attribute__ (( packed ));
194 /** A FIP max FCoE size descriptor */
195 struct fip_max_fcoe_size {
198 /** Length in 32-bit words */
200 /** Maximum FCoE size */
202 } __attribute__ (( packed ));
204 /** A FIP descriptor containing an encapsulated ELS frame */
208 /** Length in 32-bit words */
212 /** Fibre Channel frame header */
213 struct fc_frame_header fc;
215 struct fc_els_frame_common els;
216 } __attribute__ (( packed ));
218 /** A FIP descriptor containing an encapsulated login frame */
222 /** Length in 32-bit words */
226 /** Fibre Channel frame header */
227 struct fc_frame_header fc;
229 struct fc_login_frame els;
230 } __attribute__ (( packed ));
232 /** A FIP descriptor containing an encapsulated LOGO request frame */
233 struct fip_logo_request {
236 /** Length in 32-bit words */
240 /** Fibre Channel frame header */
241 struct fc_frame_header fc;
243 struct fc_logout_request_frame els;
244 } __attribute__ (( packed ));
246 /** A FIP descriptor containing an encapsulated LOGO response frame */
247 struct fip_logo_response {
250 /** Length in 32-bit words */
254 /** Fibre Channel frame header */
255 struct fc_frame_header fc;
257 struct fc_logout_response_frame els;
258 } __attribute__ (( packed ));
260 /** A FIP descriptor containing an encapsulated ELP frame */
264 /** Length in 32-bit words */
268 /** Fibre Channel frame header */
269 struct fc_frame_header fc;
271 struct fc_els_frame_common els;
272 /** Uninteresting content */
274 } __attribute__ (( packed ));
276 /** A FIP descriptor containing an encapsulated LS_RJT frame */
280 /** Length in 32-bit words */
284 /** Fibre Channel frame header */
285 struct fc_frame_header fc;
287 struct fc_ls_rjt_frame els;
288 } __attribute__ (( packed ));
290 /** A FIP Vx port identification descriptor */
291 struct fip_vx_port_id {
294 /** Length in 32-bit words */
297 uint8_t mac[ETH_ALEN];
300 /** Address identifier */
301 struct fc_port_id id;
304 } __attribute__ (( packed ));
306 /** A FIP FKA ADV period descriptor */
307 struct fip_fka_adv_p {
310 /** Length in 32-bit words */
316 /** Keep alive advertisement period in milliseconds */
318 } __attribute__ (( packed ));
320 /** FIP FKA ADV period flags */
321 enum fip_fka_adv_p_flags {
322 FIP_NO_KEEPALIVE = 0x01, /**< Do not send keepalives */
325 /** A FIP vendor ID descriptor */
326 struct fip_vendor_id {
329 /** Length in 32-bit words */
335 } __attribute__ (( packed ));
337 /** A FIP VLAN descriptor */
341 /** Length in 32-bit words */
345 } __attribute__ (( packed ));
347 /** A FIP descriptor */
348 union fip_descriptor {
350 struct fip_common common;
351 /** Priority descriptor */
352 struct fip_priority priority;
353 /** MAC address descriptor */
354 struct fip_mac_address mac_address;
355 /** FC-MAP descriptor */
356 struct fip_fc_map fc_map;
357 /** Name identifier descriptor */
358 struct fip_name_id name_id;
359 /** Fabric descriptor */
360 struct fip_fabric fabric;
361 /** Max FCoE size descriptor */
362 struct fip_max_fcoe_size max_fcoe_size;
363 /** FLOGI descriptor */
364 struct fip_els flogi;
365 /** FLOGI request descriptor */
366 struct fip_login flogi_request;
367 /** FLOGI LS_ACC descriptor */
368 struct fip_login flogi_ls_acc;
369 /** FLOGI LS_RJT descriptor */
370 struct fip_ls_rjt flogi_ls_rjt;
371 /** NPIV FDISC descriptor */
372 struct fip_els npiv_fdisc;
373 /** NPIV FDISC request descriptor */
374 struct fip_login npiv_fdisc_request;
375 /** NPIV FDISC LS_ACC descriptor */
376 struct fip_login npiv_fdisc_ls_acc;
377 /** NPIV FDISC LS_RJT descriptor */
378 struct fip_ls_rjt npiv_fdisc_ls_rjt;
379 /** LOGO descriptor */
381 /** LOGO request descriptor */
382 struct fip_logo_request logo_request;
383 /** LOGO LS_ACC descriptor */
384 struct fip_logo_response logo_ls_acc;
385 /** LOGO LS_RJT descriptor */
386 struct fip_ls_rjt logo_ls_rjt;
387 /** ELS descriptor */
389 /** ELP request descriptor */
390 struct fip_elp elp_request;
391 /** ELP LS_ACC descriptor */
392 struct fip_elp elp_ls_acc;
393 /** ELP LS_RJT descriptor */
394 struct fip_ls_rjt elp_ls_rjt;
395 /** Vx port identification descriptor */
396 struct fip_vx_port_id vx_port_id;
397 /** FKA ADV period descriptor */
398 struct fip_fka_adv_p fka_adv_p;
399 /** Vendor ID descriptor */
400 struct fip_vendor_id vendor_id;
401 /** VLAN descriptor */
402 struct fip_vlan vlan;
403 } __attribute__ (( packed ));
405 /** A FIP descriptor set */
406 struct fip_descriptors {
407 /** Descriptors, indexed by type */
408 union fip_descriptor *desc[FIP_NUM_DESCRIPTOR_TYPES];
412 * Define a function to extract a specific FIP descriptor type from a list
414 * @v type Descriptor type
415 * @v name Descriptor name
416 * @v finder Descriptor finder
418 #define FIP_DESCRIPTOR( type, name ) \
419 static inline __attribute__ (( always_inline )) \
420 typeof ( ( ( union fip_descriptor * ) NULL )->name ) * \
421 fip_ ## name ( struct fip_descriptors *descs ) { \
422 return &(descs->desc[type]->name); \
424 FIP_DESCRIPTOR ( FIP_PRIORITY, priority );
425 FIP_DESCRIPTOR ( FIP_MAC_ADDRESS, mac_address );
426 FIP_DESCRIPTOR ( FIP_FC_MAP, fc_map );
427 FIP_DESCRIPTOR ( FIP_NAME_ID, name_id );
428 FIP_DESCRIPTOR ( FIP_FABRIC, fabric );
429 FIP_DESCRIPTOR ( FIP_MAX_FCOE_SIZE, max_fcoe_size );
430 FIP_DESCRIPTOR ( FIP_FLOGI, flogi );
431 FIP_DESCRIPTOR ( FIP_FLOGI, flogi_request );
432 FIP_DESCRIPTOR ( FIP_FLOGI, flogi_ls_acc );
433 FIP_DESCRIPTOR ( FIP_FLOGI, flogi_ls_rjt );
434 FIP_DESCRIPTOR ( FIP_NPIV_FDISC, npiv_fdisc );
435 FIP_DESCRIPTOR ( FIP_NPIV_FDISC, npiv_fdisc_request );
436 FIP_DESCRIPTOR ( FIP_NPIV_FDISC, npiv_fdisc_ls_acc );
437 FIP_DESCRIPTOR ( FIP_NPIV_FDISC, npiv_fdisc_ls_rjt );
438 FIP_DESCRIPTOR ( FIP_LOGO, logo );
439 FIP_DESCRIPTOR ( FIP_LOGO, logo_request );
440 FIP_DESCRIPTOR ( FIP_LOGO, logo_ls_acc );
441 FIP_DESCRIPTOR ( FIP_LOGO, logo_ls_rjt );
442 FIP_DESCRIPTOR ( FIP_ELP, elp );
443 FIP_DESCRIPTOR ( FIP_ELP, elp_request );
444 FIP_DESCRIPTOR ( FIP_ELP, elp_ls_acc );
445 FIP_DESCRIPTOR ( FIP_ELP, elp_ls_rjt );
446 FIP_DESCRIPTOR ( FIP_VX_PORT_ID, vx_port_id );
447 FIP_DESCRIPTOR ( FIP_FKA_ADV_P, fka_adv_p );
448 FIP_DESCRIPTOR ( FIP_VENDOR_ID, vendor_id );
449 FIP_DESCRIPTOR ( FIP_VLAN, vlan );
451 #endif /* _IPXE_FIP_H */