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.
19 * bfa_fcs.c BFA FCS main
23 #include "bfa_fcbuild.h"
26 BFA_TRC_FILE(FCS
, FCS
);
31 struct bfa_fcs_mod_s
{
32 void (*attach
) (struct bfa_fcs_s
*fcs
);
33 void (*modinit
) (struct bfa_fcs_s
*fcs
);
34 void (*modexit
) (struct bfa_fcs_s
*fcs
);
37 #define BFA_FCS_MODULE(_mod) { _mod ## _modinit, _mod ## _modexit }
39 static struct bfa_fcs_mod_s fcs_modules
[] = {
40 { bfa_fcs_port_attach
, NULL
, NULL
},
41 { bfa_fcs_uf_attach
, NULL
, NULL
},
42 { bfa_fcs_fabric_attach
, bfa_fcs_fabric_modinit
,
43 bfa_fcs_fabric_modexit
},
51 bfa_fcs_exit_comp(void *fcs_cbarg
)
53 struct bfa_fcs_s
*fcs
= fcs_cbarg
;
54 struct bfad_s
*bfad
= fcs
->bfad
;
56 complete(&bfad
->comp
);
66 * fcs attach -- called once to initialize data structures at driver attach time
69 bfa_fcs_attach(struct bfa_fcs_s
*fcs
, struct bfa_s
*bfa
, struct bfad_s
*bfad
,
70 bfa_boolean_t min_cfg
)
73 struct bfa_fcs_mod_s
*mod
;
77 fcs
->min_cfg
= min_cfg
;
82 for (i
= 0; i
< sizeof(fcs_modules
) / sizeof(fcs_modules
[0]); i
++) {
83 mod
= &fcs_modules
[i
];
90 * fcs initialization, called once after bfa initialization is complete
93 bfa_fcs_init(struct bfa_fcs_s
*fcs
)
96 struct bfa_fcs_mod_s
*mod
;
97 struct bfi_pbc_vport_s pbc_vports
[BFI_PBC_MAX_VPORTS
];
99 for (i
= 0; i
< sizeof(fcs_modules
) / sizeof(fcs_modules
[0]); i
++) {
100 mod
= &fcs_modules
[i
];
104 /* Initialize pbc vports */
107 bfa_iocfc_get_pbc_vports(fcs
->bfa
, pbc_vports
);
108 for (i
= 0; i
< npbc_vports
; i
++)
109 bfa_fcb_pbc_vport_create(fcs
->bfa
->bfad
, pbc_vports
[i
]);
114 * Start FCS operations.
117 bfa_fcs_start(struct bfa_fcs_s
*fcs
)
119 bfa_fcs_fabric_modstart(fcs
);
124 * FCS driver details initialization.
126 * param[in] fcs FCS instance
127 * param[in] driver_info Driver Details
132 bfa_fcs_driver_info_init(struct bfa_fcs_s
*fcs
,
133 struct bfa_fcs_driver_info_s
*driver_info
)
136 fcs
->driver_info
= *driver_info
;
138 bfa_fcs_fabric_psymb_init(&fcs
->fabric
);
143 * FCS FDMI Driver Parameter Initialization
145 * param[in] fcs FCS instance
146 * param[in] fdmi_enable TRUE/FALSE
151 bfa_fcs_set_fdmi_param(struct bfa_fcs_s
*fcs
, bfa_boolean_t fdmi_enable
)
154 fcs
->fdmi_enabled
= fdmi_enable
;
159 * FCS instance cleanup and exit.
161 * param[in] fcs FCS instance
165 bfa_fcs_exit(struct bfa_fcs_s
*fcs
)
167 struct bfa_fcs_mod_s
*mod
;
170 bfa_wc_init(&fcs
->wc
, bfa_fcs_exit_comp
, fcs
);
172 nmods
= sizeof(fcs_modules
) / sizeof(fcs_modules
[0]);
174 for (i
= 0; i
< nmods
; i
++) {
176 mod
= &fcs_modules
[i
];
183 bfa_wc_wait(&fcs
->wc
);
188 bfa_fcs_trc_init(struct bfa_fcs_s
*fcs
, struct bfa_trc_mod_s
*trcmod
)
190 fcs
->trcmod
= trcmod
;
194 bfa_fcs_modexit_comp(struct bfa_fcs_s
*fcs
)
196 bfa_wc_down(&fcs
->wc
);
200 * Fabric module implementation.
203 #define BFA_FCS_FABRIC_RETRY_DELAY (2000) /* Milliseconds */
204 #define BFA_FCS_FABRIC_CLEANUP_DELAY (10000) /* Milliseconds */
206 #define bfa_fcs_fabric_set_opertype(__fabric) do { \
207 if (bfa_fcport_get_topology((__fabric)->fcs->bfa) \
208 == BFA_PORT_TOPOLOGY_P2P) \
209 (__fabric)->oper_type = BFA_PORT_TYPE_NPORT; \
211 (__fabric)->oper_type = BFA_PORT_TYPE_NLPORT; \
215 * forward declarations
217 static void bfa_fcs_fabric_init(struct bfa_fcs_fabric_s
*fabric
);
218 static void bfa_fcs_fabric_login(struct bfa_fcs_fabric_s
*fabric
);
219 static void bfa_fcs_fabric_notify_online(struct bfa_fcs_fabric_s
*fabric
);
220 static void bfa_fcs_fabric_notify_offline(struct bfa_fcs_fabric_s
*fabric
);
221 static void bfa_fcs_fabric_delay(void *cbarg
);
222 static void bfa_fcs_fabric_delete(struct bfa_fcs_fabric_s
*fabric
);
223 static void bfa_fcs_fabric_delete_comp(void *cbarg
);
224 static void bfa_fcs_fabric_process_uf(struct bfa_fcs_fabric_s
*fabric
,
225 struct fchs_s
*fchs
, u16 len
);
226 static void bfa_fcs_fabric_process_flogi(struct bfa_fcs_fabric_s
*fabric
,
227 struct fchs_s
*fchs
, u16 len
);
228 static void bfa_fcs_fabric_send_flogi_acc(struct bfa_fcs_fabric_s
*fabric
);
229 static void bfa_fcs_fabric_flogiacc_comp(void *fcsarg
,
230 struct bfa_fcxp_s
*fcxp
, void *cbarg
,
234 struct fchs_s
*rspfchs
);
236 * fcs_fabric_sm fabric state machine functions
240 * Fabric state machine events
242 enum bfa_fcs_fabric_event
{
243 BFA_FCS_FABRIC_SM_CREATE
= 1, /* create from driver */
244 BFA_FCS_FABRIC_SM_DELETE
= 2, /* delete from driver */
245 BFA_FCS_FABRIC_SM_LINK_DOWN
= 3, /* link down from port */
246 BFA_FCS_FABRIC_SM_LINK_UP
= 4, /* link up from port */
247 BFA_FCS_FABRIC_SM_CONT_OP
= 5, /* flogi/auth continue op */
248 BFA_FCS_FABRIC_SM_RETRY_OP
= 6, /* flogi/auth retry op */
249 BFA_FCS_FABRIC_SM_NO_FABRIC
= 7, /* from flogi/auth */
250 BFA_FCS_FABRIC_SM_PERF_EVFP
= 8, /* from flogi/auth */
251 BFA_FCS_FABRIC_SM_ISOLATE
= 9, /* from EVFP processing */
252 BFA_FCS_FABRIC_SM_NO_TAGGING
= 10, /* no VFT tagging from EVFP */
253 BFA_FCS_FABRIC_SM_DELAYED
= 11, /* timeout delay event */
254 BFA_FCS_FABRIC_SM_AUTH_FAILED
= 12, /* auth failed */
255 BFA_FCS_FABRIC_SM_AUTH_SUCCESS
= 13, /* auth successful */
256 BFA_FCS_FABRIC_SM_DELCOMP
= 14, /* all vports deleted event */
257 BFA_FCS_FABRIC_SM_LOOPBACK
= 15, /* Received our own FLOGI */
258 BFA_FCS_FABRIC_SM_START
= 16, /* from driver */
261 static void bfa_fcs_fabric_sm_uninit(struct bfa_fcs_fabric_s
*fabric
,
262 enum bfa_fcs_fabric_event event
);
263 static void bfa_fcs_fabric_sm_created(struct bfa_fcs_fabric_s
*fabric
,
264 enum bfa_fcs_fabric_event event
);
265 static void bfa_fcs_fabric_sm_linkdown(struct bfa_fcs_fabric_s
*fabric
,
266 enum bfa_fcs_fabric_event event
);
267 static void bfa_fcs_fabric_sm_flogi(struct bfa_fcs_fabric_s
*fabric
,
268 enum bfa_fcs_fabric_event event
);
269 static void bfa_fcs_fabric_sm_flogi_retry(struct bfa_fcs_fabric_s
*fabric
,
270 enum bfa_fcs_fabric_event event
);
271 static void bfa_fcs_fabric_sm_auth(struct bfa_fcs_fabric_s
*fabric
,
272 enum bfa_fcs_fabric_event event
);
273 static void bfa_fcs_fabric_sm_auth_failed(struct bfa_fcs_fabric_s
*fabric
,
274 enum bfa_fcs_fabric_event event
);
275 static void bfa_fcs_fabric_sm_loopback(struct bfa_fcs_fabric_s
*fabric
,
276 enum bfa_fcs_fabric_event event
);
277 static void bfa_fcs_fabric_sm_nofabric(struct bfa_fcs_fabric_s
*fabric
,
278 enum bfa_fcs_fabric_event event
);
279 static void bfa_fcs_fabric_sm_online(struct bfa_fcs_fabric_s
*fabric
,
280 enum bfa_fcs_fabric_event event
);
281 static void bfa_fcs_fabric_sm_evfp(struct bfa_fcs_fabric_s
*fabric
,
282 enum bfa_fcs_fabric_event event
);
283 static void bfa_fcs_fabric_sm_evfp_done(struct bfa_fcs_fabric_s
*fabric
,
284 enum bfa_fcs_fabric_event event
);
285 static void bfa_fcs_fabric_sm_isolated(struct bfa_fcs_fabric_s
*fabric
,
286 enum bfa_fcs_fabric_event event
);
287 static void bfa_fcs_fabric_sm_deleting(struct bfa_fcs_fabric_s
*fabric
,
288 enum bfa_fcs_fabric_event event
);
290 * Beginning state before fabric creation.
293 bfa_fcs_fabric_sm_uninit(struct bfa_fcs_fabric_s
*fabric
,
294 enum bfa_fcs_fabric_event event
)
296 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
297 bfa_trc(fabric
->fcs
, event
);
300 case BFA_FCS_FABRIC_SM_CREATE
:
301 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_created
);
302 bfa_fcs_fabric_init(fabric
);
303 bfa_fcs_lport_init(&fabric
->bport
, &fabric
->bport
.port_cfg
);
306 case BFA_FCS_FABRIC_SM_LINK_UP
:
307 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
311 bfa_sm_fault(fabric
->fcs
, event
);
316 * Beginning state before fabric creation.
319 bfa_fcs_fabric_sm_created(struct bfa_fcs_fabric_s
*fabric
,
320 enum bfa_fcs_fabric_event event
)
322 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
323 bfa_trc(fabric
->fcs
, event
);
326 case BFA_FCS_FABRIC_SM_START
:
327 if (bfa_fcport_is_linkup(fabric
->fcs
->bfa
)) {
328 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_flogi
);
329 bfa_fcs_fabric_login(fabric
);
331 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_linkdown
);
334 case BFA_FCS_FABRIC_SM_LINK_UP
:
335 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
338 case BFA_FCS_FABRIC_SM_DELETE
:
339 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_uninit
);
340 bfa_fcs_modexit_comp(fabric
->fcs
);
344 bfa_sm_fault(fabric
->fcs
, event
);
349 * Link is down, awaiting LINK UP event from port. This is also the
350 * first state at fabric creation.
353 bfa_fcs_fabric_sm_linkdown(struct bfa_fcs_fabric_s
*fabric
,
354 enum bfa_fcs_fabric_event event
)
356 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
357 bfa_trc(fabric
->fcs
, event
);
360 case BFA_FCS_FABRIC_SM_LINK_UP
:
361 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_flogi
);
362 bfa_fcs_fabric_login(fabric
);
365 case BFA_FCS_FABRIC_SM_RETRY_OP
:
368 case BFA_FCS_FABRIC_SM_DELETE
:
369 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_deleting
);
370 bfa_fcs_fabric_delete(fabric
);
374 bfa_sm_fault(fabric
->fcs
, event
);
379 * FLOGI is in progress, awaiting FLOGI reply.
382 bfa_fcs_fabric_sm_flogi(struct bfa_fcs_fabric_s
*fabric
,
383 enum bfa_fcs_fabric_event event
)
385 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
386 bfa_trc(fabric
->fcs
, event
);
389 case BFA_FCS_FABRIC_SM_CONT_OP
:
391 bfa_fcport_set_tx_bbcredit(fabric
->fcs
->bfa
,
393 fabric
->fab_type
= BFA_FCS_FABRIC_SWITCHED
;
395 if (fabric
->auth_reqd
&& fabric
->is_auth
) {
396 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_auth
);
397 bfa_trc(fabric
->fcs
, event
);
399 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_online
);
400 bfa_fcs_fabric_notify_online(fabric
);
404 case BFA_FCS_FABRIC_SM_RETRY_OP
:
405 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_flogi_retry
);
406 bfa_timer_start(fabric
->fcs
->bfa
, &fabric
->delay_timer
,
407 bfa_fcs_fabric_delay
, fabric
,
408 BFA_FCS_FABRIC_RETRY_DELAY
);
411 case BFA_FCS_FABRIC_SM_LOOPBACK
:
412 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_loopback
);
413 bfa_lps_discard(fabric
->lps
);
414 bfa_fcs_fabric_set_opertype(fabric
);
417 case BFA_FCS_FABRIC_SM_NO_FABRIC
:
418 fabric
->fab_type
= BFA_FCS_FABRIC_N2N
;
419 bfa_fcport_set_tx_bbcredit(fabric
->fcs
->bfa
,
421 bfa_fcs_fabric_notify_online(fabric
);
422 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_nofabric
);
425 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
426 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_linkdown
);
427 bfa_lps_discard(fabric
->lps
);
430 case BFA_FCS_FABRIC_SM_DELETE
:
431 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_deleting
);
432 bfa_lps_discard(fabric
->lps
);
433 bfa_fcs_fabric_delete(fabric
);
437 bfa_sm_fault(fabric
->fcs
, event
);
443 bfa_fcs_fabric_sm_flogi_retry(struct bfa_fcs_fabric_s
*fabric
,
444 enum bfa_fcs_fabric_event event
)
446 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
447 bfa_trc(fabric
->fcs
, event
);
450 case BFA_FCS_FABRIC_SM_DELAYED
:
451 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_flogi
);
452 bfa_fcs_fabric_login(fabric
);
455 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
456 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_linkdown
);
457 bfa_timer_stop(&fabric
->delay_timer
);
460 case BFA_FCS_FABRIC_SM_DELETE
:
461 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_deleting
);
462 bfa_timer_stop(&fabric
->delay_timer
);
463 bfa_fcs_fabric_delete(fabric
);
467 bfa_sm_fault(fabric
->fcs
, event
);
472 * Authentication is in progress, awaiting authentication results.
475 bfa_fcs_fabric_sm_auth(struct bfa_fcs_fabric_s
*fabric
,
476 enum bfa_fcs_fabric_event event
)
478 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
479 bfa_trc(fabric
->fcs
, event
);
482 case BFA_FCS_FABRIC_SM_AUTH_FAILED
:
483 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_auth_failed
);
484 bfa_lps_discard(fabric
->lps
);
487 case BFA_FCS_FABRIC_SM_AUTH_SUCCESS
:
488 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_online
);
489 bfa_fcs_fabric_notify_online(fabric
);
492 case BFA_FCS_FABRIC_SM_PERF_EVFP
:
493 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_evfp
);
496 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
497 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_linkdown
);
498 bfa_lps_discard(fabric
->lps
);
501 case BFA_FCS_FABRIC_SM_DELETE
:
502 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_deleting
);
503 bfa_fcs_fabric_delete(fabric
);
507 bfa_sm_fault(fabric
->fcs
, event
);
512 * Authentication failed
515 bfa_fcs_fabric_sm_auth_failed(struct bfa_fcs_fabric_s
*fabric
,
516 enum bfa_fcs_fabric_event event
)
518 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
519 bfa_trc(fabric
->fcs
, event
);
522 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
523 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_linkdown
);
524 bfa_fcs_fabric_notify_offline(fabric
);
527 case BFA_FCS_FABRIC_SM_DELETE
:
528 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_deleting
);
529 bfa_fcs_fabric_delete(fabric
);
533 bfa_sm_fault(fabric
->fcs
, event
);
538 * Port is in loopback mode.
541 bfa_fcs_fabric_sm_loopback(struct bfa_fcs_fabric_s
*fabric
,
542 enum bfa_fcs_fabric_event event
)
544 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
545 bfa_trc(fabric
->fcs
, event
);
548 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
549 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_linkdown
);
550 bfa_fcs_fabric_notify_offline(fabric
);
553 case BFA_FCS_FABRIC_SM_DELETE
:
554 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_deleting
);
555 bfa_fcs_fabric_delete(fabric
);
559 bfa_sm_fault(fabric
->fcs
, event
);
564 * There is no attached fabric - private loop or NPort-to-NPort topology.
567 bfa_fcs_fabric_sm_nofabric(struct bfa_fcs_fabric_s
*fabric
,
568 enum bfa_fcs_fabric_event event
)
570 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
571 bfa_trc(fabric
->fcs
, event
);
574 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
575 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_linkdown
);
576 bfa_lps_discard(fabric
->lps
);
577 bfa_fcs_fabric_notify_offline(fabric
);
580 case BFA_FCS_FABRIC_SM_DELETE
:
581 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_deleting
);
582 bfa_fcs_fabric_delete(fabric
);
585 case BFA_FCS_FABRIC_SM_NO_FABRIC
:
586 bfa_trc(fabric
->fcs
, fabric
->bb_credit
);
587 bfa_fcport_set_tx_bbcredit(fabric
->fcs
->bfa
,
592 bfa_sm_fault(fabric
->fcs
, event
);
597 * Fabric is online - normal operating state.
600 bfa_fcs_fabric_sm_online(struct bfa_fcs_fabric_s
*fabric
,
601 enum bfa_fcs_fabric_event event
)
603 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
604 bfa_trc(fabric
->fcs
, event
);
607 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
608 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_linkdown
);
609 bfa_lps_discard(fabric
->lps
);
610 bfa_fcs_fabric_notify_offline(fabric
);
613 case BFA_FCS_FABRIC_SM_DELETE
:
614 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_deleting
);
615 bfa_fcs_fabric_delete(fabric
);
618 case BFA_FCS_FABRIC_SM_AUTH_FAILED
:
619 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_auth_failed
);
620 bfa_lps_discard(fabric
->lps
);
623 case BFA_FCS_FABRIC_SM_AUTH_SUCCESS
:
627 bfa_sm_fault(fabric
->fcs
, event
);
632 * Exchanging virtual fabric parameters.
635 bfa_fcs_fabric_sm_evfp(struct bfa_fcs_fabric_s
*fabric
,
636 enum bfa_fcs_fabric_event event
)
638 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
639 bfa_trc(fabric
->fcs
, event
);
642 case BFA_FCS_FABRIC_SM_CONT_OP
:
643 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_evfp_done
);
646 case BFA_FCS_FABRIC_SM_ISOLATE
:
647 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_isolated
);
651 bfa_sm_fault(fabric
->fcs
, event
);
656 * EVFP exchange complete and VFT tagging is enabled.
659 bfa_fcs_fabric_sm_evfp_done(struct bfa_fcs_fabric_s
*fabric
,
660 enum bfa_fcs_fabric_event event
)
662 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
663 bfa_trc(fabric
->fcs
, event
);
667 * Port is isolated after EVFP exchange due to VF_ID mismatch (N and F).
670 bfa_fcs_fabric_sm_isolated(struct bfa_fcs_fabric_s
*fabric
,
671 enum bfa_fcs_fabric_event event
)
673 struct bfad_s
*bfad
= (struct bfad_s
*)fabric
->fcs
->bfad
;
674 char pwwn_ptr
[BFA_STRING_32
];
676 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
677 bfa_trc(fabric
->fcs
, event
);
678 wwn2str(pwwn_ptr
, fabric
->bport
.port_cfg
.pwwn
);
680 BFA_LOG(KERN_INFO
, bfad
, bfa_log_level
,
681 "Port is isolated due to VF_ID mismatch. "
682 "PWWN: %s Port VF_ID: %04x switch port VF_ID: %04x.",
683 pwwn_ptr
, fabric
->fcs
->port_vfid
,
684 fabric
->event_arg
.swp_vfid
);
688 * Fabric is being deleted, awaiting vport delete completions.
691 bfa_fcs_fabric_sm_deleting(struct bfa_fcs_fabric_s
*fabric
,
692 enum bfa_fcs_fabric_event event
)
694 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
695 bfa_trc(fabric
->fcs
, event
);
698 case BFA_FCS_FABRIC_SM_DELCOMP
:
699 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_uninit
);
700 bfa_fcs_modexit_comp(fabric
->fcs
);
703 case BFA_FCS_FABRIC_SM_LINK_UP
:
706 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
707 bfa_fcs_fabric_notify_offline(fabric
);
711 bfa_sm_fault(fabric
->fcs
, event
);
718 * fcs_fabric_private fabric private functions
722 bfa_fcs_fabric_init(struct bfa_fcs_fabric_s
*fabric
)
724 struct bfa_lport_cfg_s
*port_cfg
= &fabric
->bport
.port_cfg
;
726 port_cfg
->roles
= BFA_LPORT_ROLE_FCP_IM
;
727 port_cfg
->nwwn
= bfa_ioc_get_nwwn(&fabric
->fcs
->bfa
->ioc
);
728 port_cfg
->pwwn
= bfa_ioc_get_pwwn(&fabric
->fcs
->bfa
->ioc
);
732 * Port Symbolic Name Creation for base port.
735 bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s
*fabric
)
737 struct bfa_lport_cfg_s
*port_cfg
= &fabric
->bport
.port_cfg
;
738 char model
[BFA_ADAPTER_MODEL_NAME_LEN
] = {0};
739 struct bfa_fcs_driver_info_s
*driver_info
= &fabric
->fcs
->driver_info
;
741 bfa_ioc_get_adapter_model(&fabric
->fcs
->bfa
->ioc
, model
);
743 /* Model name/number */
744 strncpy((char *)&port_cfg
->sym_name
, model
,
745 BFA_FCS_PORT_SYMBNAME_MODEL_SZ
);
746 strncat((char *)&port_cfg
->sym_name
, BFA_FCS_PORT_SYMBNAME_SEPARATOR
,
747 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR
));
750 strncat((char *)&port_cfg
->sym_name
, (char *)driver_info
->version
,
751 BFA_FCS_PORT_SYMBNAME_VERSION_SZ
);
752 strncat((char *)&port_cfg
->sym_name
, BFA_FCS_PORT_SYMBNAME_SEPARATOR
,
753 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR
));
755 /* Host machine name */
756 strncat((char *)&port_cfg
->sym_name
,
757 (char *)driver_info
->host_machine_name
,
758 BFA_FCS_PORT_SYMBNAME_MACHINENAME_SZ
);
759 strncat((char *)&port_cfg
->sym_name
, BFA_FCS_PORT_SYMBNAME_SEPARATOR
,
760 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR
));
764 * If OS Patch Info is not there, do not truncate any bytes from the
765 * OS name string and instead copy the entire OS info string (64 bytes).
767 if (driver_info
->host_os_patch
[0] == '\0') {
768 strncat((char *)&port_cfg
->sym_name
,
769 (char *)driver_info
->host_os_name
,
771 strncat((char *)&port_cfg
->sym_name
,
772 BFA_FCS_PORT_SYMBNAME_SEPARATOR
,
773 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR
));
775 strncat((char *)&port_cfg
->sym_name
,
776 (char *)driver_info
->host_os_name
,
777 BFA_FCS_PORT_SYMBNAME_OSINFO_SZ
);
778 strncat((char *)&port_cfg
->sym_name
,
779 BFA_FCS_PORT_SYMBNAME_SEPARATOR
,
780 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR
));
782 /* Append host OS Patch Info */
783 strncat((char *)&port_cfg
->sym_name
,
784 (char *)driver_info
->host_os_patch
,
785 BFA_FCS_PORT_SYMBNAME_OSPATCH_SZ
);
789 port_cfg
->sym_name
.symname
[BFA_SYMNAME_MAXLEN
- 1] = 0;
793 * bfa lps login completion callback
796 bfa_cb_lps_flogi_comp(void *bfad
, void *uarg
, bfa_status_t status
)
798 struct bfa_fcs_fabric_s
*fabric
= uarg
;
800 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
801 bfa_trc(fabric
->fcs
, status
);
805 fabric
->stats
.flogi_accepts
++;
808 case BFA_STATUS_INVALID_MAC
:
810 fabric
->stats
.flogi_acc_err
++;
811 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_RETRY_OP
);
815 case BFA_STATUS_EPROTOCOL
:
816 switch (bfa_lps_get_extstatus(fabric
->lps
)) {
817 case BFA_EPROTO_BAD_ACCEPT
:
818 fabric
->stats
.flogi_acc_err
++;
821 case BFA_EPROTO_UNKNOWN_RSP
:
822 fabric
->stats
.flogi_unknown_rsp
++;
828 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_RETRY_OP
);
832 case BFA_STATUS_FABRIC_RJT
:
833 fabric
->stats
.flogi_rejects
++;
834 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_RETRY_OP
);
838 fabric
->stats
.flogi_rsp_err
++;
839 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_RETRY_OP
);
843 fabric
->bb_credit
= bfa_lps_get_peer_bbcredit(fabric
->lps
);
844 bfa_trc(fabric
->fcs
, fabric
->bb_credit
);
846 if (!bfa_lps_is_brcd_fabric(fabric
->lps
))
847 fabric
->fabric_name
= bfa_lps_get_peer_nwwn(fabric
->lps
);
850 * Check port type. It should be 1 = F-port.
852 if (bfa_lps_is_fport(fabric
->lps
)) {
853 fabric
->bport
.pid
= bfa_lps_get_pid(fabric
->lps
);
854 fabric
->is_npiv
= bfa_lps_is_npiv_en(fabric
->lps
);
855 fabric
->is_auth
= bfa_lps_is_authreq(fabric
->lps
);
856 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_CONT_OP
);
859 * Nport-2-Nport direct attached
861 fabric
->bport
.port_topo
.pn2n
.rem_port_wwn
=
862 bfa_lps_get_peer_pwwn(fabric
->lps
);
863 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_NO_FABRIC
);
866 bfa_trc(fabric
->fcs
, fabric
->bport
.pid
);
867 bfa_trc(fabric
->fcs
, fabric
->is_npiv
);
868 bfa_trc(fabric
->fcs
, fabric
->is_auth
);
871 * Allocate and send FLOGI.
874 bfa_fcs_fabric_login(struct bfa_fcs_fabric_s
*fabric
)
876 struct bfa_s
*bfa
= fabric
->fcs
->bfa
;
877 struct bfa_lport_cfg_s
*pcfg
= &fabric
->bport
.port_cfg
;
880 if (bfa_fcport_get_topology(bfa
) == BFA_PORT_TOPOLOGY_LOOP
)
881 alpa
= bfa_fcport_get_myalpa(bfa
);
883 bfa_lps_flogi(fabric
->lps
, fabric
, alpa
, bfa_fcport_get_maxfrsize(bfa
),
884 pcfg
->pwwn
, pcfg
->nwwn
, fabric
->auth_reqd
);
886 fabric
->stats
.flogi_sent
++;
890 bfa_fcs_fabric_notify_online(struct bfa_fcs_fabric_s
*fabric
)
892 struct bfa_fcs_vport_s
*vport
;
893 struct list_head
*qe
, *qen
;
895 bfa_trc(fabric
->fcs
, fabric
->fabric_name
);
897 bfa_fcs_fabric_set_opertype(fabric
);
898 fabric
->stats
.fabric_onlines
++;
901 * notify online event to base and then virtual ports
903 bfa_fcs_lport_online(&fabric
->bport
);
905 list_for_each_safe(qe
, qen
, &fabric
->vport_q
) {
906 vport
= (struct bfa_fcs_vport_s
*) qe
;
907 bfa_fcs_vport_online(vport
);
912 bfa_fcs_fabric_notify_offline(struct bfa_fcs_fabric_s
*fabric
)
914 struct bfa_fcs_vport_s
*vport
;
915 struct list_head
*qe
, *qen
;
917 bfa_trc(fabric
->fcs
, fabric
->fabric_name
);
918 fabric
->stats
.fabric_offlines
++;
921 * notify offline event first to vports and then base port.
923 list_for_each_safe(qe
, qen
, &fabric
->vport_q
) {
924 vport
= (struct bfa_fcs_vport_s
*) qe
;
925 bfa_fcs_vport_offline(vport
);
928 bfa_fcs_lport_offline(&fabric
->bport
);
930 fabric
->fabric_name
= 0;
931 fabric
->fabric_ip_addr
[0] = 0;
935 bfa_fcs_fabric_delay(void *cbarg
)
937 struct bfa_fcs_fabric_s
*fabric
= cbarg
;
939 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_DELAYED
);
943 * Delete all vports and wait for vport delete completions.
946 bfa_fcs_fabric_delete(struct bfa_fcs_fabric_s
*fabric
)
948 struct bfa_fcs_vport_s
*vport
;
949 struct list_head
*qe
, *qen
;
951 list_for_each_safe(qe
, qen
, &fabric
->vport_q
) {
952 vport
= (struct bfa_fcs_vport_s
*) qe
;
953 bfa_fcs_vport_fcs_delete(vport
);
956 bfa_fcs_lport_delete(&fabric
->bport
);
957 bfa_wc_wait(&fabric
->wc
);
961 bfa_fcs_fabric_delete_comp(void *cbarg
)
963 struct bfa_fcs_fabric_s
*fabric
= cbarg
;
965 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_DELCOMP
);
969 * fcs_fabric_public fabric public functions
973 * Attach time initialization.
976 bfa_fcs_fabric_attach(struct bfa_fcs_s
*fcs
)
978 struct bfa_fcs_fabric_s
*fabric
;
980 fabric
= &fcs
->fabric
;
981 memset(fabric
, 0, sizeof(struct bfa_fcs_fabric_s
));
984 * Initialize base fabric.
987 INIT_LIST_HEAD(&fabric
->vport_q
);
988 INIT_LIST_HEAD(&fabric
->vf_q
);
989 fabric
->lps
= bfa_lps_alloc(fcs
->bfa
);
990 bfa_assert(fabric
->lps
);
993 * Initialize fabric delete completion handler. Fabric deletion is
994 * complete when the last vport delete is complete.
996 bfa_wc_init(&fabric
->wc
, bfa_fcs_fabric_delete_comp
, fabric
);
997 bfa_wc_up(&fabric
->wc
); /* For the base port */
999 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_uninit
);
1000 bfa_fcs_lport_attach(&fabric
->bport
, fabric
->fcs
, FC_VF_ID_NULL
, NULL
);
1004 bfa_fcs_fabric_modinit(struct bfa_fcs_s
*fcs
)
1006 bfa_sm_send_event(&fcs
->fabric
, BFA_FCS_FABRIC_SM_CREATE
);
1014 bfa_fcs_fabric_modexit(struct bfa_fcs_s
*fcs
)
1016 struct bfa_fcs_fabric_s
*fabric
;
1021 * Cleanup base fabric.
1023 fabric
= &fcs
->fabric
;
1024 bfa_lps_delete(fabric
->lps
);
1025 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_DELETE
);
1029 * Fabric module start -- kick starts FCS actions
1032 bfa_fcs_fabric_modstart(struct bfa_fcs_s
*fcs
)
1034 struct bfa_fcs_fabric_s
*fabric
;
1037 fabric
= &fcs
->fabric
;
1038 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_START
);
1042 bfa_fcs_fabric_is_loopback(struct bfa_fcs_fabric_s
*fabric
)
1044 return bfa_sm_cmp_state(fabric
, bfa_fcs_fabric_sm_loopback
);
1048 bfa_fcs_fabric_is_auth_failed(struct bfa_fcs_fabric_s
*fabric
)
1050 return bfa_sm_cmp_state(fabric
, bfa_fcs_fabric_sm_auth_failed
);
1054 bfa_fcs_fabric_port_type(struct bfa_fcs_fabric_s
*fabric
)
1056 return fabric
->oper_type
;
1060 * Link up notification from BFA physical port module.
1063 bfa_fcs_fabric_link_up(struct bfa_fcs_fabric_s
*fabric
)
1065 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
1066 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_LINK_UP
);
1070 * Link down notification from BFA physical port module.
1073 bfa_fcs_fabric_link_down(struct bfa_fcs_fabric_s
*fabric
)
1075 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
1076 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_LINK_DOWN
);
1080 * A child vport is being created in the fabric.
1082 * Call from vport module at vport creation. A list of base port and vports
1083 * belonging to a fabric is maintained to propagate link events.
1085 * param[in] fabric - Fabric instance. This can be a base fabric or vf.
1086 * param[in] vport - Vport being created.
1088 * @return None (always succeeds)
1091 bfa_fcs_fabric_addvport(struct bfa_fcs_fabric_s
*fabric
,
1092 struct bfa_fcs_vport_s
*vport
)
1095 * - add vport to fabric's vport_q
1097 bfa_trc(fabric
->fcs
, fabric
->vf_id
);
1099 list_add_tail(&vport
->qe
, &fabric
->vport_q
);
1100 fabric
->num_vports
++;
1101 bfa_wc_up(&fabric
->wc
);
1105 * A child vport is being deleted from fabric.
1107 * Vport is being deleted.
1110 bfa_fcs_fabric_delvport(struct bfa_fcs_fabric_s
*fabric
,
1111 struct bfa_fcs_vport_s
*vport
)
1113 list_del(&vport
->qe
);
1114 fabric
->num_vports
--;
1115 bfa_wc_down(&fabric
->wc
);
1119 * Base port is deleted.
1122 bfa_fcs_fabric_port_delete_comp(struct bfa_fcs_fabric_s
*fabric
)
1124 bfa_wc_down(&fabric
->wc
);
1129 * Check if fabric is online.
1131 * param[in] fabric - Fabric instance. This can be a base fabric or vf.
1133 * @return TRUE/FALSE
1136 bfa_fcs_fabric_is_online(struct bfa_fcs_fabric_s
*fabric
)
1138 return bfa_sm_cmp_state(fabric
, bfa_fcs_fabric_sm_online
);
1142 * Lookup for a vport withing a fabric given its pwwn
1144 struct bfa_fcs_vport_s
*
1145 bfa_fcs_fabric_vport_lookup(struct bfa_fcs_fabric_s
*fabric
, wwn_t pwwn
)
1147 struct bfa_fcs_vport_s
*vport
;
1148 struct list_head
*qe
;
1150 list_for_each(qe
, &fabric
->vport_q
) {
1151 vport
= (struct bfa_fcs_vport_s
*) qe
;
1152 if (bfa_fcs_lport_get_pwwn(&vport
->lport
) == pwwn
)
1160 * In a given fabric, return the number of lports.
1162 * param[in] fabric - Fabric instance. This can be a base fabric or vf.
1164 * @return : 1 or more.
1167 bfa_fcs_fabric_vport_count(struct bfa_fcs_fabric_s
*fabric
)
1169 return fabric
->num_vports
;
1173 * Get OUI of the attached switch.
1175 * Note : Use of this function should be avoided as much as possible.
1176 * This function should be used only if there is any requirement
1177 * to check for FOS version below 6.3.
1178 * To check if the attached fabric is a brocade fabric, use
1179 * bfa_lps_is_brcd_fabric() which works for FOS versions 6.3
1184 bfa_fcs_fabric_get_switch_oui(struct bfa_fcs_fabric_s
*fabric
)
1190 fab_nwwn
= bfa_lps_get_peer_nwwn(fabric
->lps
);
1192 tmp
= (u8
*)&fab_nwwn
;
1193 oui
= (tmp
[3] << 8) | tmp
[4];
1198 * Unsolicited frame receive handling.
1201 bfa_fcs_fabric_uf_recv(struct bfa_fcs_fabric_s
*fabric
, struct fchs_s
*fchs
,
1204 u32 pid
= fchs
->d_id
;
1205 struct bfa_fcs_vport_s
*vport
;
1206 struct list_head
*qe
;
1207 struct fc_els_cmd_s
*els_cmd
= (struct fc_els_cmd_s
*) (fchs
+ 1);
1208 struct fc_logi_s
*flogi
= (struct fc_logi_s
*) els_cmd
;
1210 bfa_trc(fabric
->fcs
, len
);
1211 bfa_trc(fabric
->fcs
, pid
);
1214 * Look for our own FLOGI frames being looped back. This means an
1215 * external loopback cable is in place. Our own FLOGI frames are
1216 * sometimes looped back when switch port gets temporarily bypassed.
1218 if ((pid
== bfa_os_ntoh3b(FC_FABRIC_PORT
)) &&
1219 (els_cmd
->els_code
== FC_ELS_FLOGI
) &&
1220 (flogi
->port_name
== bfa_fcs_lport_get_pwwn(&fabric
->bport
))) {
1221 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_LOOPBACK
);
1226 * FLOGI/EVFP exchanges should be consumed by base fabric.
1228 if (fchs
->d_id
== bfa_os_hton3b(FC_FABRIC_PORT
)) {
1229 bfa_trc(fabric
->fcs
, pid
);
1230 bfa_fcs_fabric_process_uf(fabric
, fchs
, len
);
1234 if (fabric
->bport
.pid
== pid
) {
1236 * All authentication frames should be routed to auth
1238 bfa_trc(fabric
->fcs
, els_cmd
->els_code
);
1239 if (els_cmd
->els_code
== FC_ELS_AUTH
) {
1240 bfa_trc(fabric
->fcs
, els_cmd
->els_code
);
1244 bfa_trc(fabric
->fcs
, *(u8
*) ((u8
*) fchs
));
1245 bfa_fcs_lport_uf_recv(&fabric
->bport
, fchs
, len
);
1250 * look for a matching local port ID
1252 list_for_each(qe
, &fabric
->vport_q
) {
1253 vport
= (struct bfa_fcs_vport_s
*) qe
;
1254 if (vport
->lport
.pid
== pid
) {
1255 bfa_fcs_lport_uf_recv(&vport
->lport
, fchs
, len
);
1259 bfa_trc(fabric
->fcs
, els_cmd
->els_code
);
1260 bfa_fcs_lport_uf_recv(&fabric
->bport
, fchs
, len
);
1264 * Unsolicited frames to be processed by fabric.
1267 bfa_fcs_fabric_process_uf(struct bfa_fcs_fabric_s
*fabric
, struct fchs_s
*fchs
,
1270 struct fc_els_cmd_s
*els_cmd
= (struct fc_els_cmd_s
*) (fchs
+ 1);
1272 bfa_trc(fabric
->fcs
, els_cmd
->els_code
);
1274 switch (els_cmd
->els_code
) {
1276 bfa_fcs_fabric_process_flogi(fabric
, fchs
, len
);
1281 * need to generate a LS_RJT
1288 * Process incoming FLOGI
1291 bfa_fcs_fabric_process_flogi(struct bfa_fcs_fabric_s
*fabric
,
1292 struct fchs_s
*fchs
, u16 len
)
1294 struct fc_logi_s
*flogi
= (struct fc_logi_s
*) (fchs
+ 1);
1295 struct bfa_fcs_lport_s
*bport
= &fabric
->bport
;
1297 bfa_trc(fabric
->fcs
, fchs
->s_id
);
1299 fabric
->stats
.flogi_rcvd
++;
1301 * Check port type. It should be 0 = n-port.
1303 if (flogi
->csp
.port_type
) {
1305 * @todo: may need to send a LS_RJT
1307 bfa_trc(fabric
->fcs
, flogi
->port_name
);
1308 fabric
->stats
.flogi_rejected
++;
1312 fabric
->bb_credit
= be16_to_cpu(flogi
->csp
.bbcred
);
1313 bport
->port_topo
.pn2n
.rem_port_wwn
= flogi
->port_name
;
1314 bport
->port_topo
.pn2n
.reply_oxid
= fchs
->ox_id
;
1319 bfa_fcs_fabric_send_flogi_acc(fabric
);
1320 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_NO_FABRIC
);
1324 bfa_fcs_fabric_send_flogi_acc(struct bfa_fcs_fabric_s
*fabric
)
1326 struct bfa_lport_cfg_s
*pcfg
= &fabric
->bport
.port_cfg
;
1327 struct bfa_fcs_lport_n2n_s
*n2n_port
= &fabric
->bport
.port_topo
.pn2n
;
1328 struct bfa_s
*bfa
= fabric
->fcs
->bfa
;
1329 struct bfa_fcxp_s
*fcxp
;
1333 fcxp
= bfa_fcs_fcxp_alloc(fabric
->fcs
);
1335 * Do not expect this failure -- expect remote node to retry
1340 reqlen
= fc_flogi_acc_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
1341 bfa_os_hton3b(FC_FABRIC_PORT
),
1342 n2n_port
->reply_oxid
, pcfg
->pwwn
,
1344 bfa_fcport_get_maxfrsize(bfa
),
1345 bfa_fcport_get_rx_bbcredit(bfa
));
1347 bfa_fcxp_send(fcxp
, NULL
, fabric
->vf_id
, bfa_lps_get_tag(fabric
->lps
),
1348 BFA_FALSE
, FC_CLASS_3
,
1349 reqlen
, &fchs
, bfa_fcs_fabric_flogiacc_comp
, fabric
,
1354 * Flogi Acc completion callback.
1357 bfa_fcs_fabric_flogiacc_comp(void *fcsarg
, struct bfa_fcxp_s
*fcxp
, void *cbarg
,
1358 bfa_status_t status
, u32 rsp_len
,
1359 u32 resid_len
, struct fchs_s
*rspfchs
)
1361 struct bfa_fcs_fabric_s
*fabric
= cbarg
;
1363 bfa_trc(fabric
->fcs
, status
);
1368 * @param[in] fabric - fabric
1369 * @param[in] wwn_t - new fabric name
1374 bfa_fcs_fabric_set_fabric_name(struct bfa_fcs_fabric_s
*fabric
,
1377 struct bfad_s
*bfad
= (struct bfad_s
*)fabric
->fcs
->bfad
;
1378 char pwwn_ptr
[BFA_STRING_32
];
1379 char fwwn_ptr
[BFA_STRING_32
];
1381 bfa_trc(fabric
->fcs
, fabric_name
);
1383 if (fabric
->fabric_name
== 0) {
1385 * With BRCD switches, we don't get Fabric Name in FLOGI.
1386 * Don't generate a fabric name change event in this case.
1388 fabric
->fabric_name
= fabric_name
;
1390 fabric
->fabric_name
= fabric_name
;
1391 wwn2str(pwwn_ptr
, bfa_fcs_lport_get_pwwn(&fabric
->bport
));
1393 bfa_fcs_lport_get_fabric_name(&fabric
->bport
));
1394 BFA_LOG(KERN_WARNING
, bfad
, bfa_log_level
,
1395 "Base port WWN = %s Fabric WWN = %s\n",
1396 pwwn_ptr
, fwwn_ptr
);
1401 * Returns FCS vf structure for a given vf_id.
1403 * param[in] vf_id - VF_ID
1406 * If lookup succeeds, retuns fcs vf object, otherwise returns NULL
1409 bfa_fcs_vf_lookup(struct bfa_fcs_s
*fcs
, u16 vf_id
)
1411 bfa_trc(fcs
, vf_id
);
1412 if (vf_id
== FC_VF_ID_NULL
)
1413 return &fcs
->fabric
;
1419 * BFA FCS PPORT ( physical port)
1422 bfa_fcs_port_event_handler(void *cbarg
, enum bfa_port_linkstate event
)
1424 struct bfa_fcs_s
*fcs
= cbarg
;
1426 bfa_trc(fcs
, event
);
1429 case BFA_PORT_LINKUP
:
1430 bfa_fcs_fabric_link_up(&fcs
->fabric
);
1433 case BFA_PORT_LINKDOWN
:
1434 bfa_fcs_fabric_link_down(&fcs
->fabric
);
1443 bfa_fcs_port_attach(struct bfa_fcs_s
*fcs
)
1445 bfa_fcport_event_register(fcs
->bfa
, bfa_fcs_port_event_handler
, fcs
);
1449 * BFA FCS UF ( Unsolicited Frames)
1453 * BFA callback for unsolicited frame receive handler.
1455 * @param[in] cbarg callback arg for receive handler
1456 * @param[in] uf unsolicited frame descriptor
1461 bfa_fcs_uf_recv(void *cbarg
, struct bfa_uf_s
*uf
)
1463 struct bfa_fcs_s
*fcs
= (struct bfa_fcs_s
*) cbarg
;
1464 struct fchs_s
*fchs
= bfa_uf_get_frmbuf(uf
);
1465 u16 len
= bfa_uf_get_frmlen(uf
);
1466 struct fc_vft_s
*vft
;
1467 struct bfa_fcs_fabric_s
*fabric
;
1470 * check for VFT header
1472 if (fchs
->routing
== FC_RTG_EXT_HDR
&&
1473 fchs
->cat_info
== FC_CAT_VFT_HDR
) {
1474 bfa_stats(fcs
, uf
.tagged
);
1475 vft
= bfa_uf_get_frmbuf(uf
);
1476 if (fcs
->port_vfid
== vft
->vf_id
)
1477 fabric
= &fcs
->fabric
;
1479 fabric
= bfa_fcs_vf_lookup(fcs
, (u16
) vft
->vf_id
);
1482 * drop frame if vfid is unknown
1486 bfa_stats(fcs
, uf
.vfid_unknown
);
1494 fchs
= (struct fchs_s
*) (vft
+ 1);
1495 len
-= sizeof(struct fc_vft_s
);
1497 bfa_trc(fcs
, vft
->vf_id
);
1499 bfa_stats(fcs
, uf
.untagged
);
1500 fabric
= &fcs
->fabric
;
1503 bfa_trc(fcs
, ((u32
*) fchs
)[0]);
1504 bfa_trc(fcs
, ((u32
*) fchs
)[1]);
1505 bfa_trc(fcs
, ((u32
*) fchs
)[2]);
1506 bfa_trc(fcs
, ((u32
*) fchs
)[3]);
1507 bfa_trc(fcs
, ((u32
*) fchs
)[4]);
1508 bfa_trc(fcs
, ((u32
*) fchs
)[5]);
1511 bfa_fcs_fabric_uf_recv(fabric
, fchs
, len
);
1516 bfa_fcs_uf_attach(struct bfa_fcs_s
*fcs
)
1518 bfa_uf_recv_register(fcs
->bfa
, bfa_fcs_uf_recv
, fcs
);