Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / ipxe / src / include / ipxe / fcns.h
1 #ifndef _IPXE_FCNS_H
2 #define _IPXE_FCNS_H
3
4 /**
5  * @file
6  *
7  * Fibre Channel name server lookups
8  *
9  */
10
11 FILE_LICENCE ( GPL2_OR_LATER );
12
13 #include <stdint.h>
14 #include <ipxe/fc.h>
15
16 /** A Fibre Channel Common Transport header */
17 struct fc_ct_header {
18         /** Revision */
19         uint8_t revision;
20         /** Original requestor ID */
21         struct fc_port_id in_id;
22         /** Generic service type */
23         uint8_t type;
24         /** Generic service subtype */
25         uint8_t subtype;
26         /** Options */
27         uint8_t options;
28         /** Reserved */
29         uint8_t reserved;
30         /** Command/response code */
31         uint16_t code;
32         /** Maximum/residual size */
33         uint16_t size;
34         /** Fragment ID */
35         uint8_t fragment;
36         /** Reason code */
37         uint8_t reason;
38         /** Reason code explanation */
39         uint8_t explanation;
40         /** Vendor specific */
41         uint8_t vendor;
42 } __attribute__ (( packed ));
43
44 /** Fibre Channel Common Transport revision */
45 #define FC_CT_REVISION 1
46
47 /** Fibre Channel generic service type */
48 enum fc_gs_type {
49         /** Directory service */
50         FC_GS_TYPE_DS = 0xfc,
51 };
52
53 /** Fibre Channel generic service response codes */
54 enum fc_gs_response_code {
55         /** Accepted */
56         FC_GS_ACCEPT = 0x8002,
57         /** Rejected */
58         FC_GS_REJECT = 0x8001,
59 };
60
61 /** Fibre Channel generic service rejection reason codes */
62 enum fc_gs_reason_code {
63         /** Invalid command code */
64         FC_GS_BAD_COMMAND = 0x01,
65         /** Invalid version level */
66         FC_GS_BAD_VERSION = 0x02,
67         /** Logical error */
68         FC_GS_ERROR = 0x03,
69         /** Invalid CT_IU size */
70         FC_GS_BAD_SIZE = 0x04,
71         /** Logical busy */
72         FC_GS_BUSY = 0x05,
73         /** Protocol error */
74         FC_GS_EPROTO = 0x07,
75         /** Unable to perform command request */
76         FC_GS_UNABLE = 0x09,
77         /** Command not supported */
78         FC_GS_ENOTSUP = 0x0b,
79         /** Server not available */
80         FC_GS_UNAVAILABLE = 0x0d,
81         /** Session could not be established */
82         FC_GS_SESSION = 0x0e,
83 };
84
85 /** Fibre Channel directory service subtype */
86 enum fc_ds_subtype {
87         /** Name server */
88         FC_DS_SUBTYPE_NAME = 0x02,
89 };
90
91 /** Fibre Channel name server commands */
92 enum fc_ns_command_nibble {
93         /** Get */
94         FC_NS_GET = 0x1,
95         /** Register */
96         FC_NS_REGISTER = 0x2,
97         /** De-register */
98         FC_NS_DEREGISTER = 0x3,
99 };
100
101 /** Fibre Channel name server objects */
102 enum fc_ns_object_nibble {
103         /** Port ID */
104         FC_NS_PORT_ID = 0x1,
105         /** Port name */
106         FC_NS_PORT_NAME = 0x2,
107         /** Node name */
108         FC_NS_NODE_NAME = 0x3,
109         /** FC-4 types */
110         FC_NS_FC4_TYPES = 0x7,
111         /** Symbolic port name */
112         FC_NS_SYM_PORT_NAME = 0x8,
113         /** Symbolic node name */
114         FC_NS_SYM_NODE_NAME = 0x9,
115         /** FC-4 features */
116         FC_NS_FC4_FEATURES = 0xf,
117 };
118
119 /** Construct Fibre Channel name server command code
120  *
121  * @v command           Name server command
122  * @v key               Name server key
123  * @v value             Name server value
124  * @ret code            Name server command code
125  */
126 #define FC_NS_CODE( command, key, value )                               \
127         ( ( (command) << 8 ) | ( (key) << 4 ) | ( (value) << 0 ) )
128
129 /** Construct Fibre Channel name server "get" command code
130  *
131  * @v key               Name server key
132  * @v value             Name server value to get
133  * @ret code            Name server command code
134  */
135 #define FC_NS_GET( key, value ) FC_NS_CODE ( FC_NS_GET, key, value )
136
137 /** Construct Fibre Channel name server "register" command code
138  *
139  * @v key               Name server key
140  * @v value             Name server value to register
141  * @ret code            Name server command code
142  */
143 #define FC_NS_REGISTER( key, value ) FC_NS_CODE ( FC_NS_REGISTER, key, value )
144
145 /** Extract Fibre Channel name server command
146  *
147  * @v code              Name server command code
148  * @ret command         Name server command
149  */
150 #define FC_NS_COMMAND( code ) ( ( (code) >> 8 ) & 0xf )
151
152 /** Extract Fibre Channel name server key
153  *
154  * @v code              Name server command code
155  * @ret key             Name server key
156  */
157 #define FC_NS_KEY( code ) ( ( (code) >> 4 ) & 0xf )
158
159 /** Extract Fibre Channel name server value
160  *
161  * @v code              Name server command code
162  * @ret value           NAme server value
163  */
164 #define FC_NS_VALUE( code ) ( ( (code) >> 0 ) & 0xf )
165
166 /** A Fibre Channel name server port ID */
167 struct fc_ns_port_id {
168         /** Reserved */
169         uint8_t reserved;
170         /** Port ID */
171         struct fc_port_id port_id;
172 } __attribute__ (( packed ));
173
174 /** A Fibre Channel name server GID_PN request */
175 struct fc_ns_gid_pn_request {
176         /** Common Transport header */
177         struct fc_ct_header ct;
178         /** Port name */
179         struct fc_name port_wwn;
180 } __attribute__ (( packed ));
181
182 /** A Fibre Channel name server request */
183 union fc_ns_request {
184         /** Get ID by port name */
185         struct fc_ns_gid_pn_request gid_pn;
186 };
187
188 /** A Fibre Channel name server rejection response */
189 struct fc_ns_reject_response {
190         /** Common Transport header */
191         struct fc_ct_header ct;
192 } __attribute__ (( packed ));
193
194 /** A Fibre Channel name server GID_PN response */
195 struct fc_ns_gid_pn_response {
196         /** Common Transport header */
197         struct fc_ct_header ct;
198         /** Port ID */
199         struct fc_ns_port_id port_id;
200 } __attribute__ (( packed ));
201
202 /** A Fibre Channel name server response */
203 union fc_ns_response {
204         /** Common Transport header */
205         struct fc_ct_header ct;
206         /** Rejection */
207         struct fc_ns_reject_response reject;
208         /** Get ID by port name */
209         struct fc_ns_gid_pn_response gid_pn;
210 };
211
212 extern int fc_ns_query ( struct fc_peer *peer, struct fc_port *port,
213                          int ( * done ) ( struct fc_peer *peer,
214                                           struct fc_port *port,
215                                           struct fc_port_id *peer_port_id ) );
216
217 #endif /* _IPXE_FCNS_H */