1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
4 * Copyright (c) 2014- QLogic Corporation.
8 * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
12 * bfa_fcs.c BFA FCS main
18 #include "bfa_fcbuild.h"
20 BFA_TRC_FILE(FCS
, FCS
);
27 bfa_fcs_exit_comp(void *fcs_cbarg
)
29 struct bfa_fcs_s
*fcs
= fcs_cbarg
;
30 struct bfad_s
*bfad
= fcs
->bfad
;
32 complete(&bfad
->comp
);
36 * fcs initialization, called once after bfa initialization is complete
39 bfa_fcs_init(struct bfa_fcs_s
*fcs
)
41 bfa_sm_send_event(&fcs
->fabric
, BFA_FCS_FABRIC_SM_CREATE
);
50 * FCS update cfg - reset the pwwn/nwwn of fabric base logical port
51 * with values learned during bfa_init firmware GETATTR REQ.
54 bfa_fcs_update_cfg(struct bfa_fcs_s
*fcs
)
56 struct bfa_fcs_fabric_s
*fabric
= &fcs
->fabric
;
57 struct bfa_lport_cfg_s
*port_cfg
= &fabric
->bport
.port_cfg
;
58 struct bfa_ioc_s
*ioc
= &fabric
->fcs
->bfa
->ioc
;
60 port_cfg
->nwwn
= ioc
->attr
->nwwn
;
61 port_cfg
->pwwn
= ioc
->attr
->pwwn
;
65 * Stop FCS operations.
68 bfa_fcs_stop(struct bfa_fcs_s
*fcs
)
70 bfa_wc_init(&fcs
->wc
, bfa_fcs_exit_comp
, fcs
);
72 bfa_fcs_fabric_modstop(fcs
);
73 bfa_wc_wait(&fcs
->wc
);
77 * fcs pbc vport initialization
80 bfa_fcs_pbc_vport_init(struct bfa_fcs_s
*fcs
)
83 struct bfi_pbc_vport_s pbc_vports
[BFI_PBC_MAX_VPORTS
];
85 /* Initialize pbc vports */
88 bfa_iocfc_get_pbc_vports(fcs
->bfa
, pbc_vports
);
89 for (i
= 0; i
< npbc_vports
; i
++)
90 bfa_fcb_pbc_vport_create(fcs
->bfa
->bfad
, pbc_vports
[i
]);
96 * FCS driver details initialization.
98 * param[in] fcs FCS instance
99 * param[in] driver_info Driver Details
104 bfa_fcs_driver_info_init(struct bfa_fcs_s
*fcs
,
105 struct bfa_fcs_driver_info_s
*driver_info
)
108 fcs
->driver_info
= *driver_info
;
110 bfa_fcs_fabric_psymb_init(&fcs
->fabric
);
111 bfa_fcs_fabric_nsymb_init(&fcs
->fabric
);
116 * FCS instance cleanup and exit.
118 * param[in] fcs FCS instance
122 bfa_fcs_exit(struct bfa_fcs_s
*fcs
)
124 bfa_wc_init(&fcs
->wc
, bfa_fcs_exit_comp
, fcs
);
127 bfa_lps_delete(fcs
->fabric
.lps
);
128 bfa_sm_send_event(&fcs
->fabric
, BFA_FCS_FABRIC_SM_DELETE
);
129 bfa_wc_wait(&fcs
->wc
);
133 * Fabric module implementation.
136 #define BFA_FCS_FABRIC_RETRY_DELAY (2000) /* Milliseconds */
137 #define BFA_FCS_FABRIC_CLEANUP_DELAY (10000) /* Milliseconds */
139 #define bfa_fcs_fabric_set_opertype(__fabric) do { \
140 if (bfa_fcport_get_topology((__fabric)->fcs->bfa) \
141 == BFA_PORT_TOPOLOGY_P2P) { \
142 if (fabric->fab_type == BFA_FCS_FABRIC_SWITCHED) \
143 (__fabric)->oper_type = BFA_PORT_TYPE_NPORT; \
145 (__fabric)->oper_type = BFA_PORT_TYPE_P2P; \
147 (__fabric)->oper_type = BFA_PORT_TYPE_NLPORT; \
151 * forward declarations
153 static void bfa_fcs_fabric_init(struct bfa_fcs_fabric_s
*fabric
);
154 static void bfa_fcs_fabric_login(struct bfa_fcs_fabric_s
*fabric
);
155 static void bfa_fcs_fabric_notify_online(struct bfa_fcs_fabric_s
*fabric
);
156 static void bfa_fcs_fabric_notify_offline(struct bfa_fcs_fabric_s
*fabric
);
157 static void bfa_fcs_fabric_delay(void *cbarg
);
158 static void bfa_fcs_fabric_delete(struct bfa_fcs_fabric_s
*fabric
);
159 static void bfa_fcs_fabric_delete_comp(void *cbarg
);
160 static void bfa_fcs_fabric_stop(struct bfa_fcs_fabric_s
*fabric
);
161 static void bfa_fcs_fabric_stop_comp(void *cbarg
);
162 static void bfa_fcs_fabric_process_uf(struct bfa_fcs_fabric_s
*fabric
,
163 struct fchs_s
*fchs
, u16 len
);
164 static void bfa_fcs_fabric_process_flogi(struct bfa_fcs_fabric_s
*fabric
,
165 struct fchs_s
*fchs
, u16 len
);
166 static void bfa_fcs_fabric_send_flogi_acc(struct bfa_fcs_fabric_s
*fabric
);
167 static void bfa_fcs_fabric_flogiacc_comp(void *fcsarg
,
168 struct bfa_fcxp_s
*fcxp
, void *cbarg
,
172 struct fchs_s
*rspfchs
);
174 static void bfa_fcs_fabric_sm_uninit(struct bfa_fcs_fabric_s
*fabric
,
175 enum bfa_fcs_fabric_event event
);
176 static void bfa_fcs_fabric_sm_created(struct bfa_fcs_fabric_s
*fabric
,
177 enum bfa_fcs_fabric_event event
);
178 static void bfa_fcs_fabric_sm_linkdown(struct bfa_fcs_fabric_s
*fabric
,
179 enum bfa_fcs_fabric_event event
);
180 static void bfa_fcs_fabric_sm_flogi(struct bfa_fcs_fabric_s
*fabric
,
181 enum bfa_fcs_fabric_event event
);
182 static void bfa_fcs_fabric_sm_flogi_retry(struct bfa_fcs_fabric_s
*fabric
,
183 enum bfa_fcs_fabric_event event
);
184 static void bfa_fcs_fabric_sm_auth(struct bfa_fcs_fabric_s
*fabric
,
185 enum bfa_fcs_fabric_event event
);
186 static void bfa_fcs_fabric_sm_nofabric(struct bfa_fcs_fabric_s
*fabric
,
187 enum bfa_fcs_fabric_event event
);
188 static void bfa_fcs_fabric_sm_evfp(struct bfa_fcs_fabric_s
*fabric
,
189 enum bfa_fcs_fabric_event event
);
190 static void bfa_fcs_fabric_sm_evfp_done(struct bfa_fcs_fabric_s
*fabric
,
191 enum bfa_fcs_fabric_event event
);
192 static void bfa_fcs_fabric_sm_isolated(struct bfa_fcs_fabric_s
*fabric
,
193 enum bfa_fcs_fabric_event event
);
194 static void bfa_fcs_fabric_sm_deleting(struct bfa_fcs_fabric_s
*fabric
,
195 enum bfa_fcs_fabric_event event
);
196 static void bfa_fcs_fabric_sm_stopping(struct bfa_fcs_fabric_s
*fabric
,
197 enum bfa_fcs_fabric_event event
);
198 static void bfa_fcs_fabric_sm_cleanup(struct bfa_fcs_fabric_s
*fabric
,
199 enum bfa_fcs_fabric_event event
);
201 * Beginning state before fabric creation.
204 bfa_fcs_fabric_sm_uninit(struct bfa_fcs_fabric_s
*fabric
,
205 enum bfa_fcs_fabric_event event
)
207 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
208 bfa_trc(fabric
->fcs
, event
);
211 case BFA_FCS_FABRIC_SM_CREATE
:
212 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_created
);
213 bfa_fcs_fabric_init(fabric
);
214 bfa_fcs_lport_init(&fabric
->bport
, &fabric
->bport
.port_cfg
);
217 case BFA_FCS_FABRIC_SM_LINK_UP
:
218 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
222 bfa_sm_fault(fabric
->fcs
, event
);
227 * Beginning state before fabric creation.
230 bfa_fcs_fabric_sm_created(struct bfa_fcs_fabric_s
*fabric
,
231 enum bfa_fcs_fabric_event event
)
233 struct bfa_s
*bfa
= fabric
->fcs
->bfa
;
235 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
236 bfa_trc(fabric
->fcs
, event
);
239 case BFA_FCS_FABRIC_SM_START
:
240 if (!bfa_fcport_is_linkup(fabric
->fcs
->bfa
)) {
241 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_linkdown
);
244 if (bfa_fcport_get_topology(bfa
) ==
245 BFA_PORT_TOPOLOGY_LOOP
) {
246 fabric
->fab_type
= BFA_FCS_FABRIC_LOOP
;
247 fabric
->bport
.pid
= bfa_fcport_get_myalpa(bfa
);
248 fabric
->bport
.pid
= bfa_hton3b(fabric
->bport
.pid
);
249 bfa_sm_set_state(fabric
,
250 bfa_fcs_fabric_sm_online
);
251 bfa_fcs_fabric_set_opertype(fabric
);
252 bfa_fcs_lport_online(&fabric
->bport
);
254 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_flogi
);
255 bfa_fcs_fabric_login(fabric
);
259 case BFA_FCS_FABRIC_SM_LINK_UP
:
260 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
263 case BFA_FCS_FABRIC_SM_DELETE
:
264 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_deleting
);
265 bfa_fcs_fabric_delete(fabric
);
269 bfa_sm_fault(fabric
->fcs
, event
);
274 * Link is down, awaiting LINK UP event from port. This is also the
275 * first state at fabric creation.
278 bfa_fcs_fabric_sm_linkdown(struct bfa_fcs_fabric_s
*fabric
,
279 enum bfa_fcs_fabric_event event
)
281 struct bfa_s
*bfa
= fabric
->fcs
->bfa
;
283 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
284 bfa_trc(fabric
->fcs
, event
);
287 case BFA_FCS_FABRIC_SM_LINK_UP
:
288 if (bfa_fcport_get_topology(bfa
) != BFA_PORT_TOPOLOGY_LOOP
) {
289 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_flogi
);
290 bfa_fcs_fabric_login(fabric
);
293 fabric
->fab_type
= BFA_FCS_FABRIC_LOOP
;
294 fabric
->bport
.pid
= bfa_fcport_get_myalpa(bfa
);
295 fabric
->bport
.pid
= bfa_hton3b(fabric
->bport
.pid
);
296 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_online
);
297 bfa_fcs_fabric_set_opertype(fabric
);
298 bfa_fcs_lport_online(&fabric
->bport
);
301 case BFA_FCS_FABRIC_SM_RETRY_OP
:
302 case BFA_FCS_FABRIC_SM_LOOPBACK
:
305 case BFA_FCS_FABRIC_SM_DELETE
:
306 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_deleting
);
307 bfa_fcs_fabric_delete(fabric
);
310 case BFA_FCS_FABRIC_SM_STOP
:
311 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_cleanup
);
312 bfa_fcs_fabric_stop(fabric
);
316 bfa_sm_fault(fabric
->fcs
, event
);
321 * FLOGI is in progress, awaiting FLOGI reply.
324 bfa_fcs_fabric_sm_flogi(struct bfa_fcs_fabric_s
*fabric
,
325 enum bfa_fcs_fabric_event event
)
327 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
328 bfa_trc(fabric
->fcs
, event
);
331 case BFA_FCS_FABRIC_SM_CONT_OP
:
333 bfa_fcport_set_tx_bbcredit(fabric
->fcs
->bfa
,
335 fabric
->fab_type
= BFA_FCS_FABRIC_SWITCHED
;
337 if (fabric
->auth_reqd
&& fabric
->is_auth
) {
338 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_auth
);
339 bfa_trc(fabric
->fcs
, event
);
341 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_online
);
342 bfa_fcs_fabric_notify_online(fabric
);
346 case BFA_FCS_FABRIC_SM_RETRY_OP
:
347 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_flogi_retry
);
348 bfa_timer_start(fabric
->fcs
->bfa
, &fabric
->delay_timer
,
349 bfa_fcs_fabric_delay
, fabric
,
350 BFA_FCS_FABRIC_RETRY_DELAY
);
353 case BFA_FCS_FABRIC_SM_LOOPBACK
:
354 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_loopback
);
355 bfa_sm_send_event(fabric
->lps
, BFA_LPS_SM_OFFLINE
);
356 bfa_fcs_fabric_set_opertype(fabric
);
359 case BFA_FCS_FABRIC_SM_NO_FABRIC
:
360 fabric
->fab_type
= BFA_FCS_FABRIC_N2N
;
361 bfa_fcport_set_tx_bbcredit(fabric
->fcs
->bfa
,
363 bfa_fcs_fabric_notify_online(fabric
);
364 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_nofabric
);
367 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
368 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_linkdown
);
369 bfa_sm_send_event(fabric
->lps
, BFA_LPS_SM_OFFLINE
);
372 case BFA_FCS_FABRIC_SM_DELETE
:
373 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_deleting
);
374 bfa_sm_send_event(fabric
->lps
, BFA_LPS_SM_OFFLINE
);
375 bfa_fcs_fabric_delete(fabric
);
379 bfa_sm_fault(fabric
->fcs
, event
);
385 bfa_fcs_fabric_sm_flogi_retry(struct bfa_fcs_fabric_s
*fabric
,
386 enum bfa_fcs_fabric_event event
)
388 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
389 bfa_trc(fabric
->fcs
, event
);
392 case BFA_FCS_FABRIC_SM_DELAYED
:
393 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_flogi
);
394 bfa_fcs_fabric_login(fabric
);
397 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
398 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_linkdown
);
399 bfa_timer_stop(&fabric
->delay_timer
);
402 case BFA_FCS_FABRIC_SM_DELETE
:
403 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_deleting
);
404 bfa_timer_stop(&fabric
->delay_timer
);
405 bfa_fcs_fabric_delete(fabric
);
409 bfa_sm_fault(fabric
->fcs
, event
);
414 * Authentication is in progress, awaiting authentication results.
417 bfa_fcs_fabric_sm_auth(struct bfa_fcs_fabric_s
*fabric
,
418 enum bfa_fcs_fabric_event event
)
420 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
421 bfa_trc(fabric
->fcs
, event
);
424 case BFA_FCS_FABRIC_SM_AUTH_FAILED
:
425 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_auth_failed
);
426 bfa_sm_send_event(fabric
->lps
, BFA_LPS_SM_OFFLINE
);
429 case BFA_FCS_FABRIC_SM_AUTH_SUCCESS
:
430 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_online
);
431 bfa_fcs_fabric_notify_online(fabric
);
434 case BFA_FCS_FABRIC_SM_PERF_EVFP
:
435 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_evfp
);
438 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
439 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_linkdown
);
440 bfa_sm_send_event(fabric
->lps
, BFA_LPS_SM_OFFLINE
);
443 case BFA_FCS_FABRIC_SM_DELETE
:
444 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_deleting
);
445 bfa_fcs_fabric_delete(fabric
);
449 bfa_sm_fault(fabric
->fcs
, event
);
454 * Authentication failed
457 bfa_fcs_fabric_sm_auth_failed(struct bfa_fcs_fabric_s
*fabric
,
458 enum bfa_fcs_fabric_event event
)
460 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
461 bfa_trc(fabric
->fcs
, event
);
464 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
465 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_linkdown
);
466 bfa_fcs_fabric_notify_offline(fabric
);
469 case BFA_FCS_FABRIC_SM_DELETE
:
470 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_deleting
);
471 bfa_fcs_fabric_delete(fabric
);
475 bfa_sm_fault(fabric
->fcs
, event
);
480 * Port is in loopback mode.
483 bfa_fcs_fabric_sm_loopback(struct bfa_fcs_fabric_s
*fabric
,
484 enum bfa_fcs_fabric_event event
)
486 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
487 bfa_trc(fabric
->fcs
, event
);
490 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
491 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_linkdown
);
492 bfa_fcs_fabric_notify_offline(fabric
);
495 case BFA_FCS_FABRIC_SM_DELETE
:
496 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_deleting
);
497 bfa_fcs_fabric_delete(fabric
);
501 bfa_sm_fault(fabric
->fcs
, event
);
506 * There is no attached fabric - private loop or NPort-to-NPort topology.
509 bfa_fcs_fabric_sm_nofabric(struct bfa_fcs_fabric_s
*fabric
,
510 enum bfa_fcs_fabric_event event
)
512 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
513 bfa_trc(fabric
->fcs
, event
);
516 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
517 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_linkdown
);
518 bfa_sm_send_event(fabric
->lps
, BFA_LPS_SM_OFFLINE
);
519 bfa_fcs_fabric_notify_offline(fabric
);
522 case BFA_FCS_FABRIC_SM_DELETE
:
523 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_deleting
);
524 bfa_fcs_fabric_delete(fabric
);
527 case BFA_FCS_FABRIC_SM_NO_FABRIC
:
528 bfa_trc(fabric
->fcs
, fabric
->bb_credit
);
529 bfa_fcport_set_tx_bbcredit(fabric
->fcs
->bfa
,
533 case BFA_FCS_FABRIC_SM_RETRY_OP
:
537 bfa_sm_fault(fabric
->fcs
, event
);
542 * Fabric is online - normal operating state.
545 bfa_fcs_fabric_sm_online(struct bfa_fcs_fabric_s
*fabric
,
546 enum bfa_fcs_fabric_event event
)
548 struct bfa_s
*bfa
= fabric
->fcs
->bfa
;
550 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
551 bfa_trc(fabric
->fcs
, event
);
554 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
555 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_linkdown
);
556 if (bfa_fcport_get_topology(bfa
) == BFA_PORT_TOPOLOGY_LOOP
) {
557 bfa_fcs_lport_offline(&fabric
->bport
);
559 bfa_sm_send_event(fabric
->lps
, BFA_LPS_SM_OFFLINE
);
560 bfa_fcs_fabric_notify_offline(fabric
);
564 case BFA_FCS_FABRIC_SM_DELETE
:
565 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_deleting
);
566 bfa_fcs_fabric_delete(fabric
);
569 case BFA_FCS_FABRIC_SM_STOP
:
570 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_stopping
);
571 bfa_fcs_fabric_stop(fabric
);
574 case BFA_FCS_FABRIC_SM_AUTH_FAILED
:
575 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_auth_failed
);
576 bfa_sm_send_event(fabric
->lps
, BFA_LPS_SM_OFFLINE
);
579 case BFA_FCS_FABRIC_SM_AUTH_SUCCESS
:
583 bfa_sm_fault(fabric
->fcs
, event
);
588 * Exchanging virtual fabric parameters.
591 bfa_fcs_fabric_sm_evfp(struct bfa_fcs_fabric_s
*fabric
,
592 enum bfa_fcs_fabric_event event
)
594 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
595 bfa_trc(fabric
->fcs
, event
);
598 case BFA_FCS_FABRIC_SM_CONT_OP
:
599 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_evfp_done
);
602 case BFA_FCS_FABRIC_SM_ISOLATE
:
603 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_isolated
);
607 bfa_sm_fault(fabric
->fcs
, event
);
612 * EVFP exchange complete and VFT tagging is enabled.
615 bfa_fcs_fabric_sm_evfp_done(struct bfa_fcs_fabric_s
*fabric
,
616 enum bfa_fcs_fabric_event event
)
618 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
619 bfa_trc(fabric
->fcs
, event
);
623 * Port is isolated after EVFP exchange due to VF_ID mismatch (N and F).
626 bfa_fcs_fabric_sm_isolated(struct bfa_fcs_fabric_s
*fabric
,
627 enum bfa_fcs_fabric_event event
)
629 struct bfad_s
*bfad
= (struct bfad_s
*)fabric
->fcs
->bfad
;
630 char pwwn_ptr
[BFA_STRING_32
];
632 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
633 bfa_trc(fabric
->fcs
, event
);
634 wwn2str(pwwn_ptr
, fabric
->bport
.port_cfg
.pwwn
);
636 BFA_LOG(KERN_INFO
, bfad
, bfa_log_level
,
637 "Port is isolated due to VF_ID mismatch. "
638 "PWWN: %s Port VF_ID: %04x switch port VF_ID: %04x.",
639 pwwn_ptr
, fabric
->fcs
->port_vfid
,
640 fabric
->event_arg
.swp_vfid
);
644 * Fabric is being deleted, awaiting vport delete completions.
647 bfa_fcs_fabric_sm_deleting(struct bfa_fcs_fabric_s
*fabric
,
648 enum bfa_fcs_fabric_event event
)
650 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
651 bfa_trc(fabric
->fcs
, event
);
654 case BFA_FCS_FABRIC_SM_DELCOMP
:
655 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_uninit
);
656 bfa_wc_down(&fabric
->fcs
->wc
);
659 case BFA_FCS_FABRIC_SM_LINK_UP
:
662 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
663 bfa_fcs_fabric_notify_offline(fabric
);
667 bfa_sm_fault(fabric
->fcs
, event
);
672 * Fabric is being stopped, awaiting vport stop completions.
675 bfa_fcs_fabric_sm_stopping(struct bfa_fcs_fabric_s
*fabric
,
676 enum bfa_fcs_fabric_event event
)
678 struct bfa_s
*bfa
= fabric
->fcs
->bfa
;
680 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
681 bfa_trc(fabric
->fcs
, event
);
684 case BFA_FCS_FABRIC_SM_STOPCOMP
:
685 if (bfa_fcport_get_topology(bfa
) == BFA_PORT_TOPOLOGY_LOOP
) {
686 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_created
);
688 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_cleanup
);
689 bfa_sm_send_event(fabric
->lps
, BFA_LPS_SM_LOGOUT
);
693 case BFA_FCS_FABRIC_SM_LINK_UP
:
696 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
697 if (bfa_fcport_get_topology(bfa
) == BFA_PORT_TOPOLOGY_LOOP
)
698 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_created
);
700 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_cleanup
);
704 bfa_sm_fault(fabric
->fcs
, event
);
709 * Fabric is being stopped, cleanup without FLOGO
712 bfa_fcs_fabric_sm_cleanup(struct bfa_fcs_fabric_s
*fabric
,
713 enum bfa_fcs_fabric_event event
)
715 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
716 bfa_trc(fabric
->fcs
, event
);
719 case BFA_FCS_FABRIC_SM_STOPCOMP
:
720 case BFA_FCS_FABRIC_SM_LOGOCOMP
:
721 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_created
);
722 bfa_wc_down(&(fabric
->fcs
)->wc
);
725 case BFA_FCS_FABRIC_SM_LINK_DOWN
:
727 * Ignore - can get this event if we get notified about IOC down
728 * before the fabric completion callbk is done.
733 bfa_sm_fault(fabric
->fcs
, event
);
738 * fcs_fabric_private fabric private functions
742 bfa_fcs_fabric_init(struct bfa_fcs_fabric_s
*fabric
)
744 struct bfa_lport_cfg_s
*port_cfg
= &fabric
->bport
.port_cfg
;
746 port_cfg
->roles
= BFA_LPORT_ROLE_FCP_IM
;
747 port_cfg
->nwwn
= fabric
->fcs
->bfa
->ioc
.attr
->nwwn
;
748 port_cfg
->pwwn
= fabric
->fcs
->bfa
->ioc
.attr
->pwwn
;
752 * Port Symbolic Name Creation for base port.
755 bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s
*fabric
)
757 struct bfa_lport_cfg_s
*port_cfg
= &fabric
->bport
.port_cfg
;
758 char model
[BFA_ADAPTER_MODEL_NAME_LEN
] = {0};
759 struct bfa_fcs_driver_info_s
*driver_info
= &fabric
->fcs
->driver_info
;
761 bfa_ioc_get_adapter_model(&fabric
->fcs
->bfa
->ioc
, model
);
763 /* Model name/number */
764 strlcpy(port_cfg
->sym_name
.symname
, model
,
766 strlcat(port_cfg
->sym_name
.symname
, BFA_FCS_PORT_SYMBNAME_SEPARATOR
,
770 strlcat(port_cfg
->sym_name
.symname
, driver_info
->version
,
772 strlcat(port_cfg
->sym_name
.symname
, BFA_FCS_PORT_SYMBNAME_SEPARATOR
,
775 /* Host machine name */
776 strlcat(port_cfg
->sym_name
.symname
,
777 driver_info
->host_machine_name
,
779 strlcat(port_cfg
->sym_name
.symname
, BFA_FCS_PORT_SYMBNAME_SEPARATOR
,
784 * If OS Patch Info is not there, do not truncate any bytes from the
785 * OS name string and instead copy the entire OS info string (64 bytes).
787 if (driver_info
->host_os_patch
[0] == '\0') {
788 strlcat(port_cfg
->sym_name
.symname
,
789 driver_info
->host_os_name
,
791 strlcat(port_cfg
->sym_name
.symname
,
792 BFA_FCS_PORT_SYMBNAME_SEPARATOR
,
795 strlcat(port_cfg
->sym_name
.symname
,
796 driver_info
->host_os_name
,
798 strlcat(port_cfg
->sym_name
.symname
,
799 BFA_FCS_PORT_SYMBNAME_SEPARATOR
,
802 /* Append host OS Patch Info */
803 strlcat(port_cfg
->sym_name
.symname
,
804 driver_info
->host_os_patch
,
809 port_cfg
->sym_name
.symname
[BFA_SYMNAME_MAXLEN
- 1] = 0;
813 * Node Symbolic Name Creation for base port and all vports
816 bfa_fcs_fabric_nsymb_init(struct bfa_fcs_fabric_s
*fabric
)
818 struct bfa_lport_cfg_s
*port_cfg
= &fabric
->bport
.port_cfg
;
819 char model
[BFA_ADAPTER_MODEL_NAME_LEN
] = {0};
820 struct bfa_fcs_driver_info_s
*driver_info
= &fabric
->fcs
->driver_info
;
822 bfa_ioc_get_adapter_model(&fabric
->fcs
->bfa
->ioc
, model
);
824 /* Model name/number */
825 strlcpy(port_cfg
->node_sym_name
.symname
, model
,
827 strlcat(port_cfg
->node_sym_name
.symname
,
828 BFA_FCS_PORT_SYMBNAME_SEPARATOR
,
832 strlcat(port_cfg
->node_sym_name
.symname
, (char *)driver_info
->version
,
834 strlcat(port_cfg
->node_sym_name
.symname
,
835 BFA_FCS_PORT_SYMBNAME_SEPARATOR
,
838 /* Host machine name */
839 strlcat(port_cfg
->node_sym_name
.symname
,
840 driver_info
->host_machine_name
,
842 strlcat(port_cfg
->node_sym_name
.symname
,
843 BFA_FCS_PORT_SYMBNAME_SEPARATOR
,
847 port_cfg
->node_sym_name
.symname
[BFA_SYMNAME_MAXLEN
- 1] = 0;
851 * bfa lps login completion callback
854 bfa_cb_lps_flogi_comp(void *bfad
, void *uarg
, bfa_status_t status
)
856 struct bfa_fcs_fabric_s
*fabric
= uarg
;
858 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
859 bfa_trc(fabric
->fcs
, status
);
863 fabric
->stats
.flogi_accepts
++;
866 case BFA_STATUS_INVALID_MAC
:
868 fabric
->stats
.flogi_acc_err
++;
869 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_RETRY_OP
);
873 case BFA_STATUS_EPROTOCOL
:
874 switch (fabric
->lps
->ext_status
) {
875 case BFA_EPROTO_BAD_ACCEPT
:
876 fabric
->stats
.flogi_acc_err
++;
879 case BFA_EPROTO_UNKNOWN_RSP
:
880 fabric
->stats
.flogi_unknown_rsp
++;
886 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_RETRY_OP
);
890 case BFA_STATUS_FABRIC_RJT
:
891 fabric
->stats
.flogi_rejects
++;
892 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_RETRY_OP
);
896 fabric
->stats
.flogi_rsp_err
++;
897 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_RETRY_OP
);
901 fabric
->bb_credit
= fabric
->lps
->pr_bbcred
;
902 bfa_trc(fabric
->fcs
, fabric
->bb_credit
);
904 if (!(fabric
->lps
->brcd_switch
))
905 fabric
->fabric_name
= fabric
->lps
->pr_nwwn
;
908 * Check port type. It should be 1 = F-port.
910 if (fabric
->lps
->fport
) {
911 fabric
->bport
.pid
= fabric
->lps
->lp_pid
;
912 fabric
->is_npiv
= fabric
->lps
->npiv_en
;
913 fabric
->is_auth
= fabric
->lps
->auth_req
;
914 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_CONT_OP
);
917 * Nport-2-Nport direct attached
919 fabric
->bport
.port_topo
.pn2n
.rem_port_wwn
=
920 fabric
->lps
->pr_pwwn
;
921 fabric
->fab_type
= BFA_FCS_FABRIC_N2N
;
922 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_NO_FABRIC
);
925 bfa_trc(fabric
->fcs
, fabric
->bport
.pid
);
926 bfa_trc(fabric
->fcs
, fabric
->is_npiv
);
927 bfa_trc(fabric
->fcs
, fabric
->is_auth
);
930 * Allocate and send FLOGI.
933 bfa_fcs_fabric_login(struct bfa_fcs_fabric_s
*fabric
)
935 struct bfa_s
*bfa
= fabric
->fcs
->bfa
;
936 struct bfa_lport_cfg_s
*pcfg
= &fabric
->bport
.port_cfg
;
940 bfa_lps_flogi(fabric
->lps
, fabric
, alpa
, bfa_fcport_get_maxfrsize(bfa
),
941 pcfg
->pwwn
, pcfg
->nwwn
, fabric
->auth_reqd
);
943 fabric
->stats
.flogi_sent
++;
947 bfa_fcs_fabric_notify_online(struct bfa_fcs_fabric_s
*fabric
)
949 struct bfa_fcs_vport_s
*vport
;
950 struct list_head
*qe
, *qen
;
952 bfa_trc(fabric
->fcs
, fabric
->fabric_name
);
954 bfa_fcs_fabric_set_opertype(fabric
);
955 fabric
->stats
.fabric_onlines
++;
958 * notify online event to base and then virtual ports
960 bfa_fcs_lport_online(&fabric
->bport
);
962 list_for_each_safe(qe
, qen
, &fabric
->vport_q
) {
963 vport
= (struct bfa_fcs_vport_s
*) qe
;
964 bfa_fcs_vport_online(vport
);
969 bfa_fcs_fabric_notify_offline(struct bfa_fcs_fabric_s
*fabric
)
971 struct bfa_fcs_vport_s
*vport
;
972 struct list_head
*qe
, *qen
;
974 bfa_trc(fabric
->fcs
, fabric
->fabric_name
);
975 fabric
->stats
.fabric_offlines
++;
978 * notify offline event first to vports and then base port.
980 list_for_each_safe(qe
, qen
, &fabric
->vport_q
) {
981 vport
= (struct bfa_fcs_vport_s
*) qe
;
982 bfa_fcs_vport_offline(vport
);
985 bfa_fcs_lport_offline(&fabric
->bport
);
987 fabric
->fabric_name
= 0;
988 fabric
->fabric_ip_addr
[0] = 0;
992 bfa_fcs_fabric_delay(void *cbarg
)
994 struct bfa_fcs_fabric_s
*fabric
= cbarg
;
996 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_DELAYED
);
1000 * Stop all vports and wait for vport stop completions.
1003 bfa_fcs_fabric_stop(struct bfa_fcs_fabric_s
*fabric
)
1005 struct bfa_fcs_vport_s
*vport
;
1006 struct list_head
*qe
, *qen
;
1008 bfa_wc_init(&fabric
->stop_wc
, bfa_fcs_fabric_stop_comp
, fabric
);
1010 list_for_each_safe(qe
, qen
, &fabric
->vport_q
) {
1011 vport
= (struct bfa_fcs_vport_s
*) qe
;
1012 bfa_wc_up(&fabric
->stop_wc
);
1013 bfa_fcs_vport_fcs_stop(vport
);
1016 bfa_wc_up(&fabric
->stop_wc
);
1017 bfa_fcs_lport_stop(&fabric
->bport
);
1018 bfa_wc_wait(&fabric
->stop_wc
);
1022 * Delete all vports and wait for vport delete completions.
1025 bfa_fcs_fabric_delete(struct bfa_fcs_fabric_s
*fabric
)
1027 struct bfa_fcs_vport_s
*vport
;
1028 struct list_head
*qe
, *qen
;
1030 list_for_each_safe(qe
, qen
, &fabric
->vport_q
) {
1031 vport
= (struct bfa_fcs_vport_s
*) qe
;
1032 bfa_fcs_vport_fcs_delete(vport
);
1035 bfa_fcs_lport_delete(&fabric
->bport
);
1036 bfa_wc_wait(&fabric
->wc
);
1040 bfa_fcs_fabric_delete_comp(void *cbarg
)
1042 struct bfa_fcs_fabric_s
*fabric
= cbarg
;
1044 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_DELCOMP
);
1048 bfa_fcs_fabric_stop_comp(void *cbarg
)
1050 struct bfa_fcs_fabric_s
*fabric
= cbarg
;
1052 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_STOPCOMP
);
1056 * fcs_fabric_public fabric public functions
1060 * Fabric module stop -- stop FCS actions
1063 bfa_fcs_fabric_modstop(struct bfa_fcs_s
*fcs
)
1065 struct bfa_fcs_fabric_s
*fabric
;
1068 fabric
= &fcs
->fabric
;
1069 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_STOP
);
1073 * Fabric module start -- kick starts FCS actions
1076 bfa_fcs_fabric_modstart(struct bfa_fcs_s
*fcs
)
1078 struct bfa_fcs_fabric_s
*fabric
;
1081 fabric
= &fcs
->fabric
;
1082 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_START
);
1087 * Link up notification from BFA physical port module.
1090 bfa_fcs_fabric_link_up(struct bfa_fcs_fabric_s
*fabric
)
1092 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
1093 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_LINK_UP
);
1097 * Link down notification from BFA physical port module.
1100 bfa_fcs_fabric_link_down(struct bfa_fcs_fabric_s
*fabric
)
1102 bfa_trc(fabric
->fcs
, fabric
->bport
.port_cfg
.pwwn
);
1103 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_LINK_DOWN
);
1107 * A child vport is being created in the fabric.
1109 * Call from vport module at vport creation. A list of base port and vports
1110 * belonging to a fabric is maintained to propagate link events.
1112 * param[in] fabric - Fabric instance. This can be a base fabric or vf.
1113 * param[in] vport - Vport being created.
1115 * @return None (always succeeds)
1118 bfa_fcs_fabric_addvport(struct bfa_fcs_fabric_s
*fabric
,
1119 struct bfa_fcs_vport_s
*vport
)
1122 * - add vport to fabric's vport_q
1124 bfa_trc(fabric
->fcs
, fabric
->vf_id
);
1126 list_add_tail(&vport
->qe
, &fabric
->vport_q
);
1127 fabric
->num_vports
++;
1128 bfa_wc_up(&fabric
->wc
);
1132 * A child vport is being deleted from fabric.
1134 * Vport is being deleted.
1137 bfa_fcs_fabric_delvport(struct bfa_fcs_fabric_s
*fabric
,
1138 struct bfa_fcs_vport_s
*vport
)
1140 list_del(&vport
->qe
);
1141 fabric
->num_vports
--;
1142 bfa_wc_down(&fabric
->wc
);
1147 * Lookup for a vport within a fabric given its pwwn
1149 struct bfa_fcs_vport_s
*
1150 bfa_fcs_fabric_vport_lookup(struct bfa_fcs_fabric_s
*fabric
, wwn_t pwwn
)
1152 struct bfa_fcs_vport_s
*vport
;
1153 struct list_head
*qe
;
1155 list_for_each(qe
, &fabric
->vport_q
) {
1156 vport
= (struct bfa_fcs_vport_s
*) qe
;
1157 if (bfa_fcs_lport_get_pwwn(&vport
->lport
) == pwwn
)
1166 * Get OUI of the attached switch.
1168 * Note : Use of this function should be avoided as much as possible.
1169 * This function should be used only if there is any requirement
1170 * to check for FOS version below 6.3.
1171 * To check if the attached fabric is a brocade fabric, use
1172 * bfa_lps_is_brcd_fabric() which works for FOS versions 6.3
1177 bfa_fcs_fabric_get_switch_oui(struct bfa_fcs_fabric_s
*fabric
)
1183 fab_nwwn
= fabric
->lps
->pr_nwwn
;
1185 tmp
= (u8
*)&fab_nwwn
;
1186 oui
= (tmp
[3] << 8) | tmp
[4];
1191 * Unsolicited frame receive handling.
1194 bfa_fcs_fabric_uf_recv(struct bfa_fcs_fabric_s
*fabric
, struct fchs_s
*fchs
,
1197 u32 pid
= fchs
->d_id
;
1198 struct bfa_fcs_vport_s
*vport
;
1199 struct list_head
*qe
;
1200 struct fc_els_cmd_s
*els_cmd
= (struct fc_els_cmd_s
*) (fchs
+ 1);
1201 struct fc_logi_s
*flogi
= (struct fc_logi_s
*) els_cmd
;
1203 bfa_trc(fabric
->fcs
, len
);
1204 bfa_trc(fabric
->fcs
, pid
);
1207 * Look for our own FLOGI frames being looped back. This means an
1208 * external loopback cable is in place. Our own FLOGI frames are
1209 * sometimes looped back when switch port gets temporarily bypassed.
1211 if ((pid
== bfa_ntoh3b(FC_FABRIC_PORT
)) &&
1212 (els_cmd
->els_code
== FC_ELS_FLOGI
) &&
1213 (flogi
->port_name
== bfa_fcs_lport_get_pwwn(&fabric
->bport
))) {
1214 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_LOOPBACK
);
1219 * FLOGI/EVFP exchanges should be consumed by base fabric.
1221 if (fchs
->d_id
== bfa_hton3b(FC_FABRIC_PORT
)) {
1222 bfa_trc(fabric
->fcs
, pid
);
1223 bfa_fcs_fabric_process_uf(fabric
, fchs
, len
);
1227 if (fabric
->bport
.pid
== pid
) {
1229 * All authentication frames should be routed to auth
1231 bfa_trc(fabric
->fcs
, els_cmd
->els_code
);
1232 if (els_cmd
->els_code
== FC_ELS_AUTH
) {
1233 bfa_trc(fabric
->fcs
, els_cmd
->els_code
);
1237 bfa_trc(fabric
->fcs
, *(u8
*) ((u8
*) fchs
));
1238 bfa_fcs_lport_uf_recv(&fabric
->bport
, fchs
, len
);
1243 * look for a matching local port ID
1245 list_for_each(qe
, &fabric
->vport_q
) {
1246 vport
= (struct bfa_fcs_vport_s
*) qe
;
1247 if (vport
->lport
.pid
== pid
) {
1248 bfa_fcs_lport_uf_recv(&vport
->lport
, fchs
, len
);
1253 if (!bfa_fcs_fabric_is_switched(fabric
))
1254 bfa_fcs_lport_uf_recv(&fabric
->bport
, fchs
, len
);
1256 bfa_trc(fabric
->fcs
, fchs
->type
);
1260 * Unsolicited frames to be processed by fabric.
1263 bfa_fcs_fabric_process_uf(struct bfa_fcs_fabric_s
*fabric
, struct fchs_s
*fchs
,
1266 struct fc_els_cmd_s
*els_cmd
= (struct fc_els_cmd_s
*) (fchs
+ 1);
1268 bfa_trc(fabric
->fcs
, els_cmd
->els_code
);
1270 switch (els_cmd
->els_code
) {
1272 bfa_fcs_fabric_process_flogi(fabric
, fchs
, len
);
1277 * need to generate a LS_RJT
1284 * Process incoming FLOGI
1287 bfa_fcs_fabric_process_flogi(struct bfa_fcs_fabric_s
*fabric
,
1288 struct fchs_s
*fchs
, u16 len
)
1290 struct fc_logi_s
*flogi
= (struct fc_logi_s
*) (fchs
+ 1);
1291 struct bfa_fcs_lport_s
*bport
= &fabric
->bport
;
1293 bfa_trc(fabric
->fcs
, fchs
->s_id
);
1295 fabric
->stats
.flogi_rcvd
++;
1297 * Check port type. It should be 0 = n-port.
1299 if (flogi
->csp
.port_type
) {
1301 * @todo: may need to send a LS_RJT
1303 bfa_trc(fabric
->fcs
, flogi
->port_name
);
1304 fabric
->stats
.flogi_rejected
++;
1308 fabric
->bb_credit
= be16_to_cpu(flogi
->csp
.bbcred
);
1309 bport
->port_topo
.pn2n
.rem_port_wwn
= flogi
->port_name
;
1310 bport
->port_topo
.pn2n
.reply_oxid
= fchs
->ox_id
;
1315 bfa_fcs_fabric_send_flogi_acc(fabric
);
1316 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_NO_FABRIC
);
1320 bfa_fcs_fabric_send_flogi_acc(struct bfa_fcs_fabric_s
*fabric
)
1322 struct bfa_lport_cfg_s
*pcfg
= &fabric
->bport
.port_cfg
;
1323 struct bfa_fcs_lport_n2n_s
*n2n_port
= &fabric
->bport
.port_topo
.pn2n
;
1324 struct bfa_s
*bfa
= fabric
->fcs
->bfa
;
1325 struct bfa_fcxp_s
*fcxp
;
1329 fcxp
= bfa_fcs_fcxp_alloc(fabric
->fcs
, BFA_FALSE
);
1331 * Do not expect this failure -- expect remote node to retry
1336 reqlen
= fc_flogi_acc_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
1337 bfa_hton3b(FC_FABRIC_PORT
),
1338 n2n_port
->reply_oxid
, pcfg
->pwwn
,
1340 bfa_fcport_get_maxfrsize(bfa
),
1341 bfa_fcport_get_rx_bbcredit(bfa
), 0);
1343 bfa_fcxp_send(fcxp
, NULL
, fabric
->vf_id
, fabric
->lps
->bfa_tag
,
1344 BFA_FALSE
, FC_CLASS_3
,
1345 reqlen
, &fchs
, bfa_fcs_fabric_flogiacc_comp
, fabric
,
1350 * Flogi Acc completion callback.
1353 bfa_fcs_fabric_flogiacc_comp(void *fcsarg
, struct bfa_fcxp_s
*fcxp
, void *cbarg
,
1354 bfa_status_t status
, u32 rsp_len
,
1355 u32 resid_len
, struct fchs_s
*rspfchs
)
1357 struct bfa_fcs_fabric_s
*fabric
= cbarg
;
1359 bfa_trc(fabric
->fcs
, status
);
1364 * Send AEN notification
1367 bfa_fcs_fabric_aen_post(struct bfa_fcs_lport_s
*port
,
1368 enum bfa_port_aen_event event
)
1370 struct bfad_s
*bfad
= (struct bfad_s
*)port
->fabric
->fcs
->bfad
;
1371 struct bfa_aen_entry_s
*aen_entry
;
1373 bfad_get_aen_entry(bfad
, aen_entry
);
1377 aen_entry
->aen_data
.port
.pwwn
= bfa_fcs_lport_get_pwwn(port
);
1378 aen_entry
->aen_data
.port
.fwwn
= bfa_fcs_lport_get_fabric_name(port
);
1380 /* Send the AEN notification */
1381 bfad_im_post_vendor_event(aen_entry
, bfad
, ++port
->fcs
->fcs_aen_seq
,
1382 BFA_AEN_CAT_PORT
, event
);
1387 * @param[in] fabric - fabric
1388 * @param[in] wwn_t - new fabric name
1393 bfa_fcs_fabric_set_fabric_name(struct bfa_fcs_fabric_s
*fabric
,
1396 struct bfad_s
*bfad
= (struct bfad_s
*)fabric
->fcs
->bfad
;
1397 char pwwn_ptr
[BFA_STRING_32
];
1398 char fwwn_ptr
[BFA_STRING_32
];
1400 bfa_trc(fabric
->fcs
, fabric_name
);
1402 if (fabric
->fabric_name
== 0) {
1404 * With BRCD switches, we don't get Fabric Name in FLOGI.
1405 * Don't generate a fabric name change event in this case.
1407 fabric
->fabric_name
= fabric_name
;
1409 fabric
->fabric_name
= fabric_name
;
1410 wwn2str(pwwn_ptr
, bfa_fcs_lport_get_pwwn(&fabric
->bport
));
1412 bfa_fcs_lport_get_fabric_name(&fabric
->bport
));
1413 BFA_LOG(KERN_WARNING
, bfad
, bfa_log_level
,
1414 "Base port WWN = %s Fabric WWN = %s\n",
1415 pwwn_ptr
, fwwn_ptr
);
1416 bfa_fcs_fabric_aen_post(&fabric
->bport
,
1417 BFA_PORT_AEN_FABRIC_NAME_CHANGE
);
1422 bfa_cb_lps_flogo_comp(void *bfad
, void *uarg
)
1424 struct bfa_fcs_fabric_s
*fabric
= uarg
;
1425 bfa_sm_send_event(fabric
, BFA_FCS_FABRIC_SM_LOGOCOMP
);
1429 * Returns FCS vf structure for a given vf_id.
1431 * param[in] vf_id - VF_ID
1434 * If lookup succeeds, retuns fcs vf object, otherwise returns NULL
1437 bfa_fcs_vf_lookup(struct bfa_fcs_s
*fcs
, u16 vf_id
)
1439 bfa_trc(fcs
, vf_id
);
1440 if (vf_id
== FC_VF_ID_NULL
)
1441 return &fcs
->fabric
;
1447 * Return the list of local logical ports present in the given VF.
1449 * @param[in] vf vf for which logical ports are returned
1450 * @param[out] lpwwn returned logical port wwn list
1451 * @param[in,out] nlports in:size of lpwwn list;
1452 * out:total elements present,
1453 * actual elements returned is limited by the size
1456 bfa_fcs_vf_get_ports(bfa_fcs_vf_t
*vf
, wwn_t lpwwn
[], int *nlports
)
1458 struct list_head
*qe
;
1459 struct bfa_fcs_vport_s
*vport
;
1461 struct bfa_fcs_s
*fcs
;
1463 if (vf
== NULL
|| lpwwn
== NULL
|| *nlports
== 0)
1468 bfa_trc(fcs
, vf
->vf_id
);
1469 bfa_trc(fcs
, (uint32_t) *nlports
);
1471 lpwwn
[i
++] = vf
->bport
.port_cfg
.pwwn
;
1473 list_for_each(qe
, &vf
->vport_q
) {
1477 vport
= (struct bfa_fcs_vport_s
*) qe
;
1478 lpwwn
[i
++] = vport
->lport
.port_cfg
.pwwn
;
1486 * BFA FCS PPORT ( physical port)
1489 bfa_fcs_port_event_handler(void *cbarg
, enum bfa_port_linkstate event
)
1491 struct bfa_fcs_s
*fcs
= cbarg
;
1493 bfa_trc(fcs
, event
);
1496 case BFA_PORT_LINKUP
:
1497 bfa_fcs_fabric_link_up(&fcs
->fabric
);
1500 case BFA_PORT_LINKDOWN
:
1501 bfa_fcs_fabric_link_down(&fcs
->fabric
);
1510 * BFA FCS UF ( Unsolicited Frames)
1514 * BFA callback for unsolicited frame receive handler.
1516 * @param[in] cbarg callback arg for receive handler
1517 * @param[in] uf unsolicited frame descriptor
1522 bfa_fcs_uf_recv(void *cbarg
, struct bfa_uf_s
*uf
)
1524 struct bfa_fcs_s
*fcs
= (struct bfa_fcs_s
*) cbarg
;
1525 struct fchs_s
*fchs
= bfa_uf_get_frmbuf(uf
);
1526 u16 len
= bfa_uf_get_frmlen(uf
);
1527 struct fc_vft_s
*vft
;
1528 struct bfa_fcs_fabric_s
*fabric
;
1531 * check for VFT header
1533 if (fchs
->routing
== FC_RTG_EXT_HDR
&&
1534 fchs
->cat_info
== FC_CAT_VFT_HDR
) {
1535 bfa_stats(fcs
, uf
.tagged
);
1536 vft
= bfa_uf_get_frmbuf(uf
);
1537 if (fcs
->port_vfid
== vft
->vf_id
)
1538 fabric
= &fcs
->fabric
;
1540 fabric
= bfa_fcs_vf_lookup(fcs
, (u16
) vft
->vf_id
);
1543 * drop frame if vfid is unknown
1547 bfa_stats(fcs
, uf
.vfid_unknown
);
1555 fchs
= (struct fchs_s
*) (vft
+ 1);
1556 len
-= sizeof(struct fc_vft_s
);
1558 bfa_trc(fcs
, vft
->vf_id
);
1560 bfa_stats(fcs
, uf
.untagged
);
1561 fabric
= &fcs
->fabric
;
1564 bfa_trc(fcs
, ((u32
*) fchs
)[0]);
1565 bfa_trc(fcs
, ((u32
*) fchs
)[1]);
1566 bfa_trc(fcs
, ((u32
*) fchs
)[2]);
1567 bfa_trc(fcs
, ((u32
*) fchs
)[3]);
1568 bfa_trc(fcs
, ((u32
*) fchs
)[4]);
1569 bfa_trc(fcs
, ((u32
*) fchs
)[5]);
1572 bfa_fcs_fabric_uf_recv(fabric
, fchs
, len
);
1577 * fcs attach -- called once to initialize data structures at driver attach time
1580 bfa_fcs_attach(struct bfa_fcs_s
*fcs
, struct bfa_s
*bfa
, struct bfad_s
*bfad
,
1581 bfa_boolean_t min_cfg
)
1583 struct bfa_fcs_fabric_s
*fabric
= &fcs
->fabric
;
1587 fcs
->min_cfg
= min_cfg
;
1588 fcs
->num_rport_logins
= 0;
1590 bfa
->fcs
= BFA_TRUE
;
1593 bfa_fcport_event_register(fcs
->bfa
, bfa_fcs_port_event_handler
, fcs
);
1594 bfa_uf_recv_register(fcs
->bfa
, bfa_fcs_uf_recv
, fcs
);
1596 memset(fabric
, 0, sizeof(struct bfa_fcs_fabric_s
));
1599 * Initialize base fabric.
1602 INIT_LIST_HEAD(&fabric
->vport_q
);
1603 INIT_LIST_HEAD(&fabric
->vf_q
);
1604 fabric
->lps
= bfa_lps_alloc(fcs
->bfa
);
1605 WARN_ON(!fabric
->lps
);
1608 * Initialize fabric delete completion handler. Fabric deletion is
1609 * complete when the last vport delete is complete.
1611 bfa_wc_init(&fabric
->wc
, bfa_fcs_fabric_delete_comp
, fabric
);
1612 bfa_wc_up(&fabric
->wc
); /* For the base port */
1614 bfa_sm_set_state(fabric
, bfa_fcs_fabric_sm_uninit
);
1615 bfa_fcs_lport_attach(&fabric
->bport
, fabric
->fcs
, FC_VF_ID_NULL
, NULL
);