Emulex Logo
OneCoreā„¢ Storage SDK Release 11.2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ocs_fcp.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2015, Emulex
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors
16  * may be used to endorse or promote products derived from this software
17  * without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  *
31  */
32 
33 /**
34  * @file
35  * Define Fibre Channel types and structures.
36  */
37 
38 #ifndef _OCS_FCP_H
39 #define _OCS_FCP_H
40 
41 #define FC_ELS_CMD_RJT 0x01
42 #define FC_ELS_CMD_ACC 0x02
43 #define FC_ELS_CMD_PLOGI 0x03
44 #define FC_ELS_CMD_FLOGI 0x04
45 #define FC_ELS_CMD_LOGO 0x05
46 #define FC_ELS_CMD_RRQ 0x12
47 #define FC_ELS_CMD_PRLI 0x20
48 #define FC_ELS_CMD_PRLO 0x21
49 #define FC_ELS_CMD_PDISC 0x50
50 #define FC_ELS_CMD_FDISC 0x51
51 #define FC_ELS_CMD_ADISC 0x52
52 #define FC_ELS_CMD_RSCN 0x61
53 #define FC_ELS_CMD_SCR 0x62
54 
55 #define FC_TYPE_BASIC_LINK 0
56 #define FC_TYPE_FCP 0x08
57 #define FC_TYPE_NVME 0x28
58 #define FC_TYPE_GS 0x20
59 #define FC_TYPE_SW 0x22
60 
61 #define FC_ADDR_FABRIC 0xfffffe /** well known fabric address */
62 #define FC_ADDR_CONTROLLER 0xfffffd /** well known fabric controller address */
63 #define FC_ADDR_IS_DOMAIN_CTRL(x) (((x) & 0xffff00) == 0xfffc00) /** is well known domain controller */
64 #define FC_ADDR_GET_DOMAIN_CTRL(x) ((x) & 0x0000ff) /** get domain controller number */
65 #define FC_ADDR_NAMESERVER 0xfffffc /** well known directory server address */
66 #define FC_ADDR_FDMI 0xfffffa /** well known FDMI server address */
67 
68 #define FC_GS_TYPE_ALIAS_SERVICE 0xf8
69 #define FC_GS_TYPE_MANAGEMENT_SERVICE 0xfa
70 #define FC_GS_TYPE_DIRECTORY_SERVICE 0xfc
71 #define FC_GS_TYPE_LOOPBACK 0x10
72 
73 #define FC_GS_SUBTYPE_NAME_SERVER 0x02
74 #define FC_GS_SUBTYPE_FDMI 0x10
75 
76 /**
77  * Generic Services FC Type Bit mask macros:
78  */
79 #define FC_GS_TYPE_WORD(type) ((type) >> 5)
80 #define FC_GS_TYPE_BIT(type) ((type) & 0x1f)
81 
82 /**
83  * Generic Services Name Server Request Command codes:
84  */
85 #define FC_GS_NAMESERVER_GPN_ID 0x0112
86 #define FC_GS_NAMESERVER_GNN_ID 0x0113
87 #define FC_GS_NAMESERVER_GFPN_ID 0x011c
88 #define FC_GS_NAMESERVER_GFF_ID 0x011f
89 #define FC_GS_NAMESERVER_GID_FT 0x0171
90 #define FC_GS_NAMESERVER_GID_PT 0x01a1
91 #define FC_GS_NAMESERVER_GA_NXT 0x0100
92 #define FC_GS_NAMESERVER_RHBA 0x0200
93 #define FC_GS_NAMESERVER_RPA 0x0211
94 #define FC_GS_NAMESERVER_RPN_ID 0x0212
95 #define FC_GS_NAMESERVER_RNN_ID 0x0213
96 #define FC_GS_NAMESERVER_RCS_ID 0x0214
97 #define FC_GS_NAMESERVER_RFT_ID 0x0217
98 #define FC_GS_NAMESERVER_RFF_ID 0x021f
99 #define FC_GS_NAMESERVER_RSNN_NN 0x0239
100 #define FC_GS_NAMESERVER_RSPN_ID 0x0218
101 
102 
103 /**
104  * Generic Services FDMI Request Command codes:
105  */
106 #define FC_GS_FDMI_GRHL 0x100 /* Get registered HBA list */
107 #define FC_GS_FDMI_GHAT 0x101 /* Get HBA attributes */
108 #define FC_GS_FDMI_GRPL 0x102 /* Get registered Port list */
109 #define FC_GS_FDMI_GPAT 0x110 /* Get Port attributes */
110 #define FC_GS_FDMI_GPAS 0x120 /* Get Port Statistics */
111 #define FC_GS_FDMI_RHBA 0x200 /* Register HBA */
112 #define FC_GS_FDMI_RHAT 0x201 /* Register HBA attributes */
113 #define FC_GS_FDMI_RPRT 0x210 /* Register Port */
114 #define FC_GS_FDMI_RPA 0x211 /* Register Port attributes */
115 #define FC_GS_FDMI_DHBA 0x300 /* De-register HBA */
116 #define FC_GS_FDMI_DHAT 0x301 /* De-register HBA attributes */
117 #define FC_GS_FDMI_DPRT 0x310 /* De-register Port */
118 #define FC_GS_FDMI_DPA 0x311 /* De-register Port attributes */
119 
120 #define FC_ELX_LOOPBACK_DATA 1
121 
122 #define FC_GS_REVISION 0x03
123 
124 #define FC_GS_IO_PARAMS { .fc_ct.r_ctl = 0x02, \
125  .fc_ct.type = FC_TYPE_GS, \
126  .fc_ct.df_ctl = 0x00 }
127 
128 typedef struct fc_vft_header_s {
129  uint32_t :1,
130  vf_id:12,
131  priority:3,
132  e:1,
133  :1,
134  type:4,
135  ver:2,
136  r_ctl:8;
137  uint32_t :24,
138  hopct:8;
140 
141 
142 #if BYTE_ORDER == LITTLE_ENDIAN
143 static inline uint32_t fc_be24toh(uint32_t x) { return (ocs_be32toh(x) >> 8); }
144 #else
145 static inline uint32_t fc_be24toh(uint32_t x) { }
146 #endif
147 static inline uint32_t fc_htobe24(uint32_t x) { return fc_be24toh(x); }
148 
149 #define FC_SOFI3 0x2e
150 #define FC_SOFn3 0x36
151 #define FC_EOFN 0x41
152 #define FC_EOFT 0x42
153 
154 /**
155  * @brief FC header in big-endian order
156  */
157 typedef struct fc_header_s {
158  uint32_t info:4,
159  r_ctl:4,
160  d_id:24;
161  uint32_t cs_ctl:8,
162  s_id:24;
163  uint32_t type:8,
164  f_ctl:24;
165  uint32_t seq_id:8,
166  df_ctl:8,
167  seq_cnt:16;
168  uint32_t ox_id:16,
169  rx_id:16;
170  uint32_t parameter;
171 } fc_header_t;
172 
173 
174 /**
175  * @brief FC header in little-endian order
176  */
177 typedef struct fc_header_le_s {
178 #if BYTE_ORDER == LITTLE_ENDIAN
179  uint32_t d_id:24,
180  info:4,
181  r_ctl:4;
182  uint32_t s_id:24,
183  cs_ctl:8;
184  uint32_t f_ctl:24,
185  type:8;
186  uint32_t seq_cnt:16,
187  df_ctl:8,
188  seq_id:8;
189  uint32_t rx_id:16,
190  ox_id:16;
191  uint32_t parameter;
192 #else
193 #error big endian version not defined
194 #endif
196 
197 /**
198  * @brief FC VM header in big-endian order
199  */
200 typedef struct fc_vm_header_s {
201  uint32_t dst_vmid;
202  uint32_t src_vmid;
203  uint32_t rsvd0;
204  uint32_t rsvd1;
206 
207 #define FC_DFCTL_DEVICE_HDR_16_MASK 0x1
208 #define FC_DFCTL_NETWORK_HDR_MASK 0x20
209 #define FC_DFCTL_ESP_HDR_MASK 0x40
210 #define FC_DFCTL_NETWORK_HDR_SIZE 16
211 #define FC_DFCTL_ESP_HDR_SIZE 0 //FIXME
212 
213 #define FC_RCTL_FC4_DATA 0
214 #define FC_RCTL_ELS 2
215 #define FC_RCTL_BLS 8
216 
217 #define FC_RCTL_INFO_UNCAT 0
218 #define FC_RCTL_INFO_SOL_DATA 1
219 #define FC_RCTL_INFO_UNSOL_CTRL 2
220 #define FC_RCTL_INFO_SOL_CTRL 3
221 #define FC_RCTL_INFO_UNSOL_DATA 4
222 #define FC_RCTL_INFO_DATA_DESC 5
223 #define FC_RCTL_INFO_UNSOL_CMD 6
224 #define FC_RCTL_INFO_CMD_STATUS 7
225 
226 #define FC_FCTL_EXCHANGE_RESPONDER 0x800000
227 #define FC_FCTL_SEQUENCE_CONTEXT 0x400000
228 #define FC_FCTL_FIRST_SEQUENCE 0x200000
229 #define FC_FCTL_LAST_SEQUENCE 0x100000
230 #define FC_FCTL_END_SEQUENCE 0x080000
231 #define FC_FCTL_END_CONNECTION 0x040000
232 #define FC_FCTL_PRIORITY_ENABLE 0x020000
233 #define FC_FCTL_SEQUENCE_INITIATIVE 0x010000
234 #define FC_FCTL_FILL_DATA_BYTES_MASK 0x000003
235 
236 /**
237  * Common BLS definitions:
238  */
239 #define FC_INFO_NOP 0x0
240 #define FC_INFO_ABTS 0x1
241 #define FC_INFO_RMC 0x2
242 /* reserved 0x3 */
243 #define FC_INFO_BA_ACC 0x4
244 #define FC_INFO_BA_RJT 0x5
245 #define FC_INFO_PRMT 0x6
246 
247 /* (FC-LS) LS_RJT Reason Codes */
248 #define FC_REASON_INVALID_COMMAND_CODE 0x01
249 #define FC_REASON_LOGICAL_ERROR 0x03
250 #define FC_REASON_LOGICAL_BUSY 0x05
251 #define FC_REASON_PROTOCOL_ERROR 0x07
252 #define FC_REASON_UNABLE_TO_PERFORM 0x09
253 #define FC_REASON_COMMAND_NOT_SUPPORTED 0x0b
254 #define FC_REASON_COMMAND_IN_PROGRESS 0x0e
255 #define FC_REASON_VENDOR_SPECIFIC 0xff
256 
257 /* (FC-LS) LS_RJT Reason Codes Explanations */
258 #define FC_EXPL_NO_ADDITIONAL 0x00
259 #define FC_EXPL_SPARAM_OPTIONS 0x01
260 #define FC_EXPL_SPARAM_INITIATOR 0x03
261 #define FC_EXPL_SPARAM_RECPIENT 0x05
262 #define FC_EXPL_SPARM_DATA_SIZE 0x07
263 #define FC_EXPL_SPARM_CONCURRENT 0x09
264 #define FC_EXPL_SPARM_CREDIT 0x0b
265 #define FC_EXPL_INV_PORT_NAME 0x0d
266 #define FC_EXPL_INV_NODE_NAME 0x0e
267 #define FC_EXPL_INV_COMMON_SPARAMS 0x0f
268 #define FC_EXPL_INV_ASSOC_HEADER 0x11
269 #define FC_EXPL_ASSOC_HDR_REQUIRED 0x13
270 #define FC_EXPL_INV_ORIGINATOR_S_ID 0x15
271 #define FC_EXPL_INV_X_ID_COMBINATION 0x17
272 #define FC_EXPL_COMMAND_IN_PROGRESS 0x19
273 #define FC_EXPL_NPORT_LOGIN_REQUIRED 0x1e
274 #define FC_EXPL_N_PORT_ID 0x1f
275 #define FC_EXPL_INSUFFICIENT_RESOURCES 0x29
276 #define FC_EXPL_UNABLE_TO_SUPPLY_DATA 0x2a
277 #define FC_EXPL_REQUEST_NOT_SUPPORTED 0x2c
278 #define FC_EXPL_INV_PAYLOAD_LEN 0x1d
279 #define FC_EXPL_INV_PORT_NODE_NAME 0x44
280 #define FC_EXPL_LOGIN_EXT_NOT_SUPPORTED 0x46
281 #define FC_EXPL_AUTH_REQUIRED 0x48
282 #define FC_EXPL_SCAN_VALUE_NOT_ALLOWED 0x50
283 #define FC_EXPL_SCAN_VALUE_NOT_SUPPORTED 0x51
284 #define FC_EXPL_NO_RESOURCES_ASSIGNED 0x52
285 #define FC_EXPL_MAC_ADDR_MODE_NOT_SUPPORTED 0x60
286 #define FC_EXPL_MAC_ADDR_INCORRECTLY_FORMED 0x61
287 #define FC_EXPL_VN2VN_PORT_NOT_IN_NEIGHBOR_SET 0x62
288 
289 #define FC_EXPL_INV_X_ID 0x03 /* invalid OX_ID - RX_ID combination */
290 #define FC_EXPL_SEQUENCE_ABORTED 0x05
291 
292 typedef struct fc_ba_acc_payload_s {
293 #define FC_SEQ_ID_VALID 0x80
294 #define FC_SEQ_ID_INVALID 0x00
295  uint32_t seq_id_validity:8,
296  seq_id:8,
297  :16;
298  uint32_t ox_id:16,
299  rx_id:16;
300  uint32_t low_seq_cnt:16,
301  high_seq_cnt:16;
303 
304 typedef struct fc_ba_rjt_payload_s {
305  uint32_t vendor_unique:8,
306  reason_explanation:8,
307  reason_code:8,
308  :8;
310 
311 typedef struct fc_els_gen_s {
312  uint32_t command_code: 8,
313  resv1: 24;
314 } fc_els_gen_t;
315 
316 #define FC_PLOGI_CSP_W1_BBSCN_CLEAR_MASK 0xFFFF0FFF
317 #define FC_PLOGI_CSP_W1_VALID_VENDOR_VER_LEVEL BIT(29)
318 #define OCS_FC_PLOGI_VENDOR_VERSION_EMLX_ID 0x454d4c58 /* EMLX */
319 
320 typedef struct fc_plogi_playload_s {
321  uint32_t command_code: 8,
322  resv1: 24;
323  uint32_t common_service_parameters[4];
324  uint32_t port_name_hi;
325  uint32_t port_name_lo;
326  uint32_t node_name_hi;
327  uint32_t node_name_lo;
328  uint32_t class1_service_parameters[4];
329  uint32_t class2_service_parameters[4];
330  uint32_t class3_service_parameters[4];
331  uint32_t class4_service_parameters[4];
332  uint32_t vendor_version_level[4];
334 
336 
337 typedef struct fc_logo_payload_s {
338  uint32_t command_code: 8,
339  resv1:24;
340  uint32_t :8,
341  port_id:24;
342  uint32_t port_name_hi;
343  uint32_t port_name_lo;
345 
346 typedef struct fc_acc_payload_s {
347  uint32_t command_code: 8,
348  resv1:24;
350 
351 
352 typedef struct fc_ls_rjt_payload_s {
353  uint32_t command_code:8,
354  resv1:24;
355  uint32_t resv2:8,
356  reason_code:8,
357  reason_code_exp:8,
358  vendor_unique:8;
360 
361 typedef struct fc_prli_payload_s {
362  uint32_t command_code:8,
363  page_length:8,
364  payload_length:16;
365  uint32_t type:8,
366  type_ext:8,
367  flags:16;
368  uint32_t originator_pa;
369  uint32_t responder_pa;
370  uint32_t :16,
371  service_params:16;
373 
374 typedef struct fc_nvme_prli_payload_s {
375  uint32_t command_code:8,
376  page_length:8,
377  payload_length:16;
378  uint32_t type:8,
379  type_ext:8,
380  flags:16;
381  uint32_t reserved1;
382  uint32_t reserved2;
383  uint32_t :16,
384  service_params:16;
385  uint32_t :16,
386  first_burst_size:16;
388 
389 typedef struct fc_prlo_payload_s {
390  uint32_t command_code:8,
391  page_length:8,
392  payload_length:16;
393  uint32_t type:8,
394  type_ext:8,
395  :16;
396  uint32_t :32;
397  uint32_t :32;
398  uint32_t :32;
400 
401 typedef struct fc_prlo_acc_payload_s {
402  uint32_t command_code:8,
403  page_length:8,
404  payload_length:16;
405  uint32_t type:8,
406  type_ext:8,
407  :4,
408  response_code:4,
409  :8;
410  uint32_t :32;
411  uint32_t :32;
412  uint32_t :32;
414 
415 typedef struct fc_adisc_payload_s {
416  uint32_t command_code:8,
417  payload_length:24;
418  uint32_t :8,
419  hard_address:24;
420  uint32_t port_name_hi;
421  uint32_t port_name_lo;
422  uint32_t node_name_hi;
423  uint32_t node_name_lo;
424  uint32_t :8,
425  port_id:24;
427 
428 /* PRLI flags */
429 #define FC_PRLI_ORIGINATOR_PA_VALID 0x8000
430 #define FC_PRLI_RESPONDER_PA_VALID 0x4000
431 #define FC_PRLI_ESTABLISH_IMAGE_PAIR 0x2000
432 #define FC_PRLI_SERVICE_PARAM_INVALID 0x0800
433 #define FC_PRLI_REQUEST_EXECUTED 0x0100
434 
435 /* PRLI Service Parameters */
436 #define FC_PRLI_TASK_RETRY_ID_REQ 0x0200
437 #define FC_PRLI_RETRY 0x0100
438 #define FC_PRLI_CONFIRMED_COMPLETION 0x0080
439 #define FC_PRLI_DATA_OVERLAY 0x0040
440 #define FC_PRLI_INITIATOR_FUNCTION 0x0020
441 #define FC_PRLI_TARGET_FUNCTION 0x0010
442 #define FC_PRLI_READ_XRDY_DISABLED 0x0002
443 #define FC_PRLI_WRITE_XRDY_DISABLED 0x0001
444 #define FC_PRLI_NVME_DISC_FUNCTION 0x0008
445 
446 #define FC_PRLI_ACC_FCP_PAGE_LENGTH 16
447 #define FC_PRLI_ACC_NVME_PAGE_LENGTH 20
448 
449 /* PRLO Logout flags */
450 #define FC_PRLO_REQUEST_EXECUTED 0x0001
451 
452 typedef struct fc_scr_payload_s {
453  uint32_t command_code:8,
454  :24;
455  uint32_t :24,
456  function:8;
458 
459 #define FC_SCR_REG_FABRIC 1
460 #define FC_SCR_REG_NPORT 2
461 #define FC_SCR_REG_FULL 3
462 
463 typedef struct {
464  uint32_t :2,
465  rscn_event_qualifier:4,
466  address_format:2,
467  port_id:24;
469 
470 typedef struct fc_rscn_payload_s {
471  uint32_t command_code:8,
472  page_length:8,
473  payload_length:16;
476 
477 typedef struct fcct_iu_header_s {
478 #if BYTE_ORDER == LITTLE_ENDIAN
479  uint32_t revision:8,
480  in_id:24;
481  uint32_t gs_type:8,
482  gs_subtype:8,
483  options:8,
484  resv1:8;
485  uint32_t cmd_rsp_code:16,
486  max_residual_size:16;
487  uint32_t fragment_id:8,
488  reason_code:8,
489  reason_code_explanation:8,
490  vendor_specific:8;
491 #else
492 #error big endian version not defined
493 #endif
495 
496 #define FCCT_REJECT_INVALID_COMMAND_CODE 1
497 #define FCCT_REJECT_INVALID_VERSION_LEVEL 2
498 #define FCCT_LOGICAL_ERROR 3
499 #define FCCT_INVALID_CT_IU_SIZE 4
500 #define FCCT_LOGICAL_BUSY 5
501 #define FCCT_PROTOCOL_ERROR 7
502 #define FCCT_UNABLE_TO_PERFORM 9
503 #define FCCT_COMMAND_NOT_SUPPORTED 0x0b
504 #define FCCT_FABRIC_PORT_NAME_NOT_REGISTERED 0x0c
505 #define FCCT_SERVER_NOT_AVAILABLE 0x0d
506 #define FCCT_SESSION_COULD_NOT_BE_ESTABLISHED 0x0e
507 #define FCCT_VENDOR_SPECIFIC_ERROR 0xff
508 
509 #define FCCT_NO_ADDITIONAL_EXPLANATION 0
510 #define FCCT_AUTHORIZATION_EXCEPTION 0xf0
511 #define FCCT_AUTHENTICATION_EXCEPTION 0xf1
512 #define FCCT_DATA_BASE_FULL 0xf2
513 #define FCCT_DATA_BASE_EMPTY 0xf3
514 #define FCCT_PROCESSING_REQUEST 0xf4
515 #define FCCT_UNABLE_TO_VERIFY_CONNECTION 0xf5
516 #define FCCT_DEVICES_NOT_IN_COMMON_ZONE 0xf6
517 
518 typedef struct {
520 #if BYTE_ORDER == LITTLE_ENDIAN
521  uint32_t port_id;
522  uint32_t fc4_types;
523 #else
524 #error big endian version not defined
525 #endif
526 } fcgs_rft_id_t;
527 
528 typedef struct {
530 #if BYTE_ORDER == LITTLE_ENDIAN
531  uint32_t port_id;
532  uint32_t :16,
533  fc4_features:8,
534  type_code:8;
535 #else
536 #error big endian version not defined
537 #endif
538 } fcgs_rff_id_t;
539 
540 #pragma pack(1)
541 typedef struct {
543 #if BYTE_ORDER == LITTLE_ENDIAN
544  uint32_t port_id;
545  uint64_t port_name;
546 #else
547 #error big endian version not defined
548 #endif
549 } fcgs_rpn_id_t;
550 #pragma pack()
551 
552 #pragma pack(1)
553 typedef struct {
555 #if BYTE_ORDER == LITTLE_ENDIAN
556  uint32_t port_id;
557  uint64_t node_name;
558 // uint32_t node_name[2];
559 #else
560 #error big endian version not defined
561 #endif
562 } fcgs_rnn_id_t;
563 #pragma pack()
564 
565 #define FCCT_CLASS_OF_SERVICE_F 0x1
566 #define FCCT_CLASS_OF_SERVICE_2 0x4
567 #define FCCT_CLASS_OF_SERVICE_3 0x8
568 #pragma pack(1)
569 typedef struct {
571 #if BYTE_ORDER == LITTLE_ENDIAN
572  uint32_t port_id;
573  uint32_t class_of_srvc;
574 #else
575 #error big endian version not defined
576 #endif
577 } fcgs_rcs_id_t;
578 #pragma pack()
579 
580 #pragma pack(1)
581 typedef struct {
583 #if BYTE_ORDER == LITTLE_ENDIAN
584  uint64_t node_name;
585  uint8_t name_len;
586  char sym_node_name[1];
587 //TODO: need name length and symbolic name
588 #else
589 #error big endian version not defined
590 #endif
592 #pragma pack()
593 
594 #define FCCT_HDR_CMDRSP_ACCEPT 0x8002
595 #define FCCT_HDR_CMDRSP_REJECT 0x8001
596 
597 static inline void fcct_build_req_header(fcct_iu_header_t *hdr, uint16_t cmd,
598  uint8_t type, uint8_t gs_subtype, uint16_t max_size)
599 {
600  /* use old rev (1) to accommodate older switches */
601  hdr->revision = 1;
602  hdr->in_id = 0;
603  hdr->gs_type = type;
604  hdr->gs_subtype = gs_subtype;
605  hdr->options = 0;
606  hdr->resv1 = 0;
607  hdr->cmd_rsp_code = ocs_htobe16(cmd);
608  hdr->max_residual_size = ocs_htobe16(max_size/(sizeof(uint32_t))); /* words */
609  hdr->fragment_id = 0;
610  hdr->reason_code = 0;
611  hdr->reason_code_explanation = 0;
612  hdr->vendor_specific = 0;
613 }
614 
615 static inline void fcct_loopback_build_req_header(fcct_iu_header_t *hdr, uint16_t cmd, uint16_t max_size)
616 {
617  /* use old rev (1) to accommodate older switches */
618  hdr->revision = 1;
619  hdr->in_id = 0;
621  hdr->gs_subtype = 0;
622  hdr->options = 0;
623  hdr->resv1 = 0;
624  hdr->cmd_rsp_code = ocs_htobe16(cmd);
625  hdr->max_residual_size = ocs_htobe16(max_size/(sizeof(uint32_t))); /* words */
626  hdr->fragment_id = 0;
627  hdr->reason_code = 0;
628  hdr->reason_code_explanation = 0;
629  hdr->vendor_specific = 0;
630 }
631 typedef struct fcct_rftid_req_s {
633  uint32_t port_id;
634  uint32_t fc4_types[8];
636 
637 #define FC4_FEATURE_TARGET (1U << 0)
638 #define FC4_FEATURE_INITIATOR (1U << 1)
639 #define FC4_FEATURE_NVME_DISC (1U << 2)
640 
641 typedef struct fcct_rffid_req_s {
643  uint32_t port_id;
644  uint32_t :16,
645  fc4_feature_bits:8,
646  type:8;
648 
649 /* Attribute Entry */
650 typedef union ocs_fdmi_attr_entry_u {
651  uint32_t attr_int;
652  uint8_t attr_types[32];
653  uint8_t attr_string[256];
654  uint64_t attr_wwn;
656 /*
657  * HBA Attribute Block
658  */
659 typedef struct ocs_fdmi_attr_block_s {
660  uint32_t num_entries; /* Number of HBA attribute entries */
661  ocs_fdmi_attr_entry_t entry; /* Variable-length array */
663 
664 typedef struct fcct_fdmi_reg_port_list_s {
665  uint32_t entry_count;
666  uint32_t port_entry[0];
668 
669 typedef struct fcct_fdmi_rhba_req_s {
671  uint64_t hba_identifier;
674 
675 typedef struct fcct_fdmi_dereg_req_s {
677  uint64_t identifier;
679 
680 typedef struct fcct_fdmi_rprt_req_s {
682  uint64_t hba_identifier;
683  uint64_t port_name;
684  ocs_fdmi_attr_block_t attr_block[0];
686 
687 typedef struct fcct_fdmi_rpa_req_s {
689  uint32_t port_name[2];
690  ocs_fdmi_attr_block_t attr_block[0];
692 
693 /*Get HBA list CT request */
694 typedef struct fcct_fdmi_grhl_req_s {
697 
698 /*Get HBA list CT response */
699 typedef struct fcct_fdmi_grhl_rsp_s {
703 
704 /*Get port list CT request */
705 typedef struct fcct_fdmi_grpl_req_s {
707  uint64_t hba_identifier;
709 
710 /*Get port list CT response */
711 typedef struct fcct_fdmi_grpl_rsp_s {
715 
716 /*Get HBA attribute list CT request */
717 typedef struct fcct_fdmi_ghat_req_s {
719  uint64_t hba_identifier;
721 
722 /*Get HBA attribute list CT response */
723 typedef struct fcct_fdmi_ghat_rsp_s {
727 
728 /*Get Port attribute list CT request */
729 typedef struct fcct_fdmi_gpat_req_s {
731  uint64_t port_identifier;
733 
734 /*Get Port attribute list CT response */
735 typedef struct fcct_fdmi_gpat_rsp_s {
737  ocs_fdmi_attr_block_t attr_block[0];
739 
740 typedef struct fcct_gnnid_req_s {
742  uint32_t :8,
743  port_id:24;
745 
746 typedef struct fcct_gpnid_req_s {
748  uint32_t :8,
749  port_id:24;
751 
752 typedef struct fcct_ganxt_req_s {
754  uint32_t :8,
755  port_id:24;
757 
758 typedef struct fcct_gffid_req_s {
760  uint32_t :8,
761  port_id:24;
763 
764 typedef struct fcct_gidft_req_s {
766  uint32_t :8,
767  domain_id_scope:8,
768  area_id_scope:8,
769  type:8;
771 
772 typedef struct fcct_gidpt_req_s {
774  uint32_t port_type:8,
775  domain_id_scope:8,
776  area_id_scope:8,
777  flags:8;
779 
780 typedef struct fcct_gnnid_acc_s {
782  uint64_t node_name;
784 
785 typedef struct fcct_gpnid_acc_s {
787  uint64_t port_name;
789 
790 typedef struct fcct_gffid_acc_s {
794 
795 typedef struct fcct_gidft_acc_s {
797  struct {
798  uint32_t ctl:8,
799  port_id:24;
800  } port_list[1];
802 
803 typedef struct fcct_gidpt_acc_s {
805  struct {
806  uint32_t ctl:8,
807  port_id:24;
808  } port_list[1];
810 
811 #define FCCT_GID_PT_LAST_ID 0x80
812 #define FCCT_GIDPT_ID_MASK 0x00ffffff
813 
814 #pragma pack(1)
815 typedef struct fcct_ganxt_acc_s {
816  uint32_t port_type:8,
817  port_id:24;
818  uint64_t port_name;
820  uint8_t sym_port_name[255];
821  uint64_t node_name;
823  uint8_t sym_node_name[255];
824  uint64_t ip_associator;
825  uint8_t ip_addr[16];
826  uint32_t class_of_serv;
827  uint8_t protocol_types[32];
829 #pragma pack()
830 
831 typedef struct fcp_cmnd_iu_s {
832  uint8_t fcp_lun[8];
834  uint8_t task_attribute:3,
835  command_priority:4,
836  :1;
837  uint8_t task_management_flags;
838  uint8_t wrdata:1,
839  rddata:1,
840  additional_fcp_cdb_length:6;
841  uint8_t fcp_cdb[16];
842  uint8_t fcp_cdb_and_dl[20]; // < May contain up to 16 bytes of CDB, followed by fcp_dl
843 } fcp_cmnd_iu_t;
844 
845 #define FCP_LUN_ADDRESS_METHOD_SHIFT 6
846 #define FCP_LUN_ADDRESS_METHOD_MASK 0xc0
847 #define FCP_LUN_ADDR_METHOD_PERIPHERAL 0x0
848 #define FCP_LUN_ADDR_METHOD_FLAT 0x1
849 #define FCP_LUN_ADDR_METHOD_LOGICAL 0x2
850 #define FCP_LUN_ADDR_METHOD_EXTENDED 0x3
851 
852 #define FCP_LUN_ADDR_SIMPLE_MAX 0xff
853 #define FCP_LUN_ADDR_FLAT_MAX 0x3fff
854 
855 #define FCP_TASK_ATTR_SIMPLE 0x0
856 #define FCP_TASK_ATTR_HEAD_OF_QUEUE 0x1
857 #define FCP_TASK_ATTR_ORDERED 0x2
858 #define FCP_TASK_ATTR_ACA 0x4
859 #define FCP_TASK_ATTR_UNTAGGED 0x5
860 
861 #define FCP_QUERY_TASK_SET BIT(0)
862 #define FCP_ABORT_TASK_SET BIT(1)
863 #define FCP_CLEAR_TASK_SET BIT(2)
864 #define FCP_QUERY_ASYNCHRONOUS_EVENT BIT(3)
865 #define FCP_LOGICAL_UNIT_RESET BIT(4)
866 #define FCP_TARGET_RESET BIT(5)
867 #define FCP_CLEAR_ACA BIT(6)
868 
869 /* SPC-4 says that the maximum length of sense data is 252 bytes */
870 #define FCP_MAX_SENSE_LEN 252
871 #define FCP_MAX_RSP_LEN 8
872 /*
873  * FCP_RSP buffer will either have sense or response data, but not both
874  * so pick the larger.
875  */
876 #define FCP_MAX_RSP_INFO_LEN FCP_MAX_SENSE_LEN
877 
878 typedef struct fcp_rsp_iu_s {
879  uint8_t rsvd[8];
880  uint8_t status_qualifier[2];
881  uint8_t flags;
882  uint8_t scsi_status;
883  uint8_t fcp_resid[4];
884  uint8_t fcp_sns_len[4];
885  uint8_t fcp_rsp_len[4];
886  uint8_t data[FCP_MAX_RSP_INFO_LEN];
887 } fcp_rsp_iu_t;
888 
889 /** Flag field defines: */
890 #define FCP_RSP_LEN_VALID BIT(0)
891 #define FCP_SNS_LEN_VALID BIT(1)
892 #define FCP_RESID_OVER BIT(2)
893 #define FCP_RESID_UNDER BIT(3)
894 #define FCP_CONF_REQ BIT(4)
895 #define FCP_BIDI_READ_RESID_OVER BIT(5)
896 #define FCP_BIDI_READ_RESID_UNDER BIT(6)
897 #define FCP_BIDI_RSP BIT(7)
898 
899 /** Status values: */
900 #define FCP_TMF_COMPLETE 0x00
901 #define FCP_DATA_LENGTH_MISMATCH 0x01
902 #define FCP_INVALID_FIELD 0x02
903 #define FCP_DATA_RO_MISMATCH 0x03
904 #define FCP_TMF_REJECTED 0x04
905 #define FCP_TMF_FAILED 0x05
906 #define FCP_TMF_SUCCEEDED 0x08
907 #define FCP_TMF_INCORRECT_LUN 0x09
908 
909 /** FCP-4 Table 28, TMF response information: */
910 typedef struct fc_rsp_info_s {
911  uint8_t addl_rsp_info[3];
912  uint8_t rsp_code;
913  uint32_t :32;
915 
916 typedef struct fcp_xfer_rdy_iu_s {
917  uint8_t fcp_data_ro[4];
918  uint8_t fcp_burst_len[4];
919  uint8_t rsvd[4];
921 
922 #define MAX_ACC_REJECT_PAYLOAD (sizeof(fc_ls_rjt_payload_t) > sizeof(fc_acc_payload_t) ? sizeof(fc_ls_rjt_payload_t) : sizeof(fc_acc_payload_t))
923 
924 
925 #endif /* !_OCS_FCP_H */
926 
927 /* vim: set noexpandtab textwidth=120: */
fcct_iu_header_t hdr
Definition: ocs_fcp.h:741
fcct_iu_header_t hdr
Definition: ocs_fcp.h:765
uint32_t class_of_serv
Definition: ocs_fcp.h:826
uint64_t node_name
Definition: ocs_fcp.h:584
fcct_iu_header_t hdr
Definition: ocs_fcp.h:570
uint64_t port_name
Definition: ocs_fcp.h:787
uint64_t node_name
Definition: ocs_fcp.h:821
uint32_t port_id
Definition: ocs_fcp.h:643
fcct_iu_header_t hdr
Definition: ocs_fcp.h:688
fcct_iu_header_t hdr
Definition: ocs_fcp.h:747
fcct_iu_header_t hdr
Definition: ocs_fcp.h:700
fcct_iu_header_t hdr
Definition: ocs_fcp.h:718
uint32_t max_residual_size
Definition: ocs_fcp.h:485
uint32_t dst_vmid
Definition: ocs_fcp.h:201
fcct_iu_header_t hdr
Definition: ocs_fcp.h:753
fcct_iu_header_t hdr
Definition: ocs_fcp.h:542
FC VM header in big-endian order.
Definition: ocs_fcp.h:200
uint8_t fc4_feature_bits
Definition: ocs_fcp.h:792
uint32_t options
Definition: ocs_fcp.h:481
uint64_t port_identifier
Definition: ocs_fcp.h:731
fcct_fdmi_reg_port_list_t hba_list
Definition: ocs_fcp.h:701
uint32_t node_name_hi
Definition: ocs_fcp.h:326
fcct_iu_header_t hdr
Definition: ocs_fcp.h:706
uint32_t parameter
Definition: ocs_fcp.h:170
uint64_t hba_identifier
Definition: ocs_fcp.h:707
uint32_t cmd_rsp_code
Definition: ocs_fcp.h:485
uint64_t port_name
Definition: ocs_fcp.h:683
uint32_t parameter
Definition: ocs_fcp.h:191
uint32_t port_name_lo
Definition: ocs_fcp.h:343
fcct_iu_header_t hdr
Definition: ocs_fcp.h:582
uint32_t rsvd1
Definition: ocs_fcp.h:204
uint64_t identifier
Definition: ocs_fcp.h:677
fcct_iu_header_t hdr
Definition: ocs_fcp.h:759
uint32_t port_id
Definition: ocs_fcp.h:633
uint32_t port_id
Definition: ocs_fcp.h:572
uint8_t command_reference_number
Definition: ocs_fcp.h:833
uint32_t originator_pa
Definition: ocs_fcp.h:368
uint32_t reason_code_explanation
Definition: ocs_fcp.h:487
fcct_iu_header_t hdr
Definition: ocs_fcp.h:730
uint8_t name_len
Definition: ocs_fcp.h:585
fcct_iu_header_t hdr
Definition: ocs_fcp.h:781
uint32_t port_id
Definition: ocs_fcp.h:521
fcct_fdmi_reg_port_list_t port_list
Definition: ocs_fcp.h:713
static uint32_t fc_htobe24(uint32_t x)
Definition: ocs_fcp.h:147
uint8_t sym_node_name_len
Definition: ocs_fcp.h:822
uint32_t responder_pa
Definition: ocs_fcp.h:369
fcct_fdmi_reg_port_list_t port_list
Definition: ocs_fcp.h:725
fcct_iu_header_t hdr
Definition: ocs_fcp.h:670
Definition: ocs_fcp.h:650
uint64_t port_name
Definition: ocs_fcp.h:545
uint32_t node_name_hi
Definition: ocs_fcp.h:422
uint32_t vendor_specific
Definition: ocs_fcp.h:487
uint32_t class_of_srvc
Definition: ocs_fcp.h:573
uint32_t resv1
Definition: ocs_fcp.h:481
uint32_t port_name_lo
Definition: ocs_fcp.h:421
uint32_t gs_type
Definition: ocs_fcp.h:481
uint32_t reason_code
Definition: ocs_fcp.h:487
fcct_iu_header_t hdr
Definition: ocs_fcp.h:773
uint32_t attr_int
Definition: ocs_fcp.h:651
uint8_t flags
Definition: ocs_fcp.h:881
FC header in big-endian order.
Definition: ocs_fcp.h:157
fcct_iu_header_t hdr
Definition: ocs_fcp.h:554
uint32_t node_name_lo
Definition: ocs_fcp.h:327
fcct_iu_header_t hdr
Definition: ocs_fcp.h:736
FC header in little-endian order.
Definition: ocs_fcp.h:177
fcct_iu_header_t hdr
Definition: ocs_fcp.h:642
uint32_t node_name_lo
Definition: ocs_fcp.h:423
uint32_t port_name_lo
Definition: ocs_fcp.h:325
ocs_fdmi_attr_entry_t entry
Definition: ocs_fcp.h:661
fcct_fdmi_reg_port_list_t port_list
Definition: ocs_fcp.h:672
uint32_t fc4_types
Definition: ocs_fcp.h:522
#define FCP_MAX_RSP_INFO_LEN
Definition: ocs_fcp.h:876
fcct_iu_header_t hdr
Definition: ocs_fcp.h:791
uint64_t attr_wwn
Definition: ocs_fcp.h:654
uint32_t port_id
Definition: ocs_fcp.h:544
uint32_t port_id
Definition: ocs_fcp.h:531
fcct_iu_header_t hdr
Definition: ocs_fcp.h:681
uint32_t port_name_hi
Definition: ocs_fcp.h:324
uint64_t port_name
Definition: ocs_fcp.h:818
static void fcct_build_req_header(fcct_iu_header_t *hdr, uint16_t cmd, uint8_t type, uint8_t gs_subtype, uint16_t max_size)
Definition: ocs_fcp.h:597
fcct_iu_header_t hdr
Definition: ocs_fcp.h:519
uint32_t port_name_hi
Definition: ocs_fcp.h:420
uint64_t hba_identifier
Definition: ocs_fcp.h:682
uint32_t fragment_id
Definition: ocs_fcp.h:487
fcct_iu_header_t hdr
Definition: ocs_fcp.h:695
uint64_t ip_associator
Definition: ocs_fcp.h:824
fcct_iu_header_t hdr
Definition: ocs_fcp.h:804
static void fcct_loopback_build_req_header(fcct_iu_header_t *hdr, uint16_t cmd, uint16_t max_size)
Definition: ocs_fcp.h:615
fcct_iu_header_t hdr
Definition: ocs_fcp.h:786
uint64_t node_name
Definition: ocs_fcp.h:557
uint64_t hba_identifier
Definition: ocs_fcp.h:671
uint64_t hba_identifier
Definition: ocs_fcp.h:719
uint32_t num_entries
Definition: ocs_fcp.h:660
uint32_t port_name_hi
Definition: ocs_fcp.h:342
fcct_iu_header_t hdr
Definition: ocs_fcp.h:724
uint32_t in_id
Definition: ocs_fcp.h:479
fcct_iu_header_t hdr
Definition: ocs_fcp.h:796
uint32_t gs_subtype
Definition: ocs_fcp.h:481
fcct_iu_header_t hdr
Definition: ocs_fcp.h:712
fcct_iu_header_t hdr
Definition: ocs_fcp.h:632
uint8_t rsp_code
Definition: ocs_fcp.h:912
uint32_t rsvd0
Definition: ocs_fcp.h:203
fcct_iu_header_t hdr
Definition: ocs_fcp.h:676
uint8_t sym_port_name_len
Definition: ocs_fcp.h:819
uint32_t revision
Definition: ocs_fcp.h:479
#define FC_GS_TYPE_LOOPBACK
Definition: ocs_fcp.h:71
static uint32_t fc_be24toh(uint32_t x)
Definition: ocs_fcp.h:143
uint8_t scsi_status
Definition: ocs_fcp.h:882
uint8_t uint8_t task_management_flags
Definition: ocs_fcp.h:834
fc_plogi_payload_t fc_sparms_t
Definition: ocs_fcp.h:335
uint64_t node_name
Definition: ocs_fcp.h:782
uint32_t port_id
Definition: ocs_fcp.h:556
fcct_iu_header_t hdr
Definition: ocs_fcp.h:529
uint32_t src_vmid
Definition: ocs_fcp.h:202