]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/scsi/bfa/bfa_fcs.c
Merge tag 'gfs2-4.11.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2...
[mirror_ubuntu-artful-kernel.git] / drivers / scsi / bfa / bfa_fcs.c
CommitLineData
7725ccfd 1/*
889d0d42
AG
2 * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
3 * Copyright (c) 2014- QLogic Corporation.
7725ccfd 4 * All rights reserved
889d0d42 5 * www.qlogic.com
7725ccfd 6 *
31e1d569 7 * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
7725ccfd
JH
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License (GPL) Version 2 as
11 * published by the Free Software Foundation
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 */
18
5fbe25c7 19/*
7725ccfd
JH
20 * bfa_fcs.c BFA FCS main
21 */
22
f16a1750 23#include "bfad_drv.h"
7826f304 24#include "bfad_im.h"
a36c61f9
KG
25#include "bfa_fcs.h"
26#include "bfa_fcbuild.h"
a36c61f9
KG
27
28BFA_TRC_FILE(FCS, FCS);
7725ccfd 29
5fbe25c7 30/*
7725ccfd
JH
31 * FCS sub-modules
32 */
33struct bfa_fcs_mod_s {
82794a2e 34 void (*attach) (struct bfa_fcs_s *fcs);
a36c61f9
KG
35 void (*modinit) (struct bfa_fcs_s *fcs);
36 void (*modexit) (struct bfa_fcs_s *fcs);
7725ccfd
JH
37};
38
39#define BFA_FCS_MODULE(_mod) { _mod ## _modinit, _mod ## _modexit }
40
41static struct bfa_fcs_mod_s fcs_modules[] = {
a36c61f9 42 { bfa_fcs_port_attach, NULL, NULL },
82794a2e
KG
43 { bfa_fcs_uf_attach, NULL, NULL },
44 { bfa_fcs_fabric_attach, bfa_fcs_fabric_modinit,
a36c61f9 45 bfa_fcs_fabric_modexit },
7725ccfd
JH
46};
47
5fbe25c7 48/*
7725ccfd
JH
49 * fcs_api BFA FCS API
50 */
51
52static void
53bfa_fcs_exit_comp(void *fcs_cbarg)
54{
a36c61f9
KG
55 struct bfa_fcs_s *fcs = fcs_cbarg;
56 struct bfad_s *bfad = fcs->bfad;
7725ccfd
JH
57
58 complete(&bfad->comp);
59}
60
61
62
5fbe25c7 63/*
7725ccfd
JH
64 * fcs_api BFA FCS API
65 */
66
5fbe25c7 67/*
82794a2e 68 * fcs attach -- called once to initialize data structures at driver attach time
7725ccfd
JH
69 */
70void
82794a2e 71bfa_fcs_attach(struct bfa_fcs_s *fcs, struct bfa_s *bfa, struct bfad_s *bfad,
a36c61f9 72 bfa_boolean_t min_cfg)
7725ccfd 73{
a36c61f9 74 int i;
7725ccfd
JH
75 struct bfa_fcs_mod_s *mod;
76
77 fcs->bfa = bfa;
78 fcs->bfad = bfad;
79 fcs->min_cfg = min_cfg;
61ba4394 80 fcs->num_rport_logins = 0;
7725ccfd 81
f7f73812 82 bfa->fcs = BFA_TRUE;
7725ccfd
JH
83 fcbuild_init();
84
44416c42 85 for (i = 0; i < ARRAY_SIZE(fcs_modules); i++) {
7725ccfd 86 mod = &fcs_modules[i];
82794a2e
KG
87 if (mod->attach)
88 mod->attach(fcs);
89 }
90}
91
5fbe25c7 92/*
82794a2e
KG
93 * fcs initialization, called once after bfa initialization is complete
94 */
95void
96bfa_fcs_init(struct bfa_fcs_s *fcs)
97{
75332a70 98 int i;
82794a2e
KG
99 struct bfa_fcs_mod_s *mod;
100
44416c42 101 for (i = 0; i < ARRAY_SIZE(fcs_modules); i++) {
82794a2e
KG
102 mod = &fcs_modules[i];
103 if (mod->modinit)
104 mod->modinit(fcs);
7725ccfd 105 }
75332a70
KG
106}
107
108/*
109 * FCS update cfg - reset the pwwn/nwwn of fabric base logical port
110 * with values learned during bfa_init firmware GETATTR REQ.
111 */
112void
113bfa_fcs_update_cfg(struct bfa_fcs_s *fcs)
114{
115 struct bfa_fcs_fabric_s *fabric = &fcs->fabric;
116 struct bfa_lport_cfg_s *port_cfg = &fabric->bport.port_cfg;
117 struct bfa_ioc_s *ioc = &fabric->fcs->bfa->ioc;
118
119 port_cfg->nwwn = ioc->attr->nwwn;
120 port_cfg->pwwn = ioc->attr->pwwn;
121}
122
881c1b3c
KG
123/*
124 * Stop FCS operations.
125 */
126void
127bfa_fcs_stop(struct bfa_fcs_s *fcs)
128{
129 bfa_wc_init(&fcs->wc, bfa_fcs_exit_comp, fcs);
130 bfa_wc_up(&fcs->wc);
131 bfa_fcs_fabric_modstop(fcs);
132 bfa_wc_wait(&fcs->wc);
133}
134
75332a70
KG
135/*
136 * fcs pbc vport initialization
137 */
138void
139bfa_fcs_pbc_vport_init(struct bfa_fcs_s *fcs)
140{
141 int i, npbc_vports;
142 struct bfi_pbc_vport_s pbc_vports[BFI_PBC_MAX_VPORTS];
143
d9883548
JH
144 /* Initialize pbc vports */
145 if (!fcs->min_cfg) {
146 npbc_vports =
75332a70 147 bfa_iocfc_get_pbc_vports(fcs->bfa, pbc_vports);
d9883548
JH
148 for (i = 0; i < npbc_vports; i++)
149 bfa_fcb_pbc_vport_create(fcs->bfa->bfad, pbc_vports[i]);
150 }
7725ccfd
JH
151}
152
5fbe25c7 153/*
a36c61f9
KG
154 * brief
155 * FCS driver details initialization.
7725ccfd 156 *
a36c61f9
KG
157 * param[in] fcs FCS instance
158 * param[in] driver_info Driver Details
7725ccfd 159 *
a36c61f9 160 * return None
7725ccfd
JH
161 */
162void
163bfa_fcs_driver_info_init(struct bfa_fcs_s *fcs,
164 struct bfa_fcs_driver_info_s *driver_info)
165{
166
167 fcs->driver_info = *driver_info;
168
169 bfa_fcs_fabric_psymb_init(&fcs->fabric);
ce7242b8 170 bfa_fcs_fabric_nsymb_init(&fcs->fabric);
7725ccfd
JH
171}
172
5fbe25c7 173/*
a36c61f9
KG
174 * brief
175 * FCS instance cleanup and exit.
7725ccfd 176 *
a36c61f9
KG
177 * param[in] fcs FCS instance
178 * return None
7725ccfd
JH
179 */
180void
181bfa_fcs_exit(struct bfa_fcs_s *fcs)
182{
183 struct bfa_fcs_mod_s *mod;
a36c61f9 184 int nmods, i;
7725ccfd
JH
185
186 bfa_wc_init(&fcs->wc, bfa_fcs_exit_comp, fcs);
187
44416c42 188 nmods = ARRAY_SIZE(fcs_modules);
a36c61f9
KG
189
190 for (i = 0; i < nmods; i++) {
7725ccfd
JH
191
192 mod = &fcs_modules[i];
82794a2e
KG
193 if (mod->modexit) {
194 bfa_wc_up(&fcs->wc);
195 mod->modexit(fcs);
196 }
7725ccfd
JH
197 }
198
199 bfa_wc_wait(&fcs->wc);
200}
201
202
5fbe25c7 203/*
a36c61f9
KG
204 * Fabric module implementation.
205 */
206
207#define BFA_FCS_FABRIC_RETRY_DELAY (2000) /* Milliseconds */
208#define BFA_FCS_FABRIC_CLEANUP_DELAY (10000) /* Milliseconds */
209
210#define bfa_fcs_fabric_set_opertype(__fabric) do { \
d7be54cc
KG
211 if (bfa_fcport_get_topology((__fabric)->fcs->bfa) \
212 == BFA_PORT_TOPOLOGY_P2P) { \
213 if (fabric->fab_type == BFA_FCS_FABRIC_SWITCHED) \
a36c61f9
KG
214 (__fabric)->oper_type = BFA_PORT_TYPE_NPORT; \
215 else \
d7be54cc
KG
216 (__fabric)->oper_type = BFA_PORT_TYPE_P2P; \
217 } else \
218 (__fabric)->oper_type = BFA_PORT_TYPE_NLPORT; \
a36c61f9
KG
219} while (0)
220
221/*
222 * forward declarations
223 */
224static void bfa_fcs_fabric_init(struct bfa_fcs_fabric_s *fabric);
225static void bfa_fcs_fabric_login(struct bfa_fcs_fabric_s *fabric);
226static void bfa_fcs_fabric_notify_online(struct bfa_fcs_fabric_s *fabric);
227static void bfa_fcs_fabric_notify_offline(struct bfa_fcs_fabric_s *fabric);
228static void bfa_fcs_fabric_delay(void *cbarg);
229static void bfa_fcs_fabric_delete(struct bfa_fcs_fabric_s *fabric);
230static void bfa_fcs_fabric_delete_comp(void *cbarg);
881c1b3c
KG
231static void bfa_fcs_fabric_stop(struct bfa_fcs_fabric_s *fabric);
232static void bfa_fcs_fabric_stop_comp(void *cbarg);
a36c61f9
KG
233static void bfa_fcs_fabric_process_uf(struct bfa_fcs_fabric_s *fabric,
234 struct fchs_s *fchs, u16 len);
235static void bfa_fcs_fabric_process_flogi(struct bfa_fcs_fabric_s *fabric,
236 struct fchs_s *fchs, u16 len);
237static void bfa_fcs_fabric_send_flogi_acc(struct bfa_fcs_fabric_s *fabric);
238static void bfa_fcs_fabric_flogiacc_comp(void *fcsarg,
239 struct bfa_fcxp_s *fcxp, void *cbarg,
240 bfa_status_t status,
241 u32 rsp_len,
242 u32 resid_len,
243 struct fchs_s *rspfchs);
a36c61f9
KG
244
245static void bfa_fcs_fabric_sm_uninit(struct bfa_fcs_fabric_s *fabric,
246 enum bfa_fcs_fabric_event event);
247static void bfa_fcs_fabric_sm_created(struct bfa_fcs_fabric_s *fabric,
248 enum bfa_fcs_fabric_event event);
249static void bfa_fcs_fabric_sm_linkdown(struct bfa_fcs_fabric_s *fabric,
250 enum bfa_fcs_fabric_event event);
251static void bfa_fcs_fabric_sm_flogi(struct bfa_fcs_fabric_s *fabric,
252 enum bfa_fcs_fabric_event event);
253static void bfa_fcs_fabric_sm_flogi_retry(struct bfa_fcs_fabric_s *fabric,
254 enum bfa_fcs_fabric_event event);
255static void bfa_fcs_fabric_sm_auth(struct bfa_fcs_fabric_s *fabric,
256 enum bfa_fcs_fabric_event event);
a36c61f9
KG
257static void bfa_fcs_fabric_sm_nofabric(struct bfa_fcs_fabric_s *fabric,
258 enum bfa_fcs_fabric_event event);
a36c61f9
KG
259static void bfa_fcs_fabric_sm_evfp(struct bfa_fcs_fabric_s *fabric,
260 enum bfa_fcs_fabric_event event);
261static void bfa_fcs_fabric_sm_evfp_done(struct bfa_fcs_fabric_s *fabric,
262 enum bfa_fcs_fabric_event event);
263static void bfa_fcs_fabric_sm_isolated(struct bfa_fcs_fabric_s *fabric,
264 enum bfa_fcs_fabric_event event);
265static void bfa_fcs_fabric_sm_deleting(struct bfa_fcs_fabric_s *fabric,
266 enum bfa_fcs_fabric_event event);
881c1b3c
KG
267static void bfa_fcs_fabric_sm_stopping(struct bfa_fcs_fabric_s *fabric,
268 enum bfa_fcs_fabric_event event);
269static void bfa_fcs_fabric_sm_cleanup(struct bfa_fcs_fabric_s *fabric,
270 enum bfa_fcs_fabric_event event);
5fbe25c7 271/*
a36c61f9
KG
272 * Beginning state before fabric creation.
273 */
274static void
275bfa_fcs_fabric_sm_uninit(struct bfa_fcs_fabric_s *fabric,
276 enum bfa_fcs_fabric_event event)
277{
278 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
279 bfa_trc(fabric->fcs, event);
280
281 switch (event) {
282 case BFA_FCS_FABRIC_SM_CREATE:
283 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_created);
284 bfa_fcs_fabric_init(fabric);
285 bfa_fcs_lport_init(&fabric->bport, &fabric->bport.port_cfg);
286 break;
287
288 case BFA_FCS_FABRIC_SM_LINK_UP:
289 case BFA_FCS_FABRIC_SM_LINK_DOWN:
290 break;
291
292 default:
293 bfa_sm_fault(fabric->fcs, event);
294 }
295}
296
5fbe25c7 297/*
a36c61f9
KG
298 * Beginning state before fabric creation.
299 */
300static void
301bfa_fcs_fabric_sm_created(struct bfa_fcs_fabric_s *fabric,
302 enum bfa_fcs_fabric_event event)
303{
bc0e2c2a
KG
304 struct bfa_s *bfa = fabric->fcs->bfa;
305
a36c61f9
KG
306 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
307 bfa_trc(fabric->fcs, event);
308
309 switch (event) {
310 case BFA_FCS_FABRIC_SM_START:
bc0e2c2a
KG
311 if (!bfa_fcport_is_linkup(fabric->fcs->bfa)) {
312 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
313 break;
314 }
315 if (bfa_fcport_get_topology(bfa) ==
316 BFA_PORT_TOPOLOGY_LOOP) {
317 fabric->fab_type = BFA_FCS_FABRIC_LOOP;
318 fabric->bport.pid = bfa_fcport_get_myalpa(bfa);
319 fabric->bport.pid = bfa_hton3b(fabric->bport.pid);
320 bfa_sm_set_state(fabric,
321 bfa_fcs_fabric_sm_online);
322 bfa_fcs_fabric_set_opertype(fabric);
323 bfa_fcs_lport_online(&fabric->bport);
324 } else {
a36c61f9
KG
325 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_flogi);
326 bfa_fcs_fabric_login(fabric);
bc0e2c2a 327 }
a36c61f9
KG
328 break;
329
330 case BFA_FCS_FABRIC_SM_LINK_UP:
331 case BFA_FCS_FABRIC_SM_LINK_DOWN:
332 break;
333
334 case BFA_FCS_FABRIC_SM_DELETE:
dd5aaf45
KG
335 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
336 bfa_fcs_fabric_delete(fabric);
a36c61f9
KG
337 break;
338
339 default:
340 bfa_sm_fault(fabric->fcs, event);
341 }
342}
343
5fbe25c7 344/*
a36c61f9
KG
345 * Link is down, awaiting LINK UP event from port. This is also the
346 * first state at fabric creation.
347 */
348static void
349bfa_fcs_fabric_sm_linkdown(struct bfa_fcs_fabric_s *fabric,
350 enum bfa_fcs_fabric_event event)
351{
bc0e2c2a
KG
352 struct bfa_s *bfa = fabric->fcs->bfa;
353
a36c61f9
KG
354 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
355 bfa_trc(fabric->fcs, event);
356
357 switch (event) {
358 case BFA_FCS_FABRIC_SM_LINK_UP:
bc0e2c2a
KG
359 if (bfa_fcport_get_topology(bfa) != BFA_PORT_TOPOLOGY_LOOP) {
360 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_flogi);
361 bfa_fcs_fabric_login(fabric);
362 break;
363 }
364 fabric->fab_type = BFA_FCS_FABRIC_LOOP;
365 fabric->bport.pid = bfa_fcport_get_myalpa(bfa);
366 fabric->bport.pid = bfa_hton3b(fabric->bport.pid);
367 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_online);
368 bfa_fcs_fabric_set_opertype(fabric);
369 bfa_fcs_lport_online(&fabric->bport);
a36c61f9
KG
370 break;
371
372 case BFA_FCS_FABRIC_SM_RETRY_OP:
bc0e2c2a 373 case BFA_FCS_FABRIC_SM_LOOPBACK:
a36c61f9
KG
374 break;
375
376 case BFA_FCS_FABRIC_SM_DELETE:
377 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
378 bfa_fcs_fabric_delete(fabric);
379 break;
380
881c1b3c
KG
381 case BFA_FCS_FABRIC_SM_STOP:
382 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_cleanup);
383 bfa_fcs_fabric_stop(fabric);
384 break;
385
a36c61f9
KG
386 default:
387 bfa_sm_fault(fabric->fcs, event);
388 }
389}
390
5fbe25c7 391/*
a36c61f9
KG
392 * FLOGI is in progress, awaiting FLOGI reply.
393 */
394static void
395bfa_fcs_fabric_sm_flogi(struct bfa_fcs_fabric_s *fabric,
396 enum bfa_fcs_fabric_event event)
397{
398 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
399 bfa_trc(fabric->fcs, event);
400
401 switch (event) {
402 case BFA_FCS_FABRIC_SM_CONT_OP:
403
404 bfa_fcport_set_tx_bbcredit(fabric->fcs->bfa,
bbe37a67 405 fabric->bb_credit);
a36c61f9
KG
406 fabric->fab_type = BFA_FCS_FABRIC_SWITCHED;
407
408 if (fabric->auth_reqd && fabric->is_auth) {
409 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_auth);
410 bfa_trc(fabric->fcs, event);
411 } else {
412 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_online);
413 bfa_fcs_fabric_notify_online(fabric);
414 }
415 break;
416
417 case BFA_FCS_FABRIC_SM_RETRY_OP:
418 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_flogi_retry);
419 bfa_timer_start(fabric->fcs->bfa, &fabric->delay_timer,
420 bfa_fcs_fabric_delay, fabric,
421 BFA_FCS_FABRIC_RETRY_DELAY);
422 break;
423
424 case BFA_FCS_FABRIC_SM_LOOPBACK:
425 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_loopback);
f7f73812 426 bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE);
a36c61f9
KG
427 bfa_fcs_fabric_set_opertype(fabric);
428 break;
429
430 case BFA_FCS_FABRIC_SM_NO_FABRIC:
431 fabric->fab_type = BFA_FCS_FABRIC_N2N;
432 bfa_fcport_set_tx_bbcredit(fabric->fcs->bfa,
bbe37a67 433 fabric->bb_credit);
a36c61f9
KG
434 bfa_fcs_fabric_notify_online(fabric);
435 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_nofabric);
436 break;
437
438 case BFA_FCS_FABRIC_SM_LINK_DOWN:
439 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
f7f73812 440 bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE);
a36c61f9
KG
441 break;
442
443 case BFA_FCS_FABRIC_SM_DELETE:
444 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
f7f73812 445 bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE);
a36c61f9
KG
446 bfa_fcs_fabric_delete(fabric);
447 break;
448
449 default:
450 bfa_sm_fault(fabric->fcs, event);
451 }
452}
453
454
455static void
456bfa_fcs_fabric_sm_flogi_retry(struct bfa_fcs_fabric_s *fabric,
457 enum bfa_fcs_fabric_event event)
458{
459 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
460 bfa_trc(fabric->fcs, event);
461
462 switch (event) {
463 case BFA_FCS_FABRIC_SM_DELAYED:
464 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_flogi);
465 bfa_fcs_fabric_login(fabric);
466 break;
467
468 case BFA_FCS_FABRIC_SM_LINK_DOWN:
469 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
470 bfa_timer_stop(&fabric->delay_timer);
471 break;
472
473 case BFA_FCS_FABRIC_SM_DELETE:
474 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
475 bfa_timer_stop(&fabric->delay_timer);
476 bfa_fcs_fabric_delete(fabric);
477 break;
478
479 default:
480 bfa_sm_fault(fabric->fcs, event);
481 }
482}
483
5fbe25c7 484/*
a36c61f9
KG
485 * Authentication is in progress, awaiting authentication results.
486 */
487static void
488bfa_fcs_fabric_sm_auth(struct bfa_fcs_fabric_s *fabric,
489 enum bfa_fcs_fabric_event event)
490{
491 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
492 bfa_trc(fabric->fcs, event);
493
494 switch (event) {
495 case BFA_FCS_FABRIC_SM_AUTH_FAILED:
496 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_auth_failed);
f7f73812 497 bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE);
a36c61f9
KG
498 break;
499
500 case BFA_FCS_FABRIC_SM_AUTH_SUCCESS:
501 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_online);
502 bfa_fcs_fabric_notify_online(fabric);
503 break;
504
505 case BFA_FCS_FABRIC_SM_PERF_EVFP:
506 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_evfp);
507 break;
508
509 case BFA_FCS_FABRIC_SM_LINK_DOWN:
510 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
f7f73812 511 bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE);
a36c61f9
KG
512 break;
513
514 case BFA_FCS_FABRIC_SM_DELETE:
515 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
516 bfa_fcs_fabric_delete(fabric);
517 break;
518
519 default:
520 bfa_sm_fault(fabric->fcs, event);
521 }
522}
523
5fbe25c7 524/*
a36c61f9
KG
525 * Authentication failed
526 */
f7f73812 527void
a36c61f9
KG
528bfa_fcs_fabric_sm_auth_failed(struct bfa_fcs_fabric_s *fabric,
529 enum bfa_fcs_fabric_event event)
530{
531 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
532 bfa_trc(fabric->fcs, event);
533
534 switch (event) {
535 case BFA_FCS_FABRIC_SM_LINK_DOWN:
536 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
537 bfa_fcs_fabric_notify_offline(fabric);
538 break;
539
540 case BFA_FCS_FABRIC_SM_DELETE:
541 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
542 bfa_fcs_fabric_delete(fabric);
543 break;
544
545 default:
546 bfa_sm_fault(fabric->fcs, event);
547 }
548}
549
5fbe25c7 550/*
a36c61f9
KG
551 * Port is in loopback mode.
552 */
f7f73812 553void
a36c61f9
KG
554bfa_fcs_fabric_sm_loopback(struct bfa_fcs_fabric_s *fabric,
555 enum bfa_fcs_fabric_event event)
556{
557 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
558 bfa_trc(fabric->fcs, event);
559
560 switch (event) {
561 case BFA_FCS_FABRIC_SM_LINK_DOWN:
562 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
563 bfa_fcs_fabric_notify_offline(fabric);
564 break;
565
566 case BFA_FCS_FABRIC_SM_DELETE:
567 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
568 bfa_fcs_fabric_delete(fabric);
569 break;
570
571 default:
572 bfa_sm_fault(fabric->fcs, event);
573 }
574}
575
5fbe25c7 576/*
a36c61f9
KG
577 * There is no attached fabric - private loop or NPort-to-NPort topology.
578 */
579static void
580bfa_fcs_fabric_sm_nofabric(struct bfa_fcs_fabric_s *fabric,
581 enum bfa_fcs_fabric_event event)
582{
583 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
584 bfa_trc(fabric->fcs, event);
585
586 switch (event) {
587 case BFA_FCS_FABRIC_SM_LINK_DOWN:
588 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
f7f73812 589 bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE);
a36c61f9
KG
590 bfa_fcs_fabric_notify_offline(fabric);
591 break;
592
593 case BFA_FCS_FABRIC_SM_DELETE:
594 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
595 bfa_fcs_fabric_delete(fabric);
596 break;
597
598 case BFA_FCS_FABRIC_SM_NO_FABRIC:
599 bfa_trc(fabric->fcs, fabric->bb_credit);
600 bfa_fcport_set_tx_bbcredit(fabric->fcs->bfa,
bbe37a67 601 fabric->bb_credit);
a36c61f9
KG
602 break;
603
d7be54cc
KG
604 case BFA_FCS_FABRIC_SM_RETRY_OP:
605 break;
606
a36c61f9
KG
607 default:
608 bfa_sm_fault(fabric->fcs, event);
609 }
610}
611
5fbe25c7 612/*
a36c61f9
KG
613 * Fabric is online - normal operating state.
614 */
f7f73812 615void
a36c61f9
KG
616bfa_fcs_fabric_sm_online(struct bfa_fcs_fabric_s *fabric,
617 enum bfa_fcs_fabric_event event)
618{
bc0e2c2a
KG
619 struct bfa_s *bfa = fabric->fcs->bfa;
620
a36c61f9
KG
621 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
622 bfa_trc(fabric->fcs, event);
623
624 switch (event) {
625 case BFA_FCS_FABRIC_SM_LINK_DOWN:
626 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
bc0e2c2a
KG
627 if (bfa_fcport_get_topology(bfa) == BFA_PORT_TOPOLOGY_LOOP) {
628 bfa_fcs_lport_offline(&fabric->bport);
629 } else {
630 bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE);
631 bfa_fcs_fabric_notify_offline(fabric);
632 }
a36c61f9
KG
633 break;
634
635 case BFA_FCS_FABRIC_SM_DELETE:
636 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
637 bfa_fcs_fabric_delete(fabric);
638 break;
639
881c1b3c
KG
640 case BFA_FCS_FABRIC_SM_STOP:
641 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_stopping);
642 bfa_fcs_fabric_stop(fabric);
643 break;
644
a36c61f9
KG
645 case BFA_FCS_FABRIC_SM_AUTH_FAILED:
646 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_auth_failed);
f7f73812 647 bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE);
a36c61f9
KG
648 break;
649
650 case BFA_FCS_FABRIC_SM_AUTH_SUCCESS:
651 break;
652
653 default:
654 bfa_sm_fault(fabric->fcs, event);
655 }
656}
657
5fbe25c7 658/*
a36c61f9
KG
659 * Exchanging virtual fabric parameters.
660 */
661static void
662bfa_fcs_fabric_sm_evfp(struct bfa_fcs_fabric_s *fabric,
663 enum bfa_fcs_fabric_event event)
664{
665 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
666 bfa_trc(fabric->fcs, event);
667
668 switch (event) {
669 case BFA_FCS_FABRIC_SM_CONT_OP:
670 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_evfp_done);
671 break;
672
673 case BFA_FCS_FABRIC_SM_ISOLATE:
674 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_isolated);
675 break;
676
677 default:
678 bfa_sm_fault(fabric->fcs, event);
679 }
680}
681
5fbe25c7 682/*
a36c61f9
KG
683 * EVFP exchange complete and VFT tagging is enabled.
684 */
685static void
686bfa_fcs_fabric_sm_evfp_done(struct bfa_fcs_fabric_s *fabric,
687 enum bfa_fcs_fabric_event event)
688{
689 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
690 bfa_trc(fabric->fcs, event);
691}
692
5fbe25c7 693/*
a36c61f9
KG
694 * Port is isolated after EVFP exchange due to VF_ID mismatch (N and F).
695 */
696static void
697bfa_fcs_fabric_sm_isolated(struct bfa_fcs_fabric_s *fabric,
698 enum bfa_fcs_fabric_event event)
699{
700 struct bfad_s *bfad = (struct bfad_s *)fabric->fcs->bfad;
701 char pwwn_ptr[BFA_STRING_32];
702
703 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
704 bfa_trc(fabric->fcs, event);
705 wwn2str(pwwn_ptr, fabric->bport.port_cfg.pwwn);
706
88166242 707 BFA_LOG(KERN_INFO, bfad, bfa_log_level,
a36c61f9
KG
708 "Port is isolated due to VF_ID mismatch. "
709 "PWWN: %s Port VF_ID: %04x switch port VF_ID: %04x.",
710 pwwn_ptr, fabric->fcs->port_vfid,
711 fabric->event_arg.swp_vfid);
712}
713
5fbe25c7 714/*
a36c61f9
KG
715 * Fabric is being deleted, awaiting vport delete completions.
716 */
717static void
718bfa_fcs_fabric_sm_deleting(struct bfa_fcs_fabric_s *fabric,
719 enum bfa_fcs_fabric_event event)
7725ccfd 720{
a36c61f9
KG
721 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
722 bfa_trc(fabric->fcs, event);
723
724 switch (event) {
725 case BFA_FCS_FABRIC_SM_DELCOMP:
726 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_uninit);
f7f73812 727 bfa_wc_down(&fabric->fcs->wc);
a36c61f9
KG
728 break;
729
730 case BFA_FCS_FABRIC_SM_LINK_UP:
731 break;
732
733 case BFA_FCS_FABRIC_SM_LINK_DOWN:
734 bfa_fcs_fabric_notify_offline(fabric);
735 break;
736
737 default:
738 bfa_sm_fault(fabric->fcs, event);
739 }
7725ccfd
JH
740}
741
881c1b3c
KG
742/*
743 * Fabric is being stopped, awaiting vport stop completions.
744 */
745static void
746bfa_fcs_fabric_sm_stopping(struct bfa_fcs_fabric_s *fabric,
747 enum bfa_fcs_fabric_event event)
748{
bc0e2c2a
KG
749 struct bfa_s *bfa = fabric->fcs->bfa;
750
881c1b3c
KG
751 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
752 bfa_trc(fabric->fcs, event);
753
754 switch (event) {
755 case BFA_FCS_FABRIC_SM_STOPCOMP:
bc0e2c2a
KG
756 if (bfa_fcport_get_topology(bfa) == BFA_PORT_TOPOLOGY_LOOP) {
757 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_created);
758 } else {
759 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_cleanup);
760 bfa_sm_send_event(fabric->lps, BFA_LPS_SM_LOGOUT);
761 }
881c1b3c
KG
762 break;
763
764 case BFA_FCS_FABRIC_SM_LINK_UP:
765 break;
766
767 case BFA_FCS_FABRIC_SM_LINK_DOWN:
bc0e2c2a
KG
768 if (bfa_fcport_get_topology(bfa) == BFA_PORT_TOPOLOGY_LOOP)
769 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_created);
770 else
771 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_cleanup);
881c1b3c
KG
772 break;
773
774 default:
775 bfa_sm_fault(fabric->fcs, event);
776 }
777}
778
779/*
780 * Fabric is being stopped, cleanup without FLOGO
781 */
782static void
783bfa_fcs_fabric_sm_cleanup(struct bfa_fcs_fabric_s *fabric,
784 enum bfa_fcs_fabric_event event)
785{
786 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
787 bfa_trc(fabric->fcs, event);
788
789 switch (event) {
790 case BFA_FCS_FABRIC_SM_STOPCOMP:
791 case BFA_FCS_FABRIC_SM_LOGOCOMP:
792 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_created);
793 bfa_wc_down(&(fabric->fcs)->wc);
794 break;
795
796 case BFA_FCS_FABRIC_SM_LINK_DOWN:
797 /*
798 * Ignore - can get this event if we get notified about IOC down
799 * before the fabric completion callbk is done.
800 */
801 break;
7725ccfd 802
881c1b3c
KG
803 default:
804 bfa_sm_fault(fabric->fcs, event);
805 }
806}
a36c61f9 807
5fbe25c7 808/*
a36c61f9
KG
809 * fcs_fabric_private fabric private functions
810 */
811
812static void
813bfa_fcs_fabric_init(struct bfa_fcs_fabric_s *fabric)
814{
815 struct bfa_lport_cfg_s *port_cfg = &fabric->bport.port_cfg;
816
817 port_cfg->roles = BFA_LPORT_ROLE_FCP_IM;
f7f73812
MZ
818 port_cfg->nwwn = fabric->fcs->bfa->ioc.attr->nwwn;
819 port_cfg->pwwn = fabric->fcs->bfa->ioc.attr->pwwn;
a36c61f9
KG
820}
821
5fbe25c7 822/*
a36c61f9
KG
823 * Port Symbolic Name Creation for base port.
824 */
7725ccfd 825void
a36c61f9 826bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s *fabric)
7725ccfd 827{
a36c61f9
KG
828 struct bfa_lport_cfg_s *port_cfg = &fabric->bport.port_cfg;
829 char model[BFA_ADAPTER_MODEL_NAME_LEN] = {0};
830 struct bfa_fcs_driver_info_s *driver_info = &fabric->fcs->driver_info;
831
832 bfa_ioc_get_adapter_model(&fabric->fcs->bfa->ioc, model);
833
834 /* Model name/number */
835 strncpy((char *)&port_cfg->sym_name, model,
836 BFA_FCS_PORT_SYMBNAME_MODEL_SZ);
837 strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
838 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
839
840 /* Driver Version */
841 strncat((char *)&port_cfg->sym_name, (char *)driver_info->version,
842 BFA_FCS_PORT_SYMBNAME_VERSION_SZ);
843 strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
844 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
845
846 /* Host machine name */
847 strncat((char *)&port_cfg->sym_name,
848 (char *)driver_info->host_machine_name,
849 BFA_FCS_PORT_SYMBNAME_MACHINENAME_SZ);
850 strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
851 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
852
853 /*
854 * Host OS Info :
855 * If OS Patch Info is not there, do not truncate any bytes from the
856 * OS name string and instead copy the entire OS info string (64 bytes).
857 */
858 if (driver_info->host_os_patch[0] == '\0') {
859 strncat((char *)&port_cfg->sym_name,
860 (char *)driver_info->host_os_name,
861 BFA_FCS_OS_STR_LEN);
862 strncat((char *)&port_cfg->sym_name,
863 BFA_FCS_PORT_SYMBNAME_SEPARATOR,
864 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
865 } else {
866 strncat((char *)&port_cfg->sym_name,
867 (char *)driver_info->host_os_name,
868 BFA_FCS_PORT_SYMBNAME_OSINFO_SZ);
869 strncat((char *)&port_cfg->sym_name,
870 BFA_FCS_PORT_SYMBNAME_SEPARATOR,
871 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
872
873 /* Append host OS Patch Info */
874 strncat((char *)&port_cfg->sym_name,
875 (char *)driver_info->host_os_patch,
876 BFA_FCS_PORT_SYMBNAME_OSPATCH_SZ);
877 }
878
879 /* null terminate */
880 port_cfg->sym_name.symname[BFA_SYMNAME_MAXLEN - 1] = 0;
7725ccfd
JH
881}
882
ce7242b8
KG
883/*
884 * Node Symbolic Name Creation for base port and all vports
885 */
886void
887bfa_fcs_fabric_nsymb_init(struct bfa_fcs_fabric_s *fabric)
888{
889 struct bfa_lport_cfg_s *port_cfg = &fabric->bport.port_cfg;
890 char model[BFA_ADAPTER_MODEL_NAME_LEN] = {0};
891 struct bfa_fcs_driver_info_s *driver_info = &fabric->fcs->driver_info;
892
893 bfa_ioc_get_adapter_model(&fabric->fcs->bfa->ioc, model);
894
895 /* Model name/number */
896 strncpy((char *)&port_cfg->node_sym_name, model,
897 BFA_FCS_PORT_SYMBNAME_MODEL_SZ);
898 strncat((char *)&port_cfg->node_sym_name,
899 BFA_FCS_PORT_SYMBNAME_SEPARATOR,
900 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
901
902 /* Driver Version */
903 strncat((char *)&port_cfg->node_sym_name, (char *)driver_info->version,
904 BFA_FCS_PORT_SYMBNAME_VERSION_SZ);
905 strncat((char *)&port_cfg->node_sym_name,
906 BFA_FCS_PORT_SYMBNAME_SEPARATOR,
907 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
908
909 /* Host machine name */
910 strncat((char *)&port_cfg->node_sym_name,
911 (char *)driver_info->host_machine_name,
912 BFA_FCS_PORT_SYMBNAME_MACHINENAME_SZ);
913 strncat((char *)&port_cfg->node_sym_name,
914 BFA_FCS_PORT_SYMBNAME_SEPARATOR,
915 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
916
917 /* null terminate */
918 port_cfg->node_sym_name.symname[BFA_SYMNAME_MAXLEN - 1] = 0;
919}
920
5fbe25c7 921/*
a36c61f9
KG
922 * bfa lps login completion callback
923 */
7725ccfd 924void
a36c61f9 925bfa_cb_lps_flogi_comp(void *bfad, void *uarg, bfa_status_t status)
7725ccfd 926{
a36c61f9
KG
927 struct bfa_fcs_fabric_s *fabric = uarg;
928
929 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
930 bfa_trc(fabric->fcs, status);
931
932 switch (status) {
933 case BFA_STATUS_OK:
934 fabric->stats.flogi_accepts++;
935 break;
936
937 case BFA_STATUS_INVALID_MAC:
938 /* Only for CNA */
939 fabric->stats.flogi_acc_err++;
940 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_RETRY_OP);
941
942 return;
943
944 case BFA_STATUS_EPROTOCOL:
f7f73812 945 switch (fabric->lps->ext_status) {
a36c61f9
KG
946 case BFA_EPROTO_BAD_ACCEPT:
947 fabric->stats.flogi_acc_err++;
948 break;
949
950 case BFA_EPROTO_UNKNOWN_RSP:
951 fabric->stats.flogi_unknown_rsp++;
952 break;
953
954 default:
955 break;
956 }
957 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_RETRY_OP);
958
959 return;
960
961 case BFA_STATUS_FABRIC_RJT:
962 fabric->stats.flogi_rejects++;
963 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_RETRY_OP);
964 return;
965
966 default:
967 fabric->stats.flogi_rsp_err++;
968 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_RETRY_OP);
969 return;
970 }
971
f7f73812 972 fabric->bb_credit = fabric->lps->pr_bbcred;
a36c61f9
KG
973 bfa_trc(fabric->fcs, fabric->bb_credit);
974
f7f73812
MZ
975 if (!(fabric->lps->brcd_switch))
976 fabric->fabric_name = fabric->lps->pr_nwwn;
a36c61f9
KG
977
978 /*
979 * Check port type. It should be 1 = F-port.
980 */
f7f73812
MZ
981 if (fabric->lps->fport) {
982 fabric->bport.pid = fabric->lps->lp_pid;
983 fabric->is_npiv = fabric->lps->npiv_en;
984 fabric->is_auth = fabric->lps->auth_req;
a36c61f9
KG
985 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_CONT_OP);
986 } else {
987 /*
988 * Nport-2-Nport direct attached
989 */
990 fabric->bport.port_topo.pn2n.rem_port_wwn =
f7f73812 991 fabric->lps->pr_pwwn;
d7be54cc 992 fabric->fab_type = BFA_FCS_FABRIC_N2N;
a36c61f9
KG
993 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_NO_FABRIC);
994 }
995
996 bfa_trc(fabric->fcs, fabric->bport.pid);
997 bfa_trc(fabric->fcs, fabric->is_npiv);
998 bfa_trc(fabric->fcs, fabric->is_auth);
999}
5fbe25c7 1000/*
a36c61f9
KG
1001 * Allocate and send FLOGI.
1002 */
1003static void
1004bfa_fcs_fabric_login(struct bfa_fcs_fabric_s *fabric)
1005{
1006 struct bfa_s *bfa = fabric->fcs->bfa;
1007 struct bfa_lport_cfg_s *pcfg = &fabric->bport.port_cfg;
bbe37a67 1008 u8 alpa = 0;
a36c61f9 1009
be540a99 1010
a36c61f9 1011 bfa_lps_flogi(fabric->lps, fabric, alpa, bfa_fcport_get_maxfrsize(bfa),
bbe37a67 1012 pcfg->pwwn, pcfg->nwwn, fabric->auth_reqd);
a36c61f9
KG
1013
1014 fabric->stats.flogi_sent++;
1015}
1016
1017static void
1018bfa_fcs_fabric_notify_online(struct bfa_fcs_fabric_s *fabric)
1019{
1020 struct bfa_fcs_vport_s *vport;
1021 struct list_head *qe, *qen;
1022
1023 bfa_trc(fabric->fcs, fabric->fabric_name);
1024
1025 bfa_fcs_fabric_set_opertype(fabric);
1026 fabric->stats.fabric_onlines++;
1027
5fbe25c7 1028 /*
a36c61f9
KG
1029 * notify online event to base and then virtual ports
1030 */
1031 bfa_fcs_lport_online(&fabric->bport);
1032
1033 list_for_each_safe(qe, qen, &fabric->vport_q) {
1034 vport = (struct bfa_fcs_vport_s *) qe;
1035 bfa_fcs_vport_online(vport);
1036 }
1037}
1038
1039static void
1040bfa_fcs_fabric_notify_offline(struct bfa_fcs_fabric_s *fabric)
1041{
1042 struct bfa_fcs_vport_s *vport;
1043 struct list_head *qe, *qen;
1044
1045 bfa_trc(fabric->fcs, fabric->fabric_name);
1046 fabric->stats.fabric_offlines++;
1047
5fbe25c7 1048 /*
a36c61f9
KG
1049 * notify offline event first to vports and then base port.
1050 */
1051 list_for_each_safe(qe, qen, &fabric->vport_q) {
1052 vport = (struct bfa_fcs_vport_s *) qe;
1053 bfa_fcs_vport_offline(vport);
1054 }
1055
1056 bfa_fcs_lport_offline(&fabric->bport);
1057
1058 fabric->fabric_name = 0;
1059 fabric->fabric_ip_addr[0] = 0;
1060}
1061
1062static void
1063bfa_fcs_fabric_delay(void *cbarg)
1064{
1065 struct bfa_fcs_fabric_s *fabric = cbarg;
1066
1067 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_DELAYED);
1068}
1069
881c1b3c
KG
1070/*
1071 * Stop all vports and wait for vport stop completions.
1072 */
1073static void
1074bfa_fcs_fabric_stop(struct bfa_fcs_fabric_s *fabric)
1075{
1076 struct bfa_fcs_vport_s *vport;
1077 struct list_head *qe, *qen;
1078
1079 bfa_wc_init(&fabric->stop_wc, bfa_fcs_fabric_stop_comp, fabric);
1080
1081 list_for_each_safe(qe, qen, &fabric->vport_q) {
1082 vport = (struct bfa_fcs_vport_s *) qe;
1083 bfa_wc_up(&fabric->stop_wc);
1084 bfa_fcs_vport_fcs_stop(vport);
1085 }
1086
1087 bfa_wc_up(&fabric->stop_wc);
1088 bfa_fcs_lport_stop(&fabric->bport);
1089 bfa_wc_wait(&fabric->stop_wc);
1090}
1091
5fbe25c7 1092/*
a36c61f9
KG
1093 * Delete all vports and wait for vport delete completions.
1094 */
1095static void
1096bfa_fcs_fabric_delete(struct bfa_fcs_fabric_s *fabric)
1097{
1098 struct bfa_fcs_vport_s *vport;
1099 struct list_head *qe, *qen;
1100
1101 list_for_each_safe(qe, qen, &fabric->vport_q) {
1102 vport = (struct bfa_fcs_vport_s *) qe;
1103 bfa_fcs_vport_fcs_delete(vport);
1104 }
1105
1106 bfa_fcs_lport_delete(&fabric->bport);
1107 bfa_wc_wait(&fabric->wc);
7725ccfd
JH
1108}
1109
a36c61f9
KG
1110static void
1111bfa_fcs_fabric_delete_comp(void *cbarg)
1112{
1113 struct bfa_fcs_fabric_s *fabric = cbarg;
1114
1115 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_DELCOMP);
1116}
7725ccfd 1117
881c1b3c
KG
1118static void
1119bfa_fcs_fabric_stop_comp(void *cbarg)
1120{
1121 struct bfa_fcs_fabric_s *fabric = cbarg;
1122
1123 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_STOPCOMP);
1124}
1125
5fbe25c7 1126/*
a36c61f9
KG
1127 * fcs_fabric_public fabric public functions
1128 */
1129
5fbe25c7 1130/*
a36c61f9
KG
1131 * Attach time initialization.
1132 */
1133void
1134bfa_fcs_fabric_attach(struct bfa_fcs_s *fcs)
1135{
1136 struct bfa_fcs_fabric_s *fabric;
1137
1138 fabric = &fcs->fabric;
6a18b167 1139 memset(fabric, 0, sizeof(struct bfa_fcs_fabric_s));
a36c61f9 1140
5fbe25c7 1141 /*
a36c61f9
KG
1142 * Initialize base fabric.
1143 */
1144 fabric->fcs = fcs;
1145 INIT_LIST_HEAD(&fabric->vport_q);
1146 INIT_LIST_HEAD(&fabric->vf_q);
1147 fabric->lps = bfa_lps_alloc(fcs->bfa);
d4b671c5 1148 WARN_ON(!fabric->lps);
a36c61f9 1149
5fbe25c7 1150 /*
a36c61f9
KG
1151 * Initialize fabric delete completion handler. Fabric deletion is
1152 * complete when the last vport delete is complete.
1153 */
1154 bfa_wc_init(&fabric->wc, bfa_fcs_fabric_delete_comp, fabric);
1155 bfa_wc_up(&fabric->wc); /* For the base port */
1156
1157 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_uninit);
1158 bfa_fcs_lport_attach(&fabric->bport, fabric->fcs, FC_VF_ID_NULL, NULL);
1159}
1160
1161void
1162bfa_fcs_fabric_modinit(struct bfa_fcs_s *fcs)
1163{
1164 bfa_sm_send_event(&fcs->fabric, BFA_FCS_FABRIC_SM_CREATE);
1165 bfa_trc(fcs, 0);
1166}
1167
5fbe25c7 1168/*
a36c61f9
KG
1169 * Module cleanup
1170 */
1171void
1172bfa_fcs_fabric_modexit(struct bfa_fcs_s *fcs)
1173{
1174 struct bfa_fcs_fabric_s *fabric;
1175
1176 bfa_trc(fcs, 0);
1177
5fbe25c7 1178 /*
a36c61f9
KG
1179 * Cleanup base fabric.
1180 */
1181 fabric = &fcs->fabric;
1182 bfa_lps_delete(fabric->lps);
1183 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_DELETE);
1184}
1185
881c1b3c
KG
1186/*
1187 * Fabric module stop -- stop FCS actions
1188 */
1189void
1190bfa_fcs_fabric_modstop(struct bfa_fcs_s *fcs)
1191{
1192 struct bfa_fcs_fabric_s *fabric;
1193
1194 bfa_trc(fcs, 0);
1195 fabric = &fcs->fabric;
1196 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_STOP);
1197}
1198
5fbe25c7 1199/*
a36c61f9
KG
1200 * Fabric module start -- kick starts FCS actions
1201 */
1202void
1203bfa_fcs_fabric_modstart(struct bfa_fcs_s *fcs)
1204{
1205 struct bfa_fcs_fabric_s *fabric;
1206
1207 bfa_trc(fcs, 0);
1208 fabric = &fcs->fabric;
1209 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_START);
1210}
1211
a36c61f9 1212
5fbe25c7 1213/*
a36c61f9
KG
1214 * Link up notification from BFA physical port module.
1215 */
1216void
1217bfa_fcs_fabric_link_up(struct bfa_fcs_fabric_s *fabric)
1218{
1219 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
1220 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_LINK_UP);
1221}
1222
5fbe25c7 1223/*
a36c61f9
KG
1224 * Link down notification from BFA physical port module.
1225 */
1226void
1227bfa_fcs_fabric_link_down(struct bfa_fcs_fabric_s *fabric)
1228{
1229 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
1230 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_LINK_DOWN);
1231}
1232
5fbe25c7 1233/*
a36c61f9
KG
1234 * A child vport is being created in the fabric.
1235 *
1236 * Call from vport module at vport creation. A list of base port and vports
1237 * belonging to a fabric is maintained to propagate link events.
1238 *
1239 * param[in] fabric - Fabric instance. This can be a base fabric or vf.
1240 * param[in] vport - Vport being created.
1241 *
1242 * @return None (always succeeds)
1243 */
1244void
1245bfa_fcs_fabric_addvport(struct bfa_fcs_fabric_s *fabric,
1246 struct bfa_fcs_vport_s *vport)
1247{
5fbe25c7 1248 /*
a36c61f9
KG
1249 * - add vport to fabric's vport_q
1250 */
1251 bfa_trc(fabric->fcs, fabric->vf_id);
1252
1253 list_add_tail(&vport->qe, &fabric->vport_q);
1254 fabric->num_vports++;
1255 bfa_wc_up(&fabric->wc);
1256}
1257
5fbe25c7 1258/*
a36c61f9
KG
1259 * A child vport is being deleted from fabric.
1260 *
1261 * Vport is being deleted.
1262 */
1263void
1264bfa_fcs_fabric_delvport(struct bfa_fcs_fabric_s *fabric,
1265 struct bfa_fcs_vport_s *vport)
1266{
1267 list_del(&vport->qe);
1268 fabric->num_vports--;
1269 bfa_wc_down(&fabric->wc);
1270}
1271
a36c61f9 1272
5fbe25c7 1273/*
25985edc 1274 * Lookup for a vport within a fabric given its pwwn
a36c61f9
KG
1275 */
1276struct bfa_fcs_vport_s *
1277bfa_fcs_fabric_vport_lookup(struct bfa_fcs_fabric_s *fabric, wwn_t pwwn)
1278{
1279 struct bfa_fcs_vport_s *vport;
1280 struct list_head *qe;
1281
1282 list_for_each(qe, &fabric->vport_q) {
1283 vport = (struct bfa_fcs_vport_s *) qe;
1284 if (bfa_fcs_lport_get_pwwn(&vport->lport) == pwwn)
1285 return vport;
1286 }
1287
1288 return NULL;
1289}
1290
a36c61f9
KG
1291
1292/*
1293 * Get OUI of the attached switch.
1294 *
1295 * Note : Use of this function should be avoided as much as possible.
1296 * This function should be used only if there is any requirement
1297* to check for FOS version below 6.3.
1298 * To check if the attached fabric is a brocade fabric, use
1299 * bfa_lps_is_brcd_fabric() which works for FOS versions 6.3
1300 * or above only.
1301 */
1302
1303u16
1304bfa_fcs_fabric_get_switch_oui(struct bfa_fcs_fabric_s *fabric)
1305{
1306 wwn_t fab_nwwn;
1307 u8 *tmp;
1308 u16 oui;
1309
f7f73812 1310 fab_nwwn = fabric->lps->pr_nwwn;
a36c61f9
KG
1311
1312 tmp = (u8 *)&fab_nwwn;
1313 oui = (tmp[3] << 8) | tmp[4];
1314
1315 return oui;
1316}
5fbe25c7 1317/*
a36c61f9
KG
1318 * Unsolicited frame receive handling.
1319 */
1320void
1321bfa_fcs_fabric_uf_recv(struct bfa_fcs_fabric_s *fabric, struct fchs_s *fchs,
1322 u16 len)
1323{
1324 u32 pid = fchs->d_id;
1325 struct bfa_fcs_vport_s *vport;
1326 struct list_head *qe;
1327 struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
1328 struct fc_logi_s *flogi = (struct fc_logi_s *) els_cmd;
1329
1330 bfa_trc(fabric->fcs, len);
1331 bfa_trc(fabric->fcs, pid);
1332
5fbe25c7 1333 /*
a36c61f9
KG
1334 * Look for our own FLOGI frames being looped back. This means an
1335 * external loopback cable is in place. Our own FLOGI frames are
1336 * sometimes looped back when switch port gets temporarily bypassed.
1337 */
f16a1750 1338 if ((pid == bfa_ntoh3b(FC_FABRIC_PORT)) &&
a36c61f9
KG
1339 (els_cmd->els_code == FC_ELS_FLOGI) &&
1340 (flogi->port_name == bfa_fcs_lport_get_pwwn(&fabric->bport))) {
1341 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_LOOPBACK);
1342 return;
1343 }
1344
5fbe25c7 1345 /*
a36c61f9
KG
1346 * FLOGI/EVFP exchanges should be consumed by base fabric.
1347 */
f16a1750 1348 if (fchs->d_id == bfa_hton3b(FC_FABRIC_PORT)) {
a36c61f9
KG
1349 bfa_trc(fabric->fcs, pid);
1350 bfa_fcs_fabric_process_uf(fabric, fchs, len);
1351 return;
1352 }
1353
1354 if (fabric->bport.pid == pid) {
5fbe25c7 1355 /*
a36c61f9
KG
1356 * All authentication frames should be routed to auth
1357 */
1358 bfa_trc(fabric->fcs, els_cmd->els_code);
1359 if (els_cmd->els_code == FC_ELS_AUTH) {
1360 bfa_trc(fabric->fcs, els_cmd->els_code);
1361 return;
1362 }
1363
1364 bfa_trc(fabric->fcs, *(u8 *) ((u8 *) fchs));
1365 bfa_fcs_lport_uf_recv(&fabric->bport, fchs, len);
1366 return;
1367 }
1368
5fbe25c7 1369 /*
a36c61f9
KG
1370 * look for a matching local port ID
1371 */
1372 list_for_each(qe, &fabric->vport_q) {
1373 vport = (struct bfa_fcs_vport_s *) qe;
1374 if (vport->lport.pid == pid) {
1375 bfa_fcs_lport_uf_recv(&vport->lport, fchs, len);
1376 return;
1377 }
1378 }
61ba4394
KG
1379
1380 if (!bfa_fcs_fabric_is_switched(fabric))
1381 bfa_fcs_lport_uf_recv(&fabric->bport, fchs, len);
1382
1383 bfa_trc(fabric->fcs, fchs->type);
a36c61f9
KG
1384}
1385
5fbe25c7 1386/*
a36c61f9
KG
1387 * Unsolicited frames to be processed by fabric.
1388 */
1389static void
1390bfa_fcs_fabric_process_uf(struct bfa_fcs_fabric_s *fabric, struct fchs_s *fchs,
1391 u16 len)
1392{
1393 struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
1394
1395 bfa_trc(fabric->fcs, els_cmd->els_code);
1396
1397 switch (els_cmd->els_code) {
1398 case FC_ELS_FLOGI:
1399 bfa_fcs_fabric_process_flogi(fabric, fchs, len);
1400 break;
1401
1402 default:
1403 /*
1404 * need to generate a LS_RJT
1405 */
1406 break;
1407 }
1408}
1409
5fbe25c7 1410/*
a36c61f9
KG
1411 * Process incoming FLOGI
1412 */
1413static void
1414bfa_fcs_fabric_process_flogi(struct bfa_fcs_fabric_s *fabric,
1415 struct fchs_s *fchs, u16 len)
1416{
1417 struct fc_logi_s *flogi = (struct fc_logi_s *) (fchs + 1);
1418 struct bfa_fcs_lport_s *bport = &fabric->bport;
1419
1420 bfa_trc(fabric->fcs, fchs->s_id);
1421
1422 fabric->stats.flogi_rcvd++;
1423 /*
1424 * Check port type. It should be 0 = n-port.
1425 */
1426 if (flogi->csp.port_type) {
1427 /*
1428 * @todo: may need to send a LS_RJT
1429 */
1430 bfa_trc(fabric->fcs, flogi->port_name);
1431 fabric->stats.flogi_rejected++;
1432 return;
1433 }
1434
ba816ea8 1435 fabric->bb_credit = be16_to_cpu(flogi->csp.bbcred);
a36c61f9
KG
1436 bport->port_topo.pn2n.rem_port_wwn = flogi->port_name;
1437 bport->port_topo.pn2n.reply_oxid = fchs->ox_id;
1438
1439 /*
1440 * Send a Flogi Acc
1441 */
1442 bfa_fcs_fabric_send_flogi_acc(fabric);
1443 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_NO_FABRIC);
1444}
1445
1446static void
1447bfa_fcs_fabric_send_flogi_acc(struct bfa_fcs_fabric_s *fabric)
1448{
1449 struct bfa_lport_cfg_s *pcfg = &fabric->bport.port_cfg;
1450 struct bfa_fcs_lport_n2n_s *n2n_port = &fabric->bport.port_topo.pn2n;
1451 struct bfa_s *bfa = fabric->fcs->bfa;
1452 struct bfa_fcxp_s *fcxp;
1453 u16 reqlen;
1454 struct fchs_s fchs;
1455
c3f1b123 1456 fcxp = bfa_fcs_fcxp_alloc(fabric->fcs, BFA_FALSE);
5fbe25c7 1457 /*
a36c61f9
KG
1458 * Do not expect this failure -- expect remote node to retry
1459 */
1460 if (!fcxp)
1461 return;
1462
1463 reqlen = fc_flogi_acc_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
f16a1750 1464 bfa_hton3b(FC_FABRIC_PORT),
a36c61f9
KG
1465 n2n_port->reply_oxid, pcfg->pwwn,
1466 pcfg->nwwn,
1467 bfa_fcport_get_maxfrsize(bfa),
bbe37a67 1468 bfa_fcport_get_rx_bbcredit(bfa), 0);
a36c61f9 1469
3fd45980 1470 bfa_fcxp_send(fcxp, NULL, fabric->vf_id, fabric->lps->bfa_tag,
a36c61f9
KG
1471 BFA_FALSE, FC_CLASS_3,
1472 reqlen, &fchs, bfa_fcs_fabric_flogiacc_comp, fabric,
1473 FC_MAX_PDUSZ, 0);
1474}
1475
5fbe25c7 1476/*
a36c61f9
KG
1477 * Flogi Acc completion callback.
1478 */
1479static void
1480bfa_fcs_fabric_flogiacc_comp(void *fcsarg, struct bfa_fcxp_s *fcxp, void *cbarg,
1481 bfa_status_t status, u32 rsp_len,
1482 u32 resid_len, struct fchs_s *rspfchs)
1483{
1484 struct bfa_fcs_fabric_s *fabric = cbarg;
1485
1486 bfa_trc(fabric->fcs, status);
1487}
1488
7826f304
KG
1489
1490/*
1491 * Send AEN notification
1492 */
1493static void
1494bfa_fcs_fabric_aen_post(struct bfa_fcs_lport_s *port,
1495 enum bfa_port_aen_event event)
1496{
1497 struct bfad_s *bfad = (struct bfad_s *)port->fabric->fcs->bfad;
1498 struct bfa_aen_entry_s *aen_entry;
1499
1500 bfad_get_aen_entry(bfad, aen_entry);
1501 if (!aen_entry)
1502 return;
1503
1504 aen_entry->aen_data.port.pwwn = bfa_fcs_lport_get_pwwn(port);
1505 aen_entry->aen_data.port.fwwn = bfa_fcs_lport_get_fabric_name(port);
1506
1507 /* Send the AEN notification */
1508 bfad_im_post_vendor_event(aen_entry, bfad, ++port->fcs->fcs_aen_seq,
1509 BFA_AEN_CAT_PORT, event);
1510}
1511
a36c61f9
KG
1512/*
1513 *
1514 * @param[in] fabric - fabric
1515 * @param[in] wwn_t - new fabric name
1516 *
1517 * @return - none
1518 */
1519void
1520bfa_fcs_fabric_set_fabric_name(struct bfa_fcs_fabric_s *fabric,
1521 wwn_t fabric_name)
1522{
1523 struct bfad_s *bfad = (struct bfad_s *)fabric->fcs->bfad;
1524 char pwwn_ptr[BFA_STRING_32];
1525 char fwwn_ptr[BFA_STRING_32];
1526
1527 bfa_trc(fabric->fcs, fabric_name);
1528
1529 if (fabric->fabric_name == 0) {
1530 /*
1531 * With BRCD switches, we don't get Fabric Name in FLOGI.
1532 * Don't generate a fabric name change event in this case.
1533 */
1534 fabric->fabric_name = fabric_name;
1535 } else {
1536 fabric->fabric_name = fabric_name;
1537 wwn2str(pwwn_ptr, bfa_fcs_lport_get_pwwn(&fabric->bport));
1538 wwn2str(fwwn_ptr,
1539 bfa_fcs_lport_get_fabric_name(&fabric->bport));
88166242 1540 BFA_LOG(KERN_WARNING, bfad, bfa_log_level,
a36c61f9
KG
1541 "Base port WWN = %s Fabric WWN = %s\n",
1542 pwwn_ptr, fwwn_ptr);
7826f304
KG
1543 bfa_fcs_fabric_aen_post(&fabric->bport,
1544 BFA_PORT_AEN_FABRIC_NAME_CHANGE);
a36c61f9
KG
1545 }
1546}
1547
881c1b3c
KG
1548void
1549bfa_cb_lps_flogo_comp(void *bfad, void *uarg)
1550{
1551 struct bfa_fcs_fabric_s *fabric = uarg;
1552 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_LOGOCOMP);
1553}
1554
5fbe25c7 1555/*
a36c61f9
KG
1556 * Returns FCS vf structure for a given vf_id.
1557 *
1558 * param[in] vf_id - VF_ID
1559 *
1560 * return
1561 * If lookup succeeds, retuns fcs vf object, otherwise returns NULL
1562 */
1563bfa_fcs_vf_t *
1564bfa_fcs_vf_lookup(struct bfa_fcs_s *fcs, u16 vf_id)
1565{
1566 bfa_trc(fcs, vf_id);
1567 if (vf_id == FC_VF_ID_NULL)
1568 return &fcs->fabric;
1569
1570 return NULL;
b85daafe
KG
1571}
1572
1573/*
1574 * Return the list of local logical ports present in the given VF.
1575 *
1576 * @param[in] vf vf for which logical ports are returned
1577 * @param[out] lpwwn returned logical port wwn list
1578 * @param[in,out] nlports in:size of lpwwn list;
1579 * out:total elements present,
1580 * actual elements returned is limited by the size
1581 */
1582void
1583bfa_fcs_vf_get_ports(bfa_fcs_vf_t *vf, wwn_t lpwwn[], int *nlports)
1584{
1585 struct list_head *qe;
1586 struct bfa_fcs_vport_s *vport;
1587 int i = 0;
1588 struct bfa_fcs_s *fcs;
1589
1590 if (vf == NULL || lpwwn == NULL || *nlports == 0)
1591 return;
1592
1593 fcs = vf->fcs;
1594
1595 bfa_trc(fcs, vf->vf_id);
1596 bfa_trc(fcs, (uint32_t) *nlports);
1597
1598 lpwwn[i++] = vf->bport.port_cfg.pwwn;
1599
1600 list_for_each(qe, &vf->vport_q) {
1601 if (i >= *nlports)
1602 break;
1603
1604 vport = (struct bfa_fcs_vport_s *) qe;
1605 lpwwn[i++] = vport->lport.port_cfg.pwwn;
1606 }
1607
1608 bfa_trc(fcs, i);
1609 *nlports = i;
a36c61f9
KG
1610}
1611
5fbe25c7 1612/*
a36c61f9
KG
1613 * BFA FCS PPORT ( physical port)
1614 */
1615static void
1616bfa_fcs_port_event_handler(void *cbarg, enum bfa_port_linkstate event)
1617{
1618 struct bfa_fcs_s *fcs = cbarg;
1619
1620 bfa_trc(fcs, event);
1621
1622 switch (event) {
1623 case BFA_PORT_LINKUP:
1624 bfa_fcs_fabric_link_up(&fcs->fabric);
1625 break;
1626
1627 case BFA_PORT_LINKDOWN:
1628 bfa_fcs_fabric_link_down(&fcs->fabric);
1629 break;
1630
1631 default:
d4b671c5 1632 WARN_ON(1);
a36c61f9
KG
1633 }
1634}
1635
1636void
1637bfa_fcs_port_attach(struct bfa_fcs_s *fcs)
1638{
1639 bfa_fcport_event_register(fcs->bfa, bfa_fcs_port_event_handler, fcs);
1640}
1641
5fbe25c7 1642/*
a36c61f9
KG
1643 * BFA FCS UF ( Unsolicited Frames)
1644 */
1645
5fbe25c7 1646/*
a36c61f9
KG
1647 * BFA callback for unsolicited frame receive handler.
1648 *
1649 * @param[in] cbarg callback arg for receive handler
1650 * @param[in] uf unsolicited frame descriptor
1651 *
1652 * @return None
1653 */
1654static void
1655bfa_fcs_uf_recv(void *cbarg, struct bfa_uf_s *uf)
1656{
1657 struct bfa_fcs_s *fcs = (struct bfa_fcs_s *) cbarg;
1658 struct fchs_s *fchs = bfa_uf_get_frmbuf(uf);
1659 u16 len = bfa_uf_get_frmlen(uf);
1660 struct fc_vft_s *vft;
1661 struct bfa_fcs_fabric_s *fabric;
1662
5fbe25c7 1663 /*
a36c61f9
KG
1664 * check for VFT header
1665 */
1666 if (fchs->routing == FC_RTG_EXT_HDR &&
1667 fchs->cat_info == FC_CAT_VFT_HDR) {
1668 bfa_stats(fcs, uf.tagged);
1669 vft = bfa_uf_get_frmbuf(uf);
1670 if (fcs->port_vfid == vft->vf_id)
1671 fabric = &fcs->fabric;
1672 else
1673 fabric = bfa_fcs_vf_lookup(fcs, (u16) vft->vf_id);
1674
5fbe25c7 1675 /*
a36c61f9
KG
1676 * drop frame if vfid is unknown
1677 */
1678 if (!fabric) {
d4b671c5 1679 WARN_ON(1);
a36c61f9
KG
1680 bfa_stats(fcs, uf.vfid_unknown);
1681 bfa_uf_free(uf);
1682 return;
1683 }
1684
5fbe25c7 1685 /*
a36c61f9
KG
1686 * skip vft header
1687 */
1688 fchs = (struct fchs_s *) (vft + 1);
1689 len -= sizeof(struct fc_vft_s);
1690
1691 bfa_trc(fcs, vft->vf_id);
1692 } else {
1693 bfa_stats(fcs, uf.untagged);
1694 fabric = &fcs->fabric;
1695 }
1696
1697 bfa_trc(fcs, ((u32 *) fchs)[0]);
1698 bfa_trc(fcs, ((u32 *) fchs)[1]);
1699 bfa_trc(fcs, ((u32 *) fchs)[2]);
1700 bfa_trc(fcs, ((u32 *) fchs)[3]);
1701 bfa_trc(fcs, ((u32 *) fchs)[4]);
1702 bfa_trc(fcs, ((u32 *) fchs)[5]);
1703 bfa_trc(fcs, len);
1704
1705 bfa_fcs_fabric_uf_recv(fabric, fchs, len);
1706 bfa_uf_free(uf);
1707}
1708
1709void
1710bfa_fcs_uf_attach(struct bfa_fcs_s *fcs)
1711{
1712 bfa_uf_recv_register(fcs->bfa, bfa_fcs_uf_recv, fcs);
1713}