iPXE
fcns.h
Go to the documentation of this file.
00001 #ifndef _IPXE_FCNS_H
00002 #define _IPXE_FCNS_H
00003 
00004 /**
00005  * @file
00006  *
00007  * Fibre Channel name server lookups
00008  *
00009  */
00010 
00011 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00012 
00013 #include <stdint.h>
00014 #include <ipxe/fc.h>
00015 
00016 /** A Fibre Channel Common Transport header */
00017 struct fc_ct_header {
00018         /** Revision */
00019         uint8_t revision;
00020         /** Original requestor ID */
00021         struct fc_port_id in_id;
00022         /** Generic service type */
00023         uint8_t type;
00024         /** Generic service subtype */
00025         uint8_t subtype;
00026         /** Options */
00027         uint8_t options;
00028         /** Reserved */
00029         uint8_t reserved;
00030         /** Command/response code */
00031         uint16_t code;
00032         /** Maximum/residual size */
00033         uint16_t size;
00034         /** Fragment ID */
00035         uint8_t fragment;
00036         /** Reason code */
00037         uint8_t reason;
00038         /** Reason code explanation */
00039         uint8_t explanation;
00040         /** Vendor specific */
00041         uint8_t vendor;
00042 } __attribute__ (( packed ));
00043 
00044 /** Fibre Channel Common Transport revision */
00045 #define FC_CT_REVISION 1
00046 
00047 /** Fibre Channel generic service type */
00048 enum fc_gs_type {
00049         /** Directory service */
00050         FC_GS_TYPE_DS = 0xfc,
00051 };
00052 
00053 /** Fibre Channel generic service response codes */
00054 enum fc_gs_response_code {
00055         /** Accepted */
00056         FC_GS_ACCEPT = 0x8002,
00057         /** Rejected */
00058         FC_GS_REJECT = 0x8001,
00059 };
00060 
00061 /** Fibre Channel generic service rejection reason codes */
00062 enum fc_gs_reason_code {
00063         /** Invalid command code */
00064         FC_GS_BAD_COMMAND = 0x01,
00065         /** Invalid version level */
00066         FC_GS_BAD_VERSION = 0x02,
00067         /** Logical error */
00068         FC_GS_ERROR = 0x03,
00069         /** Invalid CT_IU size */
00070         FC_GS_BAD_SIZE = 0x04,
00071         /** Logical busy */
00072         FC_GS_BUSY = 0x05,
00073         /** Protocol error */
00074         FC_GS_EPROTO = 0x07,
00075         /** Unable to perform command request */
00076         FC_GS_UNABLE = 0x09,
00077         /** Command not supported */
00078         FC_GS_ENOTSUP = 0x0b,
00079         /** Server not available */
00080         FC_GS_UNAVAILABLE = 0x0d,
00081         /** Session could not be established */
00082         FC_GS_SESSION = 0x0e,
00083 };
00084 
00085 /** Fibre Channel directory service subtype */
00086 enum fc_ds_subtype {
00087         /** Name server */
00088         FC_DS_SUBTYPE_NAME = 0x02,
00089 };
00090 
00091 /** Fibre Channel name server commands */
00092 enum fc_ns_command_nibble {
00093         /** Get */
00094         FC_NS_GET = 0x1,
00095         /** Register */
00096         FC_NS_REGISTER = 0x2,
00097         /** De-register */
00098         FC_NS_DEREGISTER = 0x3,
00099 };
00100 
00101 /** Fibre Channel name server objects */
00102 enum fc_ns_object_nibble {
00103         /** Port ID */
00104         FC_NS_PORT_ID = 0x1,
00105         /** Port name */
00106         FC_NS_PORT_NAME = 0x2,
00107         /** Node name */
00108         FC_NS_NODE_NAME = 0x3,
00109         /** FC-4 types */
00110         FC_NS_FC4_TYPES = 0x7,
00111         /** Symbolic port name */
00112         FC_NS_SYM_PORT_NAME = 0x8,
00113         /** Symbolic node name */
00114         FC_NS_SYM_NODE_NAME = 0x9,
00115         /** FC-4 features */
00116         FC_NS_FC4_FEATURES = 0xf,
00117 };
00118 
00119 /** Construct Fibre Channel name server command code
00120  *
00121  * @v command           Name server command
00122  * @v key               Name server key
00123  * @v value             Name server value
00124  * @ret code            Name server command code
00125  */
00126 #define FC_NS_CODE( command, key, value )                               \
00127         ( ( (command) << 8 ) | ( (key) << 4 ) | ( (value) << 0 ) )
00128 
00129 /** Construct Fibre Channel name server "get" command code
00130  *
00131  * @v key               Name server key
00132  * @v value             Name server value to get
00133  * @ret code            Name server command code
00134  */
00135 #define FC_NS_GET( key, value ) FC_NS_CODE ( FC_NS_GET, key, value )
00136 
00137 /** Construct Fibre Channel name server "register" command code
00138  *
00139  * @v key               Name server key
00140  * @v value             Name server value to register
00141  * @ret code            Name server command code
00142  */
00143 #define FC_NS_REGISTER( key, value ) FC_NS_CODE ( FC_NS_REGISTER, key, value )
00144 
00145 /** Extract Fibre Channel name server command
00146  *
00147  * @v code              Name server command code
00148  * @ret command         Name server command
00149  */
00150 #define FC_NS_COMMAND( code ) ( ( (code) >> 8 ) & 0xf )
00151 
00152 /** Extract Fibre Channel name server key
00153  *
00154  * @v code              Name server command code
00155  * @ret key             Name server key
00156  */
00157 #define FC_NS_KEY( code ) ( ( (code) >> 4 ) & 0xf )
00158 
00159 /** Extract Fibre Channel name server value
00160  *
00161  * @v code              Name server command code
00162  * @ret value           NAme server value
00163  */
00164 #define FC_NS_VALUE( code ) ( ( (code) >> 0 ) & 0xf )
00165 
00166 /** A Fibre Channel name server port ID */
00167 struct fc_ns_port_id {
00168         /** Reserved */
00169         uint8_t reserved;
00170         /** Port ID */
00171         struct fc_port_id port_id;
00172 } __attribute__ (( packed ));
00173 
00174 /** A Fibre Channel name server GID_PN request */
00175 struct fc_ns_gid_pn_request {
00176         /** Common Transport header */
00177         struct fc_ct_header ct;
00178         /** Port name */
00179         struct fc_name port_wwn;
00180 } __attribute__ (( packed ));
00181 
00182 /** A Fibre Channel name server request */
00183 union fc_ns_request {
00184         /** Get ID by port name */
00185         struct fc_ns_gid_pn_request gid_pn;
00186 };
00187 
00188 /** A Fibre Channel name server rejection response */
00189 struct fc_ns_reject_response {
00190         /** Common Transport header */
00191         struct fc_ct_header ct;
00192 } __attribute__ (( packed ));
00193 
00194 /** A Fibre Channel name server GID_PN response */
00195 struct fc_ns_gid_pn_response {
00196         /** Common Transport header */
00197         struct fc_ct_header ct;
00198         /** Port ID */
00199         struct fc_ns_port_id port_id;
00200 } __attribute__ (( packed ));
00201 
00202 /** A Fibre Channel name server response */
00203 union fc_ns_response {
00204         /** Common Transport header */
00205         struct fc_ct_header ct;
00206         /** Rejection */
00207         struct fc_ns_reject_response reject;
00208         /** Get ID by port name */
00209         struct fc_ns_gid_pn_response gid_pn;
00210 };
00211 
00212 extern int fc_ns_query ( struct fc_peer *peer, struct fc_port *port,
00213                          int ( * done ) ( struct fc_peer *peer,
00214                                           struct fc_port *port,
00215                                           struct fc_port_id *peer_port_id ) );
00216 
00217 #endif /* _IPXE_FCNS_H */