blob: 20a686a420a2485018525ff3e144b763e43a5311 [file] [log] [blame]
Jing Huang7725ccf2009-09-23 17:46:15 -07001/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
3 * All rights reserved
4 * www.brocade.com
5 *
6 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
7 *
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
11 *
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.
16 */
17
18/**
19 * fabric.c Fabric module implementation.
20 */
21
22#include "fcs_fabric.h"
23#include "fcs_lport.h"
24#include "fcs_vport.h"
25#include "fcs_trcmod.h"
26#include "fcs_fcxp.h"
27#include "fcs_auth.h"
28#include "fcs.h"
29#include "fcbuild.h"
30#include <log/bfa_log_fcs.h>
31#include <aen/bfa_aen_port.h>
32#include <bfa_svc.h>
33
34BFA_TRC_FILE(FCS, FABRIC);
35
36#define BFA_FCS_FABRIC_RETRY_DELAY (2000) /* Milliseconds */
37#define BFA_FCS_FABRIC_CLEANUP_DELAY (10000) /* Milliseconds */
38
Jing Huangf8ceafd2009-09-25 12:29:54 -070039#define bfa_fcs_fabric_set_opertype(__fabric) do { \
40 if (bfa_pport_get_topology((__fabric)->fcs->bfa) \
41 == BFA_PPORT_TOPOLOGY_P2P) \
42 (__fabric)->oper_type = BFA_PPORT_TYPE_NPORT; \
43 else \
44 (__fabric)->oper_type = BFA_PPORT_TYPE_NLPORT; \
Jing Huang7725ccf2009-09-23 17:46:15 -070045} while (0)
46
47/*
48 * forward declarations
49 */
50static void bfa_fcs_fabric_init(struct bfa_fcs_fabric_s *fabric);
51static void bfa_fcs_fabric_login(struct bfa_fcs_fabric_s *fabric);
52static void bfa_fcs_fabric_notify_online(struct bfa_fcs_fabric_s *fabric);
53static void bfa_fcs_fabric_notify_offline(struct bfa_fcs_fabric_s *fabric);
54static void bfa_fcs_fabric_delay(void *cbarg);
55static void bfa_fcs_fabric_delete(struct bfa_fcs_fabric_s *fabric);
56static void bfa_fcs_fabric_delete_comp(void *cbarg);
57static void bfa_fcs_fabric_process_uf(struct bfa_fcs_fabric_s *fabric,
58 struct fchs_s *fchs, u16 len);
59static void bfa_fcs_fabric_process_flogi(struct bfa_fcs_fabric_s *fabric,
60 struct fchs_s *fchs, u16 len);
61static void bfa_fcs_fabric_send_flogi_acc(struct bfa_fcs_fabric_s *fabric);
62static void bfa_fcs_fabric_flogiacc_comp(void *fcsarg,
63 struct bfa_fcxp_s *fcxp,
64 void *cbarg, bfa_status_t status,
65 u32 rsp_len,
66 u32 resid_len,
67 struct fchs_s *rspfchs);
68/**
69 * fcs_fabric_sm fabric state machine functions
70 */
71
72/**
73 * Fabric state machine events
74 */
75enum bfa_fcs_fabric_event {
76 BFA_FCS_FABRIC_SM_CREATE = 1, /* fabric create from driver */
77 BFA_FCS_FABRIC_SM_DELETE = 2, /* fabric delete from driver */
78 BFA_FCS_FABRIC_SM_LINK_DOWN = 3, /* link down from port */
79 BFA_FCS_FABRIC_SM_LINK_UP = 4, /* link up from port */
80 BFA_FCS_FABRIC_SM_CONT_OP = 5, /* continue op from flogi/auth */
81 BFA_FCS_FABRIC_SM_RETRY_OP = 6, /* continue op from flogi/auth */
82 BFA_FCS_FABRIC_SM_NO_FABRIC = 7, /* no fabric from flogi/auth
83 */
84 BFA_FCS_FABRIC_SM_PERF_EVFP = 8, /* perform EVFP from
85 *flogi/auth */
86 BFA_FCS_FABRIC_SM_ISOLATE = 9, /* isolate from EVFP processing */
87 BFA_FCS_FABRIC_SM_NO_TAGGING = 10,/* no VFT tagging from EVFP */
88 BFA_FCS_FABRIC_SM_DELAYED = 11, /* timeout delay event */
89 BFA_FCS_FABRIC_SM_AUTH_FAILED = 12, /* authentication failed */
90 BFA_FCS_FABRIC_SM_AUTH_SUCCESS = 13, /* authentication successful
91 */
92 BFA_FCS_FABRIC_SM_DELCOMP = 14, /* all vports deleted event */
93 BFA_FCS_FABRIC_SM_LOOPBACK = 15, /* Received our own FLOGI */
94 BFA_FCS_FABRIC_SM_START = 16, /* fabric delete from driver */
95};
96
97static void bfa_fcs_fabric_sm_uninit(struct bfa_fcs_fabric_s *fabric,
98 enum bfa_fcs_fabric_event event);
99static void bfa_fcs_fabric_sm_created(struct bfa_fcs_fabric_s *fabric,
100 enum bfa_fcs_fabric_event event);
101static void bfa_fcs_fabric_sm_linkdown(struct bfa_fcs_fabric_s *fabric,
102 enum bfa_fcs_fabric_event event);
103static void bfa_fcs_fabric_sm_flogi(struct bfa_fcs_fabric_s *fabric,
104 enum bfa_fcs_fabric_event event);
105static void bfa_fcs_fabric_sm_flogi_retry(struct bfa_fcs_fabric_s *fabric,
106 enum bfa_fcs_fabric_event event);
107static void bfa_fcs_fabric_sm_auth(struct bfa_fcs_fabric_s *fabric,
108 enum bfa_fcs_fabric_event event);
109static void bfa_fcs_fabric_sm_auth_failed(struct bfa_fcs_fabric_s *fabric,
110 enum bfa_fcs_fabric_event event);
111static void bfa_fcs_fabric_sm_loopback(struct bfa_fcs_fabric_s *fabric,
112 enum bfa_fcs_fabric_event event);
113static void bfa_fcs_fabric_sm_nofabric(struct bfa_fcs_fabric_s *fabric,
114 enum bfa_fcs_fabric_event event);
115static void bfa_fcs_fabric_sm_online(struct bfa_fcs_fabric_s *fabric,
116 enum bfa_fcs_fabric_event event);
117static void bfa_fcs_fabric_sm_evfp(struct bfa_fcs_fabric_s *fabric,
118 enum bfa_fcs_fabric_event event);
119static void bfa_fcs_fabric_sm_evfp_done(struct bfa_fcs_fabric_s *fabric,
120 enum bfa_fcs_fabric_event event);
121static void bfa_fcs_fabric_sm_isolated(struct bfa_fcs_fabric_s *fabric,
122 enum bfa_fcs_fabric_event event);
123static void bfa_fcs_fabric_sm_deleting(struct bfa_fcs_fabric_s *fabric,
124 enum bfa_fcs_fabric_event event);
125/**
126 * Beginning state before fabric creation.
127 */
128static void
129bfa_fcs_fabric_sm_uninit(struct bfa_fcs_fabric_s *fabric,
130 enum bfa_fcs_fabric_event event)
131{
132 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
133 bfa_trc(fabric->fcs, event);
134
135 switch (event) {
136 case BFA_FCS_FABRIC_SM_CREATE:
137 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_created);
138 bfa_fcs_fabric_init(fabric);
Krishna Gudipatie6714322010-03-03 17:44:02 -0800139 bfa_fcs_lport_init(&fabric->bport, &fabric->bport.port_cfg);
Jing Huang7725ccf2009-09-23 17:46:15 -0700140 break;
141
142 case BFA_FCS_FABRIC_SM_LINK_UP:
143 case BFA_FCS_FABRIC_SM_LINK_DOWN:
144 break;
145
146 default:
147 bfa_sm_fault(fabric->fcs, event);
148 }
149}
150
151/**
152 * Beginning state before fabric creation.
153 */
154static void
155bfa_fcs_fabric_sm_created(struct bfa_fcs_fabric_s *fabric,
156 enum bfa_fcs_fabric_event event)
157{
158 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
159 bfa_trc(fabric->fcs, event);
160
161 switch (event) {
162 case BFA_FCS_FABRIC_SM_START:
163 if (bfa_pport_is_linkup(fabric->fcs->bfa)) {
164 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_flogi);
165 bfa_fcs_fabric_login(fabric);
166 } else
167 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
168 break;
169
170 case BFA_FCS_FABRIC_SM_LINK_UP:
171 case BFA_FCS_FABRIC_SM_LINK_DOWN:
172 break;
173
174 case BFA_FCS_FABRIC_SM_DELETE:
175 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_uninit);
176 bfa_fcs_modexit_comp(fabric->fcs);
177 break;
178
179 default:
180 bfa_sm_fault(fabric->fcs, event);
181 }
182}
183
184/**
185 * Link is down, awaiting LINK UP event from port. This is also the
186 * first state at fabric creation.
187 */
188static void
189bfa_fcs_fabric_sm_linkdown(struct bfa_fcs_fabric_s *fabric,
190 enum bfa_fcs_fabric_event event)
191{
192 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
193 bfa_trc(fabric->fcs, event);
194
195 switch (event) {
196 case BFA_FCS_FABRIC_SM_LINK_UP:
197 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_flogi);
198 bfa_fcs_fabric_login(fabric);
199 break;
200
201 case BFA_FCS_FABRIC_SM_RETRY_OP:
202 break;
203
204 case BFA_FCS_FABRIC_SM_DELETE:
205 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
206 bfa_fcs_fabric_delete(fabric);
207 break;
208
209 default:
210 bfa_sm_fault(fabric->fcs, event);
211 }
212}
213
214/**
215 * FLOGI is in progress, awaiting FLOGI reply.
216 */
217static void
218bfa_fcs_fabric_sm_flogi(struct bfa_fcs_fabric_s *fabric,
219 enum bfa_fcs_fabric_event event)
220{
221 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
222 bfa_trc(fabric->fcs, event);
223
224 switch (event) {
225 case BFA_FCS_FABRIC_SM_CONT_OP:
226
227 bfa_pport_set_tx_bbcredit(fabric->fcs->bfa, fabric->bb_credit);
228 fabric->fab_type = BFA_FCS_FABRIC_SWITCHED;
229
230 if (fabric->auth_reqd && fabric->is_auth) {
231 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_auth);
232 bfa_trc(fabric->fcs, event);
233 } else {
234 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_online);
235 bfa_fcs_fabric_notify_online(fabric);
236 }
237 break;
238
239 case BFA_FCS_FABRIC_SM_RETRY_OP:
240 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_flogi_retry);
241 bfa_timer_start(fabric->fcs->bfa, &fabric->delay_timer,
242 bfa_fcs_fabric_delay, fabric,
243 BFA_FCS_FABRIC_RETRY_DELAY);
244 break;
245
246 case BFA_FCS_FABRIC_SM_LOOPBACK:
247 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_loopback);
248 bfa_lps_discard(fabric->lps);
249 bfa_fcs_fabric_set_opertype(fabric);
250 break;
251
252 case BFA_FCS_FABRIC_SM_NO_FABRIC:
253 fabric->fab_type = BFA_FCS_FABRIC_N2N;
254 bfa_pport_set_tx_bbcredit(fabric->fcs->bfa, fabric->bb_credit);
255 bfa_fcs_fabric_notify_online(fabric);
256 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_nofabric);
257 break;
258
259 case BFA_FCS_FABRIC_SM_LINK_DOWN:
260 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
261 bfa_lps_discard(fabric->lps);
262 break;
263
264 case BFA_FCS_FABRIC_SM_DELETE:
265 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
266 bfa_lps_discard(fabric->lps);
267 bfa_fcs_fabric_delete(fabric);
268 break;
269
270 default:
271 bfa_sm_fault(fabric->fcs, event);
272 }
273}
274
275
276static void
277bfa_fcs_fabric_sm_flogi_retry(struct bfa_fcs_fabric_s *fabric,
278 enum bfa_fcs_fabric_event event)
279{
280 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
281 bfa_trc(fabric->fcs, event);
282
283 switch (event) {
284 case BFA_FCS_FABRIC_SM_DELAYED:
285 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_flogi);
286 bfa_fcs_fabric_login(fabric);
287 break;
288
289 case BFA_FCS_FABRIC_SM_LINK_DOWN:
290 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
291 bfa_timer_stop(&fabric->delay_timer);
292 break;
293
294 case BFA_FCS_FABRIC_SM_DELETE:
295 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
296 bfa_timer_stop(&fabric->delay_timer);
297 bfa_fcs_fabric_delete(fabric);
298 break;
299
300 default:
301 bfa_sm_fault(fabric->fcs, event);
302 }
303}
304
305/**
306 * Authentication is in progress, awaiting authentication results.
307 */
308static void
309bfa_fcs_fabric_sm_auth(struct bfa_fcs_fabric_s *fabric,
310 enum bfa_fcs_fabric_event event)
311{
312 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
313 bfa_trc(fabric->fcs, event);
314
315 switch (event) {
316 case BFA_FCS_FABRIC_SM_AUTH_FAILED:
317 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_auth_failed);
318 bfa_lps_discard(fabric->lps);
319 break;
320
321 case BFA_FCS_FABRIC_SM_AUTH_SUCCESS:
322 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_online);
323 bfa_fcs_fabric_notify_online(fabric);
324 break;
325
326 case BFA_FCS_FABRIC_SM_PERF_EVFP:
327 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_evfp);
328 break;
329
330 case BFA_FCS_FABRIC_SM_LINK_DOWN:
331 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
332 bfa_lps_discard(fabric->lps);
333 break;
334
335 case BFA_FCS_FABRIC_SM_DELETE:
336 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
337 bfa_fcs_fabric_delete(fabric);
338 break;
339
340 default:
341 bfa_sm_fault(fabric->fcs, event);
342 }
343}
344
345/**
346 * Authentication failed
347 */
348static void
349bfa_fcs_fabric_sm_auth_failed(struct bfa_fcs_fabric_s *fabric,
350 enum bfa_fcs_fabric_event event)
351{
352 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
353 bfa_trc(fabric->fcs, event);
354
355 switch (event) {
356 case BFA_FCS_FABRIC_SM_LINK_DOWN:
357 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
358 bfa_fcs_fabric_notify_offline(fabric);
359 break;
360
361 case BFA_FCS_FABRIC_SM_DELETE:
362 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
363 bfa_fcs_fabric_delete(fabric);
364 break;
365
366 default:
367 bfa_sm_fault(fabric->fcs, event);
368 }
369}
370
371/**
372 * Port is in loopback mode.
373 */
374static void
375bfa_fcs_fabric_sm_loopback(struct bfa_fcs_fabric_s *fabric,
376 enum bfa_fcs_fabric_event event)
377{
378 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
379 bfa_trc(fabric->fcs, event);
380
381 switch (event) {
382 case BFA_FCS_FABRIC_SM_LINK_DOWN:
383 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
384 bfa_fcs_fabric_notify_offline(fabric);
385 break;
386
387 case BFA_FCS_FABRIC_SM_DELETE:
388 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
389 bfa_fcs_fabric_delete(fabric);
390 break;
391
392 default:
393 bfa_sm_fault(fabric->fcs, event);
394 }
395}
396
397/**
398 * There is no attached fabric - private loop or NPort-to-NPort topology.
399 */
400static void
401bfa_fcs_fabric_sm_nofabric(struct bfa_fcs_fabric_s *fabric,
402 enum bfa_fcs_fabric_event event)
403{
404 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
405 bfa_trc(fabric->fcs, event);
406
407 switch (event) {
408 case BFA_FCS_FABRIC_SM_LINK_DOWN:
409 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
410 bfa_lps_discard(fabric->lps);
411 bfa_fcs_fabric_notify_offline(fabric);
412 break;
413
414 case BFA_FCS_FABRIC_SM_DELETE:
415 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
416 bfa_fcs_fabric_delete(fabric);
417 break;
418
419 case BFA_FCS_FABRIC_SM_NO_FABRIC:
420 bfa_trc(fabric->fcs, fabric->bb_credit);
421 bfa_pport_set_tx_bbcredit(fabric->fcs->bfa, fabric->bb_credit);
422 break;
423
424 default:
425 bfa_sm_fault(fabric->fcs, event);
426 }
427}
428
429/**
430 * Fabric is online - normal operating state.
431 */
432static void
433bfa_fcs_fabric_sm_online(struct bfa_fcs_fabric_s *fabric,
434 enum bfa_fcs_fabric_event event)
435{
436 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
437 bfa_trc(fabric->fcs, event);
438
439 switch (event) {
440 case BFA_FCS_FABRIC_SM_LINK_DOWN:
441 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
442 bfa_lps_discard(fabric->lps);
443 bfa_fcs_fabric_notify_offline(fabric);
444 break;
445
446 case BFA_FCS_FABRIC_SM_DELETE:
447 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
448 bfa_fcs_fabric_delete(fabric);
449 break;
450
451 case BFA_FCS_FABRIC_SM_AUTH_FAILED:
452 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_auth_failed);
453 bfa_lps_discard(fabric->lps);
454 break;
455
456 case BFA_FCS_FABRIC_SM_AUTH_SUCCESS:
457 break;
458
459 default:
460 bfa_sm_fault(fabric->fcs, event);
461 }
462}
463
464/**
465 * Exchanging virtual fabric parameters.
466 */
467static void
468bfa_fcs_fabric_sm_evfp(struct bfa_fcs_fabric_s *fabric,
469 enum bfa_fcs_fabric_event event)
470{
471 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
472 bfa_trc(fabric->fcs, event);
473
474 switch (event) {
475 case BFA_FCS_FABRIC_SM_CONT_OP:
476 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_evfp_done);
477 break;
478
479 case BFA_FCS_FABRIC_SM_ISOLATE:
480 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_isolated);
481 break;
482
483 default:
484 bfa_sm_fault(fabric->fcs, event);
485 }
486}
487
488/**
489 * EVFP exchange complete and VFT tagging is enabled.
490 */
491static void
492bfa_fcs_fabric_sm_evfp_done(struct bfa_fcs_fabric_s *fabric,
493 enum bfa_fcs_fabric_event event)
494{
495 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
496 bfa_trc(fabric->fcs, event);
497}
498
499/**
500 * Port is isolated after EVFP exchange due to VF_ID mismatch (N and F).
501 */
502static void
503bfa_fcs_fabric_sm_isolated(struct bfa_fcs_fabric_s *fabric,
504 enum bfa_fcs_fabric_event event)
505{
506 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
507 bfa_trc(fabric->fcs, event);
508
509 bfa_log(fabric->fcs->logm, BFA_LOG_FCS_FABRIC_ISOLATED,
510 fabric->bport.port_cfg.pwwn, fabric->fcs->port_vfid,
511 fabric->event_arg.swp_vfid);
512}
513
514/**
515 * Fabric is being deleted, awaiting vport delete completions.
516 */
517static void
518bfa_fcs_fabric_sm_deleting(struct bfa_fcs_fabric_s *fabric,
519 enum bfa_fcs_fabric_event event)
520{
521 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
522 bfa_trc(fabric->fcs, event);
523
524 switch (event) {
525 case BFA_FCS_FABRIC_SM_DELCOMP:
526 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_uninit);
527 bfa_fcs_modexit_comp(fabric->fcs);
528 break;
529
530 case BFA_FCS_FABRIC_SM_LINK_UP:
531 break;
532
533 case BFA_FCS_FABRIC_SM_LINK_DOWN:
534 bfa_fcs_fabric_notify_offline(fabric);
535 break;
536
537 default:
538 bfa_sm_fault(fabric->fcs, event);
539 }
540}
541
542
543
544/**
545 * fcs_fabric_private fabric private functions
546 */
547
548static void
549bfa_fcs_fabric_init(struct bfa_fcs_fabric_s *fabric)
550{
551 struct bfa_port_cfg_s *port_cfg = &fabric->bport.port_cfg;
552
553 port_cfg->roles = BFA_PORT_ROLE_FCP_IM;
554 port_cfg->nwwn = bfa_ioc_get_nwwn(&fabric->fcs->bfa->ioc);
555 port_cfg->pwwn = bfa_ioc_get_pwwn(&fabric->fcs->bfa->ioc);
556}
557
558/**
559 * Port Symbolic Name Creation for base port.
560 */
561void
562bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s *fabric)
563{
564 struct bfa_port_cfg_s *port_cfg = &fabric->bport.port_cfg;
565 struct bfa_adapter_attr_s adapter_attr;
566 struct bfa_fcs_driver_info_s *driver_info = &fabric->fcs->driver_info;
567
568 bfa_os_memset((void *)&adapter_attr, 0,
569 sizeof(struct bfa_adapter_attr_s));
570 bfa_ioc_get_adapter_attr(&fabric->fcs->bfa->ioc, &adapter_attr);
571
572 /*
573 * Model name/number
574 */
575 strncpy((char *)&port_cfg->sym_name, adapter_attr.model,
576 BFA_FCS_PORT_SYMBNAME_MODEL_SZ);
577 strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
578 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
579
580 /*
581 * Driver Version
582 */
583 strncat((char *)&port_cfg->sym_name, (char *)driver_info->version,
584 BFA_FCS_PORT_SYMBNAME_VERSION_SZ);
585 strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
586 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
587
588 /*
589 * Host machine name
590 */
591 strncat((char *)&port_cfg->sym_name,
592 (char *)driver_info->host_machine_name,
593 BFA_FCS_PORT_SYMBNAME_MACHINENAME_SZ);
594 strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
595 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
596
597 /*
598 * Host OS Info :
599 * If OS Patch Info is not there, do not truncate any bytes from the
600 * OS name string and instead copy the entire OS info string (64 bytes).
601 */
602 if (driver_info->host_os_patch[0] == '\0') {
603 strncat((char *)&port_cfg->sym_name,
604 (char *)driver_info->host_os_name, BFA_FCS_OS_STR_LEN);
605 strncat((char *)&port_cfg->sym_name,
606 BFA_FCS_PORT_SYMBNAME_SEPARATOR,
607 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
608 } else {
609 strncat((char *)&port_cfg->sym_name,
610 (char *)driver_info->host_os_name,
611 BFA_FCS_PORT_SYMBNAME_OSINFO_SZ);
612 strncat((char *)&port_cfg->sym_name,
613 BFA_FCS_PORT_SYMBNAME_SEPARATOR,
614 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
615
616 /*
617 * Append host OS Patch Info
618 */
619 strncat((char *)&port_cfg->sym_name,
620 (char *)driver_info->host_os_patch,
621 BFA_FCS_PORT_SYMBNAME_OSPATCH_SZ);
622 }
623
624 /*
625 * null terminate
626 */
627 port_cfg->sym_name.symname[BFA_SYMNAME_MAXLEN - 1] = 0;
628}
629
630/**
631 * bfa lps login completion callback
632 */
633void
634bfa_cb_lps_flogi_comp(void *bfad, void *uarg, bfa_status_t status)
635{
636 struct bfa_fcs_fabric_s *fabric = uarg;
637
638 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
639 bfa_trc(fabric->fcs, status);
640
641 switch (status) {
642 case BFA_STATUS_OK:
643 fabric->stats.flogi_accepts++;
644 break;
645
646 case BFA_STATUS_INVALID_MAC:
647 /*
648 * Only for CNA
649 */
650 fabric->stats.flogi_acc_err++;
651 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_RETRY_OP);
652
653 return;
654
655 case BFA_STATUS_EPROTOCOL:
656 switch (bfa_lps_get_extstatus(fabric->lps)) {
657 case BFA_EPROTO_BAD_ACCEPT:
658 fabric->stats.flogi_acc_err++;
659 break;
660
661 case BFA_EPROTO_UNKNOWN_RSP:
662 fabric->stats.flogi_unknown_rsp++;
663 break;
664
665 default:
666 break;
667 }
668 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_RETRY_OP);
669
670 return;
671
672 case BFA_STATUS_FABRIC_RJT:
673 fabric->stats.flogi_rejects++;
674 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_RETRY_OP);
675 return;
676
677 default:
678 fabric->stats.flogi_rsp_err++;
679 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_RETRY_OP);
680 return;
681 }
682
683 fabric->bb_credit = bfa_lps_get_peer_bbcredit(fabric->lps);
684 bfa_trc(fabric->fcs, fabric->bb_credit);
685
686 if (!bfa_lps_is_brcd_fabric(fabric->lps))
687 fabric->fabric_name = bfa_lps_get_peer_nwwn(fabric->lps);
688
689 /*
690 * Check port type. It should be 1 = F-port.
691 */
692 if (bfa_lps_is_fport(fabric->lps)) {
693 fabric->bport.pid = bfa_lps_get_pid(fabric->lps);
694 fabric->is_npiv = bfa_lps_is_npiv_en(fabric->lps);
695 fabric->is_auth = bfa_lps_is_authreq(fabric->lps);
696 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_CONT_OP);
697 } else {
698 /*
699 * Nport-2-Nport direct attached
700 */
701 fabric->bport.port_topo.pn2n.rem_port_wwn =
702 bfa_lps_get_peer_pwwn(fabric->lps);
703 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_NO_FABRIC);
704 }
705
706 bfa_trc(fabric->fcs, fabric->bport.pid);
707 bfa_trc(fabric->fcs, fabric->is_npiv);
708 bfa_trc(fabric->fcs, fabric->is_auth);
709}
710
711/**
712 * Allocate and send FLOGI.
713 */
714static void
715bfa_fcs_fabric_login(struct bfa_fcs_fabric_s *fabric)
716{
717 struct bfa_s *bfa = fabric->fcs->bfa;
718 struct bfa_port_cfg_s *pcfg = &fabric->bport.port_cfg;
719 u8 alpa = 0;
720
721 if (bfa_pport_get_topology(bfa) == BFA_PPORT_TOPOLOGY_LOOP)
722 alpa = bfa_pport_get_myalpa(bfa);
723
724 bfa_lps_flogi(fabric->lps, fabric, alpa, bfa_pport_get_maxfrsize(bfa),
725 pcfg->pwwn, pcfg->nwwn, fabric->auth_reqd);
726
727 fabric->stats.flogi_sent++;
728}
729
730static void
731bfa_fcs_fabric_notify_online(struct bfa_fcs_fabric_s *fabric)
732{
733 struct bfa_fcs_vport_s *vport;
734 struct list_head *qe, *qen;
735
736 bfa_trc(fabric->fcs, fabric->fabric_name);
737
738 bfa_fcs_fabric_set_opertype(fabric);
739 fabric->stats.fabric_onlines++;
740
741 /**
742 * notify online event to base and then virtual ports
743 */
744 bfa_fcs_port_online(&fabric->bport);
745
746 list_for_each_safe(qe, qen, &fabric->vport_q) {
747 vport = (struct bfa_fcs_vport_s *)qe;
748 bfa_fcs_vport_online(vport);
749 }
750}
751
752static void
753bfa_fcs_fabric_notify_offline(struct bfa_fcs_fabric_s *fabric)
754{
755 struct bfa_fcs_vport_s *vport;
756 struct list_head *qe, *qen;
757
758 bfa_trc(fabric->fcs, fabric->fabric_name);
759 fabric->stats.fabric_offlines++;
760
761 /**
762 * notify offline event first to vports and then base port.
763 */
764 list_for_each_safe(qe, qen, &fabric->vport_q) {
765 vport = (struct bfa_fcs_vport_s *)qe;
766 bfa_fcs_vport_offline(vport);
767 }
768
769 bfa_fcs_port_offline(&fabric->bport);
770
771 fabric->fabric_name = 0;
772 fabric->fabric_ip_addr[0] = 0;
773}
774
775static void
776bfa_fcs_fabric_delay(void *cbarg)
777{
778 struct bfa_fcs_fabric_s *fabric = cbarg;
779
780 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_DELAYED);
781}
782
783/**
784 * Delete all vports and wait for vport delete completions.
785 */
786static void
787bfa_fcs_fabric_delete(struct bfa_fcs_fabric_s *fabric)
788{
789 struct bfa_fcs_vport_s *vport;
790 struct list_head *qe, *qen;
791
792 list_for_each_safe(qe, qen, &fabric->vport_q) {
793 vport = (struct bfa_fcs_vport_s *)qe;
794 bfa_fcs_vport_delete(vport);
795 }
796
797 bfa_fcs_port_delete(&fabric->bport);
798 bfa_wc_wait(&fabric->wc);
799}
800
801static void
802bfa_fcs_fabric_delete_comp(void *cbarg)
803{
804 struct bfa_fcs_fabric_s *fabric = cbarg;
805
806 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_DELCOMP);
807}
808
809
810
811/**
812 * fcs_fabric_public fabric public functions
813 */
814
815/**
Krishna Gudipati82794a22010-03-03 17:43:30 -0800816 * Attach time initialization
Jing Huang7725ccf2009-09-23 17:46:15 -0700817 */
818void
Krishna Gudipati82794a22010-03-03 17:43:30 -0800819bfa_fcs_fabric_attach(struct bfa_fcs_s *fcs)
Jing Huang7725ccf2009-09-23 17:46:15 -0700820{
821 struct bfa_fcs_fabric_s *fabric;
822
823 fabric = &fcs->fabric;
824 bfa_os_memset(fabric, 0, sizeof(struct bfa_fcs_fabric_s));
825
826 /**
827 * Initialize base fabric.
828 */
829 fabric->fcs = fcs;
830 INIT_LIST_HEAD(&fabric->vport_q);
831 INIT_LIST_HEAD(&fabric->vf_q);
832 fabric->lps = bfa_lps_alloc(fcs->bfa);
833 bfa_assert(fabric->lps);
834
835 /**
836 * Initialize fabric delete completion handler. Fabric deletion is complete
837 * when the last vport delete is complete.
838 */
839 bfa_wc_init(&fabric->wc, bfa_fcs_fabric_delete_comp, fabric);
840 bfa_wc_up(&fabric->wc); /* For the base port */
841
842 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_uninit);
Krishna Gudipatie6714322010-03-03 17:44:02 -0800843 bfa_fcs_lport_attach(&fabric->bport, fabric->fcs, FC_VF_ID_NULL, NULL);
Krishna Gudipati82794a22010-03-03 17:43:30 -0800844}
845
846void
847bfa_fcs_fabric_modinit(struct bfa_fcs_s *fcs)
848{
849 bfa_sm_send_event(&fcs->fabric, BFA_FCS_FABRIC_SM_CREATE);
Jing Huang7725ccf2009-09-23 17:46:15 -0700850 bfa_trc(fcs, 0);
851}
852
853/**
854 * Module cleanup
855 */
856void
857bfa_fcs_fabric_modexit(struct bfa_fcs_s *fcs)
858{
859 struct bfa_fcs_fabric_s *fabric;
860
861 bfa_trc(fcs, 0);
862
863 /**
864 * Cleanup base fabric.
865 */
866 fabric = &fcs->fabric;
867 bfa_lps_delete(fabric->lps);
868 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_DELETE);
869}
870
871/**
872 * Fabric module start -- kick starts FCS actions
873 */
874void
875bfa_fcs_fabric_modstart(struct bfa_fcs_s *fcs)
876{
877 struct bfa_fcs_fabric_s *fabric;
878
879 bfa_trc(fcs, 0);
880 fabric = &fcs->fabric;
881 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_START);
882}
883
884/**
885 * Suspend fabric activity as part of driver suspend.
886 */
887void
888bfa_fcs_fabric_modsusp(struct bfa_fcs_s *fcs)
889{
890}
891
892bfa_boolean_t
893bfa_fcs_fabric_is_loopback(struct bfa_fcs_fabric_s *fabric)
894{
Jing Huangf8ceafd2009-09-25 12:29:54 -0700895 return bfa_sm_cmp_state(fabric, bfa_fcs_fabric_sm_loopback);
Jing Huang7725ccf2009-09-23 17:46:15 -0700896}
897
898enum bfa_pport_type
899bfa_fcs_fabric_port_type(struct bfa_fcs_fabric_s *fabric)
900{
901 return fabric->oper_type;
902}
903
904/**
905 * Link up notification from BFA physical port module.
906 */
907void
908bfa_fcs_fabric_link_up(struct bfa_fcs_fabric_s *fabric)
909{
910 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
911 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_LINK_UP);
912}
913
914/**
915 * Link down notification from BFA physical port module.
916 */
917void
918bfa_fcs_fabric_link_down(struct bfa_fcs_fabric_s *fabric)
919{
920 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
921 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_LINK_DOWN);
922}
923
924/**
925 * A child vport is being created in the fabric.
926 *
927 * Call from vport module at vport creation. A list of base port and vports
928 * belonging to a fabric is maintained to propagate link events.
929 *
930 * param[in] fabric - Fabric instance. This can be a base fabric or vf.
931 * param[in] vport - Vport being created.
932 *
933 * @return None (always succeeds)
934 */
935void
936bfa_fcs_fabric_addvport(struct bfa_fcs_fabric_s *fabric,
937 struct bfa_fcs_vport_s *vport)
938{
939 /**
940 * - add vport to fabric's vport_q
941 */
942 bfa_trc(fabric->fcs, fabric->vf_id);
943
944 list_add_tail(&vport->qe, &fabric->vport_q);
945 fabric->num_vports++;
946 bfa_wc_up(&fabric->wc);
947}
948
949/**
950 * A child vport is being deleted from fabric.
951 *
952 * Vport is being deleted.
953 */
954void
955bfa_fcs_fabric_delvport(struct bfa_fcs_fabric_s *fabric,
956 struct bfa_fcs_vport_s *vport)
957{
958 list_del(&vport->qe);
959 fabric->num_vports--;
960 bfa_wc_down(&fabric->wc);
961}
962
963/**
964 * Base port is deleted.
965 */
966void
967bfa_fcs_fabric_port_delete_comp(struct bfa_fcs_fabric_s *fabric)
968{
969 bfa_wc_down(&fabric->wc);
970}
971
972/**
973 * Check if fabric is online.
974 *
975 * param[in] fabric - Fabric instance. This can be a base fabric or vf.
976 *
977 * @return TRUE/FALSE
978 */
979int
980bfa_fcs_fabric_is_online(struct bfa_fcs_fabric_s *fabric)
981{
Jing Huangf8ceafd2009-09-25 12:29:54 -0700982 return bfa_sm_cmp_state(fabric, bfa_fcs_fabric_sm_online);
Jing Huang7725ccf2009-09-23 17:46:15 -0700983}
984
985
986bfa_status_t
987bfa_fcs_fabric_addvf(struct bfa_fcs_fabric_s *vf, struct bfa_fcs_s *fcs,
988 struct bfa_port_cfg_s *port_cfg,
989 struct bfad_vf_s *vf_drv)
990{
991 bfa_sm_set_state(vf, bfa_fcs_fabric_sm_uninit);
992 return BFA_STATUS_OK;
993}
994
995/**
996 * Lookup for a vport withing a fabric given its pwwn
997 */
998struct bfa_fcs_vport_s *
999bfa_fcs_fabric_vport_lookup(struct bfa_fcs_fabric_s *fabric, wwn_t pwwn)
1000{
1001 struct bfa_fcs_vport_s *vport;
1002 struct list_head *qe;
1003
1004 list_for_each(qe, &fabric->vport_q) {
1005 vport = (struct bfa_fcs_vport_s *)qe;
1006 if (bfa_fcs_port_get_pwwn(&vport->lport) == pwwn)
1007 return vport;
1008 }
1009
1010 return NULL;
1011}
1012
1013/**
1014 * In a given fabric, return the number of lports.
1015 *
1016 * param[in] fabric - Fabric instance. This can be a base fabric or vf.
1017 *
1018* @return : 1 or more.
1019 */
1020u16
1021bfa_fcs_fabric_vport_count(struct bfa_fcs_fabric_s *fabric)
1022{
Jing Huangf8ceafd2009-09-25 12:29:54 -07001023 return fabric->num_vports;
Jing Huang7725ccf2009-09-23 17:46:15 -07001024}
1025
1026/**
1027 * Unsolicited frame receive handling.
1028 */
1029void
1030bfa_fcs_fabric_uf_recv(struct bfa_fcs_fabric_s *fabric, struct fchs_s *fchs,
1031 u16 len)
1032{
1033 u32 pid = fchs->d_id;
1034 struct bfa_fcs_vport_s *vport;
1035 struct list_head *qe;
1036 struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
1037 struct fc_logi_s *flogi = (struct fc_logi_s *) els_cmd;
1038
1039 bfa_trc(fabric->fcs, len);
1040 bfa_trc(fabric->fcs, pid);
1041
1042 /**
1043 * Look for our own FLOGI frames being looped back. This means an
1044 * external loopback cable is in place. Our own FLOGI frames are
1045 * sometimes looped back when switch port gets temporarily bypassed.
1046 */
1047 if ((pid == bfa_os_ntoh3b(FC_FABRIC_PORT))
1048 && (els_cmd->els_code == FC_ELS_FLOGI)
1049 && (flogi->port_name == bfa_fcs_port_get_pwwn(&fabric->bport))) {
1050 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_LOOPBACK);
1051 return;
1052 }
1053
1054 /**
1055 * FLOGI/EVFP exchanges should be consumed by base fabric.
1056 */
1057 if (fchs->d_id == bfa_os_hton3b(FC_FABRIC_PORT)) {
1058 bfa_trc(fabric->fcs, pid);
1059 bfa_fcs_fabric_process_uf(fabric, fchs, len);
1060 return;
1061 }
1062
1063 if (fabric->bport.pid == pid) {
1064 /**
1065 * All authentication frames should be routed to auth
1066 */
1067 bfa_trc(fabric->fcs, els_cmd->els_code);
1068 if (els_cmd->els_code == FC_ELS_AUTH) {
1069 bfa_trc(fabric->fcs, els_cmd->els_code);
1070 fabric->auth.response = (u8 *) els_cmd;
1071 return;
1072 }
1073
1074 bfa_trc(fabric->fcs, *(u8 *) ((u8 *) fchs));
1075 bfa_fcs_port_uf_recv(&fabric->bport, fchs, len);
1076 return;
1077 }
1078
1079 /**
1080 * look for a matching local port ID
1081 */
1082 list_for_each(qe, &fabric->vport_q) {
1083 vport = (struct bfa_fcs_vport_s *)qe;
1084 if (vport->lport.pid == pid) {
1085 bfa_fcs_port_uf_recv(&vport->lport, fchs, len);
1086 return;
1087 }
1088 }
1089 bfa_trc(fabric->fcs, els_cmd->els_code);
1090 bfa_fcs_port_uf_recv(&fabric->bport, fchs, len);
1091}
1092
1093/**
1094 * Unsolicited frames to be processed by fabric.
1095 */
1096static void
1097bfa_fcs_fabric_process_uf(struct bfa_fcs_fabric_s *fabric, struct fchs_s *fchs,
1098 u16 len)
1099{
1100 struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
1101
1102 bfa_trc(fabric->fcs, els_cmd->els_code);
1103
1104 switch (els_cmd->els_code) {
1105 case FC_ELS_FLOGI:
1106 bfa_fcs_fabric_process_flogi(fabric, fchs, len);
1107 break;
1108
1109 default:
1110 /*
1111 * need to generate a LS_RJT
1112 */
1113 break;
1114 }
1115}
1116
1117/**
1118 * Process incoming FLOGI
1119 */
1120static void
1121bfa_fcs_fabric_process_flogi(struct bfa_fcs_fabric_s *fabric,
1122 struct fchs_s *fchs, u16 len)
1123{
1124 struct fc_logi_s *flogi = (struct fc_logi_s *) (fchs + 1);
1125 struct bfa_fcs_port_s *bport = &fabric->bport;
1126
1127 bfa_trc(fabric->fcs, fchs->s_id);
1128
1129 fabric->stats.flogi_rcvd++;
1130 /*
1131 * Check port type. It should be 0 = n-port.
1132 */
1133 if (flogi->csp.port_type) {
1134 /*
1135 * @todo: may need to send a LS_RJT
1136 */
1137 bfa_trc(fabric->fcs, flogi->port_name);
1138 fabric->stats.flogi_rejected++;
1139 return;
1140 }
1141
1142 fabric->bb_credit = bfa_os_ntohs(flogi->csp.bbcred);
1143 bport->port_topo.pn2n.rem_port_wwn = flogi->port_name;
1144 bport->port_topo.pn2n.reply_oxid = fchs->ox_id;
1145
1146 /*
1147 * Send a Flogi Acc
1148 */
1149 bfa_fcs_fabric_send_flogi_acc(fabric);
1150 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_NO_FABRIC);
1151}
1152
1153static void
1154bfa_fcs_fabric_send_flogi_acc(struct bfa_fcs_fabric_s *fabric)
1155{
1156 struct bfa_port_cfg_s *pcfg = &fabric->bport.port_cfg;
1157 struct bfa_fcs_port_n2n_s *n2n_port = &fabric->bport.port_topo.pn2n;
1158 struct bfa_s *bfa = fabric->fcs->bfa;
1159 struct bfa_fcxp_s *fcxp;
1160 u16 reqlen;
1161 struct fchs_s fchs;
1162
1163 fcxp = bfa_fcs_fcxp_alloc(fabric->fcs);
1164 /**
1165 * Do not expect this failure -- expect remote node to retry
1166 */
1167 if (!fcxp)
1168 return;
1169
1170 reqlen = fc_flogi_acc_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
1171 bfa_os_hton3b(FC_FABRIC_PORT),
1172 n2n_port->reply_oxid, pcfg->pwwn,
1173 pcfg->nwwn, bfa_pport_get_maxfrsize(bfa),
1174 bfa_pport_get_rx_bbcredit(bfa));
1175
1176 bfa_fcxp_send(fcxp, NULL, fabric->vf_id, bfa_lps_get_tag(fabric->lps),
1177 BFA_FALSE, FC_CLASS_3, reqlen, &fchs,
1178 bfa_fcs_fabric_flogiacc_comp, fabric,
1179 FC_MAX_PDUSZ, 0); /* Timeout 0 indicates no
1180 * response expected
1181 */
1182}
1183
1184/**
1185 * Flogi Acc completion callback.
1186 */
1187static void
1188bfa_fcs_fabric_flogiacc_comp(void *fcsarg, struct bfa_fcxp_s *fcxp, void *cbarg,
1189 bfa_status_t status, u32 rsp_len,
1190 u32 resid_len, struct fchs_s *rspfchs)
1191{
1192 struct bfa_fcs_fabric_s *fabric = cbarg;
1193
1194 bfa_trc(fabric->fcs, status);
1195}
1196
1197/*
1198 *
1199 * @param[in] fabric - fabric
1200 * @param[in] result - 1
1201 *
1202 * @return - none
1203 */
1204void
1205bfa_fcs_auth_finished(struct bfa_fcs_fabric_s *fabric, enum auth_status status)
1206{
1207 bfa_trc(fabric->fcs, status);
1208
1209 if (status == FC_AUTH_STATE_SUCCESS)
1210 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_AUTH_SUCCESS);
1211 else
1212 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_AUTH_FAILED);
1213}
1214
1215/**
1216 * Send AEN notification
1217 */
1218static void
1219bfa_fcs_fabric_aen_post(struct bfa_fcs_port_s *port,
1220 enum bfa_port_aen_event event)
1221{
1222 union bfa_aen_data_u aen_data;
1223 struct bfa_log_mod_s *logmod = port->fcs->logm;
1224 wwn_t pwwn = bfa_fcs_port_get_pwwn(port);
1225 wwn_t fwwn = bfa_fcs_port_get_fabric_name(port);
1226 char pwwn_ptr[BFA_STRING_32];
1227 char fwwn_ptr[BFA_STRING_32];
1228
1229 wwn2str(pwwn_ptr, pwwn);
1230 wwn2str(fwwn_ptr, fwwn);
1231
1232 switch (event) {
1233 case BFA_PORT_AEN_FABRIC_NAME_CHANGE:
1234 bfa_log(logmod, BFA_AEN_PORT_FABRIC_NAME_CHANGE, pwwn_ptr,
1235 fwwn_ptr);
1236 break;
1237 default:
1238 break;
1239 }
1240
1241 aen_data.port.pwwn = pwwn;
1242 aen_data.port.fwwn = fwwn;
1243}
1244
1245/*
1246 *
1247 * @param[in] fabric - fabric
1248 * @param[in] wwn_t - new fabric name
1249 *
1250 * @return - none
1251 */
1252void
1253bfa_fcs_fabric_set_fabric_name(struct bfa_fcs_fabric_s *fabric,
1254 wwn_t fabric_name)
1255{
1256 bfa_trc(fabric->fcs, fabric_name);
1257
1258 if (fabric->fabric_name == 0) {
1259 /*
1260 * With BRCD switches, we don't get Fabric Name in FLOGI.
1261 * Don't generate a fabric name change event in this case.
1262 */
1263 fabric->fabric_name = fabric_name;
1264 } else {
1265 fabric->fabric_name = fabric_name;
1266 /*
1267 * Generate a Event
1268 */
1269 bfa_fcs_fabric_aen_post(&fabric->bport,
1270 BFA_PORT_AEN_FABRIC_NAME_CHANGE);
1271 }
1272
1273}
1274
1275/**
1276 * Not used by FCS.
1277 */
1278void
1279bfa_cb_lps_flogo_comp(void *bfad, void *uarg)
1280{
1281}
1282
1283