2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
6 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License (GPL) Version 2 as
10 * published by the Free Software Foundation
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.
18 * fcbuild.c - FC link service frame building and parsing routines
22 #include "bfa_fcbuild.h"
25 * static build functions
27 static void fc_els_rsp_build(struct fchs_s
*fchs
, u32 d_id
, u32 s_id
,
29 static void fc_bls_rsp_build(struct fchs_s
*fchs
, u32 d_id
, u32 s_id
,
31 static struct fchs_s fc_els_req_tmpl
;
32 static struct fchs_s fc_els_rsp_tmpl
;
33 static struct fchs_s fc_bls_req_tmpl
;
34 static struct fchs_s fc_bls_rsp_tmpl
;
35 static struct fc_ba_acc_s ba_acc_tmpl
;
36 static struct fc_logi_s plogi_tmpl
;
37 static struct fc_prli_s prli_tmpl
;
38 static struct fc_rrq_s rrq_tmpl
;
39 static struct fchs_s fcp_fchs_tmpl
;
47 fc_els_req_tmpl
.routing
= FC_RTG_EXT_LINK
;
48 fc_els_req_tmpl
.cat_info
= FC_CAT_LD_REQUEST
;
49 fc_els_req_tmpl
.type
= FC_TYPE_ELS
;
50 fc_els_req_tmpl
.f_ctl
=
51 bfa_hton3b(FCTL_SEQ_INI
| FCTL_FS_EXCH
| FCTL_END_SEQ
|
53 fc_els_req_tmpl
.rx_id
= FC_RXID_ANY
;
58 fc_els_rsp_tmpl
.routing
= FC_RTG_EXT_LINK
;
59 fc_els_rsp_tmpl
.cat_info
= FC_CAT_LD_REPLY
;
60 fc_els_rsp_tmpl
.type
= FC_TYPE_ELS
;
61 fc_els_rsp_tmpl
.f_ctl
=
62 bfa_hton3b(FCTL_EC_RESP
| FCTL_SEQ_INI
| FCTL_LS_EXCH
|
63 FCTL_END_SEQ
| FCTL_SI_XFER
);
64 fc_els_rsp_tmpl
.rx_id
= FC_RXID_ANY
;
69 fc_bls_req_tmpl
.routing
= FC_RTG_BASIC_LINK
;
70 fc_bls_req_tmpl
.type
= FC_TYPE_BLS
;
71 fc_bls_req_tmpl
.f_ctl
= bfa_hton3b(FCTL_END_SEQ
| FCTL_SI_XFER
);
72 fc_bls_req_tmpl
.rx_id
= FC_RXID_ANY
;
77 fc_bls_rsp_tmpl
.routing
= FC_RTG_BASIC_LINK
;
78 fc_bls_rsp_tmpl
.cat_info
= FC_CAT_BA_ACC
;
79 fc_bls_rsp_tmpl
.type
= FC_TYPE_BLS
;
80 fc_bls_rsp_tmpl
.f_ctl
=
81 bfa_hton3b(FCTL_EC_RESP
| FCTL_SEQ_INI
| FCTL_LS_EXCH
|
82 FCTL_END_SEQ
| FCTL_SI_XFER
);
83 fc_bls_rsp_tmpl
.rx_id
= FC_RXID_ANY
;
88 ba_acc_tmpl
.seq_id_valid
= 0;
89 ba_acc_tmpl
.low_seq_cnt
= 0;
90 ba_acc_tmpl
.high_seq_cnt
= 0xFFFF;
95 plogi_tmpl
.csp
.verhi
= FC_PH_VER_PH_3
;
96 plogi_tmpl
.csp
.verlo
= FC_PH_VER_4_3
;
97 plogi_tmpl
.csp
.bbcred
= cpu_to_be16(0x0004);
98 plogi_tmpl
.csp
.ciro
= 0x1;
99 plogi_tmpl
.csp
.cisc
= 0x0;
100 plogi_tmpl
.csp
.altbbcred
= 0x0;
101 plogi_tmpl
.csp
.conseq
= cpu_to_be16(0x00FF);
102 plogi_tmpl
.csp
.ro_bitmap
= cpu_to_be16(0x0002);
103 plogi_tmpl
.csp
.e_d_tov
= cpu_to_be32(2000);
105 plogi_tmpl
.class3
.class_valid
= 1;
106 plogi_tmpl
.class3
.sequential
= 1;
107 plogi_tmpl
.class3
.conseq
= 0xFF;
108 plogi_tmpl
.class3
.ospx
= 1;
113 prli_tmpl
.command
= FC_ELS_PRLI
;
114 prli_tmpl
.pglen
= 0x10;
115 prli_tmpl
.pagebytes
= cpu_to_be16(0x0014);
116 prli_tmpl
.parampage
.type
= FC_TYPE_FCP
;
117 prli_tmpl
.parampage
.imagepair
= 1;
118 prli_tmpl
.parampage
.servparams
.rxrdisab
= 1;
123 rrq_tmpl
.els_cmd
.els_code
= FC_ELS_RRQ
;
126 * fcp_struct fchs_s mpl
128 fcp_fchs_tmpl
.routing
= FC_RTG_FC4_DEV_DATA
;
129 fcp_fchs_tmpl
.cat_info
= FC_CAT_UNSOLICIT_CMD
;
130 fcp_fchs_tmpl
.type
= FC_TYPE_FCP
;
131 fcp_fchs_tmpl
.f_ctl
=
132 bfa_hton3b(FCTL_FS_EXCH
| FCTL_END_SEQ
| FCTL_SI_XFER
);
133 fcp_fchs_tmpl
.seq_id
= 1;
134 fcp_fchs_tmpl
.rx_id
= FC_RXID_ANY
;
138 fc_gs_fchdr_build(struct fchs_s
*fchs
, u32 d_id
, u32 s_id
, u32 ox_id
)
140 memset(fchs
, 0, sizeof(struct fchs_s
));
142 fchs
->routing
= FC_RTG_FC4_DEV_DATA
;
143 fchs
->cat_info
= FC_CAT_UNSOLICIT_CTRL
;
144 fchs
->type
= FC_TYPE_SERVICES
;
146 bfa_hton3b(FCTL_SEQ_INI
| FCTL_FS_EXCH
| FCTL_END_SEQ
|
148 fchs
->rx_id
= FC_RXID_ANY
;
151 fchs
->ox_id
= cpu_to_be16(ox_id
);
154 * @todo no need to set ox_id for request
155 * no need to set rx_id for response
160 fc_els_req_build(struct fchs_s
*fchs
, u32 d_id
, u32 s_id
, __be16 ox_id
)
162 memcpy(fchs
, &fc_els_req_tmpl
, sizeof(struct fchs_s
));
165 fchs
->ox_id
= cpu_to_be16(ox_id
);
169 fc_els_rsp_build(struct fchs_s
*fchs
, u32 d_id
, u32 s_id
, __be16 ox_id
)
171 memcpy(fchs
, &fc_els_rsp_tmpl
, sizeof(struct fchs_s
));
178 fc_els_rsp_parse(struct fchs_s
*fchs
, int len
)
180 struct fc_els_cmd_s
*els_cmd
= (struct fc_els_cmd_s
*) (fchs
+ 1);
181 struct fc_ls_rjt_s
*ls_rjt
= (struct fc_ls_rjt_s
*) els_cmd
;
185 switch (els_cmd
->els_code
) {
187 if (ls_rjt
->reason_code
== FC_LS_RJT_RSN_LOGICAL_BUSY
)
188 return FC_PARSE_BUSY
;
190 return FC_PARSE_FAILURE
;
199 fc_bls_rsp_build(struct fchs_s
*fchs
, u32 d_id
, u32 s_id
, __be16 ox_id
)
201 memcpy(fchs
, &fc_bls_rsp_tmpl
, sizeof(struct fchs_s
));
208 fc_plogi_x_build(struct fchs_s
*fchs
, void *pld
, u32 d_id
, u32 s_id
,
209 __be16 ox_id
, wwn_t port_name
, wwn_t node_name
,
210 u16 pdu_size
, u8 els_code
)
212 struct fc_logi_s
*plogi
= (struct fc_logi_s
*) (pld
);
214 memcpy(plogi
, &plogi_tmpl
, sizeof(struct fc_logi_s
));
216 plogi
->els_cmd
.els_code
= els_code
;
217 if (els_code
== FC_ELS_PLOGI
)
218 fc_els_req_build(fchs
, d_id
, s_id
, ox_id
);
220 fc_els_rsp_build(fchs
, d_id
, s_id
, ox_id
);
222 plogi
->csp
.rxsz
= plogi
->class3
.rxsz
= cpu_to_be16(pdu_size
);
224 memcpy(&plogi
->port_name
, &port_name
, sizeof(wwn_t
));
225 memcpy(&plogi
->node_name
, &node_name
, sizeof(wwn_t
));
227 return sizeof(struct fc_logi_s
);
231 fc_flogi_build(struct fchs_s
*fchs
, struct fc_logi_s
*flogi
, u32 s_id
,
232 u16 ox_id
, wwn_t port_name
, wwn_t node_name
, u16 pdu_size
,
233 u8 set_npiv
, u8 set_auth
, u16 local_bb_credits
)
235 u32 d_id
= bfa_hton3b(FC_FABRIC_PORT
);
238 memcpy(flogi
, &plogi_tmpl
, sizeof(struct fc_logi_s
));
240 flogi
->els_cmd
.els_code
= FC_ELS_FLOGI
;
241 fc_els_req_build(fchs
, d_id
, s_id
, ox_id
);
243 flogi
->csp
.rxsz
= flogi
->class3
.rxsz
= cpu_to_be16(pdu_size
);
244 flogi
->port_name
= port_name
;
245 flogi
->node_name
= node_name
;
248 * Set the NPIV Capability Bit ( word 1, bit 31) of Common
249 * Service Parameters.
251 flogi
->csp
.ciro
= set_npiv
;
253 /* set AUTH capability */
254 flogi
->csp
.security
= set_auth
;
256 flogi
->csp
.bbcred
= cpu_to_be16(local_bb_credits
);
258 /* Set brcd token in VVL */
259 vvl_info
= (u32
*)&flogi
->vvl
[0];
261 /* set the flag to indicate the presence of VVL */
262 flogi
->csp
.npiv_supp
= 1; /* @todo. field name is not correct */
263 vvl_info
[0] = cpu_to_be32(FLOGI_VVL_BRCD
);
265 return sizeof(struct fc_logi_s
);
269 fc_flogi_acc_build(struct fchs_s
*fchs
, struct fc_logi_s
*flogi
, u32 s_id
,
270 __be16 ox_id
, wwn_t port_name
, wwn_t node_name
,
271 u16 pdu_size
, u16 local_bb_credits
)
275 memcpy(flogi
, &plogi_tmpl
, sizeof(struct fc_logi_s
));
276 fc_els_rsp_build(fchs
, d_id
, s_id
, ox_id
);
278 flogi
->els_cmd
.els_code
= FC_ELS_ACC
;
279 flogi
->csp
.rxsz
= flogi
->class3
.rxsz
= cpu_to_be16(pdu_size
);
280 flogi
->port_name
= port_name
;
281 flogi
->node_name
= node_name
;
283 flogi
->csp
.bbcred
= cpu_to_be16(local_bb_credits
);
285 return sizeof(struct fc_logi_s
);
289 fc_fdisc_build(struct fchs_s
*fchs
, struct fc_logi_s
*flogi
, u32 s_id
,
290 u16 ox_id
, wwn_t port_name
, wwn_t node_name
, u16 pdu_size
)
292 u32 d_id
= bfa_hton3b(FC_FABRIC_PORT
);
294 memcpy(flogi
, &plogi_tmpl
, sizeof(struct fc_logi_s
));
296 flogi
->els_cmd
.els_code
= FC_ELS_FDISC
;
297 fc_els_req_build(fchs
, d_id
, s_id
, ox_id
);
299 flogi
->csp
.rxsz
= flogi
->class3
.rxsz
= cpu_to_be16(pdu_size
);
300 flogi
->port_name
= port_name
;
301 flogi
->node_name
= node_name
;
303 return sizeof(struct fc_logi_s
);
307 fc_plogi_build(struct fchs_s
*fchs
, void *pld
, u32 d_id
, u32 s_id
,
308 u16 ox_id
, wwn_t port_name
, wwn_t node_name
,
311 return fc_plogi_x_build(fchs
, pld
, d_id
, s_id
, ox_id
, port_name
,
312 node_name
, pdu_size
, FC_ELS_PLOGI
);
316 fc_plogi_acc_build(struct fchs_s
*fchs
, void *pld
, u32 d_id
, u32 s_id
,
317 u16 ox_id
, wwn_t port_name
, wwn_t node_name
,
320 return fc_plogi_x_build(fchs
, pld
, d_id
, s_id
, ox_id
, port_name
,
321 node_name
, pdu_size
, FC_ELS_ACC
);
325 fc_plogi_rsp_parse(struct fchs_s
*fchs
, int len
, wwn_t port_name
)
327 struct fc_els_cmd_s
*els_cmd
= (struct fc_els_cmd_s
*) (fchs
+ 1);
328 struct fc_logi_s
*plogi
;
329 struct fc_ls_rjt_s
*ls_rjt
;
331 switch (els_cmd
->els_code
) {
333 ls_rjt
= (struct fc_ls_rjt_s
*) (fchs
+ 1);
334 if (ls_rjt
->reason_code
== FC_LS_RJT_RSN_LOGICAL_BUSY
)
335 return FC_PARSE_BUSY
;
337 return FC_PARSE_FAILURE
;
339 plogi
= (struct fc_logi_s
*) (fchs
+ 1);
340 if (len
< sizeof(struct fc_logi_s
))
341 return FC_PARSE_FAILURE
;
343 if (!wwn_is_equal(plogi
->port_name
, port_name
))
344 return FC_PARSE_FAILURE
;
346 if (!plogi
->class3
.class_valid
)
347 return FC_PARSE_FAILURE
;
349 if (be16_to_cpu(plogi
->class3
.rxsz
) < (FC_MIN_PDUSZ
))
350 return FC_PARSE_FAILURE
;
354 return FC_PARSE_FAILURE
;
359 fc_plogi_parse(struct fchs_s
*fchs
)
361 struct fc_logi_s
*plogi
= (struct fc_logi_s
*) (fchs
+ 1);
363 if (plogi
->class3
.class_valid
!= 1)
364 return FC_PARSE_FAILURE
;
366 if ((be16_to_cpu(plogi
->class3
.rxsz
) < FC_MIN_PDUSZ
)
367 || (be16_to_cpu(plogi
->class3
.rxsz
) > FC_MAX_PDUSZ
)
368 || (plogi
->class3
.rxsz
== 0))
369 return FC_PARSE_FAILURE
;
375 fc_prli_build(struct fchs_s
*fchs
, void *pld
, u32 d_id
, u32 s_id
,
378 struct fc_prli_s
*prli
= (struct fc_prli_s
*) (pld
);
380 fc_els_req_build(fchs
, d_id
, s_id
, ox_id
);
381 memcpy(prli
, &prli_tmpl
, sizeof(struct fc_prli_s
));
383 prli
->command
= FC_ELS_PRLI
;
384 prli
->parampage
.servparams
.initiator
= 1;
385 prli
->parampage
.servparams
.retry
= 1;
386 prli
->parampage
.servparams
.rec_support
= 1;
387 prli
->parampage
.servparams
.task_retry_id
= 0;
388 prli
->parampage
.servparams
.confirm
= 1;
390 return sizeof(struct fc_prli_s
);
394 fc_prli_acc_build(struct fchs_s
*fchs
, void *pld
, u32 d_id
, u32 s_id
,
395 __be16 ox_id
, enum bfa_lport_role role
)
397 struct fc_prli_s
*prli
= (struct fc_prli_s
*) (pld
);
399 fc_els_rsp_build(fchs
, d_id
, s_id
, ox_id
);
400 memcpy(prli
, &prli_tmpl
, sizeof(struct fc_prli_s
));
402 prli
->command
= FC_ELS_ACC
;
404 prli
->parampage
.servparams
.initiator
= 1;
406 prli
->parampage
.rspcode
= FC_PRLI_ACC_XQTD
;
408 return sizeof(struct fc_prli_s
);
412 fc_prli_rsp_parse(struct fc_prli_s
*prli
, int len
)
414 if (len
< sizeof(struct fc_prli_s
))
415 return FC_PARSE_FAILURE
;
417 if (prli
->command
!= FC_ELS_ACC
)
418 return FC_PARSE_FAILURE
;
420 if ((prli
->parampage
.rspcode
!= FC_PRLI_ACC_XQTD
)
421 && (prli
->parampage
.rspcode
!= FC_PRLI_ACC_PREDEF_IMG
))
422 return FC_PARSE_FAILURE
;
424 if (prli
->parampage
.servparams
.target
!= 1)
425 return FC_PARSE_FAILURE
;
431 fc_prli_parse(struct fc_prli_s
*prli
)
433 if (prli
->parampage
.type
!= FC_TYPE_FCP
)
434 return FC_PARSE_FAILURE
;
436 if (!prli
->parampage
.imagepair
)
437 return FC_PARSE_FAILURE
;
439 if (!prli
->parampage
.servparams
.initiator
)
440 return FC_PARSE_FAILURE
;
446 fc_logo_build(struct fchs_s
*fchs
, struct fc_logo_s
*logo
, u32 d_id
, u32 s_id
,
447 u16 ox_id
, wwn_t port_name
)
449 fc_els_req_build(fchs
, d_id
, s_id
, ox_id
);
451 memset(logo
, '\0', sizeof(struct fc_logo_s
));
452 logo
->els_cmd
.els_code
= FC_ELS_LOGO
;
453 logo
->nport_id
= (s_id
);
454 logo
->orig_port_name
= port_name
;
456 return sizeof(struct fc_logo_s
);
460 fc_adisc_x_build(struct fchs_s
*fchs
, struct fc_adisc_s
*adisc
, u32 d_id
,
461 u32 s_id
, __be16 ox_id
, wwn_t port_name
,
462 wwn_t node_name
, u8 els_code
)
464 memset(adisc
, '\0', sizeof(struct fc_adisc_s
));
466 adisc
->els_cmd
.els_code
= els_code
;
468 if (els_code
== FC_ELS_ADISC
)
469 fc_els_req_build(fchs
, d_id
, s_id
, ox_id
);
471 fc_els_rsp_build(fchs
, d_id
, s_id
, ox_id
);
474 adisc
->orig_port_name
= port_name
;
475 adisc
->orig_node_name
= node_name
;
476 adisc
->nport_id
= (s_id
);
478 return sizeof(struct fc_adisc_s
);
482 fc_adisc_build(struct fchs_s
*fchs
, struct fc_adisc_s
*adisc
, u32 d_id
,
483 u32 s_id
, __be16 ox_id
, wwn_t port_name
, wwn_t node_name
)
485 return fc_adisc_x_build(fchs
, adisc
, d_id
, s_id
, ox_id
, port_name
,
486 node_name
, FC_ELS_ADISC
);
490 fc_adisc_acc_build(struct fchs_s
*fchs
, struct fc_adisc_s
*adisc
, u32 d_id
,
491 u32 s_id
, __be16 ox_id
, wwn_t port_name
,
494 return fc_adisc_x_build(fchs
, adisc
, d_id
, s_id
, ox_id
, port_name
,
495 node_name
, FC_ELS_ACC
);
499 fc_adisc_rsp_parse(struct fc_adisc_s
*adisc
, int len
, wwn_t port_name
,
503 if (len
< sizeof(struct fc_adisc_s
))
504 return FC_PARSE_FAILURE
;
506 if (adisc
->els_cmd
.els_code
!= FC_ELS_ACC
)
507 return FC_PARSE_FAILURE
;
509 if (!wwn_is_equal(adisc
->orig_port_name
, port_name
))
510 return FC_PARSE_FAILURE
;
516 fc_adisc_parse(struct fchs_s
*fchs
, void *pld
, u32 host_dap
, wwn_t node_name
,
519 struct fc_adisc_s
*adisc
= (struct fc_adisc_s
*) pld
;
521 if (adisc
->els_cmd
.els_code
!= FC_ELS_ACC
)
522 return FC_PARSE_FAILURE
;
524 if ((adisc
->nport_id
== (host_dap
))
525 && wwn_is_equal(adisc
->orig_port_name
, port_name
)
526 && wwn_is_equal(adisc
->orig_node_name
, node_name
))
529 return FC_PARSE_FAILURE
;
533 fc_pdisc_parse(struct fchs_s
*fchs
, wwn_t node_name
, wwn_t port_name
)
535 struct fc_logi_s
*pdisc
= (struct fc_logi_s
*) (fchs
+ 1);
537 if (pdisc
->class3
.class_valid
!= 1)
538 return FC_PARSE_FAILURE
;
540 if ((be16_to_cpu(pdisc
->class3
.rxsz
) <
541 (FC_MIN_PDUSZ
- sizeof(struct fchs_s
)))
542 || (pdisc
->class3
.rxsz
== 0))
543 return FC_PARSE_FAILURE
;
545 if (!wwn_is_equal(pdisc
->port_name
, port_name
))
546 return FC_PARSE_FAILURE
;
548 if (!wwn_is_equal(pdisc
->node_name
, node_name
))
549 return FC_PARSE_FAILURE
;
555 fc_abts_build(struct fchs_s
*fchs
, u32 d_id
, u32 s_id
, u16 ox_id
)
557 memcpy(fchs
, &fc_bls_req_tmpl
, sizeof(struct fchs_s
));
558 fchs
->cat_info
= FC_CAT_ABTS
;
561 fchs
->ox_id
= cpu_to_be16(ox_id
);
563 return sizeof(struct fchs_s
);
567 fc_abts_rsp_parse(struct fchs_s
*fchs
, int len
)
569 if ((fchs
->cat_info
== FC_CAT_BA_ACC
)
570 || (fchs
->cat_info
== FC_CAT_BA_RJT
))
573 return FC_PARSE_FAILURE
;
577 fc_rrq_build(struct fchs_s
*fchs
, struct fc_rrq_s
*rrq
, u32 d_id
, u32 s_id
,
578 u16 ox_id
, u16 rrq_oxid
)
580 fc_els_req_build(fchs
, d_id
, s_id
, ox_id
);
585 memcpy(rrq
, &rrq_tmpl
, sizeof(struct fc_rrq_s
));
587 rrq
->ox_id
= cpu_to_be16(rrq_oxid
);
588 rrq
->rx_id
= FC_RXID_ANY
;
590 return sizeof(struct fc_rrq_s
);
594 fc_logo_acc_build(struct fchs_s
*fchs
, void *pld
, u32 d_id
, u32 s_id
,
597 struct fc_els_cmd_s
*acc
= pld
;
599 fc_els_rsp_build(fchs
, d_id
, s_id
, ox_id
);
601 memset(acc
, 0, sizeof(struct fc_els_cmd_s
));
602 acc
->els_code
= FC_ELS_ACC
;
604 return sizeof(struct fc_els_cmd_s
);
608 fc_ls_rjt_build(struct fchs_s
*fchs
, struct fc_ls_rjt_s
*ls_rjt
, u32 d_id
,
609 u32 s_id
, __be16 ox_id
, u8 reason_code
,
612 fc_els_rsp_build(fchs
, d_id
, s_id
, ox_id
);
613 memset(ls_rjt
, 0, sizeof(struct fc_ls_rjt_s
));
615 ls_rjt
->els_cmd
.els_code
= FC_ELS_LS_RJT
;
616 ls_rjt
->reason_code
= reason_code
;
617 ls_rjt
->reason_code_expl
= reason_code_expl
;
618 ls_rjt
->vendor_unique
= 0x00;
620 return sizeof(struct fc_ls_rjt_s
);
624 fc_ba_acc_build(struct fchs_s
*fchs
, struct fc_ba_acc_s
*ba_acc
, u32 d_id
,
625 u32 s_id
, __be16 ox_id
, u16 rx_id
)
627 fc_bls_rsp_build(fchs
, d_id
, s_id
, ox_id
);
629 memcpy(ba_acc
, &ba_acc_tmpl
, sizeof(struct fc_ba_acc_s
));
633 ba_acc
->ox_id
= fchs
->ox_id
;
634 ba_acc
->rx_id
= fchs
->rx_id
;
636 return sizeof(struct fc_ba_acc_s
);
640 fc_ls_acc_build(struct fchs_s
*fchs
, struct fc_els_cmd_s
*els_cmd
, u32 d_id
,
641 u32 s_id
, __be16 ox_id
)
643 fc_els_rsp_build(fchs
, d_id
, s_id
, ox_id
);
644 memset(els_cmd
, 0, sizeof(struct fc_els_cmd_s
));
645 els_cmd
->els_code
= FC_ELS_ACC
;
647 return sizeof(struct fc_els_cmd_s
);
651 fc_logout_params_pages(struct fchs_s
*fc_frame
, u8 els_code
)
654 struct fc_prlo_s
*prlo
;
655 struct fc_tprlo_s
*tprlo
;
657 if (els_code
== FC_ELS_PRLO
) {
658 prlo
= (struct fc_prlo_s
*) (fc_frame
+ 1);
659 num_pages
= (be16_to_cpu(prlo
->payload_len
) - 4) / 16;
661 tprlo
= (struct fc_tprlo_s
*) (fc_frame
+ 1);
662 num_pages
= (be16_to_cpu(tprlo
->payload_len
) - 4) / 16;
668 fc_tprlo_acc_build(struct fchs_s
*fchs
, struct fc_tprlo_acc_s
*tprlo_acc
,
669 u32 d_id
, u32 s_id
, __be16 ox_id
, int num_pages
)
673 fc_els_rsp_build(fchs
, d_id
, s_id
, ox_id
);
675 memset(tprlo_acc
, 0, (num_pages
* 16) + 4);
676 tprlo_acc
->command
= FC_ELS_ACC
;
678 tprlo_acc
->page_len
= 0x10;
679 tprlo_acc
->payload_len
= cpu_to_be16((num_pages
* 16) + 4);
681 for (page
= 0; page
< num_pages
; page
++) {
682 tprlo_acc
->tprlo_acc_params
[page
].opa_valid
= 0;
683 tprlo_acc
->tprlo_acc_params
[page
].rpa_valid
= 0;
684 tprlo_acc
->tprlo_acc_params
[page
].fc4type_csp
= FC_TYPE_FCP
;
685 tprlo_acc
->tprlo_acc_params
[page
].orig_process_assc
= 0;
686 tprlo_acc
->tprlo_acc_params
[page
].resp_process_assc
= 0;
688 return be16_to_cpu(tprlo_acc
->payload_len
);
692 fc_prlo_acc_build(struct fchs_s
*fchs
, struct fc_prlo_acc_s
*prlo_acc
, u32 d_id
,
693 u32 s_id
, __be16 ox_id
, int num_pages
)
697 fc_els_rsp_build(fchs
, d_id
, s_id
, ox_id
);
699 memset(prlo_acc
, 0, (num_pages
* 16) + 4);
700 prlo_acc
->command
= FC_ELS_ACC
;
701 prlo_acc
->page_len
= 0x10;
702 prlo_acc
->payload_len
= cpu_to_be16((num_pages
* 16) + 4);
704 for (page
= 0; page
< num_pages
; page
++) {
705 prlo_acc
->prlo_acc_params
[page
].opa_valid
= 0;
706 prlo_acc
->prlo_acc_params
[page
].rpa_valid
= 0;
707 prlo_acc
->prlo_acc_params
[page
].fc4type_csp
= FC_TYPE_FCP
;
708 prlo_acc
->prlo_acc_params
[page
].orig_process_assc
= 0;
709 prlo_acc
->prlo_acc_params
[page
].resp_process_assc
= 0;
712 return be16_to_cpu(prlo_acc
->payload_len
);
716 fc_rnid_build(struct fchs_s
*fchs
, struct fc_rnid_cmd_s
*rnid
, u32 d_id
,
717 u32 s_id
, u16 ox_id
, u32 data_format
)
719 fc_els_req_build(fchs
, d_id
, s_id
, ox_id
);
721 memset(rnid
, 0, sizeof(struct fc_rnid_cmd_s
));
723 rnid
->els_cmd
.els_code
= FC_ELS_RNID
;
724 rnid
->node_id_data_format
= data_format
;
726 return sizeof(struct fc_rnid_cmd_s
);
730 fc_rnid_acc_build(struct fchs_s
*fchs
, struct fc_rnid_acc_s
*rnid_acc
, u32 d_id
,
731 u32 s_id
, __be16 ox_id
, u32 data_format
,
732 struct fc_rnid_common_id_data_s
*common_id_data
,
733 struct fc_rnid_general_topology_data_s
*gen_topo_data
)
735 memset(rnid_acc
, 0, sizeof(struct fc_rnid_acc_s
));
737 fc_els_rsp_build(fchs
, d_id
, s_id
, ox_id
);
739 rnid_acc
->els_cmd
.els_code
= FC_ELS_ACC
;
740 rnid_acc
->node_id_data_format
= data_format
;
741 rnid_acc
->common_id_data_length
=
742 sizeof(struct fc_rnid_common_id_data_s
);
743 rnid_acc
->common_id_data
= *common_id_data
;
745 if (data_format
== RNID_NODEID_DATA_FORMAT_DISCOVERY
) {
746 rnid_acc
->specific_id_data_length
=
747 sizeof(struct fc_rnid_general_topology_data_s
);
748 rnid_acc
->gen_topology_data
= *gen_topo_data
;
749 return sizeof(struct fc_rnid_acc_s
);
751 return sizeof(struct fc_rnid_acc_s
) -
752 sizeof(struct fc_rnid_general_topology_data_s
);
758 fc_rpsc_build(struct fchs_s
*fchs
, struct fc_rpsc_cmd_s
*rpsc
, u32 d_id
,
761 fc_els_req_build(fchs
, d_id
, s_id
, ox_id
);
763 memset(rpsc
, 0, sizeof(struct fc_rpsc_cmd_s
));
765 rpsc
->els_cmd
.els_code
= FC_ELS_RPSC
;
766 return sizeof(struct fc_rpsc_cmd_s
);
770 fc_rpsc2_build(struct fchs_s
*fchs
, struct fc_rpsc2_cmd_s
*rpsc2
, u32 d_id
,
771 u32 s_id
, u32
*pid_list
, u16 npids
)
773 u32 dctlr_id
= FC_DOMAIN_CTRLR(bfa_hton3b(d_id
));
776 fc_els_req_build(fchs
, bfa_hton3b(dctlr_id
), s_id
, 0);
778 memset(rpsc2
, 0, sizeof(struct fc_rpsc2_cmd_s
));
780 rpsc2
->els_cmd
.els_code
= FC_ELS_RPSC
;
781 rpsc2
->token
= cpu_to_be32(FC_BRCD_TOKEN
);
782 rpsc2
->num_pids
= cpu_to_be16(npids
);
783 for (i
= 0; i
< npids
; i
++)
784 rpsc2
->pid_list
[i
].pid
= pid_list
[i
];
786 return sizeof(struct fc_rpsc2_cmd_s
) + ((npids
- 1) * (sizeof(u32
)));
790 fc_rpsc_acc_build(struct fchs_s
*fchs
, struct fc_rpsc_acc_s
*rpsc_acc
,
791 u32 d_id
, u32 s_id
, __be16 ox_id
,
792 struct fc_rpsc_speed_info_s
*oper_speed
)
794 memset(rpsc_acc
, 0, sizeof(struct fc_rpsc_acc_s
));
796 fc_els_rsp_build(fchs
, d_id
, s_id
, ox_id
);
798 rpsc_acc
->command
= FC_ELS_ACC
;
799 rpsc_acc
->num_entries
= cpu_to_be16(1);
801 rpsc_acc
->speed_info
[0].port_speed_cap
=
802 cpu_to_be16(oper_speed
->port_speed_cap
);
804 rpsc_acc
->speed_info
[0].port_op_speed
=
805 cpu_to_be16(oper_speed
->port_op_speed
);
807 return sizeof(struct fc_rpsc_acc_s
);
811 fc_logo_rsp_parse(struct fchs_s
*fchs
, int len
)
813 struct fc_els_cmd_s
*els_cmd
= (struct fc_els_cmd_s
*) (fchs
+ 1);
816 if (els_cmd
->els_code
!= FC_ELS_ACC
)
817 return FC_PARSE_FAILURE
;
823 fc_pdisc_build(struct fchs_s
*fchs
, u32 d_id
, u32 s_id
, u16 ox_id
,
824 wwn_t port_name
, wwn_t node_name
, u16 pdu_size
)
826 struct fc_logi_s
*pdisc
= (struct fc_logi_s
*) (fchs
+ 1);
828 memcpy(pdisc
, &plogi_tmpl
, sizeof(struct fc_logi_s
));
830 pdisc
->els_cmd
.els_code
= FC_ELS_PDISC
;
831 fc_els_req_build(fchs
, d_id
, s_id
, ox_id
);
833 pdisc
->csp
.rxsz
= pdisc
->class3
.rxsz
= cpu_to_be16(pdu_size
);
834 pdisc
->port_name
= port_name
;
835 pdisc
->node_name
= node_name
;
837 return sizeof(struct fc_logi_s
);
841 fc_pdisc_rsp_parse(struct fchs_s
*fchs
, int len
, wwn_t port_name
)
843 struct fc_logi_s
*pdisc
= (struct fc_logi_s
*) (fchs
+ 1);
845 if (len
< sizeof(struct fc_logi_s
))
846 return FC_PARSE_LEN_INVAL
;
848 if (pdisc
->els_cmd
.els_code
!= FC_ELS_ACC
)
849 return FC_PARSE_ACC_INVAL
;
851 if (!wwn_is_equal(pdisc
->port_name
, port_name
))
852 return FC_PARSE_PWWN_NOT_EQUAL
;
854 if (!pdisc
->class3
.class_valid
)
855 return FC_PARSE_NWWN_NOT_EQUAL
;
857 if (be16_to_cpu(pdisc
->class3
.rxsz
) < (FC_MIN_PDUSZ
))
858 return FC_PARSE_RXSZ_INVAL
;
864 fc_prlo_build(struct fchs_s
*fchs
, u32 d_id
, u32 s_id
, u16 ox_id
,
867 struct fc_prlo_s
*prlo
= (struct fc_prlo_s
*) (fchs
+ 1);
870 fc_els_req_build(fchs
, d_id
, s_id
, ox_id
);
871 memset(prlo
, 0, (num_pages
* 16) + 4);
872 prlo
->command
= FC_ELS_PRLO
;
873 prlo
->page_len
= 0x10;
874 prlo
->payload_len
= cpu_to_be16((num_pages
* 16) + 4);
876 for (page
= 0; page
< num_pages
; page
++) {
877 prlo
->prlo_params
[page
].type
= FC_TYPE_FCP
;
878 prlo
->prlo_params
[page
].opa_valid
= 0;
879 prlo
->prlo_params
[page
].rpa_valid
= 0;
880 prlo
->prlo_params
[page
].orig_process_assc
= 0;
881 prlo
->prlo_params
[page
].resp_process_assc
= 0;
884 return be16_to_cpu(prlo
->payload_len
);
888 fc_prlo_rsp_parse(struct fchs_s
*fchs
, int len
)
890 struct fc_prlo_acc_s
*prlo
= (struct fc_prlo_acc_s
*) (fchs
+ 1);
896 if (prlo
->command
!= FC_ELS_ACC
)
897 return FC_PARSE_FAILURE
;
899 num_pages
= ((be16_to_cpu(prlo
->payload_len
)) - 4) / 16;
901 for (page
= 0; page
< num_pages
; page
++) {
902 if (prlo
->prlo_acc_params
[page
].type
!= FC_TYPE_FCP
)
903 return FC_PARSE_FAILURE
;
905 if (prlo
->prlo_acc_params
[page
].opa_valid
!= 0)
906 return FC_PARSE_FAILURE
;
908 if (prlo
->prlo_acc_params
[page
].rpa_valid
!= 0)
909 return FC_PARSE_FAILURE
;
911 if (prlo
->prlo_acc_params
[page
].orig_process_assc
!= 0)
912 return FC_PARSE_FAILURE
;
914 if (prlo
->prlo_acc_params
[page
].resp_process_assc
!= 0)
915 return FC_PARSE_FAILURE
;
922 fc_tprlo_build(struct fchs_s
*fchs
, u32 d_id
, u32 s_id
, u16 ox_id
,
923 int num_pages
, enum fc_tprlo_type tprlo_type
, u32 tpr_id
)
925 struct fc_tprlo_s
*tprlo
= (struct fc_tprlo_s
*) (fchs
+ 1);
928 fc_els_req_build(fchs
, d_id
, s_id
, ox_id
);
929 memset(tprlo
, 0, (num_pages
* 16) + 4);
930 tprlo
->command
= FC_ELS_TPRLO
;
931 tprlo
->page_len
= 0x10;
932 tprlo
->payload_len
= cpu_to_be16((num_pages
* 16) + 4);
934 for (page
= 0; page
< num_pages
; page
++) {
935 tprlo
->tprlo_params
[page
].type
= FC_TYPE_FCP
;
936 tprlo
->tprlo_params
[page
].opa_valid
= 0;
937 tprlo
->tprlo_params
[page
].rpa_valid
= 0;
938 tprlo
->tprlo_params
[page
].orig_process_assc
= 0;
939 tprlo
->tprlo_params
[page
].resp_process_assc
= 0;
940 if (tprlo_type
== FC_GLOBAL_LOGO
) {
941 tprlo
->tprlo_params
[page
].global_process_logout
= 1;
942 } else if (tprlo_type
== FC_TPR_LOGO
) {
943 tprlo
->tprlo_params
[page
].tpo_nport_valid
= 1;
944 tprlo
->tprlo_params
[page
].tpo_nport_id
= (tpr_id
);
948 return be16_to_cpu(tprlo
->payload_len
);
952 fc_tprlo_rsp_parse(struct fchs_s
*fchs
, int len
)
954 struct fc_tprlo_acc_s
*tprlo
= (struct fc_tprlo_acc_s
*) (fchs
+ 1);
960 if (tprlo
->command
!= FC_ELS_ACC
)
961 return FC_PARSE_ACC_INVAL
;
963 num_pages
= (be16_to_cpu(tprlo
->payload_len
) - 4) / 16;
965 for (page
= 0; page
< num_pages
; page
++) {
966 if (tprlo
->tprlo_acc_params
[page
].type
!= FC_TYPE_FCP
)
967 return FC_PARSE_NOT_FCP
;
968 if (tprlo
->tprlo_acc_params
[page
].opa_valid
!= 0)
969 return FC_PARSE_OPAFLAG_INVAL
;
970 if (tprlo
->tprlo_acc_params
[page
].rpa_valid
!= 0)
971 return FC_PARSE_RPAFLAG_INVAL
;
972 if (tprlo
->tprlo_acc_params
[page
].orig_process_assc
!= 0)
973 return FC_PARSE_OPA_INVAL
;
974 if (tprlo
->tprlo_acc_params
[page
].resp_process_assc
!= 0)
975 return FC_PARSE_RPA_INVAL
;
981 fc_rrq_rsp_parse(struct fchs_s
*fchs
, int len
)
983 struct fc_els_cmd_s
*els_cmd
= (struct fc_els_cmd_s
*) (fchs
+ 1);
986 if (els_cmd
->els_code
!= FC_ELS_ACC
)
987 return FC_PARSE_FAILURE
;
993 fc_ba_rjt_build(struct fchs_s
*fchs
, u32 d_id
, u32 s_id
, __be16 ox_id
,
994 u32 reason_code
, u32 reason_expl
)
996 struct fc_ba_rjt_s
*ba_rjt
= (struct fc_ba_rjt_s
*) (fchs
+ 1);
998 fc_bls_rsp_build(fchs
, d_id
, s_id
, ox_id
);
1000 fchs
->cat_info
= FC_CAT_BA_RJT
;
1001 ba_rjt
->reason_code
= reason_code
;
1002 ba_rjt
->reason_expl
= reason_expl
;
1003 return sizeof(struct fc_ba_rjt_s
);
1007 fc_gs_cthdr_build(struct ct_hdr_s
*cthdr
, u32 s_id
, u16 cmd_code
)
1009 memset(cthdr
, 0, sizeof(struct ct_hdr_s
));
1010 cthdr
->rev_id
= CT_GS3_REVISION
;
1011 cthdr
->gs_type
= CT_GSTYPE_DIRSERVICE
;
1012 cthdr
->gs_sub_type
= CT_GSSUBTYPE_NAMESERVER
;
1013 cthdr
->cmd_rsp_code
= cpu_to_be16(cmd_code
);
1017 fc_gs_fdmi_cthdr_build(struct ct_hdr_s
*cthdr
, u32 s_id
, u16 cmd_code
)
1019 memset(cthdr
, 0, sizeof(struct ct_hdr_s
));
1020 cthdr
->rev_id
= CT_GS3_REVISION
;
1021 cthdr
->gs_type
= CT_GSTYPE_MGMTSERVICE
;
1022 cthdr
->gs_sub_type
= CT_GSSUBTYPE_HBA_MGMTSERVER
;
1023 cthdr
->cmd_rsp_code
= cpu_to_be16(cmd_code
);
1027 fc_gs_ms_cthdr_build(struct ct_hdr_s
*cthdr
, u32 s_id
, u16 cmd_code
,
1030 memset(cthdr
, 0, sizeof(struct ct_hdr_s
));
1031 cthdr
->rev_id
= CT_GS3_REVISION
;
1032 cthdr
->gs_type
= CT_GSTYPE_MGMTSERVICE
;
1033 cthdr
->gs_sub_type
= sub_type
;
1034 cthdr
->cmd_rsp_code
= cpu_to_be16(cmd_code
);
1038 fc_gidpn_build(struct fchs_s
*fchs
, void *pyld
, u32 s_id
, u16 ox_id
,
1041 struct ct_hdr_s
*cthdr
= (struct ct_hdr_s
*) pyld
;
1042 struct fcgs_gidpn_req_s
*gidpn
= (struct fcgs_gidpn_req_s
*)(cthdr
+ 1);
1043 u32 d_id
= bfa_hton3b(FC_NAME_SERVER
);
1045 fc_gs_fchdr_build(fchs
, d_id
, s_id
, ox_id
);
1046 fc_gs_cthdr_build(cthdr
, s_id
, GS_GID_PN
);
1048 memset(gidpn
, 0, sizeof(struct fcgs_gidpn_req_s
));
1049 gidpn
->port_name
= port_name
;
1050 return sizeof(struct fcgs_gidpn_req_s
) + sizeof(struct ct_hdr_s
);
1054 fc_gpnid_build(struct fchs_s
*fchs
, void *pyld
, u32 s_id
, u16 ox_id
,
1057 struct ct_hdr_s
*cthdr
= (struct ct_hdr_s
*) pyld
;
1058 fcgs_gpnid_req_t
*gpnid
= (fcgs_gpnid_req_t
*) (cthdr
+ 1);
1059 u32 d_id
= bfa_hton3b(FC_NAME_SERVER
);
1061 fc_gs_fchdr_build(fchs
, d_id
, s_id
, ox_id
);
1062 fc_gs_cthdr_build(cthdr
, s_id
, GS_GPN_ID
);
1064 memset(gpnid
, 0, sizeof(fcgs_gpnid_req_t
));
1065 gpnid
->dap
= port_id
;
1066 return sizeof(fcgs_gpnid_req_t
) + sizeof(struct ct_hdr_s
);
1070 fc_gnnid_build(struct fchs_s
*fchs
, void *pyld
, u32 s_id
, u16 ox_id
,
1073 struct ct_hdr_s
*cthdr
= (struct ct_hdr_s
*) pyld
;
1074 fcgs_gnnid_req_t
*gnnid
= (fcgs_gnnid_req_t
*) (cthdr
+ 1);
1075 u32 d_id
= bfa_hton3b(FC_NAME_SERVER
);
1077 fc_gs_fchdr_build(fchs
, d_id
, s_id
, ox_id
);
1078 fc_gs_cthdr_build(cthdr
, s_id
, GS_GNN_ID
);
1080 memset(gnnid
, 0, sizeof(fcgs_gnnid_req_t
));
1081 gnnid
->dap
= port_id
;
1082 return sizeof(fcgs_gnnid_req_t
) + sizeof(struct ct_hdr_s
);
1086 fc_ct_rsp_parse(struct ct_hdr_s
*cthdr
)
1088 if (be16_to_cpu(cthdr
->cmd_rsp_code
) != CT_RSP_ACCEPT
) {
1089 if (cthdr
->reason_code
== CT_RSN_LOGICAL_BUSY
)
1090 return FC_PARSE_BUSY
;
1092 return FC_PARSE_FAILURE
;
1099 fc_scr_build(struct fchs_s
*fchs
, struct fc_scr_s
*scr
,
1100 u8 set_br_reg
, u32 s_id
, u16 ox_id
)
1102 u32 d_id
= bfa_hton3b(FC_FABRIC_CONTROLLER
);
1104 fc_els_req_build(fchs
, d_id
, s_id
, ox_id
);
1106 memset(scr
, 0, sizeof(struct fc_scr_s
));
1107 scr
->command
= FC_ELS_SCR
;
1108 scr
->reg_func
= FC_SCR_REG_FUNC_FULL
;
1110 scr
->vu_reg_func
= FC_VU_SCR_REG_FUNC_FABRIC_NAME_CHANGE
;
1112 return sizeof(struct fc_scr_s
);
1116 fc_rscn_build(struct fchs_s
*fchs
, struct fc_rscn_pl_s
*rscn
,
1117 u32 s_id
, u16 ox_id
)
1119 u32 d_id
= bfa_hton3b(FC_FABRIC_CONTROLLER
);
1122 fc_els_req_build(fchs
, d_id
, s_id
, ox_id
);
1123 rscn
->command
= FC_ELS_RSCN
;
1124 rscn
->pagelen
= sizeof(rscn
->event
[0]);
1126 payldlen
= sizeof(u32
) + rscn
->pagelen
;
1127 rscn
->payldlen
= cpu_to_be16(payldlen
);
1129 rscn
->event
[0].format
= FC_RSCN_FORMAT_PORTID
;
1130 rscn
->event
[0].portid
= s_id
;
1132 return sizeof(struct fc_rscn_pl_s
);
1136 fc_rftid_build(struct fchs_s
*fchs
, void *pyld
, u32 s_id
, u16 ox_id
,
1137 enum bfa_lport_role roles
)
1139 struct ct_hdr_s
*cthdr
= (struct ct_hdr_s
*) pyld
;
1140 struct fcgs_rftid_req_s
*rftid
= (struct fcgs_rftid_req_s
*)(cthdr
+ 1);
1141 u32 type_value
, d_id
= bfa_hton3b(FC_NAME_SERVER
);
1144 fc_gs_fchdr_build(fchs
, d_id
, s_id
, ox_id
);
1145 fc_gs_cthdr_build(cthdr
, s_id
, GS_RFT_ID
);
1147 memset(rftid
, 0, sizeof(struct fcgs_rftid_req_s
));
1151 /* By default, FCP FC4 Type is registered */
1152 index
= FC_TYPE_FCP
>> 5;
1153 type_value
= 1 << (FC_TYPE_FCP
% 32);
1154 rftid
->fc4_type
[index
] = cpu_to_be32(type_value
);
1156 return sizeof(struct fcgs_rftid_req_s
) + sizeof(struct ct_hdr_s
);
1160 fc_rftid_build_sol(struct fchs_s
*fchs
, void *pyld
, u32 s_id
, u16 ox_id
,
1161 u8
*fc4_bitmap
, u32 bitmap_size
)
1163 struct ct_hdr_s
*cthdr
= (struct ct_hdr_s
*) pyld
;
1164 struct fcgs_rftid_req_s
*rftid
= (struct fcgs_rftid_req_s
*)(cthdr
+ 1);
1165 u32 d_id
= bfa_hton3b(FC_NAME_SERVER
);
1167 fc_gs_fchdr_build(fchs
, d_id
, s_id
, ox_id
);
1168 fc_gs_cthdr_build(cthdr
, s_id
, GS_RFT_ID
);
1170 memset(rftid
, 0, sizeof(struct fcgs_rftid_req_s
));
1173 memcpy((void *)rftid
->fc4_type
, (void *)fc4_bitmap
,
1174 (bitmap_size
< 32 ? bitmap_size
: 32));
1176 return sizeof(struct fcgs_rftid_req_s
) + sizeof(struct ct_hdr_s
);
1180 fc_rffid_build(struct fchs_s
*fchs
, void *pyld
, u32 s_id
, u16 ox_id
,
1181 u8 fc4_type
, u8 fc4_ftrs
)
1183 struct ct_hdr_s
*cthdr
= (struct ct_hdr_s
*) pyld
;
1184 struct fcgs_rffid_req_s
*rffid
= (struct fcgs_rffid_req_s
*)(cthdr
+ 1);
1185 u32 d_id
= bfa_hton3b(FC_NAME_SERVER
);
1187 fc_gs_fchdr_build(fchs
, d_id
, s_id
, ox_id
);
1188 fc_gs_cthdr_build(cthdr
, s_id
, GS_RFF_ID
);
1190 memset(rffid
, 0, sizeof(struct fcgs_rffid_req_s
));
1193 rffid
->fc4ftr_bits
= fc4_ftrs
;
1194 rffid
->fc4_type
= fc4_type
;
1196 return sizeof(struct fcgs_rffid_req_s
) + sizeof(struct ct_hdr_s
);
1200 fc_rspnid_build(struct fchs_s
*fchs
, void *pyld
, u32 s_id
, u16 ox_id
,
1204 struct ct_hdr_s
*cthdr
= (struct ct_hdr_s
*) pyld
;
1205 struct fcgs_rspnid_req_s
*rspnid
=
1206 (struct fcgs_rspnid_req_s
*)(cthdr
+ 1);
1207 u32 d_id
= bfa_hton3b(FC_NAME_SERVER
);
1209 fc_gs_fchdr_build(fchs
, d_id
, s_id
, ox_id
);
1210 fc_gs_cthdr_build(cthdr
, s_id
, GS_RSPN_ID
);
1212 memset(rspnid
, 0, sizeof(struct fcgs_rspnid_req_s
));
1215 rspnid
->spn_len
= (u8
) strlen((char *)name
);
1216 strncpy((char *)rspnid
->spn
, (char *)name
, rspnid
->spn_len
);
1218 return sizeof(struct fcgs_rspnid_req_s
) + sizeof(struct ct_hdr_s
);
1222 fc_gid_ft_build(struct fchs_s
*fchs
, void *pyld
, u32 s_id
, u8 fc4_type
)
1225 struct ct_hdr_s
*cthdr
= (struct ct_hdr_s
*) pyld
;
1226 struct fcgs_gidft_req_s
*gidft
= (struct fcgs_gidft_req_s
*)(cthdr
+ 1);
1227 u32 d_id
= bfa_hton3b(FC_NAME_SERVER
);
1229 fc_gs_fchdr_build(fchs
, d_id
, s_id
, 0);
1231 fc_gs_cthdr_build(cthdr
, s_id
, GS_GID_FT
);
1233 memset(gidft
, 0, sizeof(struct fcgs_gidft_req_s
));
1234 gidft
->fc4_type
= fc4_type
;
1235 gidft
->domain_id
= 0;
1238 return sizeof(struct fcgs_gidft_req_s
) + sizeof(struct ct_hdr_s
);
1242 fc_rpnid_build(struct fchs_s
*fchs
, void *pyld
, u32 s_id
, u32 port_id
,
1245 struct ct_hdr_s
*cthdr
= (struct ct_hdr_s
*) pyld
;
1246 struct fcgs_rpnid_req_s
*rpnid
= (struct fcgs_rpnid_req_s
*)(cthdr
+ 1);
1247 u32 d_id
= bfa_hton3b(FC_NAME_SERVER
);
1249 fc_gs_fchdr_build(fchs
, d_id
, s_id
, 0);
1250 fc_gs_cthdr_build(cthdr
, s_id
, GS_RPN_ID
);
1252 memset(rpnid
, 0, sizeof(struct fcgs_rpnid_req_s
));
1253 rpnid
->port_id
= port_id
;
1254 rpnid
->port_name
= port_name
;
1256 return sizeof(struct fcgs_rpnid_req_s
) + sizeof(struct ct_hdr_s
);
1260 fc_rnnid_build(struct fchs_s
*fchs
, void *pyld
, u32 s_id
, u32 port_id
,
1263 struct ct_hdr_s
*cthdr
= (struct ct_hdr_s
*) pyld
;
1264 struct fcgs_rnnid_req_s
*rnnid
= (struct fcgs_rnnid_req_s
*)(cthdr
+ 1);
1265 u32 d_id
= bfa_hton3b(FC_NAME_SERVER
);
1267 fc_gs_fchdr_build(fchs
, d_id
, s_id
, 0);
1268 fc_gs_cthdr_build(cthdr
, s_id
, GS_RNN_ID
);
1270 memset(rnnid
, 0, sizeof(struct fcgs_rnnid_req_s
));
1271 rnnid
->port_id
= port_id
;
1272 rnnid
->node_name
= node_name
;
1274 return sizeof(struct fcgs_rnnid_req_s
) + sizeof(struct ct_hdr_s
);
1278 fc_rcsid_build(struct fchs_s
*fchs
, void *pyld
, u32 s_id
, u32 port_id
,
1281 struct ct_hdr_s
*cthdr
= (struct ct_hdr_s
*) pyld
;
1282 struct fcgs_rcsid_req_s
*rcsid
=
1283 (struct fcgs_rcsid_req_s
*) (cthdr
+ 1);
1284 u32 d_id
= bfa_hton3b(FC_NAME_SERVER
);
1286 fc_gs_fchdr_build(fchs
, d_id
, s_id
, 0);
1287 fc_gs_cthdr_build(cthdr
, s_id
, GS_RCS_ID
);
1289 memset(rcsid
, 0, sizeof(struct fcgs_rcsid_req_s
));
1290 rcsid
->port_id
= port_id
;
1293 return sizeof(struct fcgs_rcsid_req_s
) + sizeof(struct ct_hdr_s
);
1297 fc_rptid_build(struct fchs_s
*fchs
, void *pyld
, u32 s_id
, u32 port_id
,
1300 struct ct_hdr_s
*cthdr
= (struct ct_hdr_s
*) pyld
;
1301 struct fcgs_rptid_req_s
*rptid
= (struct fcgs_rptid_req_s
*)(cthdr
+ 1);
1302 u32 d_id
= bfa_hton3b(FC_NAME_SERVER
);
1304 fc_gs_fchdr_build(fchs
, d_id
, s_id
, 0);
1305 fc_gs_cthdr_build(cthdr
, s_id
, GS_RPT_ID
);
1307 memset(rptid
, 0, sizeof(struct fcgs_rptid_req_s
));
1308 rptid
->port_id
= port_id
;
1309 rptid
->port_type
= port_type
;
1311 return sizeof(struct fcgs_rptid_req_s
) + sizeof(struct ct_hdr_s
);
1315 fc_ganxt_build(struct fchs_s
*fchs
, void *pyld
, u32 s_id
, u32 port_id
)
1317 struct ct_hdr_s
*cthdr
= (struct ct_hdr_s
*) pyld
;
1318 struct fcgs_ganxt_req_s
*ganxt
= (struct fcgs_ganxt_req_s
*)(cthdr
+ 1);
1319 u32 d_id
= bfa_hton3b(FC_NAME_SERVER
);
1321 fc_gs_fchdr_build(fchs
, d_id
, s_id
, 0);
1322 fc_gs_cthdr_build(cthdr
, s_id
, GS_GA_NXT
);
1324 memset(ganxt
, 0, sizeof(struct fcgs_ganxt_req_s
));
1325 ganxt
->port_id
= port_id
;
1327 return sizeof(struct ct_hdr_s
) + sizeof(struct fcgs_ganxt_req_s
);
1331 * Builds fc hdr and ct hdr for FDMI requests.
1334 fc_fdmi_reqhdr_build(struct fchs_s
*fchs
, void *pyld
, u32 s_id
,
1338 struct ct_hdr_s
*cthdr
= (struct ct_hdr_s
*) pyld
;
1339 u32 d_id
= bfa_hton3b(FC_MGMT_SERVER
);
1341 fc_gs_fchdr_build(fchs
, d_id
, s_id
, 0);
1342 fc_gs_fdmi_cthdr_build(cthdr
, s_id
, cmd_code
);
1344 return sizeof(struct ct_hdr_s
);
1348 * Given a FC4 Type, this function returns a fc4 type bitmask
1351 fc_get_fc4type_bitmask(u8 fc4_type
, u8
*bit_mask
)
1354 __be32
*ptr
= (__be32
*) bit_mask
;
1358 * @todo : Check for bitmask size
1361 index
= fc4_type
>> 5;
1362 type_value
= 1 << (fc4_type
% 32);
1363 ptr
[index
] = cpu_to_be32(type_value
);
1371 fc_gmal_req_build(struct fchs_s
*fchs
, void *pyld
, u32 s_id
, wwn_t wwn
)
1373 struct ct_hdr_s
*cthdr
= (struct ct_hdr_s
*) pyld
;
1374 fcgs_gmal_req_t
*gmal
= (fcgs_gmal_req_t
*) (cthdr
+ 1);
1375 u32 d_id
= bfa_hton3b(FC_MGMT_SERVER
);
1377 fc_gs_fchdr_build(fchs
, d_id
, s_id
, 0);
1378 fc_gs_ms_cthdr_build(cthdr
, s_id
, GS_FC_GMAL_CMD
,
1379 CT_GSSUBTYPE_CFGSERVER
);
1381 memset(gmal
, 0, sizeof(fcgs_gmal_req_t
));
1384 return sizeof(struct ct_hdr_s
) + sizeof(fcgs_gmal_req_t
);
1388 * GFN (Get Fabric Name) Request
1391 fc_gfn_req_build(struct fchs_s
*fchs
, void *pyld
, u32 s_id
, wwn_t wwn
)
1393 struct ct_hdr_s
*cthdr
= (struct ct_hdr_s
*) pyld
;
1394 fcgs_gfn_req_t
*gfn
= (fcgs_gfn_req_t
*) (cthdr
+ 1);
1395 u32 d_id
= bfa_hton3b(FC_MGMT_SERVER
);
1397 fc_gs_fchdr_build(fchs
, d_id
, s_id
, 0);
1398 fc_gs_ms_cthdr_build(cthdr
, s_id
, GS_FC_GFN_CMD
,
1399 CT_GSSUBTYPE_CFGSERVER
);
1401 memset(gfn
, 0, sizeof(fcgs_gfn_req_t
));
1404 return sizeof(struct ct_hdr_s
) + sizeof(fcgs_gfn_req_t
);