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
25 #include "bfa_fcbuild.h"
27 BFA_TRC_FILE(FCS
, FCS
);
32 struct bfa_fcs_mod_s
{
33 void (*attach
) (struct bfa_fcs_s
*fcs
);
34 void (*modinit
) (struct bfa_fcs_s
*fcs
);
35 void (*modexit
) (struct bfa_fcs_s
*fcs
);
38 #define BFA_FCS_MODULE(_mod) { _mod ## _modinit, _mod ## _modexit }
40 static struct bfa_fcs_mod_s fcs_modules
[] = {
41 { bfa_fcs_port_attach
, NULL
, NULL
},
42 { bfa_fcs_uf_attach
, NULL
, NULL
},
43 { bfa_fcs_fabric_attach
, bfa_fcs_fabric_modinit
,
44 bfa_fcs_fabric_modexit
},
52 bfa_fcs_exit_comp(void *fcs_cbarg
)
54 struct bfa_fcs_s
*fcs
= fcs_cbarg
;
55 struct bfad_s
*bfad
= fcs
->bfad
;
57 complete(&bfad
->comp
);
67 * fcs attach -- called once to initialize data structures at driver attach time
70 bfa_fcs_attach(struct bfa_fcs_s
*fcs
, struct bfa_s
*bfa
, struct bfad_s
*bfad
,
71 bfa_boolean_t min_cfg
)
74 struct bfa_fcs_mod_s
*mod
;
78 fcs
->min_cfg
= min_cfg
;
79 fcs
->num_rport_logins
= 0;
84 for (i
= 0; i
< sizeof(fcs_modules
) / sizeof(fcs_modules
[0]); i
++) {
85 mod
= &fcs_modules
[i
];
92 * fcs initialization, called once after bfa initialization is complete
95 bfa_fcs_init(struct bfa_fcs_s
*fcs
)
98 struct bfa_fcs_mod_s
*mod
;
100 for (i
= 0; i
< sizeof(fcs_modules
) / sizeof(fcs_modules
[0]); i
++) {
101 mod
= &fcs_modules
[i
];
108 * FCS update cfg - reset the pwwn/nwwn of fabric base logical port
109 * with values learned during bfa_init firmware GETATTR REQ.
112 bfa_fcs_update_cfg(struct bfa_fcs_s
*fcs
)
114 struct bfa_fcs_fabric_s
*fabric
= &fcs
->fabric
;
115 struct bfa_lport_cfg_s
*port_cfg
= &fabric
->bport
.port_cfg
;
116 struct bfa_ioc_s
*ioc
= &fabric
->fcs
->bfa
->ioc
;
118 port_cfg
->nwwn
= ioc
->attr
->nwwn
;
119 port_cfg
->pwwn
= ioc
->attr
->pwwn
;
123 * Stop FCS operations.
126 bfa_fcs_stop(struct bfa_fcs_s
*fcs
)
128 bfa_wc_init(&fcs
->wc
, bfa_fcs_exit_comp
, fcs
);
130 bfa_fcs_fabric_modstop(fcs
);
131 bfa_wc_wait(&fcs
->wc
);
135 * fcs pbc vport initialization
138 bfa_fcs_pbc_vport_init(struct bfa_fcs_s
*fcs
)
141 struct bfi_pbc_vport_s pbc_vports
[BFI_PBC_MAX_VPORTS
];
143 /* Initialize pbc vports */
146 bfa_iocfc_get_pbc_vports(fcs
->bfa
, pbc_vports
);
147 for (i
= 0; i
< npbc_vports
; i
++)
148 bfa_fcb_pbc_vport_create(fcs
->bfa
->bfad
, pbc_vports
[i
]);
154 * FCS driver details initialization.
156 * param[in] fcs FCS instance
157 * param[in] driver_info Driver Details
162 bfa_fcs_driver_info_init(struct bfa_fcs_s
*fcs
,
163 struct bfa_fcs_driver_info_s
*driver_info
)
166 fcs
->driver_info
= *driver_info
;
168 bfa_fcs_fabric_psymb_init(&fcs
->fabric
);
169 bfa_fcs_fabric_nsymb_init(&fcs
->fabric
);
174 * FCS instance cleanup and exit.
176 * param[in] fcs FCS instance
180 bfa_fcs_exit(struct bfa_fcs_s
*fcs
)
182 struct bfa_fcs_mod_s
*mod
;
185 bfa_wc_init(&fcs
->wc
, bfa_fcs_exit_comp
, fcs
);
187 nmods
= sizeof(fcs_modules
) / sizeof(fcs_modules
[0]);
189 for (i
= 0; i
< nmods
; i
++) {
191 mod
= &fcs_modules
[i
];
198 bfa_wc_wait(&fcs
->wc
);
203 * Fabric module implementation.
206 #define BFA_FCS_FABRIC_RETRY_DELAY (2000) /* Milliseconds */
207 #define BFA_FCS_FABRIC_CLEANUP_DELAY (10000) /* Milliseconds */
209 #define bfa_fcs_fabric_set_opertype(__fabric) do { \
210 if (bfa_fcport_get_topology((__fabric)->fcs->bfa) \
211 == BFA_PORT_TOPOLOGY_P2P) { \
212 if (fabric->fab_type == BFA_FCS_FABRIC_SWITCHED) \
213 (__fabric)->oper_type = BFA_PORT_TYPE_NPORT; \
215 (__fabric)->oper_type = BFA_PORT_TYPE_P2P; \
217 (__fabric)->oper_type = BFA_PORT_TYPE_NLPORT; \
221 * forward declarations
223 static void bfa_fcs_fabric_init(struct bfa_fcs_fabric_s
*fabric
);
224 static void bfa_fcs_fabric_login(struct bfa_fcs_fabric_s
*fabric
);
225 static void bfa_fcs_fabric_notify_online(struct bfa_fcs_fabric_s
*fabric
);
226 static void bfa_fcs_fabric_notify_offline(struct bfa_fcs_fabric_s
*fabric
);
227 static void bfa_fcs_fabric_delay(void *cbarg
);
228 static void bfa_fcs_fabric_delete(struct bfa_fcs_fabric_s
*fabric
);
229 static void bfa_fcs_fabric_delete_comp(void *cbarg
);
230 static void bfa_fcs_fabric_stop(struct bfa_fcs_fabric_s
*fabric
);
231 static void bfa_fcs_fabric_stop_comp(void *cbarg
);
232 static void bfa_fcs_fabric_process_uf(struct bfa_fcs_fabric_s
*fabric
,
233 struct fchs_s
*fchs
, u16 len
);
234 static void bfa_fcs_fabric_process_flogi(struct bfa_fcs_fabric_s
*fabric
,
235 struct fchs_s
*fchs
, u16 len
);
236 static void bfa_fcs_fabric_send_flogi_acc(struct bfa_fcs_fabric_s
*fabric
);
237 static void bfa_fcs_fabric_flogiacc_comp(void *fcsarg
,
238 struct bfa_fcxp_s
*fcxp
, void *cbarg
,
242 struct fchs_s
*rspfchs
);
244 static void bfa_fcs_fabric_sm_uninit(struct bfa_fcs_fabric_s
*fabric
,
245 enum bfa_fcs_fabric_event event
);
246 static void bfa_fcs_fabric_sm_created(struct bfa_fcs_fabric_s
*fabric
,
247 enum bfa_fcs_fabric_event event
);
248 static void bfa_fcs_fabric_sm_linkdown(struct bfa_fcs_fabric_s
*fabric
,
249 enum bfa_fcs_fabric_event event
);
250 static void bfa_fcs_fabric_sm_flogi(struct bfa_fcs_fabric_s
*fabric
,
251 enum bfa_fcs_fabric_event event
);
252 static void bfa_fcs_fabric_sm_flogi_retry(struct bfa_fcs_fabric_s
*fabric
,
253 enum bfa_fcs_fabric_event event
);
254 static void bfa_fcs_fabric_sm_auth(struct bfa_fcs_fabric_s
*fabric
,
255 enum bfa_fcs_fabric_event event
);
256 static void bfa_fcs_fabric_sm_nofabric(struct bfa_fcs_fabric_s
*fabric
,
257 enum bfa_fcs_fabric_event event
);
258 static void bfa_fcs_fabric_sm_evfp(struct bfa_fcs_fabric_s
*fabric
,
259 enum bfa_fcs_fabric_event event
);
260 static void bfa_fcs_fabric_sm_evfp_done(struct bfa_fcs_fabric_s
*fabric
,
261 enum bfa_fcs_fabric_event event
);
262 static void bfa_fcs_fabric_sm_isolated(struct bfa_fcs_fabric_s
*fabric
,
263 enum bfa_fcs_fabric_event event
);
264 static void bfa_fcs_fabric_sm_deleting(struct bfa_fcs_fabric_s
*fabric
,
265 enum bfa_fcs_fabric_event event
);
266 static void bfa_fcs_fabric_sm_stopping(struct bfa_fcs_fabric_s
*fabric
,
267 enum bfa_fcs_fabric_event event
);
268 static void bfa_fcs_fabric_sm_cleanup(struct bfa_fcs_fabric_s
*fabric
,
269 enum bfa_fcs_fabric_event event
);
271 * Beginning state before fabric creation.
274 bfa_fcs_fabric_sm_uninit(struct bfa_fcs_fabric_s
*fabric
,
275 enum bfa_fcs_fabric_event event
)
277 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
278 bfa_trc(fabric
->fcs
, event
);
281 case BFA_FCS_FABRIC_SM_CREATE
:
282 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_created
);
283 bfa_fcs_fabric_init(fabric
);
284 bfa_fcs_lport_init(&fabric
->bport
, &fabric
->bport
.port_cfg
);
287 case BFA_FCS_FABRIC_SM_LINK_UP
:
288 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
292 bfa_sm_fault(fabric
->fcs
, event
);
297 * Beginning state before fabric creation.
300 bfa_fcs_fabric_sm_created(struct bfa_fcs_fabric_s
*fabric
,
301 enum bfa_fcs_fabric_event event
)
303 struct bfa_s
*bfa
= fabric
->fcs
->bfa
;
305 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
306 bfa_trc(fabric
->fcs
, event
);
309 case BFA_FCS_FABRIC_SM_START
:
310 if (!bfa_fcport_is_linkup(fabric
->fcs
->bfa
)) {
311 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_linkdown
);
314 if (bfa_fcport_get_topology(bfa
) ==
315 BFA_PORT_TOPOLOGY_LOOP
) {
316 fabric
->fab_type
= BFA_FCS_FABRIC_LOOP
;
317 fabric
->bport
.pid
= bfa_fcport_get_myalpa(bfa
);
318 fabric
->bport
.pid
= bfa_hton3b(fabric
->bport
.pid
);
319 bfa_sm_set_state(fabric
,
320 bfa_fcs_fabric_sm_online
);
321 bfa_fcs_fabric_set_opertype(fabric
);
322 bfa_fcs_lport_online(&fabric
->bport
);
324 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_flogi
);
325 bfa_fcs_fabric_login(fabric
);
329 case BFA_FCS_FABRIC_SM_LINK_UP
:
330 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
333 case BFA_FCS_FABRIC_SM_DELETE
:
334 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_deleting
);
335 bfa_fcs_fabric_delete(fabric
);
339 bfa_sm_fault(fabric
->fcs
, event
);
344 * Link is down, awaiting LINK UP event from port. This is also the
345 * first state at fabric creation.
348 bfa_fcs_fabric_sm_linkdown(struct bfa_fcs_fabric_s
*fabric
,
349 enum bfa_fcs_fabric_event event
)
351 struct bfa_s
*bfa
= fabric
->fcs
->bfa
;
353 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
354 bfa_trc(fabric
->fcs
, event
);
357 case BFA_FCS_FABRIC_SM_LINK_UP
:
358 if (bfa_fcport_get_topology(bfa
) != BFA_PORT_TOPOLOGY_LOOP
) {
359 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_flogi
);
360 bfa_fcs_fabric_login(fabric
);
363 fabric
->fab_type
= BFA_FCS_FABRIC_LOOP
;
364 fabric
->bport
.pid
= bfa_fcport_get_myalpa(bfa
);
365 fabric
->bport
.pid
= bfa_hton3b(fabric
->bport
.pid
);
366 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_online
);
367 bfa_fcs_fabric_set_opertype(fabric
);
368 bfa_fcs_lport_online(&fabric
->bport
);
371 case BFA_FCS_FABRIC_SM_RETRY_OP
:
372 case BFA_FCS_FABRIC_SM_LOOPBACK
:
375 case BFA_FCS_FABRIC_SM_DELETE
:
376 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_deleting
);
377 bfa_fcs_fabric_delete(fabric
);
380 case BFA_FCS_FABRIC_SM_STOP
:
381 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_cleanup
);
382 bfa_fcs_fabric_stop(fabric
);
386 bfa_sm_fault(fabric
->fcs
, event
);
391 * FLOGI is in progress, awaiting FLOGI reply.
394 bfa_fcs_fabric_sm_flogi(struct bfa_fcs_fabric_s
*fabric
,
395 enum bfa_fcs_fabric_event event
)
397 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
398 bfa_trc(fabric
->fcs
, event
);
401 case BFA_FCS_FABRIC_SM_CONT_OP
:
403 bfa_fcport_set_tx_bbcredit(fabric
->fcs
->bfa
,
405 fabric
->fab_type
= BFA_FCS_FABRIC_SWITCHED
;
407 if (fabric
->auth_reqd
&& fabric
->is_auth
) {
408 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_auth
);
409 bfa_trc(fabric
->fcs
, event
);
411 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_online
);
412 bfa_fcs_fabric_notify_online(fabric
);
416 case BFA_FCS_FABRIC_SM_RETRY_OP
:
417 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_flogi_retry
);
418 bfa_timer_start(fabric
->fcs
->bfa
, &fabric
->delay_timer
,
419 bfa_fcs_fabric_delay
, fabric
,
420 BFA_FCS_FABRIC_RETRY_DELAY
);
423 case BFA_FCS_FABRIC_SM_LOOPBACK
:
424 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_loopback
);
425 bfa_sm_send_event(fabric
->lps
, BFA_LPS_SM_OFFLINE
);
426 bfa_fcs_fabric_set_opertype(fabric
);
429 case BFA_FCS_FABRIC_SM_NO_FABRIC
:
430 fabric
->fab_type
= BFA_FCS_FABRIC_N2N
;
431 bfa_fcport_set_tx_bbcredit(fabric
->fcs
->bfa
,
433 bfa_fcs_fabric_notify_online(fabric
);
434 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_nofabric
);
437 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
438 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_linkdown
);
439 bfa_sm_send_event(fabric
->lps
, BFA_LPS_SM_OFFLINE
);
442 case BFA_FCS_FABRIC_SM_DELETE
:
443 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_deleting
);
444 bfa_sm_send_event(fabric
->lps
, BFA_LPS_SM_OFFLINE
);
445 bfa_fcs_fabric_delete(fabric
);
449 bfa_sm_fault(fabric
->fcs
, event
);
455 bfa_fcs_fabric_sm_flogi_retry(struct bfa_fcs_fabric_s
*fabric
,
456 enum bfa_fcs_fabric_event event
)
458 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
459 bfa_trc(fabric
->fcs
, event
);
462 case BFA_FCS_FABRIC_SM_DELAYED
:
463 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_flogi
);
464 bfa_fcs_fabric_login(fabric
);
467 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
468 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_linkdown
);
469 bfa_timer_stop(&fabric
->delay_timer
);
472 case BFA_FCS_FABRIC_SM_DELETE
:
473 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_deleting
);
474 bfa_timer_stop(&fabric
->delay_timer
);
475 bfa_fcs_fabric_delete(fabric
);
479 bfa_sm_fault(fabric
->fcs
, event
);
484 * Authentication is in progress, awaiting authentication results.
487 bfa_fcs_fabric_sm_auth(struct bfa_fcs_fabric_s
*fabric
,
488 enum bfa_fcs_fabric_event event
)
490 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
491 bfa_trc(fabric
->fcs
, event
);
494 case BFA_FCS_FABRIC_SM_AUTH_FAILED
:
495 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_auth_failed
);
496 bfa_sm_send_event(fabric
->lps
, BFA_LPS_SM_OFFLINE
);
499 case BFA_FCS_FABRIC_SM_AUTH_SUCCESS
:
500 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_online
);
501 bfa_fcs_fabric_notify_online(fabric
);
504 case BFA_FCS_FABRIC_SM_PERF_EVFP
:
505 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_evfp
);
508 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
509 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_linkdown
);
510 bfa_sm_send_event(fabric
->lps
, BFA_LPS_SM_OFFLINE
);
513 case BFA_FCS_FABRIC_SM_DELETE
:
514 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_deleting
);
515 bfa_fcs_fabric_delete(fabric
);
519 bfa_sm_fault(fabric
->fcs
, event
);
524 * Authentication failed
527 bfa_fcs_fabric_sm_auth_failed(struct bfa_fcs_fabric_s
*fabric
,
528 enum bfa_fcs_fabric_event event
)
530 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
531 bfa_trc(fabric
->fcs
, event
);
534 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
535 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_linkdown
);
536 bfa_fcs_fabric_notify_offline(fabric
);
539 case BFA_FCS_FABRIC_SM_DELETE
:
540 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_deleting
);
541 bfa_fcs_fabric_delete(fabric
);
545 bfa_sm_fault(fabric
->fcs
, event
);
550 * Port is in loopback mode.
553 bfa_fcs_fabric_sm_loopback(struct bfa_fcs_fabric_s
*fabric
,
554 enum bfa_fcs_fabric_event event
)
556 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
557 bfa_trc(fabric
->fcs
, event
);
560 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
561 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_linkdown
);
562 bfa_fcs_fabric_notify_offline(fabric
);
565 case BFA_FCS_FABRIC_SM_DELETE
:
566 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_deleting
);
567 bfa_fcs_fabric_delete(fabric
);
571 bfa_sm_fault(fabric
->fcs
, event
);
576 * There is no attached fabric - private loop or NPort-to-NPort topology.
579 bfa_fcs_fabric_sm_nofabric(struct bfa_fcs_fabric_s
*fabric
,
580 enum bfa_fcs_fabric_event event
)
582 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
583 bfa_trc(fabric
->fcs
, event
);
586 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
587 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_linkdown
);
588 bfa_sm_send_event(fabric
->lps
, BFA_LPS_SM_OFFLINE
);
589 bfa_fcs_fabric_notify_offline(fabric
);
592 case BFA_FCS_FABRIC_SM_DELETE
:
593 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_deleting
);
594 bfa_fcs_fabric_delete(fabric
);
597 case BFA_FCS_FABRIC_SM_NO_FABRIC
:
598 bfa_trc(fabric
->fcs
, fabric
->bb_credit
);
599 bfa_fcport_set_tx_bbcredit(fabric
->fcs
->bfa
,
603 case BFA_FCS_FABRIC_SM_RETRY_OP
:
607 bfa_sm_fault(fabric
->fcs
, event
);
612 * Fabric is online - normal operating state.
615 bfa_fcs_fabric_sm_online(struct bfa_fcs_fabric_s
*fabric
,
616 enum bfa_fcs_fabric_event event
)
618 struct bfa_s
*bfa
= fabric
->fcs
->bfa
;
620 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
621 bfa_trc(fabric
->fcs
, event
);
624 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
625 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_linkdown
);
626 if (bfa_fcport_get_topology(bfa
) == BFA_PORT_TOPOLOGY_LOOP
) {
627 bfa_fcs_lport_offline(&fabric
->bport
);
629 bfa_sm_send_event(fabric
->lps
, BFA_LPS_SM_OFFLINE
);
630 bfa_fcs_fabric_notify_offline(fabric
);
634 case BFA_FCS_FABRIC_SM_DELETE
:
635 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_deleting
);
636 bfa_fcs_fabric_delete(fabric
);
639 case BFA_FCS_FABRIC_SM_STOP
:
640 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_stopping
);
641 bfa_fcs_fabric_stop(fabric
);
644 case BFA_FCS_FABRIC_SM_AUTH_FAILED
:
645 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_auth_failed
);
646 bfa_sm_send_event(fabric
->lps
, BFA_LPS_SM_OFFLINE
);
649 case BFA_FCS_FABRIC_SM_AUTH_SUCCESS
:
653 bfa_sm_fault(fabric
->fcs
, event
);
658 * Exchanging virtual fabric parameters.
661 bfa_fcs_fabric_sm_evfp(struct bfa_fcs_fabric_s
*fabric
,
662 enum bfa_fcs_fabric_event event
)
664 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
665 bfa_trc(fabric
->fcs
, event
);
668 case BFA_FCS_FABRIC_SM_CONT_OP
:
669 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_evfp_done
);
672 case BFA_FCS_FABRIC_SM_ISOLATE
:
673 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_isolated
);
677 bfa_sm_fault(fabric
->fcs
, event
);
682 * EVFP exchange complete and VFT tagging is enabled.
685 bfa_fcs_fabric_sm_evfp_done(struct bfa_fcs_fabric_s
*fabric
,
686 enum bfa_fcs_fabric_event event
)
688 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
689 bfa_trc(fabric
->fcs
, event
);
693 * Port is isolated after EVFP exchange due to VF_ID mismatch (N and F).
696 bfa_fcs_fabric_sm_isolated(struct bfa_fcs_fabric_s
*fabric
,
697 enum bfa_fcs_fabric_event event
)
699 struct bfad_s
*bfad
= (struct bfad_s
*)fabric
->fcs
->bfad
;
700 char pwwn_ptr
[BFA_STRING_32
];
702 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
703 bfa_trc(fabric
->fcs
, event
);
704 wwn2str(pwwn_ptr
, fabric
->bport
.port_cfg
.pwwn
);
706 BFA_LOG(KERN_INFO
, bfad
, bfa_log_level
,
707 "Port is isolated due to VF_ID mismatch. "
708 "PWWN: %s Port VF_ID: %04x switch port VF_ID: %04x.",
709 pwwn_ptr
, fabric
->fcs
->port_vfid
,
710 fabric
->event_arg
.swp_vfid
);
714 * Fabric is being deleted, awaiting vport delete completions.
717 bfa_fcs_fabric_sm_deleting(struct bfa_fcs_fabric_s
*fabric
,
718 enum bfa_fcs_fabric_event event
)
720 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
721 bfa_trc(fabric
->fcs
, event
);
724 case BFA_FCS_FABRIC_SM_DELCOMP
:
725 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_uninit
);
726 bfa_wc_down(&fabric
->fcs
->wc
);
729 case BFA_FCS_FABRIC_SM_LINK_UP
:
732 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
733 bfa_fcs_fabric_notify_offline(fabric
);
737 bfa_sm_fault(fabric
->fcs
, event
);
742 * Fabric is being stopped, awaiting vport stop completions.
745 bfa_fcs_fabric_sm_stopping(struct bfa_fcs_fabric_s
*fabric
,
746 enum bfa_fcs_fabric_event event
)
748 struct bfa_s
*bfa
= fabric
->fcs
->bfa
;
750 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
751 bfa_trc(fabric
->fcs
, event
);
754 case BFA_FCS_FABRIC_SM_STOPCOMP
:
755 if (bfa_fcport_get_topology(bfa
) == BFA_PORT_TOPOLOGY_LOOP
) {
756 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_created
);
758 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_cleanup
);
759 bfa_sm_send_event(fabric
->lps
, BFA_LPS_SM_LOGOUT
);
763 case BFA_FCS_FABRIC_SM_LINK_UP
:
766 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
767 if (bfa_fcport_get_topology(bfa
) == BFA_PORT_TOPOLOGY_LOOP
)
768 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_created
);
770 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_cleanup
);
774 bfa_sm_fault(fabric
->fcs
, event
);
779 * Fabric is being stopped, cleanup without FLOGO
782 bfa_fcs_fabric_sm_cleanup(struct bfa_fcs_fabric_s
*fabric
,
783 enum bfa_fcs_fabric_event event
)
785 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
786 bfa_trc(fabric
->fcs
, event
);
789 case BFA_FCS_FABRIC_SM_STOPCOMP
:
790 case BFA_FCS_FABRIC_SM_LOGOCOMP
:
791 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_created
);
792 bfa_wc_down(&(fabric
->fcs
)->wc
);
795 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
797 * Ignore - can get this event if we get notified about IOC down
798 * before the fabric completion callbk is done.
803 bfa_sm_fault(fabric
->fcs
, event
);
808 * fcs_fabric_private fabric private functions
812 bfa_fcs_fabric_init(struct bfa_fcs_fabric_s
*fabric
)
814 struct bfa_lport_cfg_s
*port_cfg
= &fabric
->bport
.port_cfg
;
816 port_cfg
->roles
= BFA_LPORT_ROLE_FCP_IM
;
817 port_cfg
->nwwn
= fabric
->fcs
->bfa
->ioc
.attr
->nwwn
;
818 port_cfg
->pwwn
= fabric
->fcs
->bfa
->ioc
.attr
->pwwn
;
822 * Port Symbolic Name Creation for base port.
825 bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s
*fabric
)
827 struct bfa_lport_cfg_s
*port_cfg
= &fabric
->bport
.port_cfg
;
828 char model
[BFA_ADAPTER_MODEL_NAME_LEN
] = {0};
829 struct bfa_fcs_driver_info_s
*driver_info
= &fabric
->fcs
->driver_info
;
831 bfa_ioc_get_adapter_model(&fabric
->fcs
->bfa
->ioc
, model
);
833 /* Model name/number */
834 strncpy((char *)&port_cfg
->sym_name
, model
,
835 BFA_FCS_PORT_SYMBNAME_MODEL_SZ
);
836 strncat((char *)&port_cfg
->sym_name
, BFA_FCS_PORT_SYMBNAME_SEPARATOR
,
837 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR
));
840 strncat((char *)&port_cfg
->sym_name
, (char *)driver_info
->version
,
841 BFA_FCS_PORT_SYMBNAME_VERSION_SZ
);
842 strncat((char *)&port_cfg
->sym_name
, BFA_FCS_PORT_SYMBNAME_SEPARATOR
,
843 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR
));
845 /* Host machine name */
846 strncat((char *)&port_cfg
->sym_name
,
847 (char *)driver_info
->host_machine_name
,
848 BFA_FCS_PORT_SYMBNAME_MACHINENAME_SZ
);
849 strncat((char *)&port_cfg
->sym_name
, BFA_FCS_PORT_SYMBNAME_SEPARATOR
,
850 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR
));
854 * If OS Patch Info is not there, do not truncate any bytes from the
855 * OS name string and instead copy the entire OS info string (64 bytes).
857 if (driver_info
->host_os_patch
[0] == '\0') {
858 strncat((char *)&port_cfg
->sym_name
,
859 (char *)driver_info
->host_os_name
,
861 strncat((char *)&port_cfg
->sym_name
,
862 BFA_FCS_PORT_SYMBNAME_SEPARATOR
,
863 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR
));
865 strncat((char *)&port_cfg
->sym_name
,
866 (char *)driver_info
->host_os_name
,
867 BFA_FCS_PORT_SYMBNAME_OSINFO_SZ
);
868 strncat((char *)&port_cfg
->sym_name
,
869 BFA_FCS_PORT_SYMBNAME_SEPARATOR
,
870 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR
));
872 /* Append host OS Patch Info */
873 strncat((char *)&port_cfg
->sym_name
,
874 (char *)driver_info
->host_os_patch
,
875 BFA_FCS_PORT_SYMBNAME_OSPATCH_SZ
);
879 port_cfg
->sym_name
.symname
[BFA_SYMNAME_MAXLEN
- 1] = 0;
883 * Node Symbolic Name Creation for base port and all vports
886 bfa_fcs_fabric_nsymb_init(struct bfa_fcs_fabric_s
*fabric
)
888 struct bfa_lport_cfg_s
*port_cfg
= &fabric
->bport
.port_cfg
;
889 char model
[BFA_ADAPTER_MODEL_NAME_LEN
] = {0};
890 struct bfa_fcs_driver_info_s
*driver_info
= &fabric
->fcs
->driver_info
;
892 bfa_ioc_get_adapter_model(&fabric
->fcs
->bfa
->ioc
, model
);
894 /* Model name/number */
895 strncpy((char *)&port_cfg
->node_sym_name
, model
,
896 BFA_FCS_PORT_SYMBNAME_MODEL_SZ
);
897 strncat((char *)&port_cfg
->node_sym_name
,
898 BFA_FCS_PORT_SYMBNAME_SEPARATOR
,
899 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR
));
902 strncat((char *)&port_cfg
->node_sym_name
, (char *)driver_info
->version
,
903 BFA_FCS_PORT_SYMBNAME_VERSION_SZ
);
904 strncat((char *)&port_cfg
->node_sym_name
,
905 BFA_FCS_PORT_SYMBNAME_SEPARATOR
,
906 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR
));
908 /* Host machine name */
909 strncat((char *)&port_cfg
->node_sym_name
,
910 (char *)driver_info
->host_machine_name
,
911 BFA_FCS_PORT_SYMBNAME_MACHINENAME_SZ
);
912 strncat((char *)&port_cfg
->node_sym_name
,
913 BFA_FCS_PORT_SYMBNAME_SEPARATOR
,
914 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR
));
917 port_cfg
->node_sym_name
.symname
[BFA_SYMNAME_MAXLEN
- 1] = 0;
921 * bfa lps login completion callback
924 bfa_cb_lps_flogi_comp(void *bfad
, void *uarg
, bfa_status_t status
)
926 struct bfa_fcs_fabric_s
*fabric
= uarg
;
928 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
929 bfa_trc(fabric
->fcs
, status
);
933 fabric
->stats
.flogi_accepts
++;
936 case BFA_STATUS_INVALID_MAC
:
938 fabric
->stats
.flogi_acc_err
++;
939 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_RETRY_OP
);
943 case BFA_STATUS_EPROTOCOL
:
944 switch (fabric
->lps
->ext_status
) {
945 case BFA_EPROTO_BAD_ACCEPT
:
946 fabric
->stats
.flogi_acc_err
++;
949 case BFA_EPROTO_UNKNOWN_RSP
:
950 fabric
->stats
.flogi_unknown_rsp
++;
956 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_RETRY_OP
);
960 case BFA_STATUS_FABRIC_RJT
:
961 fabric
->stats
.flogi_rejects
++;
962 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_RETRY_OP
);
966 fabric
->stats
.flogi_rsp_err
++;
967 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_RETRY_OP
);
971 fabric
->bb_credit
= fabric
->lps
->pr_bbcred
;
972 bfa_trc(fabric
->fcs
, fabric
->bb_credit
);
974 if (!(fabric
->lps
->brcd_switch
))
975 fabric
->fabric_name
= fabric
->lps
->pr_nwwn
;
978 * Check port type. It should be 1 = F-port.
980 if (fabric
->lps
->fport
) {
981 fabric
->bport
.pid
= fabric
->lps
->lp_pid
;
982 fabric
->is_npiv
= fabric
->lps
->npiv_en
;
983 fabric
->is_auth
= fabric
->lps
->auth_req
;
984 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_CONT_OP
);
987 * Nport-2-Nport direct attached
989 fabric
->bport
.port_topo
.pn2n
.rem_port_wwn
=
990 fabric
->lps
->pr_pwwn
;
991 fabric
->fab_type
= BFA_FCS_FABRIC_N2N
;
992 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_NO_FABRIC
);
995 bfa_trc(fabric
->fcs
, fabric
->bport
.pid
);
996 bfa_trc(fabric
->fcs
, fabric
->is_npiv
);
997 bfa_trc(fabric
->fcs
, fabric
->is_auth
);
1000 * Allocate and send FLOGI.
1003 bfa_fcs_fabric_login(struct bfa_fcs_fabric_s
*fabric
)
1005 struct bfa_s
*bfa
= fabric
->fcs
->bfa
;
1006 struct bfa_lport_cfg_s
*pcfg
= &fabric
->bport
.port_cfg
;
1010 bfa_lps_flogi(fabric
->lps
, fabric
, alpa
, bfa_fcport_get_maxfrsize(bfa
),
1011 pcfg
->pwwn
, pcfg
->nwwn
, fabric
->auth_reqd
);
1013 fabric
->stats
.flogi_sent
++;
1017 bfa_fcs_fabric_notify_online(struct bfa_fcs_fabric_s
*fabric
)
1019 struct bfa_fcs_vport_s
*vport
;
1020 struct list_head
*qe
, *qen
;
1022 bfa_trc(fabric
->fcs
, fabric
->fabric_name
);
1024 bfa_fcs_fabric_set_opertype(fabric
);
1025 fabric
->stats
.fabric_onlines
++;
1028 * notify online event to base and then virtual ports
1030 bfa_fcs_lport_online(&fabric
->bport
);
1032 list_for_each_safe(qe
, qen
, &fabric
->vport_q
) {
1033 vport
= (struct bfa_fcs_vport_s
*) qe
;
1034 bfa_fcs_vport_online(vport
);
1039 bfa_fcs_fabric_notify_offline(struct bfa_fcs_fabric_s
*fabric
)
1041 struct bfa_fcs_vport_s
*vport
;
1042 struct list_head
*qe
, *qen
;
1044 bfa_trc(fabric
->fcs
, fabric
->fabric_name
);
1045 fabric
->stats
.fabric_offlines
++;
1048 * notify offline event first to vports and then base port.
1050 list_for_each_safe(qe
, qen
, &fabric
->vport_q
) {
1051 vport
= (struct bfa_fcs_vport_s
*) qe
;
1052 bfa_fcs_vport_offline(vport
);
1055 bfa_fcs_lport_offline(&fabric
->bport
);
1057 fabric
->fabric_name
= 0;
1058 fabric
->fabric_ip_addr
[0] = 0;
1062 bfa_fcs_fabric_delay(void *cbarg
)
1064 struct bfa_fcs_fabric_s
*fabric
= cbarg
;
1066 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_DELAYED
);
1070 * Stop all vports and wait for vport stop completions.
1073 bfa_fcs_fabric_stop(struct bfa_fcs_fabric_s
*fabric
)
1075 struct bfa_fcs_vport_s
*vport
;
1076 struct list_head
*qe
, *qen
;
1078 bfa_wc_init(&fabric
->stop_wc
, bfa_fcs_fabric_stop_comp
, fabric
);
1080 list_for_each_safe(qe
, qen
, &fabric
->vport_q
) {
1081 vport
= (struct bfa_fcs_vport_s
*) qe
;
1082 bfa_wc_up(&fabric
->stop_wc
);
1083 bfa_fcs_vport_fcs_stop(vport
);
1086 bfa_wc_up(&fabric
->stop_wc
);
1087 bfa_fcs_lport_stop(&fabric
->bport
);
1088 bfa_wc_wait(&fabric
->stop_wc
);
1092 * Delete all vports and wait for vport delete completions.
1095 bfa_fcs_fabric_delete(struct bfa_fcs_fabric_s
*fabric
)
1097 struct bfa_fcs_vport_s
*vport
;
1098 struct list_head
*qe
, *qen
;
1100 list_for_each_safe(qe
, qen
, &fabric
->vport_q
) {
1101 vport
= (struct bfa_fcs_vport_s
*) qe
;
1102 bfa_fcs_vport_fcs_delete(vport
);
1105 bfa_fcs_lport_delete(&fabric
->bport
);
1106 bfa_wc_wait(&fabric
->wc
);
1110 bfa_fcs_fabric_delete_comp(void *cbarg
)
1112 struct bfa_fcs_fabric_s
*fabric
= cbarg
;
1114 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_DELCOMP
);
1118 bfa_fcs_fabric_stop_comp(void *cbarg
)
1120 struct bfa_fcs_fabric_s
*fabric
= cbarg
;
1122 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_STOPCOMP
);
1126 * fcs_fabric_public fabric public functions
1130 * Attach time initialization.
1133 bfa_fcs_fabric_attach(struct bfa_fcs_s
*fcs
)
1135 struct bfa_fcs_fabric_s
*fabric
;
1137 fabric
= &fcs
->fabric
;
1138 memset(fabric
, 0, sizeof(struct bfa_fcs_fabric_s
));
1141 * Initialize base fabric.
1144 INIT_LIST_HEAD(&fabric
->vport_q
);
1145 INIT_LIST_HEAD(&fabric
->vf_q
);
1146 fabric
->lps
= bfa_lps_alloc(fcs
->bfa
);
1147 WARN_ON(!fabric
->lps
);
1150 * Initialize fabric delete completion handler. Fabric deletion is
1151 * complete when the last vport delete is complete.
1153 bfa_wc_init(&fabric
->wc
, bfa_fcs_fabric_delete_comp
, fabric
);
1154 bfa_wc_up(&fabric
->wc
); /* For the base port */
1156 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_uninit
);
1157 bfa_fcs_lport_attach(&fabric
->bport
, fabric
->fcs
, FC_VF_ID_NULL
, NULL
);
1161 bfa_fcs_fabric_modinit(struct bfa_fcs_s
*fcs
)
1163 bfa_sm_send_event(&fcs
->fabric
, BFA_FCS_FABRIC_SM_CREATE
);
1171 bfa_fcs_fabric_modexit(struct bfa_fcs_s
*fcs
)
1173 struct bfa_fcs_fabric_s
*fabric
;
1178 * Cleanup base fabric.
1180 fabric
= &fcs
->fabric
;
1181 bfa_lps_delete(fabric
->lps
);
1182 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_DELETE
);
1186 * Fabric module stop -- stop FCS actions
1189 bfa_fcs_fabric_modstop(struct bfa_fcs_s
*fcs
)
1191 struct bfa_fcs_fabric_s
*fabric
;
1194 fabric
= &fcs
->fabric
;
1195 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_STOP
);
1199 * Fabric module start -- kick starts FCS actions
1202 bfa_fcs_fabric_modstart(struct bfa_fcs_s
*fcs
)
1204 struct bfa_fcs_fabric_s
*fabric
;
1207 fabric
= &fcs
->fabric
;
1208 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_START
);
1213 * Link up notification from BFA physical port module.
1216 bfa_fcs_fabric_link_up(struct bfa_fcs_fabric_s
*fabric
)
1218 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
1219 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_LINK_UP
);
1223 * Link down notification from BFA physical port module.
1226 bfa_fcs_fabric_link_down(struct bfa_fcs_fabric_s
*fabric
)
1228 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
1229 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_LINK_DOWN
);
1233 * A child vport is being created in the fabric.
1235 * Call from vport module at vport creation. A list of base port and vports
1236 * belonging to a fabric is maintained to propagate link events.
1238 * param[in] fabric - Fabric instance. This can be a base fabric or vf.
1239 * param[in] vport - Vport being created.
1241 * @return None (always succeeds)
1244 bfa_fcs_fabric_addvport(struct bfa_fcs_fabric_s
*fabric
,
1245 struct bfa_fcs_vport_s
*vport
)
1248 * - add vport to fabric's vport_q
1250 bfa_trc(fabric
->fcs
, fabric
->vf_id
);
1252 list_add_tail(&vport
->qe
, &fabric
->vport_q
);
1253 fabric
->num_vports
++;
1254 bfa_wc_up(&fabric
->wc
);
1258 * A child vport is being deleted from fabric.
1260 * Vport is being deleted.
1263 bfa_fcs_fabric_delvport(struct bfa_fcs_fabric_s
*fabric
,
1264 struct bfa_fcs_vport_s
*vport
)
1266 list_del(&vport
->qe
);
1267 fabric
->num_vports
--;
1268 bfa_wc_down(&fabric
->wc
);
1273 * Lookup for a vport within a fabric given its pwwn
1275 struct bfa_fcs_vport_s
*
1276 bfa_fcs_fabric_vport_lookup(struct bfa_fcs_fabric_s
*fabric
, wwn_t pwwn
)
1278 struct bfa_fcs_vport_s
*vport
;
1279 struct list_head
*qe
;
1281 list_for_each(qe
, &fabric
->vport_q
) {
1282 vport
= (struct bfa_fcs_vport_s
*) qe
;
1283 if (bfa_fcs_lport_get_pwwn(&vport
->lport
) == pwwn
)
1292 * Get OUI of the attached switch.
1294 * Note : Use of this function should be avoided as much as possible.
1295 * This function should be used only if there is any requirement
1296 * to check for FOS version below 6.3.
1297 * To check if the attached fabric is a brocade fabric, use
1298 * bfa_lps_is_brcd_fabric() which works for FOS versions 6.3
1303 bfa_fcs_fabric_get_switch_oui(struct bfa_fcs_fabric_s
*fabric
)
1309 fab_nwwn
= fabric
->lps
->pr_nwwn
;
1311 tmp
= (u8
*)&fab_nwwn
;
1312 oui
= (tmp
[3] << 8) | tmp
[4];
1317 * Unsolicited frame receive handling.
1320 bfa_fcs_fabric_uf_recv(struct bfa_fcs_fabric_s
*fabric
, struct fchs_s
*fchs
,
1323 u32 pid
= fchs
->d_id
;
1324 struct bfa_fcs_vport_s
*vport
;
1325 struct list_head
*qe
;
1326 struct fc_els_cmd_s
*els_cmd
= (struct fc_els_cmd_s
*) (fchs
+ 1);
1327 struct fc_logi_s
*flogi
= (struct fc_logi_s
*) els_cmd
;
1329 bfa_trc(fabric
->fcs
, len
);
1330 bfa_trc(fabric
->fcs
, pid
);
1333 * Look for our own FLOGI frames being looped back. This means an
1334 * external loopback cable is in place. Our own FLOGI frames are
1335 * sometimes looped back when switch port gets temporarily bypassed.
1337 if ((pid
== bfa_ntoh3b(FC_FABRIC_PORT
)) &&
1338 (els_cmd
->els_code
== FC_ELS_FLOGI
) &&
1339 (flogi
->port_name
== bfa_fcs_lport_get_pwwn(&fabric
->bport
))) {
1340 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_LOOPBACK
);
1345 * FLOGI/EVFP exchanges should be consumed by base fabric.
1347 if (fchs
->d_id
== bfa_hton3b(FC_FABRIC_PORT
)) {
1348 bfa_trc(fabric
->fcs
, pid
);
1349 bfa_fcs_fabric_process_uf(fabric
, fchs
, len
);
1353 if (fabric
->bport
.pid
== pid
) {
1355 * All authentication frames should be routed to auth
1357 bfa_trc(fabric
->fcs
, els_cmd
->els_code
);
1358 if (els_cmd
->els_code
== FC_ELS_AUTH
) {
1359 bfa_trc(fabric
->fcs
, els_cmd
->els_code
);
1363 bfa_trc(fabric
->fcs
, *(u8
*) ((u8
*) fchs
));
1364 bfa_fcs_lport_uf_recv(&fabric
->bport
, fchs
, len
);
1369 * look for a matching local port ID
1371 list_for_each(qe
, &fabric
->vport_q
) {
1372 vport
= (struct bfa_fcs_vport_s
*) qe
;
1373 if (vport
->lport
.pid
== pid
) {
1374 bfa_fcs_lport_uf_recv(&vport
->lport
, fchs
, len
);
1379 if (!bfa_fcs_fabric_is_switched(fabric
))
1380 bfa_fcs_lport_uf_recv(&fabric
->bport
, fchs
, len
);
1382 bfa_trc(fabric
->fcs
, fchs
->type
);
1386 * Unsolicited frames to be processed by fabric.
1389 bfa_fcs_fabric_process_uf(struct bfa_fcs_fabric_s
*fabric
, struct fchs_s
*fchs
,
1392 struct fc_els_cmd_s
*els_cmd
= (struct fc_els_cmd_s
*) (fchs
+ 1);
1394 bfa_trc(fabric
->fcs
, els_cmd
->els_code
);
1396 switch (els_cmd
->els_code
) {
1398 bfa_fcs_fabric_process_flogi(fabric
, fchs
, len
);
1403 * need to generate a LS_RJT
1410 * Process incoming FLOGI
1413 bfa_fcs_fabric_process_flogi(struct bfa_fcs_fabric_s
*fabric
,
1414 struct fchs_s
*fchs
, u16 len
)
1416 struct fc_logi_s
*flogi
= (struct fc_logi_s
*) (fchs
+ 1);
1417 struct bfa_fcs_lport_s
*bport
= &fabric
->bport
;
1419 bfa_trc(fabric
->fcs
, fchs
->s_id
);
1421 fabric
->stats
.flogi_rcvd
++;
1423 * Check port type. It should be 0 = n-port.
1425 if (flogi
->csp
.port_type
) {
1427 * @todo: may need to send a LS_RJT
1429 bfa_trc(fabric
->fcs
, flogi
->port_name
);
1430 fabric
->stats
.flogi_rejected
++;
1434 fabric
->bb_credit
= be16_to_cpu(flogi
->csp
.bbcred
);
1435 bport
->port_topo
.pn2n
.rem_port_wwn
= flogi
->port_name
;
1436 bport
->port_topo
.pn2n
.reply_oxid
= fchs
->ox_id
;
1441 bfa_fcs_fabric_send_flogi_acc(fabric
);
1442 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_NO_FABRIC
);
1446 bfa_fcs_fabric_send_flogi_acc(struct bfa_fcs_fabric_s
*fabric
)
1448 struct bfa_lport_cfg_s
*pcfg
= &fabric
->bport
.port_cfg
;
1449 struct bfa_fcs_lport_n2n_s
*n2n_port
= &fabric
->bport
.port_topo
.pn2n
;
1450 struct bfa_s
*bfa
= fabric
->fcs
->bfa
;
1451 struct bfa_fcxp_s
*fcxp
;
1455 fcxp
= bfa_fcs_fcxp_alloc(fabric
->fcs
, BFA_FALSE
);
1457 * Do not expect this failure -- expect remote node to retry
1462 reqlen
= fc_flogi_acc_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
1463 bfa_hton3b(FC_FABRIC_PORT
),
1464 n2n_port
->reply_oxid
, pcfg
->pwwn
,
1466 bfa_fcport_get_maxfrsize(bfa
),
1467 bfa_fcport_get_rx_bbcredit(bfa
), 0);
1469 bfa_fcxp_send(fcxp
, NULL
, fabric
->vf_id
, fabric
->lps
->bfa_tag
,
1470 BFA_FALSE
, FC_CLASS_3
,
1471 reqlen
, &fchs
, bfa_fcs_fabric_flogiacc_comp
, fabric
,
1476 * Flogi Acc completion callback.
1479 bfa_fcs_fabric_flogiacc_comp(void *fcsarg
, struct bfa_fcxp_s
*fcxp
, void *cbarg
,
1480 bfa_status_t status
, u32 rsp_len
,
1481 u32 resid_len
, struct fchs_s
*rspfchs
)
1483 struct bfa_fcs_fabric_s
*fabric
= cbarg
;
1485 bfa_trc(fabric
->fcs
, status
);
1490 * Send AEN notification
1493 bfa_fcs_fabric_aen_post(struct bfa_fcs_lport_s
*port
,
1494 enum bfa_port_aen_event event
)
1496 struct bfad_s
*bfad
= (struct bfad_s
*)port
->fabric
->fcs
->bfad
;
1497 struct bfa_aen_entry_s
*aen_entry
;
1499 bfad_get_aen_entry(bfad
, aen_entry
);
1503 aen_entry
->aen_data
.port
.pwwn
= bfa_fcs_lport_get_pwwn(port
);
1504 aen_entry
->aen_data
.port
.fwwn
= bfa_fcs_lport_get_fabric_name(port
);
1506 /* Send the AEN notification */
1507 bfad_im_post_vendor_event(aen_entry
, bfad
, ++port
->fcs
->fcs_aen_seq
,
1508 BFA_AEN_CAT_PORT
, event
);
1513 * @param[in] fabric - fabric
1514 * @param[in] wwn_t - new fabric name
1519 bfa_fcs_fabric_set_fabric_name(struct bfa_fcs_fabric_s
*fabric
,
1522 struct bfad_s
*bfad
= (struct bfad_s
*)fabric
->fcs
->bfad
;
1523 char pwwn_ptr
[BFA_STRING_32
];
1524 char fwwn_ptr
[BFA_STRING_32
];
1526 bfa_trc(fabric
->fcs
, fabric_name
);
1528 if (fabric
->fabric_name
== 0) {
1530 * With BRCD switches, we don't get Fabric Name in FLOGI.
1531 * Don't generate a fabric name change event in this case.
1533 fabric
->fabric_name
= fabric_name
;
1535 fabric
->fabric_name
= fabric_name
;
1536 wwn2str(pwwn_ptr
, bfa_fcs_lport_get_pwwn(&fabric
->bport
));
1538 bfa_fcs_lport_get_fabric_name(&fabric
->bport
));
1539 BFA_LOG(KERN_WARNING
, bfad
, bfa_log_level
,
1540 "Base port WWN = %s Fabric WWN = %s\n",
1541 pwwn_ptr
, fwwn_ptr
);
1542 bfa_fcs_fabric_aen_post(&fabric
->bport
,
1543 BFA_PORT_AEN_FABRIC_NAME_CHANGE
);
1548 bfa_cb_lps_flogo_comp(void *bfad
, void *uarg
)
1550 struct bfa_fcs_fabric_s
*fabric
= uarg
;
1551 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_LOGOCOMP
);
1555 * Returns FCS vf structure for a given vf_id.
1557 * param[in] vf_id - VF_ID
1560 * If lookup succeeds, retuns fcs vf object, otherwise returns NULL
1563 bfa_fcs_vf_lookup(struct bfa_fcs_s
*fcs
, u16 vf_id
)
1565 bfa_trc(fcs
, vf_id
);
1566 if (vf_id
== FC_VF_ID_NULL
)
1567 return &fcs
->fabric
;
1573 * Return the list of local logical ports present in the given VF.
1575 * @param[in] vf vf for which logical ports are returned
1576 * @param[out] lpwwn returned logical port wwn list
1577 * @param[in,out] nlports in:size of lpwwn list;
1578 * out:total elements present,
1579 * actual elements returned is limited by the size
1582 bfa_fcs_vf_get_ports(bfa_fcs_vf_t
*vf
, wwn_t lpwwn
[], int *nlports
)
1584 struct list_head
*qe
;
1585 struct bfa_fcs_vport_s
*vport
;
1587 struct bfa_fcs_s
*fcs
;
1589 if (vf
== NULL
|| lpwwn
== NULL
|| *nlports
== 0)
1594 bfa_trc(fcs
, vf
->vf_id
);
1595 bfa_trc(fcs
, (uint32_t) *nlports
);
1597 lpwwn
[i
++] = vf
->bport
.port_cfg
.pwwn
;
1599 list_for_each(qe
, &vf
->vport_q
) {
1603 vport
= (struct bfa_fcs_vport_s
*) qe
;
1604 lpwwn
[i
++] = vport
->lport
.port_cfg
.pwwn
;
1612 * BFA FCS PPORT ( physical port)
1615 bfa_fcs_port_event_handler(void *cbarg
, enum bfa_port_linkstate event
)
1617 struct bfa_fcs_s
*fcs
= cbarg
;
1619 bfa_trc(fcs
, event
);
1622 case BFA_PORT_LINKUP
:
1623 bfa_fcs_fabric_link_up(&fcs
->fabric
);
1626 case BFA_PORT_LINKDOWN
:
1627 bfa_fcs_fabric_link_down(&fcs
->fabric
);
1636 bfa_fcs_port_attach(struct bfa_fcs_s
*fcs
)
1638 bfa_fcport_event_register(fcs
->bfa
, bfa_fcs_port_event_handler
, fcs
);
1642 * BFA FCS UF ( Unsolicited Frames)
1646 * BFA callback for unsolicited frame receive handler.
1648 * @param[in] cbarg callback arg for receive handler
1649 * @param[in] uf unsolicited frame descriptor
1654 bfa_fcs_uf_recv(void *cbarg
, struct bfa_uf_s
*uf
)
1656 struct bfa_fcs_s
*fcs
= (struct bfa_fcs_s
*) cbarg
;
1657 struct fchs_s
*fchs
= bfa_uf_get_frmbuf(uf
);
1658 u16 len
= bfa_uf_get_frmlen(uf
);
1659 struct fc_vft_s
*vft
;
1660 struct bfa_fcs_fabric_s
*fabric
;
1663 * check for VFT header
1665 if (fchs
->routing
== FC_RTG_EXT_HDR
&&
1666 fchs
->cat_info
== FC_CAT_VFT_HDR
) {
1667 bfa_stats(fcs
, uf
.tagged
);
1668 vft
= bfa_uf_get_frmbuf(uf
);
1669 if (fcs
->port_vfid
== vft
->vf_id
)
1670 fabric
= &fcs
->fabric
;
1672 fabric
= bfa_fcs_vf_lookup(fcs
, (u16
) vft
->vf_id
);
1675 * drop frame if vfid is unknown
1679 bfa_stats(fcs
, uf
.vfid_unknown
);
1687 fchs
= (struct fchs_s
*) (vft
+ 1);
1688 len
-= sizeof(struct fc_vft_s
);
1690 bfa_trc(fcs
, vft
->vf_id
);
1692 bfa_stats(fcs
, uf
.untagged
);
1693 fabric
= &fcs
->fabric
;
1696 bfa_trc(fcs
, ((u32
*) fchs
)[0]);
1697 bfa_trc(fcs
, ((u32
*) fchs
)[1]);
1698 bfa_trc(fcs
, ((u32
*) fchs
)[2]);
1699 bfa_trc(fcs
, ((u32
*) fchs
)[3]);
1700 bfa_trc(fcs
, ((u32
*) fchs
)[4]);
1701 bfa_trc(fcs
, ((u32
*) fchs
)[5]);
1704 bfa_fcs_fabric_uf_recv(fabric
, fchs
, len
);
1709 bfa_fcs_uf_attach(struct bfa_fcs_s
*fcs
)
1711 bfa_uf_recv_register(fcs
->bfa
, bfa_fcs_uf_recv
, fcs
);