1 /*-
2 * Copyright (c) 2017 Broadcom. All rights reserved.
3 * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
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 * $FreeBSD$
32 */
33
34 /**
35 * @file
36 * Define Fibre Channel types and structures.
37 */
38
39 #ifndef _OCS_FCP_H
40 #define _OCS_FCP_H
41
42 #define FC_ELS_CMD_RJT 0x01
43 #define FC_ELS_CMD_ACC 0x02
44 #define FC_ELS_CMD_PLOGI 0x03
45 #define FC_ELS_CMD_FLOGI 0x04
46 #define FC_ELS_CMD_LOGO 0x05
47 #define FC_ELS_CMD_RRQ 0x12
48 #define FC_ELS_CMD_PRLI 0x20
49 #define FC_ELS_CMD_PRLO 0x21
50 #define FC_ELS_CMD_PDISC 0x50
51 #define FC_ELS_CMD_FDISC 0x51
52 #define FC_ELS_CMD_ADISC 0x52
53 #define FC_ELS_CMD_RSCN 0x61
54 #define FC_ELS_CMD_SCR 0x62
55
56 #define FC_TYPE_BASIC_LINK 0
57 #define FC_TYPE_FCP 0x08
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
67 #define FC_GS_TYPE_ALIAS_SERVICE 0xf8
68 #define FC_GS_TYPE_MANAGEMENT_SERVICE 0xfa
69 #define FC_GS_TYPE_DIRECTORY_SERVICE 0xfc
70
71 #define FC_GS_SUBTYPE_NAME_SERVER 0x02
72
73 /**
74 * Generic Services FC Type Bit mask macros:
75 */
76 #define FC_GS_TYPE_WORD(type) ((type) >> 5)
77 #define FC_GS_TYPE_BIT(type) ((type) & 0x1f)
78
79 /**
80 * Generic Services Name Server Request Command codes:
81 */
82 #define FC_GS_NAMESERVER_GPN_ID 0x0112
83 #define FC_GS_NAMESERVER_GNN_ID 0x0113
84 #define FC_GS_NAMESERVER_GFPN_ID 0x011c
85 #define FC_GS_NAMESERVER_GFF_ID 0x011f
86 #define FC_GS_NAMESERVER_GID_FT 0x0171
87 #define FC_GS_NAMESERVER_GID_PT 0x01a1
88 #define FC_GS_NAMESERVER_RHBA 0x0200
89 #define FC_GS_NAMESERVER_RPA 0x0211
90 #define FC_GS_NAMESERVER_RPN_ID 0x0212
91 #define FC_GS_NAMESERVER_RNN_ID 0x0213
92 #define FC_GS_NAMESERVER_RCS_ID 0x0214
93 #define FC_GS_NAMESERVER_RFT_ID 0x0217
94 #define FC_GS_NAMESERVER_RFF_ID 0x021f
95 #define FC_GS_NAMESERVER_RSNN_NN 0x0239
96 #define FC_GS_NAMESERVER_RSPN_ID 0x0218
97
98 #define FC_GS_REVISION 0x03
99
100 #define FC_GS_IO_PARAMS { .fc_ct.r_ctl = 0x02, \
101 .fc_ct.type = FC_TYPE_GS, \
102 .fc_ct.df_ctl = 0x00 }
103
104 typedef struct fc_vft_header_s {
105 uint32_t :1,
106 vf_id:12,
107 priority:3,
108 e:1,
109 :1,
110 type:4,
111 ver:2,
112 r_ctl:8;
113 uint32_t :24,
114 hopct:8;
115 } fc_vft_header_t;
116
117 #if BYTE_ORDER == LITTLE_ENDIAN
118 static inline uint32_t fc_be24toh(uint32_t x) { return (ocs_be32toh(x) >> 8); }
119 #else
120 static inline uint32_t fc_be24toh(uint32_t x) { }
121 #endif
122 static inline uint32_t fc_htobe24(uint32_t x) { return fc_be24toh(x); }
123
124 #define FC_SOFI3 0x2e
125 #define FC_SOFn3 0x36
126 #define FC_EOFN 0x41
127 #define FC_EOFT 0x42
128
129 /**
130 * @brief FC header in big-endian order
131 */
132 typedef struct fc_header_s {
133 uint32_t info:4,
134 r_ctl:4,
135 d_id:24;
136 uint32_t cs_ctl:8,
137 s_id:24;
138 uint32_t type:8,
139 f_ctl:24;
140 uint32_t seq_id:8,
141 df_ctl:8,
142 seq_cnt:16;
143 uint32_t ox_id:16,
144 rx_id:16;
145 uint32_t parameter;
146 } fc_header_t;
147
148 /**
149 * @brief FC header in little-endian order
150 */
151 typedef struct fc_header_le_s {
152 #if BYTE_ORDER == LITTLE_ENDIAN
153 uint32_t d_id:24,
154 info:4,
155 r_ctl:4;
156 uint32_t s_id:24,
157 cs_ctl:8;
158 uint32_t f_ctl:24,
159 type:8;
160 uint32_t seq_cnt:16,
161 df_ctl:8,
162 seq_id:8;
163 uint32_t rx_id:16,
164 ox_id:16;
165 uint32_t parameter;
166 #else
167 #error big endian version not defined
168 #endif
169 } fc_header_le_t;
170
171 /**
172 * @brief FC VM header in big-endian order
173 */
174 typedef struct fc_vm_header_s {
175 uint32_t dst_vmid;
176 uint32_t src_vmid;
177 uint32_t rsvd0;
178 uint32_t rsvd1;
179 } fc_vm_header_t;
180
181 #define FC_DFCTL_DEVICE_HDR_16_MASK 0x1
182 #define FC_DFCTL_NETWORK_HDR_MASK 0x20
183 #define FC_DFCTL_ESP_HDR_MASK 0x40
184 #define FC_DFCTL_NETWORK_HDR_SIZE 16
185 #define FC_DFCTL_ESP_HDR_SIZE 0 //FIXME
186
187 #define FC_RCTL_FC4_DATA 0
188 #define FC_RCTL_ELS 2
189 #define FC_RCTL_BLS 8
190
191 #define FC_RCTL_INFO_UNCAT 0
192 #define FC_RCTL_INFO_SOL_DATA 1
193 #define FC_RCTL_INFO_UNSOL_CTRL 2
194 #define FC_RCTL_INFO_SOL_CTRL 3
195 #define FC_RCTL_INFO_UNSOL_DATA 4
196 #define FC_RCTL_INFO_DATA_DESC 5
197 #define FC_RCTL_INFO_UNSOL_CMD 6
198 #define FC_RCTL_INFO_CMD_STATUS 7
199
200 #define FC_FCTL_EXCHANGE_RESPONDER 0x800000
201 #define FC_FCTL_SEQUENCE_CONTEXT 0x400000
202 #define FC_FCTL_FIRST_SEQUENCE 0x200000
203 #define FC_FCTL_LAST_SEQUENCE 0x100000
204 #define FC_FCTL_END_SEQUENCE 0x080000
205 #define FC_FCTL_END_CONNECTION 0x040000
206 #define FC_FCTL_PRIORITY_ENABLE 0x020000
207 #define FC_FCTL_SEQUENCE_INITIATIVE 0x010000
208 #define FC_FCTL_FILL_DATA_BYTES_MASK 0x000003
209
210 /**
211 * Common BLS definitions:
212 */
213 #define FC_INFO_NOP 0x0
214 #define FC_INFO_ABTS 0x1
215 #define FC_INFO_RMC 0x2
216 /* reserved 0x3 */
217 #define FC_INFO_BA_ACC 0x4
218 #define FC_INFO_BA_RJT 0x5
219 #define FC_INFO_PRMT 0x6
220
221 /* (FC-LS) LS_RJT Reason Codes */
222 #define FC_REASON_INVALID_COMMAND_CODE 0x01
223 #define FC_REASON_LOGICAL_ERROR 0x03
224 #define FC_REASON_LOGICAL_BUSY 0x05
225 #define FC_REASON_PROTOCOL_ERROR 0x07
226 #define FC_REASON_UNABLE_TO_PERFORM 0x09
227 #define FC_REASON_COMMAND_NOT_SUPPORTED 0x0b
228 #define FC_REASON_COMMAND_IN_PROGRESS 0x0e
229 #define FC_REASON_VENDOR_SPECIFIC 0xff
230
231 /* (FC-LS) LS_RJT Reason Codes Explanations */
232 #define FC_EXPL_NO_ADDITIONAL 0x00
233 #define FC_EXPL_SPARAM_OPTIONS 0x01
234 #define FC_EXPL_SPARAM_INITIATOR 0x03
235 #define FC_EXPL_SPARAM_RECPIENT 0x05
236 #define FC_EXPL_SPARM_DATA_SIZE 0x07
237 #define FC_EXPL_SPARM_CONCURRENT 0x09
238 #define FC_EXPL_SPARM_CREDIT 0x0b
239 #define FC_EXPL_INV_PORT_NAME 0x0d
240 #define FC_EXPL_INV_NODE_NAME 0x0e
241 #define FC_EXPL_INV_COMMON_SPARAMS 0x0f
242 #define FC_EXPL_INV_ASSOC_HEADER 0x11
243 #define FC_EXPL_ASSOC_HDR_REQUIRED 0x13
244 #define FC_EXPL_INV_ORIGINATOR_S_ID 0x15
245 #define FC_EXPL_INV_X_ID_COMBINATION 0x17
246 #define FC_EXPL_COMMAND_IN_PROGRESS 0x19
247 #define FC_EXPL_NPORT_LOGIN_REQUIRED 0x1e
248 #define FC_EXPL_N_PORT_ID 0x1f
249 #define FC_EXPL_INSUFFICIENT_RESOURCES 0x29
250 #define FC_EXPL_UNABLE_TO_SUPPLY_DATA 0x2a
251 #define FC_EXPL_REQUEST_NOT_SUPPORTED 0x2c
252 #define FC_EXPL_INV_PAYLOAD_LEN 0x1d
253 #define FC_EXPL_INV_PORT_NODE_NAME 0x44
254 #define FC_EXPL_LOGIN_EXT_NOT_SUPPORTED 0x46
255 #define FC_EXPL_AUTH_REQUIRED 0x48
256 #define FC_EXPL_SCAN_VALUE_NOT_ALLOWED 0x50
257 #define FC_EXPL_SCAN_VALUE_NOT_SUPPORTED 0x51
258 #define FC_EXPL_NO_RESOURCES_ASSIGNED 0x52
259 #define FC_EXPL_MAC_ADDR_MODE_NOT_SUPPORTED 0x60
260 #define FC_EXPL_MAC_ADDR_INCORRECTLY_FORMED 0x61
261 #define FC_EXPL_VN2VN_PORT_NOT_IN_NEIGHBOR_SET 0x62
262
263 #define FC_EXPL_INV_X_ID 0x03 /* invalid OX_ID - RX_ID combination */
264 #define FC_EXPL_SEQUENCE_ABORTED 0x05
265
266 typedef struct fc_ba_acc_payload_s {
267 #define FC_SEQ_ID_VALID 0x80
268 #define FC_SEQ_ID_INVALID 0x00
269 uint32_t seq_id_validity:8,
270 seq_id:8,
271 :16;
272 uint32_t ox_id:16,
273 rx_id:16;
274 uint32_t low_seq_cnt:16,
275 high_seq_cnt:16;
276 } fc_ba_acc_payload_t;
277
278 typedef struct fc_ba_rjt_payload_s {
279 uint32_t vendor_unique:8,
280 reason_explanation:8,
281 reason_code:8,
282 :8;
283 } fc_ba_rjt_payload_t;
284
285 typedef struct fc_els_gen_s {
286 uint32_t command_code: 8,
287 resv1: 24;
288 } fc_els_gen_t;
289
290 typedef struct fc_plogi_playload_s {
291 uint32_t command_code: 8,
292 resv1: 24;
293 uint32_t common_service_parameters[4];
294 uint32_t port_name_hi;
295 uint32_t port_name_lo;
296 uint32_t node_name_hi;
297 uint32_t node_name_lo;
298 uint32_t class1_service_parameters[4];
299 uint32_t class2_service_parameters[4];
300 uint32_t class3_service_parameters[4];
301 uint32_t class4_service_parameters[4];
302 uint32_t vendor_version_level[4];
303 } fc_plogi_payload_t;
304
305 typedef fc_plogi_payload_t fc_sparms_t;
306
307 typedef struct fc_logo_payload_s {
308 uint32_t command_code: 8,
309 resv1:24;
310 uint32_t :8,
311 port_id:24;
312 uint32_t port_name_hi;
313 uint32_t port_name_lo;
314 } fc_logo_payload_t;
315
316 typedef struct fc_acc_payload_s {
317 uint32_t command_code: 8,
318 resv1:24;
319 } fc_acc_payload_t;
320
321 typedef struct fc_ls_rjt_payload_s {
322 uint32_t command_code:8,
323 resv1:24;
324 uint32_t resv2:8,
325 reason_code:8,
326 reason_code_exp:8,
327 vendor_unique:8;
328 } fc_ls_rjt_payload_t;
329
330 typedef struct fc_prli_payload_s {
331 uint32_t command_code:8,
332 page_length:8,
333 payload_length:16;
334 uint32_t type:8,
335 type_ext:8,
336 flags:16;
337 uint32_t originator_pa;
338 uint32_t responder_pa;
339 uint32_t :16,
340 service_params:16;
341 } fc_prli_payload_t;
342
343 typedef struct fc_prlo_payload_s {
344 uint32_t command_code:8,
345 page_length:8,
346 payload_length:16;
347 uint32_t type:8,
348 type_ext:8,
349 :16;
350 uint32_t :32;
351 uint32_t :32;
352 uint32_t :32;
353 } fc_prlo_payload_t;
354
355 typedef struct fc_prlo_acc_payload_s {
356 uint32_t command_code:8,
357 page_length:8,
358 payload_length:16;
359 uint32_t type:8,
360 type_ext:8,
361 :4,
362 response_code:4,
363 :8;
364 uint32_t :32;
365 uint32_t :32;
366 uint32_t :32;
367 } fc_prlo_acc_payload_t;
368
369 typedef struct fc_adisc_payload_s {
370 uint32_t command_code:8,
371 payload_length:24;
372 uint32_t :8,
373 hard_address:24;
374 uint32_t port_name_hi;
375 uint32_t port_name_lo;
376 uint32_t node_name_hi;
377 uint32_t node_name_lo;
378 uint32_t :8,
379 port_id:24;
380 } fc_adisc_payload_t;
381
382 /* PRLI flags */
383 #define FC_PRLI_ORIGINATOR_PA_VALID 0x8000
384 #define FC_PRLI_RESPONDER_PA_VALID 0x4000
385 #define FC_PRLI_ESTABLISH_IMAGE_PAIR 0x2000
386 #define FC_PRLI_SERVICE_PARAM_INVALID 0x0800
387 #define FC_PRLI_REQUEST_EXECUTED 0x0100
388
389 /* PRLI Service Parameters */
390 #define FC_PRLI_REC_SUPPORT 0x0400
391 #define FC_PRLI_TASK_RETRY_ID_REQ 0x0200
392 #define FC_PRLI_RETRY 0x0100
393 #define FC_PRLI_CONFIRMED_COMPLETION 0x0080
394 #define FC_PRLI_DATA_OVERLAY 0x0040
395 #define FC_PRLI_INITIATOR_FUNCTION 0x0020
396 #define FC_PRLI_TARGET_FUNCTION 0x0010
397 #define FC_PRLI_READ_XRDY_DISABLED 0x0002
398 #define FC_PRLI_WRITE_XRDY_DISABLED 0x0001
399
400 /* PRLO Logout flags */
401 #define FC_PRLO_REQUEST_EXECUTED 0x0001
402
403 typedef struct fc_scr_payload_s {
404 uint32_t command_code:8,
405 :24;
406 uint32_t :24,
407 function:8;
408 } fc_scr_payload_t;
409
410 #define FC_SCR_REG_FABRIC 1
411 #define FC_SCR_REG_NPORT 2
412 #define FC_SCR_REG_FULL 3
413
414 typedef struct {
415 uint32_t :2,
416 rscn_event_qualifier:4,
417 address_format:2,
418 port_id:24;
419 } fc_rscn_affected_port_id_page_t;
420
421 typedef struct fc_rscn_payload_s {
422 uint32_t command_code:8,
423 page_length:8,
424 payload_length:16;
425 fc_rscn_affected_port_id_page_t port_list[1];
426 } fc_rscn_payload_t;
427
428 typedef struct fcct_iu_header_s {
429 #if BYTE_ORDER == LITTLE_ENDIAN
430 uint32_t revision:8,
431 in_id:24;
432 uint32_t gs_type:8,
433 gs_subtype:8,
434 options:8,
435 resv1:8;
436 uint32_t cmd_rsp_code:16,
437 max_residual_size:16;
438 uint32_t fragment_id:8,
439 reason_code:8,
440 reason_code_explanation:8,
441 vendor_specific:8;
442 #else
443 #error big endian version not defined
444 #endif
445 } fcct_iu_header_t;
446
447 #define FCCT_REJECT_INVALID_COMMAND_CODE 1
448 #define FCCT_REJECT_INVALID_VERSION_LEVEL 2
449 #define FCCT_LOGICAL_ERROR 3
450 #define FCCT_INVALID_CT_IU_SIZE 4
451 #define FCCT_LOGICAL_BUSY 5
452 #define FCCT_PROTOCOL_ERROR 7
453 #define FCCT_UNABLE_TO_PERFORM 9
454 #define FCCT_COMMAND_NOT_SUPPORTED 0x0b
455 #define FCCT_FABRIC_PORT_NAME_NOT_REGISTERED 0x0c
456 #define FCCT_SERVER_NOT_AVAILABLE 0x0d
457 #define FCCT_SESSION_COULD_NOT_BE_ESTABLISHED 0x0e
458 #define FCCT_VENDOR_SPECIFIC_ERROR 0xff
459
460 #define FCCT_NO_ADDITIONAL_EXPLANATION 0
461 #define FCCT_AUTHORIZATION_EXCEPTION 0xf0
462 #define FCCT_AUTHENTICATION_EXCEPTION 0xf1
463 #define FCCT_DATA_BASE_FULL 0xf2
464 #define FCCT_DATA_BASE_EMPTY 0xf3
465 #define FCCT_PROCESSING_REQUEST 0xf4
466 #define FCCT_UNABLE_TO_VERIFY_CONNECTION 0xf5
467 #define FCCT_DEVICES_NOT_IN_COMMON_ZONE 0xf6
468
469 typedef struct {
470 fcct_iu_header_t hdr;
471 #if BYTE_ORDER == LITTLE_ENDIAN
472 uint32_t port_id;
473 uint32_t fc4_types;
474 #else
475 #error big endian version not defined
476 #endif
477 } fcgs_rft_id_t;
478
479 typedef struct {
480 fcct_iu_header_t hdr;
481 #if BYTE_ORDER == LITTLE_ENDIAN
482 uint32_t port_id;
483 uint32_t :16,
484 fc4_features:8,
485 type_code:8;
486 #else
487 #error big endian version not defined
488 #endif
489 } fcgs_rff_id_t;
490
491 #pragma pack(1)
492 typedef struct {
493 fcct_iu_header_t hdr;
494 #if BYTE_ORDER == LITTLE_ENDIAN
495 uint32_t port_id;
496 uint64_t port_name;
497 #else
498 #error big endian version not defined
499 #endif
500 } fcgs_rpn_id_t;
501 #pragma pack()
502
503 #pragma pack(1)
504 typedef struct {
505 fcct_iu_header_t hdr;
506 #if BYTE_ORDER == LITTLE_ENDIAN
507 uint32_t port_id;
508 uint64_t node_name;
509 #else
510 #error big endian version not defined
511 #endif
512 } fcgs_rnn_id_t;
513 #pragma pack()
514
515 #define FCCT_CLASS_OF_SERVICE_F 0x1
516 #define FCCT_CLASS_OF_SERVICE_2 0x4
517 #define FCCT_CLASS_OF_SERVICE_3 0x8
518 #pragma pack(1)
519 typedef struct {
520 fcct_iu_header_t hdr;
521 #if BYTE_ORDER == LITTLE_ENDIAN
522 uint32_t port_id;
523 uint32_t class_of_srvc;
524 #else
525 #error big endian version not defined
526 #endif
527 } fcgs_rcs_id_t;
528 #pragma pack()
529
530 #pragma pack(1)
531 typedef struct {
532 fcct_iu_header_t hdr;
533 #if BYTE_ORDER == LITTLE_ENDIAN
534 uint64_t node_name;
535 uint8_t name_len;
536 char sym_node_name[1];
537 /*TODO: need name length and symbolic name */
538 #else
539 #error big endian version not defined
540 #endif
541 } fcgs_rsnn_nn_t;
542 #pragma pack()
543
544 #define FCCT_HDR_CMDRSP_ACCEPT 0x8002
545 #define FCCT_HDR_CMDRSP_REJECT 0x8001
546
547 static inline void fcct_build_req_header(fcct_iu_header_t *hdr, uint16_t cmd, uint16_t max_size)
548 {
549 /* use old rev (1) to accommodate older switches */
550 hdr->revision = 1;
551 hdr->in_id = 0;
552 hdr->gs_type = FC_GS_TYPE_DIRECTORY_SERVICE;
553 hdr->gs_subtype = FC_GS_SUBTYPE_NAME_SERVER;
554 hdr->options = 0;
555 hdr->resv1 = 0;
556 hdr->cmd_rsp_code = ocs_htobe16(cmd);
557 hdr->max_residual_size = ocs_htobe16(max_size/(sizeof(uint32_t))); /* words */
558 hdr->fragment_id = 0;
559 hdr->reason_code = 0;
560 hdr->reason_code_explanation = 0;
561 hdr->vendor_specific = 0;
562 }
563
564 typedef struct fcct_rftid_req_s {
565 fcct_iu_header_t hdr;
566 uint32_t port_id;
567 uint32_t fc4_types[8];
568 } fcct_rftid_req_t;
569
570 #define FC4_FEATURE_TARGET (1U << 0)
571 #define FC4_FEATURE_INITIATOR (1U << 1)
572
573 typedef struct fcct_rffid_req_s {
574 fcct_iu_header_t hdr;
575 uint32_t port_id;
576 uint32_t :16,
577 fc4_feature_bits:8,
578 type:8;
579 } fcct_rffid_req_t;
580
581 typedef struct fcct_gnnid_req_s {
582 fcct_iu_header_t hdr;
583 uint32_t :8,
584 port_id:24;
585 } fcct_gnnid_req_t;
586
587 typedef struct fcct_gpnid_req_s {
588 fcct_iu_header_t hdr;
589 uint32_t :8,
590 port_id:24;
591 } fcct_gpnid_req_t;
592
593 typedef struct fcct_gffid_req_s {
594 fcct_iu_header_t hdr;
595 uint32_t :8,
596 port_id:24;
597 } fcct_gffid_req_t;
598
599 typedef struct fcct_gidft_req_s {
600 fcct_iu_header_t hdr;
601 uint32_t :8,
602 domain_id_scope:8,
603 area_id_scope:8,
604 type:8;
605 } fcct_gidft_req_t;
606
607 typedef struct fcct_gidpt_req_s {
608 fcct_iu_header_t hdr;
609 uint32_t port_type:8,
610 domain_id_scope:8,
611 area_id_scope:8,
612 flags:8;
613 } fcct_gidpt_req_t;
614
615 typedef struct fcct_gnnid_acc_s {
616 fcct_iu_header_t hdr;
617 uint64_t node_name;
618 } fcct_gnnid_acc_t;
619
620 typedef struct fcct_gpnid_acc_s {
621 fcct_iu_header_t hdr;
622 uint64_t port_name;
623 } fcct_gpnid_acc_t;
624
625 typedef struct fcct_gffid_acc_s {
626 fcct_iu_header_t hdr;
627 uint8_t fc4_feature_bits;
628 } fcct_gffid_acc_t;
629
630 typedef struct fcct_gidft_acc_s {
631 fcct_iu_header_t hdr;
632 struct {
633 uint32_t ctl:8,
634 port_id:24;
635 } port_list[1];
636 } fcct_gidft_acc_t;
637
638 typedef struct fcct_gidpt_acc_s {
639 fcct_iu_header_t hdr;
640 struct {
641 uint32_t ctl:8,
642 port_id:24;
643 } port_list[1];
644 } fcct_gidpt_acc_t;
645
646 #define FCCT_GID_PT_LAST_ID 0x80
647 #define FCCT_GIDPT_ID_MASK 0x00ffffff
648
649 typedef struct fcp_cmnd_iu_s {
650 uint8_t fcp_lun[8];
651 uint8_t command_reference_number;
652 uint8_t task_attribute:3,
653 command_priority:4,
654 :1;
655 uint8_t task_management_flags;
656 uint8_t wrdata:1,
657 rddata:1,
658 additional_fcp_cdb_length:6;
659 uint8_t fcp_cdb[16];
660 uint8_t fcp_cdb_and_dl[20]; /* < May contain up to 16 bytes of CDB, followed by fcp_dl */
661 } fcp_cmnd_iu_t;
662
663 #define FCP_LUN_ADDRESS_METHOD_SHIFT 6
664 #define FCP_LUN_ADDRESS_METHOD_MASK 0xc0
665 #define FCP_LUN_ADDR_METHOD_PERIPHERAL 0x0
666 #define FCP_LUN_ADDR_METHOD_FLAT 0x1
667 #define FCP_LUN_ADDR_METHOD_LOGICAL 0x2
668 #define FCP_LUN_ADDR_METHOD_EXTENDED 0x3
669
670 #define FCP_LUN_ADDR_SIMPLE_MAX 0xff
671 #define FCP_LUN_ADDR_FLAT_MAX 0x3fff
672
673 #define FCP_TASK_ATTR_SIMPLE 0x0
674 #define FCP_TASK_ATTR_HEAD_OF_QUEUE 0x1
675 #define FCP_TASK_ATTR_ORDERED 0x2
676 #define FCP_TASK_ATTR_ACA 0x4
677 #define FCP_TASK_ATTR_UNTAGGED 0x5
678
679 #define FCP_QUERY_TASK_SET BIT(0)
680 #define FCP_ABORT_TASK_SET BIT(1)
681 #define FCP_CLEAR_TASK_SET BIT(2)
682 #define FCP_QUERY_ASYNCHRONOUS_EVENT BIT(3)
683 #define FCP_LOGICAL_UNIT_RESET BIT(4)
684 #define FCP_TARGET_RESET BIT(5)
685 #define FCP_CLEAR_ACA BIT(6)
686
687 /* SPC-4 says that the maximum length of sense data is 252 bytes */
688 #define FCP_MAX_SENSE_LEN 252
689 #define FCP_MAX_RSP_LEN 8
690 /*
691 * FCP_RSP buffer will either have sense or response data, but not both
692 * so pick the larger.
693 */
694 #define FCP_MAX_RSP_INFO_LEN FCP_MAX_SENSE_LEN
695
696 typedef struct fcp_rsp_iu_s {
697 uint8_t rsvd[8];
698 uint8_t status_qualifier[2];
699 uint8_t flags;
700 uint8_t scsi_status;
701 uint8_t fcp_resid[4];
702 uint8_t fcp_sns_len[4];
703 uint8_t fcp_rsp_len[4];
704 uint8_t data[FCP_MAX_RSP_INFO_LEN];
705 } fcp_rsp_iu_t;
706
707 /** Flag field defines: */
708 #define FCP_RSP_LEN_VALID BIT(0)
709 #define FCP_SNS_LEN_VALID BIT(1)
710 #define FCP_RESID_OVER BIT(2)
711 #define FCP_RESID_UNDER BIT(3)
712 #define FCP_CONF_REQ BIT(4)
713 #define FCP_BIDI_READ_RESID_OVER BIT(5)
714 #define FCP_BIDI_READ_RESID_UNDER BIT(6)
715 #define FCP_BIDI_RSP BIT(7)
716
717 /** Status values: */
718 #define FCP_TMF_COMPLETE 0x00
719 #define FCP_DATA_LENGTH_MISMATCH 0x01
720 #define FCP_INVALID_FIELD 0x02
721 #define FCP_DATA_RO_MISMATCH 0x03
722 #define FCP_TMF_REJECTED 0x04
723 #define FCP_TMF_FAILED 0x05
724 #define FCP_TMF_SUCCEEDED 0x08
725 #define FCP_TMF_INCORRECT_LUN 0x09
726
727 /** FCP-4 Table 28, TMF response information: */
728 typedef struct fc_rsp_info_s {
729 uint8_t addl_rsp_info[3];
730 uint8_t rsp_code;
731 uint32_t :32;
732 } fcp_rsp_info_t;
733
734 typedef struct fcp_xfer_rdy_iu_s {
735 uint8_t fcp_data_ro[4];
736 uint8_t fcp_burst_len[4];
737 uint8_t rsvd[4];
738 } fcp_xfer_rdy_iu_t;
739
740 #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))
741
742 #endif /* !_OCS_FCP_H */
Cache object: 4e965ffae8348174cd10ffd858f9eede
|