blob: e229898866464153bc344417e5ef0a5d58ecab41 [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);
139 bfa_fcs_lport_init(&fabric->bport, fabric->fcs, FC_VF_ID_NULL,
140 &fabric->bport.port_cfg, NULL);
141 break;
142
143 case BFA_FCS_FABRIC_SM_LINK_UP:
144 case BFA_FCS_FABRIC_SM_LINK_DOWN:
145 break;
146
147 default:
148 bfa_sm_fault(fabric->fcs, event);
149 }
150}
151
152/**
153 * Beginning state before fabric creation.
154 */
155static void
156bfa_fcs_fabric_sm_created(struct bfa_fcs_fabric_s *fabric,
157 enum bfa_fcs_fabric_event event)
158{
159 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
160 bfa_trc(fabric->fcs, event);
161
162 switch (event) {
163 case BFA_FCS_FABRIC_SM_START:
164 if (bfa_pport_is_linkup(fabric->fcs->bfa)) {
165 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_flogi);
166 bfa_fcs_fabric_login(fabric);
167 } else
168 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
169 break;
170
171 case BFA_FCS_FABRIC_SM_LINK_UP:
172 case BFA_FCS_FABRIC_SM_LINK_DOWN:
173 break;
174
175 case BFA_FCS_FABRIC_SM_DELETE:
176 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_uninit);
177 bfa_fcs_modexit_comp(fabric->fcs);
178 break;
179
180 default:
181 bfa_sm_fault(fabric->fcs, event);
182 }
183}
184
185/**
186 * Link is down, awaiting LINK UP event from port. This is also the
187 * first state at fabric creation.
188 */
189static void
190bfa_fcs_fabric_sm_linkdown(struct bfa_fcs_fabric_s *fabric,
191 enum bfa_fcs_fabric_event event)
192{
193 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
194 bfa_trc(fabric->fcs, event);
195
196 switch (event) {
197 case BFA_FCS_FABRIC_SM_LINK_UP:
198 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_flogi);
199 bfa_fcs_fabric_login(fabric);
200 break;
201
202 case BFA_FCS_FABRIC_SM_RETRY_OP:
203 break;
204
205 case BFA_FCS_FABRIC_SM_DELETE:
206 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
207 bfa_fcs_fabric_delete(fabric);
208 break;
209
210 default:
211 bfa_sm_fault(fabric->fcs, event);
212 }
213}
214
215/**
216 * FLOGI is in progress, awaiting FLOGI reply.
217 */
218static void
219bfa_fcs_fabric_sm_flogi(struct bfa_fcs_fabric_s *fabric,
220 enum bfa_fcs_fabric_event event)
221{
222 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
223 bfa_trc(fabric->fcs, event);
224
225 switch (event) {
226 case BFA_FCS_FABRIC_SM_CONT_OP:
227
228 bfa_pport_set_tx_bbcredit(fabric->fcs->bfa, fabric->bb_credit);
229 fabric->fab_type = BFA_FCS_FABRIC_SWITCHED;
230
231 if (fabric->auth_reqd && fabric->is_auth) {
232 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_auth);
233 bfa_trc(fabric->fcs, event);
234 } else {
235 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_online);
236 bfa_fcs_fabric_notify_online(fabric);
237 }
238 break;
239
240 case BFA_FCS_FABRIC_SM_RETRY_OP:
241 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_flogi_retry);
242 bfa_timer_start(fabric->fcs->bfa, &fabric->delay_timer,
243 bfa_fcs_fabric_delay, fabric,
244 BFA_FCS_FABRIC_RETRY_DELAY);
245 break;
246
247 case BFA_FCS_FABRIC_SM_LOOPBACK:
248 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_loopback);
249 bfa_lps_discard(fabric->lps);
250 bfa_fcs_fabric_set_opertype(fabric);
251 break;
252
253 case BFA_FCS_FABRIC_SM_NO_FABRIC:
254 fabric->fab_type = BFA_FCS_FABRIC_N2N;
255 bfa_pport_set_tx_bbcredit(fabric->fcs->bfa, fabric->bb_credit);
256 bfa_fcs_fabric_notify_online(fabric);
257 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_nofabric);
258 break;
259
260 case BFA_FCS_FABRIC_SM_LINK_DOWN:
261 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
262 bfa_lps_discard(fabric->lps);
263 break;
264
265 case BFA_FCS_FABRIC_SM_DELETE:
266 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
267 bfa_lps_discard(fabric->lps);
268 bfa_fcs_fabric_delete(fabric);
269 break;
270
271 default:
272 bfa_sm_fault(fabric->fcs, event);
273 }
274}
275
276
277static void
278bfa_fcs_fabric_sm_flogi_retry(struct bfa_fcs_fabric_s *fabric,
279 enum bfa_fcs_fabric_event event)
280{
281 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
282 bfa_trc(fabric->fcs, event);
283
284 switch (event) {
285 case BFA_FCS_FABRIC_SM_DELAYED:
286 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_flogi);
287 bfa_fcs_fabric_login(fabric);
288 break;
289
290 case BFA_FCS_FABRIC_SM_LINK_DOWN:
291 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
292 bfa_timer_stop(&fabric->delay_timer);
293 break;
294
295 case BFA_FCS_FABRIC_SM_DELETE:
296 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
297 bfa_timer_stop(&fabric->delay_timer);
298 bfa_fcs_fabric_delete(fabric);
299 break;
300
301 default:
302 bfa_sm_fault(fabric->fcs, event);
303 }
304}
305
306/**
307 * Authentication is in progress, awaiting authentication results.
308 */
309static void
310bfa_fcs_fabric_sm_auth(struct bfa_fcs_fabric_s *fabric,
311 enum bfa_fcs_fabric_event event)
312{
313 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
314 bfa_trc(fabric->fcs, event);
315
316 switch (event) {
317 case BFA_FCS_FABRIC_SM_AUTH_FAILED:
318 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_auth_failed);
319 bfa_lps_discard(fabric->lps);
320 break;
321
322 case BFA_FCS_FABRIC_SM_AUTH_SUCCESS:
323 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_online);
324 bfa_fcs_fabric_notify_online(fabric);
325 break;
326
327 case BFA_FCS_FABRIC_SM_PERF_EVFP:
328 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_evfp);
329 break;
330
331 case BFA_FCS_FABRIC_SM_LINK_DOWN:
332 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
333 bfa_lps_discard(fabric->lps);
334 break;
335
336 case BFA_FCS_FABRIC_SM_DELETE:
337 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
338 bfa_fcs_fabric_delete(fabric);
339 break;
340
341 default:
342 bfa_sm_fault(fabric->fcs, event);
343 }
344}
345
346/**
347 * Authentication failed
348 */
349static void
350bfa_fcs_fabric_sm_auth_failed(struct bfa_fcs_fabric_s *fabric,
351 enum bfa_fcs_fabric_event event)
352{
353 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
354 bfa_trc(fabric->fcs, event);
355
356 switch (event) {
357 case BFA_FCS_FABRIC_SM_LINK_DOWN:
358 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
359 bfa_fcs_fabric_notify_offline(fabric);
360 break;
361
362 case BFA_FCS_FABRIC_SM_DELETE:
363 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
364 bfa_fcs_fabric_delete(fabric);
365 break;
366
367 default:
368 bfa_sm_fault(fabric->fcs, event);
369 }
370}
371
372/**
373 * Port is in loopback mode.
374 */
375static void
376bfa_fcs_fabric_sm_loopback(struct bfa_fcs_fabric_s *fabric,
377 enum bfa_fcs_fabric_event event)
378{
379 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
380 bfa_trc(fabric->fcs, event);
381
382 switch (event) {
383 case BFA_FCS_FABRIC_SM_LINK_DOWN:
384 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
385 bfa_fcs_fabric_notify_offline(fabric);
386 break;
387
388 case BFA_FCS_FABRIC_SM_DELETE:
389 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
390 bfa_fcs_fabric_delete(fabric);
391 break;
392
393 default:
394 bfa_sm_fault(fabric->fcs, event);
395 }
396}
397
398/**
399 * There is no attached fabric - private loop or NPort-to-NPort topology.
400 */
401static void
402bfa_fcs_fabric_sm_nofabric(struct bfa_fcs_fabric_s *fabric,
403 enum bfa_fcs_fabric_event event)
404{
405 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
406 bfa_trc(fabric->fcs, event);
407
408 switch (event) {
409 case BFA_FCS_FABRIC_SM_LINK_DOWN:
410 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
411 bfa_lps_discard(fabric->lps);
412 bfa_fcs_fabric_notify_offline(fabric);
413 break;
414
415 case BFA_FCS_FABRIC_SM_DELETE:
416 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
417 bfa_fcs_fabric_delete(fabric);
418 break;
419
420 case BFA_FCS_FABRIC_SM_NO_FABRIC:
421 bfa_trc(fabric->fcs, fabric->bb_credit);
422 bfa_pport_set_tx_bbcredit(fabric->fcs->bfa, fabric->bb_credit);
423 break;
424
425 default:
426 bfa_sm_fault(fabric->fcs, event);
427 }
428}
429
430/**
431 * Fabric is online - normal operating state.
432 */
433static void
434bfa_fcs_fabric_sm_online(struct bfa_fcs_fabric_s *fabric,
435 enum bfa_fcs_fabric_event event)
436{
437 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
438 bfa_trc(fabric->fcs, event);
439
440 switch (event) {
441 case BFA_FCS_FABRIC_SM_LINK_DOWN:
442 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
443 bfa_lps_discard(fabric->lps);
444 bfa_fcs_fabric_notify_offline(fabric);
445 break;
446
447 case BFA_FCS_FABRIC_SM_DELETE:
448 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
449 bfa_fcs_fabric_delete(fabric);
450 break;
451
452 case BFA_FCS_FABRIC_SM_AUTH_FAILED:
453 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_auth_failed);
454 bfa_lps_discard(fabric->lps);
455 break;
456
457 case BFA_FCS_FABRIC_SM_AUTH_SUCCESS:
458 break;
459
460 default:
461 bfa_sm_fault(fabric->fcs, event);
462 }
463}
464
465/**
466 * Exchanging virtual fabric parameters.
467 */
468static void
469bfa_fcs_fabric_sm_evfp(struct bfa_fcs_fabric_s *fabric,
470 enum bfa_fcs_fabric_event event)
471{
472 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
473 bfa_trc(fabric->fcs, event);
474
475 switch (event) {
476 case BFA_FCS_FABRIC_SM_CONT_OP:
477 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_evfp_done);
478 break;
479
480 case BFA_FCS_FABRIC_SM_ISOLATE:
481 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_isolated);
482 break;
483
484 default:
485 bfa_sm_fault(fabric->fcs, event);
486 }
487}
488
489/**
490 * EVFP exchange complete and VFT tagging is enabled.
491 */
492static void
493bfa_fcs_fabric_sm_evfp_done(struct bfa_fcs_fabric_s *fabric,
494 enum bfa_fcs_fabric_event event)
495{
496 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
497 bfa_trc(fabric->fcs, event);
498}
499
500/**
501 * Port is isolated after EVFP exchange due to VF_ID mismatch (N and F).
502 */
503static void
504bfa_fcs_fabric_sm_isolated(struct bfa_fcs_fabric_s *fabric,
505 enum bfa_fcs_fabric_event event)
506{
507 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
508 bfa_trc(fabric->fcs, event);
509
510 bfa_log(fabric->fcs->logm, BFA_LOG_FCS_FABRIC_ISOLATED,
511 fabric->bport.port_cfg.pwwn, fabric->fcs->port_vfid,
512 fabric->event_arg.swp_vfid);
513}
514
515/**
516 * Fabric is being deleted, awaiting vport delete completions.
517 */
518static void
519bfa_fcs_fabric_sm_deleting(struct bfa_fcs_fabric_s *fabric,
520 enum bfa_fcs_fabric_event event)
521{
522 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
523 bfa_trc(fabric->fcs, event);
524
525 switch (event) {
526 case BFA_FCS_FABRIC_SM_DELCOMP:
527 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_uninit);
528 bfa_fcs_modexit_comp(fabric->fcs);
529 break;
530
531 case BFA_FCS_FABRIC_SM_LINK_UP:
532 break;
533
534 case BFA_FCS_FABRIC_SM_LINK_DOWN:
535 bfa_fcs_fabric_notify_offline(fabric);
536 break;
537
538 default:
539 bfa_sm_fault(fabric->fcs, event);
540 }
541}
542
543
544
545/**
546 * fcs_fabric_private fabric private functions
547 */
548
549static void
550bfa_fcs_fabric_init(struct bfa_fcs_fabric_s *fabric)
551{
552 struct bfa_port_cfg_s *port_cfg = &fabric->bport.port_cfg;
553
554 port_cfg->roles = BFA_PORT_ROLE_FCP_IM;
555 port_cfg->nwwn = bfa_ioc_get_nwwn(&fabric->fcs->bfa->ioc);
556 port_cfg->pwwn = bfa_ioc_get_pwwn(&fabric->fcs->bfa->ioc);
557}
558
559/**
560 * Port Symbolic Name Creation for base port.
561 */
562void
563bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s *fabric)
564{
565 struct bfa_port_cfg_s *port_cfg = &fabric->bport.port_cfg;
566 struct bfa_adapter_attr_s adapter_attr;
567 struct bfa_fcs_driver_info_s *driver_info = &fabric->fcs->driver_info;
568
569 bfa_os_memset((void *)&adapter_attr, 0,
570 sizeof(struct bfa_adapter_attr_s));
571 bfa_ioc_get_adapter_attr(&fabric->fcs->bfa->ioc, &adapter_attr);
572
573 /*
574 * Model name/number
575 */
576 strncpy((char *)&port_cfg->sym_name, adapter_attr.model,
577 BFA_FCS_PORT_SYMBNAME_MODEL_SZ);
578 strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
579 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
580
581 /*
582 * Driver Version
583 */
584 strncat((char *)&port_cfg->sym_name, (char *)driver_info->version,
585 BFA_FCS_PORT_SYMBNAME_VERSION_SZ);
586 strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
587 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
588
589 /*
590 * Host machine name
591 */
592 strncat((char *)&port_cfg->sym_name,
593 (char *)driver_info->host_machine_name,
594 BFA_FCS_PORT_SYMBNAME_MACHINENAME_SZ);
595 strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
596 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
597
598 /*
599 * Host OS Info :
600 * If OS Patch Info is not there, do not truncate any bytes from the
601 * OS name string and instead copy the entire OS info string (64 bytes).
602 */
603 if (driver_info->host_os_patch[0] == '\0') {
604 strncat((char *)&port_cfg->sym_name,
605 (char *)driver_info->host_os_name, BFA_FCS_OS_STR_LEN);
606 strncat((char *)&port_cfg->sym_name,
607 BFA_FCS_PORT_SYMBNAME_SEPARATOR,
608 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
609 } else {
610 strncat((char *)&port_cfg->sym_name,
611 (char *)driver_info->host_os_name,
612 BFA_FCS_PORT_SYMBNAME_OSINFO_SZ);
613 strncat((char *)&port_cfg->sym_name,
614 BFA_FCS_PORT_SYMBNAME_SEPARATOR,
615 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
616
617 /*
618 * Append host OS Patch Info
619 */
620 strncat((char *)&port_cfg->sym_name,
621 (char *)driver_info->host_os_patch,
622 BFA_FCS_PORT_SYMBNAME_OSPATCH_SZ);
623 }
624
625 /*
626 * null terminate
627 */
628 port_cfg->sym_name.symname[BFA_SYMNAME_MAXLEN - 1] = 0;
629}
630
631/**
632 * bfa lps login completion callback
633 */
634void
635bfa_cb_lps_flogi_comp(void *bfad, void *uarg, bfa_status_t status)
636{
637 struct bfa_fcs_fabric_s *fabric = uarg;
638
639 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
640 bfa_trc(fabric->fcs, status);
641
642 switch (status) {
643 case BFA_STATUS_OK:
644 fabric->stats.flogi_accepts++;
645 break;
646
647 case BFA_STATUS_INVALID_MAC:
648 /*
649 * Only for CNA
650 */
651 fabric->stats.flogi_acc_err++;
652 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_RETRY_OP);
653
654 return;
655
656 case BFA_STATUS_EPROTOCOL:
657 switch (bfa_lps_get_extstatus(fabric->lps)) {
658 case BFA_EPROTO_BAD_ACCEPT:
659 fabric->stats.flogi_acc_err++;
660 break;
661
662 case BFA_EPROTO_UNKNOWN_RSP:
663 fabric->stats.flogi_unknown_rsp++;
664 break;
665
666 default:
667 break;
668 }
669 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_RETRY_OP);
670
671 return;
672
673 case BFA_STATUS_FABRIC_RJT:
674 fabric->stats.flogi_rejects++;
675 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_RETRY_OP);
676 return;
677
678 default:
679 fabric->stats.flogi_rsp_err++;
680 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_RETRY_OP);
681 return;
682 }
683
684 fabric->bb_credit = bfa_lps_get_peer_bbcredit(fabric->lps);
685 bfa_trc(fabric->fcs, fabric->bb_credit);
686
687 if (!bfa_lps_is_brcd_fabric(fabric->lps))
688 fabric->fabric_name = bfa_lps_get_peer_nwwn(fabric->lps);
689
690 /*
691 * Check port type. It should be 1 = F-port.
692 */
693 if (bfa_lps_is_fport(fabric->lps)) {
694 fabric->bport.pid = bfa_lps_get_pid(fabric->lps);
695 fabric->is_npiv = bfa_lps_is_npiv_en(fabric->lps);
696 fabric->is_auth = bfa_lps_is_authreq(fabric->lps);
697 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_CONT_OP);
698 } else {
699 /*
700 * Nport-2-Nport direct attached
701 */
702 fabric->bport.port_topo.pn2n.rem_port_wwn =
703 bfa_lps_get_peer_pwwn(fabric->lps);
704 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_NO_FABRIC);
705 }
706
707 bfa_trc(fabric->fcs, fabric->bport.pid);
708 bfa_trc(fabric->fcs, fabric->is_npiv);
709 bfa_trc(fabric->fcs, fabric->is_auth);
710}
711
712/**
713 * Allocate and send FLOGI.
714 */
715static void
716bfa_fcs_fabric_login(struct bfa_fcs_fabric_s *fabric)
717{
718 struct bfa_s *bfa = fabric->fcs->bfa;
719 struct bfa_port_cfg_s *pcfg = &fabric->bport.port_cfg;
720 u8 alpa = 0;
721
722 if (bfa_pport_get_topology(bfa) == BFA_PPORT_TOPOLOGY_LOOP)
723 alpa = bfa_pport_get_myalpa(bfa);
724
725 bfa_lps_flogi(fabric->lps, fabric, alpa, bfa_pport_get_maxfrsize(bfa),
726 pcfg->pwwn, pcfg->nwwn, fabric->auth_reqd);
727
728 fabric->stats.flogi_sent++;
729}
730
731static void
732bfa_fcs_fabric_notify_online(struct bfa_fcs_fabric_s *fabric)
733{
734 struct bfa_fcs_vport_s *vport;
735 struct list_head *qe, *qen;
736
737 bfa_trc(fabric->fcs, fabric->fabric_name);
738
739 bfa_fcs_fabric_set_opertype(fabric);
740 fabric->stats.fabric_onlines++;
741
742 /**
743 * notify online event to base and then virtual ports
744 */
745 bfa_fcs_port_online(&fabric->bport);
746
747 list_for_each_safe(qe, qen, &fabric->vport_q) {
748 vport = (struct bfa_fcs_vport_s *)qe;
749 bfa_fcs_vport_online(vport);
750 }
751}
752
753static void
754bfa_fcs_fabric_notify_offline(struct bfa_fcs_fabric_s *fabric)
755{
756 struct bfa_fcs_vport_s *vport;
757 struct list_head *qe, *qen;
758
759 bfa_trc(fabric->fcs, fabric->fabric_name);
760 fabric->stats.fabric_offlines++;
761
762 /**
763 * notify offline event first to vports and then base port.
764 */
765 list_for_each_safe(qe, qen, &fabric->vport_q) {
766 vport = (struct bfa_fcs_vport_s *)qe;
767 bfa_fcs_vport_offline(vport);
768 }
769
770 bfa_fcs_port_offline(&fabric->bport);
771
772 fabric->fabric_name = 0;
773 fabric->fabric_ip_addr[0] = 0;
774}
775
776static void
777bfa_fcs_fabric_delay(void *cbarg)
778{
779 struct bfa_fcs_fabric_s *fabric = cbarg;
780
781 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_DELAYED);
782}
783
784/**
785 * Delete all vports and wait for vport delete completions.
786 */
787static void
788bfa_fcs_fabric_delete(struct bfa_fcs_fabric_s *fabric)
789{
790 struct bfa_fcs_vport_s *vport;
791 struct list_head *qe, *qen;
792
793 list_for_each_safe(qe, qen, &fabric->vport_q) {
794 vport = (struct bfa_fcs_vport_s *)qe;
795 bfa_fcs_vport_delete(vport);
796 }
797
798 bfa_fcs_port_delete(&fabric->bport);
799 bfa_wc_wait(&fabric->wc);
800}
801
802static void
803bfa_fcs_fabric_delete_comp(void *cbarg)
804{
805 struct bfa_fcs_fabric_s *fabric = cbarg;
806
807 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_DELCOMP);
808}
809
810
811
812/**
813 * fcs_fabric_public fabric public functions
814 */
815
816/**
Krishna Gudipati82794a22010-03-03 17:43:30 -0800817 * Attach time initialization
Jing Huang7725ccf2009-09-23 17:46:15 -0700818 */
819void
Krishna Gudipati82794a22010-03-03 17:43:30 -0800820bfa_fcs_fabric_attach(struct bfa_fcs_s *fcs)
Jing Huang7725ccf2009-09-23 17:46:15 -0700821{
822 struct bfa_fcs_fabric_s *fabric;
823
824 fabric = &fcs->fabric;
825 bfa_os_memset(fabric, 0, sizeof(struct bfa_fcs_fabric_s));
826
827 /**
828 * Initialize base fabric.
829 */
830 fabric->fcs = fcs;
831 INIT_LIST_HEAD(&fabric->vport_q);
832 INIT_LIST_HEAD(&fabric->vf_q);
833 fabric->lps = bfa_lps_alloc(fcs->bfa);
834 bfa_assert(fabric->lps);
835
836 /**
837 * Initialize fabric delete completion handler. Fabric deletion is complete
838 * when the last vport delete is complete.
839 */
840 bfa_wc_init(&fabric->wc, bfa_fcs_fabric_delete_comp, fabric);
841 bfa_wc_up(&fabric->wc); /* For the base port */
842
843 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_uninit);
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