2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
6 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License (GPL) Version 2 as
10 * published by the Free Software Foundation
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
21 #include "bfa_fcbuild.h"
24 BFA_TRC_FILE(FCS
, PORT
);
27 * ALPA to LIXA bitmap mapping
29 * ALPA 0x00 (Word 0, Bit 30) is invalid for N_Ports. Also Word 0 Bit 31
30 * is for L_bit (login required) and is filled as ALPA 0x00 here.
32 static const u8 loop_alpa_map
[] = {
33 0x00, 0x00, 0x01, 0x02, 0x04, 0x08, 0x0F, 0x10, /* Word 0 Bits 31..24 */
34 0x17, 0x18, 0x1B, 0x1D, 0x1E, 0x1F, 0x23, 0x25, /* Word 0 Bits 23..16 */
35 0x26, 0x27, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, /* Word 0 Bits 15..08 */
36 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x39, 0x3A, /* Word 0 Bits 07..00 */
38 0x3C, 0x43, 0x45, 0x46, 0x47, 0x49, 0x4A, 0x4B, /* Word 1 Bits 31..24 */
39 0x4C, 0x4D, 0x4E, 0x51, 0x52, 0x53, 0x54, 0x55, /* Word 1 Bits 23..16 */
40 0x56, 0x59, 0x5A, 0x5C, 0x63, 0x65, 0x66, 0x67, /* Word 1 Bits 15..08 */
41 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x71, 0x72, /* Word 1 Bits 07..00 */
43 0x73, 0x74, 0x75, 0x76, 0x79, 0x7A, 0x7C, 0x80, /* Word 2 Bits 31..24 */
44 0x81, 0x82, 0x84, 0x88, 0x8F, 0x90, 0x97, 0x98, /* Word 2 Bits 23..16 */
45 0x9B, 0x9D, 0x9E, 0x9F, 0xA3, 0xA5, 0xA6, 0xA7, /* Word 2 Bits 15..08 */
46 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xB1, 0xB2, /* Word 2 Bits 07..00 */
48 0xB3, 0xB4, 0xB5, 0xB6, 0xB9, 0xBA, 0xBC, 0xC3, /* Word 3 Bits 31..24 */
49 0xC5, 0xC6, 0xC7, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, /* Word 3 Bits 23..16 */
50 0xCE, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD9, /* Word 3 Bits 15..08 */
51 0xDA, 0xDC, 0xE0, 0xE1, 0xE2, 0xE4, 0xE8, 0xEF, /* Word 3 Bits 07..00 */
54 static void bfa_fcs_lport_send_ls_rjt(struct bfa_fcs_lport_s
*port
,
55 struct fchs_s
*rx_fchs
, u8 reason_code
,
57 static void bfa_fcs_lport_plogi(struct bfa_fcs_lport_s
*port
,
58 struct fchs_s
*rx_fchs
, struct fc_logi_s
*plogi
);
59 static void bfa_fcs_lport_online_actions(struct bfa_fcs_lport_s
*port
);
60 static void bfa_fcs_lport_offline_actions(struct bfa_fcs_lport_s
*port
);
61 static void bfa_fcs_lport_unknown_init(struct bfa_fcs_lport_s
*port
);
62 static void bfa_fcs_lport_unknown_online(struct bfa_fcs_lport_s
*port
);
63 static void bfa_fcs_lport_unknown_offline(struct bfa_fcs_lport_s
*port
);
64 static void bfa_fcs_lport_deleted(struct bfa_fcs_lport_s
*port
);
65 static void bfa_fcs_lport_echo(struct bfa_fcs_lport_s
*port
,
66 struct fchs_s
*rx_fchs
,
67 struct fc_echo_s
*echo
, u16 len
);
68 static void bfa_fcs_lport_rnid(struct bfa_fcs_lport_s
*port
,
69 struct fchs_s
*rx_fchs
,
70 struct fc_rnid_cmd_s
*rnid
, u16 len
);
71 static void bfa_fs_port_get_gen_topo_data(struct bfa_fcs_lport_s
*port
,
72 struct fc_rnid_general_topology_data_s
*gen_topo_data
);
74 static void bfa_fcs_lport_fab_init(struct bfa_fcs_lport_s
*port
);
75 static void bfa_fcs_lport_fab_online(struct bfa_fcs_lport_s
*port
);
76 static void bfa_fcs_lport_fab_offline(struct bfa_fcs_lport_s
*port
);
78 static void bfa_fcs_lport_n2n_init(struct bfa_fcs_lport_s
*port
);
79 static void bfa_fcs_lport_n2n_online(struct bfa_fcs_lport_s
*port
);
80 static void bfa_fcs_lport_n2n_offline(struct bfa_fcs_lport_s
*port
);
82 static void bfa_fcs_lport_loop_init(struct bfa_fcs_lport_s
*port
);
83 static void bfa_fcs_lport_loop_online(struct bfa_fcs_lport_s
*port
);
84 static void bfa_fcs_lport_loop_offline(struct bfa_fcs_lport_s
*port
);
87 void (*init
) (struct bfa_fcs_lport_s
*port
);
88 void (*online
) (struct bfa_fcs_lport_s
*port
);
89 void (*offline
) (struct bfa_fcs_lport_s
*port
);
92 bfa_fcs_lport_unknown_init
, bfa_fcs_lport_unknown_online
,
93 bfa_fcs_lport_unknown_offline
}, {
94 bfa_fcs_lport_fab_init
, bfa_fcs_lport_fab_online
,
95 bfa_fcs_lport_fab_offline
}, {
96 bfa_fcs_lport_n2n_init
, bfa_fcs_lport_n2n_online
,
97 bfa_fcs_lport_n2n_offline
}, {
98 bfa_fcs_lport_loop_init
, bfa_fcs_lport_loop_online
,
99 bfa_fcs_lport_loop_offline
},
103 * fcs_port_sm FCS logical port state machine
106 enum bfa_fcs_lport_event
{
107 BFA_FCS_PORT_SM_CREATE
= 1,
108 BFA_FCS_PORT_SM_ONLINE
= 2,
109 BFA_FCS_PORT_SM_OFFLINE
= 3,
110 BFA_FCS_PORT_SM_DELETE
= 4,
111 BFA_FCS_PORT_SM_DELRPORT
= 5,
112 BFA_FCS_PORT_SM_STOP
= 6,
115 static void bfa_fcs_lport_sm_uninit(struct bfa_fcs_lport_s
*port
,
116 enum bfa_fcs_lport_event event
);
117 static void bfa_fcs_lport_sm_init(struct bfa_fcs_lport_s
*port
,
118 enum bfa_fcs_lport_event event
);
119 static void bfa_fcs_lport_sm_online(struct bfa_fcs_lport_s
*port
,
120 enum bfa_fcs_lport_event event
);
121 static void bfa_fcs_lport_sm_offline(struct bfa_fcs_lport_s
*port
,
122 enum bfa_fcs_lport_event event
);
123 static void bfa_fcs_lport_sm_deleting(struct bfa_fcs_lport_s
*port
,
124 enum bfa_fcs_lport_event event
);
125 static void bfa_fcs_lport_sm_stopping(struct bfa_fcs_lport_s
*port
,
126 enum bfa_fcs_lport_event event
);
129 bfa_fcs_lport_sm_uninit(
130 struct bfa_fcs_lport_s
*port
,
131 enum bfa_fcs_lport_event event
)
133 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
134 bfa_trc(port
->fcs
, event
);
137 case BFA_FCS_PORT_SM_CREATE
:
138 bfa_sm_set_state(port
, bfa_fcs_lport_sm_init
);
142 bfa_sm_fault(port
->fcs
, event
);
147 bfa_fcs_lport_sm_init(struct bfa_fcs_lport_s
*port
,
148 enum bfa_fcs_lport_event event
)
150 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
151 bfa_trc(port
->fcs
, event
);
154 case BFA_FCS_PORT_SM_ONLINE
:
155 bfa_sm_set_state(port
, bfa_fcs_lport_sm_online
);
156 bfa_fcs_lport_online_actions(port
);
159 case BFA_FCS_PORT_SM_DELETE
:
160 bfa_sm_set_state(port
, bfa_fcs_lport_sm_uninit
);
161 bfa_fcs_lport_deleted(port
);
164 case BFA_FCS_PORT_SM_STOP
:
165 /* If vport - send completion call back */
167 bfa_fcs_vport_stop_comp(port
->vport
);
169 bfa_wc_down(&(port
->fabric
->stop_wc
));
172 case BFA_FCS_PORT_SM_OFFLINE
:
176 bfa_sm_fault(port
->fcs
, event
);
181 bfa_fcs_lport_sm_online(
182 struct bfa_fcs_lport_s
*port
,
183 enum bfa_fcs_lport_event event
)
185 struct bfa_fcs_rport_s
*rport
;
186 struct list_head
*qe
, *qen
;
188 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
189 bfa_trc(port
->fcs
, event
);
192 case BFA_FCS_PORT_SM_OFFLINE
:
193 bfa_sm_set_state(port
, bfa_fcs_lport_sm_offline
);
194 bfa_fcs_lport_offline_actions(port
);
197 case BFA_FCS_PORT_SM_STOP
:
198 __port_action
[port
->fabric
->fab_type
].offline(port
);
200 if (port
->num_rports
== 0) {
201 bfa_sm_set_state(port
, bfa_fcs_lport_sm_init
);
202 /* If vport - send completion call back */
204 bfa_fcs_vport_stop_comp(port
->vport
);
206 bfa_wc_down(&(port
->fabric
->stop_wc
));
208 bfa_sm_set_state(port
, bfa_fcs_lport_sm_stopping
);
209 list_for_each_safe(qe
, qen
, &port
->rport_q
) {
210 rport
= (struct bfa_fcs_rport_s
*) qe
;
211 bfa_sm_send_event(rport
, RPSM_EVENT_DELETE
);
216 case BFA_FCS_PORT_SM_DELETE
:
218 __port_action
[port
->fabric
->fab_type
].offline(port
);
220 if (port
->num_rports
== 0) {
221 bfa_sm_set_state(port
, bfa_fcs_lport_sm_uninit
);
222 bfa_fcs_lport_deleted(port
);
224 bfa_sm_set_state(port
, bfa_fcs_lport_sm_deleting
);
225 list_for_each_safe(qe
, qen
, &port
->rport_q
) {
226 rport
= (struct bfa_fcs_rport_s
*) qe
;
227 bfa_sm_send_event(rport
, RPSM_EVENT_DELETE
);
232 case BFA_FCS_PORT_SM_DELRPORT
:
236 bfa_sm_fault(port
->fcs
, event
);
241 bfa_fcs_lport_sm_offline(
242 struct bfa_fcs_lport_s
*port
,
243 enum bfa_fcs_lport_event event
)
245 struct bfa_fcs_rport_s
*rport
;
246 struct list_head
*qe
, *qen
;
248 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
249 bfa_trc(port
->fcs
, event
);
252 case BFA_FCS_PORT_SM_ONLINE
:
253 bfa_sm_set_state(port
, bfa_fcs_lport_sm_online
);
254 bfa_fcs_lport_online_actions(port
);
257 case BFA_FCS_PORT_SM_STOP
:
258 if (port
->num_rports
== 0) {
259 bfa_sm_set_state(port
, bfa_fcs_lport_sm_init
);
260 /* If vport - send completion call back */
262 bfa_fcs_vport_stop_comp(port
->vport
);
264 bfa_wc_down(&(port
->fabric
->stop_wc
));
266 bfa_sm_set_state(port
, bfa_fcs_lport_sm_stopping
);
267 list_for_each_safe(qe
, qen
, &port
->rport_q
) {
268 rport
= (struct bfa_fcs_rport_s
*) qe
;
269 bfa_sm_send_event(rport
, RPSM_EVENT_DELETE
);
274 case BFA_FCS_PORT_SM_DELETE
:
275 if (port
->num_rports
== 0) {
276 bfa_sm_set_state(port
, bfa_fcs_lport_sm_uninit
);
277 bfa_fcs_lport_deleted(port
);
279 bfa_sm_set_state(port
, bfa_fcs_lport_sm_deleting
);
280 list_for_each_safe(qe
, qen
, &port
->rport_q
) {
281 rport
= (struct bfa_fcs_rport_s
*) qe
;
282 bfa_sm_send_event(rport
, RPSM_EVENT_DELETE
);
287 case BFA_FCS_PORT_SM_DELRPORT
:
288 case BFA_FCS_PORT_SM_OFFLINE
:
292 bfa_sm_fault(port
->fcs
, event
);
297 bfa_fcs_lport_sm_stopping(struct bfa_fcs_lport_s
*port
,
298 enum bfa_fcs_lport_event event
)
300 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
301 bfa_trc(port
->fcs
, event
);
304 case BFA_FCS_PORT_SM_DELRPORT
:
305 if (port
->num_rports
== 0) {
306 bfa_sm_set_state(port
, bfa_fcs_lport_sm_init
);
307 /* If vport - send completion call back */
309 bfa_fcs_vport_stop_comp(port
->vport
);
311 bfa_wc_down(&(port
->fabric
->stop_wc
));
316 bfa_sm_fault(port
->fcs
, event
);
321 bfa_fcs_lport_sm_deleting(
322 struct bfa_fcs_lport_s
*port
,
323 enum bfa_fcs_lport_event event
)
325 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
326 bfa_trc(port
->fcs
, event
);
329 case BFA_FCS_PORT_SM_DELRPORT
:
330 if (port
->num_rports
== 0) {
331 bfa_sm_set_state(port
, bfa_fcs_lport_sm_uninit
);
332 bfa_fcs_lport_deleted(port
);
337 bfa_sm_fault(port
->fcs
, event
);
346 * Send AEN notification
349 bfa_fcs_lport_aen_post(struct bfa_fcs_lport_s
*port
,
350 enum bfa_lport_aen_event event
)
352 struct bfad_s
*bfad
= (struct bfad_s
*)port
->fabric
->fcs
->bfad
;
353 struct bfa_aen_entry_s
*aen_entry
;
355 bfad_get_aen_entry(bfad
, aen_entry
);
359 aen_entry
->aen_data
.lport
.vf_id
= port
->fabric
->vf_id
;
360 aen_entry
->aen_data
.lport
.roles
= port
->port_cfg
.roles
;
361 aen_entry
->aen_data
.lport
.ppwwn
= bfa_fcs_lport_get_pwwn(
362 bfa_fcs_get_base_port(port
->fcs
));
363 aen_entry
->aen_data
.lport
.lpwwn
= bfa_fcs_lport_get_pwwn(port
);
365 /* Send the AEN notification */
366 bfad_im_post_vendor_event(aen_entry
, bfad
, ++port
->fcs
->fcs_aen_seq
,
367 BFA_AEN_CAT_LPORT
, event
);
374 bfa_fcs_lport_send_ls_rjt(struct bfa_fcs_lport_s
*port
, struct fchs_s
*rx_fchs
,
375 u8 reason_code
, u8 reason_code_expl
)
378 struct bfa_fcxp_s
*fcxp
;
379 struct bfa_rport_s
*bfa_rport
= NULL
;
382 bfa_trc(port
->fcs
, rx_fchs
->d_id
);
383 bfa_trc(port
->fcs
, rx_fchs
->s_id
);
385 fcxp
= bfa_fcs_fcxp_alloc(port
->fcs
, BFA_FALSE
);
389 len
= fc_ls_rjt_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
390 rx_fchs
->s_id
, bfa_fcs_lport_get_fcid(port
),
391 rx_fchs
->ox_id
, reason_code
, reason_code_expl
);
393 bfa_fcxp_send(fcxp
, bfa_rport
, port
->fabric
->vf_id
, port
->lp_tag
,
394 BFA_FALSE
, FC_CLASS_3
, len
, &fchs
, NULL
, NULL
,
402 bfa_fcs_lport_send_fcgs_rjt(struct bfa_fcs_lport_s
*port
,
403 struct fchs_s
*rx_fchs
, u8 reason_code
, u8 reason_code_expl
)
406 struct bfa_fcxp_s
*fcxp
;
407 struct bfa_rport_s
*bfa_rport
= NULL
;
409 struct ct_hdr_s
*rx_cthdr
= (struct ct_hdr_s
*)(rx_fchs
+ 1);
410 struct ct_hdr_s
*ct_hdr
;
412 bfa_trc(port
->fcs
, rx_fchs
->d_id
);
413 bfa_trc(port
->fcs
, rx_fchs
->s_id
);
415 fcxp
= bfa_fcs_fcxp_alloc(port
->fcs
, BFA_FALSE
);
419 ct_hdr
= bfa_fcxp_get_reqbuf(fcxp
);
420 ct_hdr
->gs_type
= rx_cthdr
->gs_type
;
421 ct_hdr
->gs_sub_type
= rx_cthdr
->gs_sub_type
;
423 len
= fc_gs_rjt_build(&fchs
, ct_hdr
, rx_fchs
->s_id
,
424 bfa_fcs_lport_get_fcid(port
),
425 rx_fchs
->ox_id
, reason_code
, reason_code_expl
);
427 bfa_fcxp_send(fcxp
, bfa_rport
, port
->fabric
->vf_id
, port
->lp_tag
,
428 BFA_FALSE
, FC_CLASS_3
, len
, &fchs
, NULL
, NULL
,
433 * Process incoming plogi from a remote port.
436 bfa_fcs_lport_plogi(struct bfa_fcs_lport_s
*port
,
437 struct fchs_s
*rx_fchs
, struct fc_logi_s
*plogi
)
439 struct bfa_fcs_rport_s
*rport
;
441 bfa_trc(port
->fcs
, rx_fchs
->d_id
);
442 bfa_trc(port
->fcs
, rx_fchs
->s_id
);
445 * If min cfg mode is enabled, drop any incoming PLOGIs
447 if (__fcs_min_cfg(port
->fcs
)) {
448 bfa_trc(port
->fcs
, rx_fchs
->s_id
);
452 if (fc_plogi_parse(rx_fchs
) != FC_PARSE_OK
) {
453 bfa_trc(port
->fcs
, rx_fchs
->s_id
);
457 bfa_fcs_lport_send_ls_rjt(port
, rx_fchs
,
458 FC_LS_RJT_RSN_PROTOCOL_ERROR
,
459 FC_LS_RJT_EXP_SPARMS_ERR_OPTIONS
);
464 * Direct Attach P2P mode : verify address assigned by the r-port.
466 if ((!bfa_fcs_fabric_is_switched(port
->fabric
)) &&
467 (memcmp((void *)&bfa_fcs_lport_get_pwwn(port
),
468 (void *)&plogi
->port_name
, sizeof(wwn_t
)) < 0)) {
469 if (BFA_FCS_PID_IS_WKA(rx_fchs
->d_id
)) {
470 /* Address assigned to us cannot be a WKA */
471 bfa_fcs_lport_send_ls_rjt(port
, rx_fchs
,
472 FC_LS_RJT_RSN_PROTOCOL_ERROR
,
473 FC_LS_RJT_EXP_INVALID_NPORT_ID
);
476 port
->pid
= rx_fchs
->d_id
;
477 bfa_lps_set_n2n_pid(port
->fabric
->lps
, rx_fchs
->d_id
);
481 * First, check if we know the device by pwwn.
483 rport
= bfa_fcs_lport_get_rport_by_pwwn(port
, plogi
->port_name
);
486 * Direct Attach P2P mode : handle address assigned by r-port.
488 if ((!bfa_fcs_fabric_is_switched(port
->fabric
)) &&
489 (memcmp((void *)&bfa_fcs_lport_get_pwwn(port
),
490 (void *)&plogi
->port_name
, sizeof(wwn_t
)) < 0)) {
491 port
->pid
= rx_fchs
->d_id
;
492 bfa_lps_set_n2n_pid(port
->fabric
->lps
, rx_fchs
->d_id
);
493 rport
->pid
= rx_fchs
->s_id
;
495 bfa_fcs_rport_plogi(rport
, rx_fchs
, plogi
);
500 * Next, lookup rport by PID.
502 rport
= bfa_fcs_lport_get_rport_by_pid(port
, rx_fchs
->s_id
);
505 * Inbound PLOGI from a new device.
507 bfa_fcs_rport_plogi_create(port
, rx_fchs
, plogi
);
512 * Rport is known only by PID.
516 * This is a different device with the same pid. Old device
517 * disappeared. Send implicit LOGO to old device.
519 WARN_ON(rport
->pwwn
== plogi
->port_name
);
520 bfa_sm_send_event(rport
, RPSM_EVENT_LOGO_IMP
);
523 * Inbound PLOGI from a new device (with old PID).
525 bfa_fcs_rport_plogi_create(port
, rx_fchs
, plogi
);
530 * PLOGI crossing each other.
532 WARN_ON(rport
->pwwn
!= WWN_NULL
);
533 bfa_fcs_rport_plogi(rport
, rx_fchs
, plogi
);
537 * Process incoming ECHO.
538 * Since it does not require a login, it is processed here.
541 bfa_fcs_lport_echo(struct bfa_fcs_lport_s
*port
, struct fchs_s
*rx_fchs
,
542 struct fc_echo_s
*echo
, u16 rx_len
)
545 struct bfa_fcxp_s
*fcxp
;
546 struct bfa_rport_s
*bfa_rport
= NULL
;
549 bfa_trc(port
->fcs
, rx_fchs
->s_id
);
550 bfa_trc(port
->fcs
, rx_fchs
->d_id
);
552 fcxp
= bfa_fcs_fcxp_alloc(port
->fcs
, BFA_FALSE
);
556 len
= fc_ls_acc_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
557 rx_fchs
->s_id
, bfa_fcs_lport_get_fcid(port
),
561 * Copy the payload (if any) from the echo frame
563 pyld_len
= rx_len
- sizeof(struct fchs_s
);
564 bfa_trc(port
->fcs
, rx_len
);
565 bfa_trc(port
->fcs
, pyld_len
);
568 memcpy(((u8
*) bfa_fcxp_get_reqbuf(fcxp
)) +
569 sizeof(struct fc_echo_s
), (echo
+ 1),
570 (pyld_len
- sizeof(struct fc_echo_s
)));
572 bfa_fcxp_send(fcxp
, bfa_rport
, port
->fabric
->vf_id
, port
->lp_tag
,
573 BFA_FALSE
, FC_CLASS_3
, pyld_len
, &fchs
, NULL
, NULL
,
578 * Process incoming RNID.
579 * Since it does not require a login, it is processed here.
582 bfa_fcs_lport_rnid(struct bfa_fcs_lport_s
*port
, struct fchs_s
*rx_fchs
,
583 struct fc_rnid_cmd_s
*rnid
, u16 rx_len
)
585 struct fc_rnid_common_id_data_s common_id_data
;
586 struct fc_rnid_general_topology_data_s gen_topo_data
;
588 struct bfa_fcxp_s
*fcxp
;
589 struct bfa_rport_s
*bfa_rport
= NULL
;
593 bfa_trc(port
->fcs
, rx_fchs
->s_id
);
594 bfa_trc(port
->fcs
, rx_fchs
->d_id
);
595 bfa_trc(port
->fcs
, rx_len
);
597 fcxp
= bfa_fcs_fcxp_alloc(port
->fcs
, BFA_FALSE
);
602 * Check Node Indentification Data Format
603 * We only support General Topology Discovery Format.
604 * For any other requested Data Formats, we return Common Node Id Data
605 * only, as per FC-LS.
607 bfa_trc(port
->fcs
, rnid
->node_id_data_format
);
608 if (rnid
->node_id_data_format
== RNID_NODEID_DATA_FORMAT_DISCOVERY
) {
609 data_format
= RNID_NODEID_DATA_FORMAT_DISCOVERY
;
611 * Get General topology data for this port
613 bfa_fs_port_get_gen_topo_data(port
, &gen_topo_data
);
615 data_format
= RNID_NODEID_DATA_FORMAT_COMMON
;
619 * Copy the Node Id Info
621 common_id_data
.port_name
= bfa_fcs_lport_get_pwwn(port
);
622 common_id_data
.node_name
= bfa_fcs_lport_get_nwwn(port
);
624 len
= fc_rnid_acc_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
625 rx_fchs
->s_id
, bfa_fcs_lport_get_fcid(port
),
626 rx_fchs
->ox_id
, data_format
, &common_id_data
,
629 bfa_fcxp_send(fcxp
, bfa_rport
, port
->fabric
->vf_id
, port
->lp_tag
,
630 BFA_FALSE
, FC_CLASS_3
, len
, &fchs
, NULL
, NULL
,
635 * Fill out General Topolpgy Discovery Data for RNID ELS.
638 bfa_fs_port_get_gen_topo_data(struct bfa_fcs_lport_s
*port
,
639 struct fc_rnid_general_topology_data_s
*gen_topo_data
)
641 memset(gen_topo_data
, 0,
642 sizeof(struct fc_rnid_general_topology_data_s
));
644 gen_topo_data
->asso_type
= cpu_to_be32(RNID_ASSOCIATED_TYPE_HOST
);
645 gen_topo_data
->phy_port_num
= 0; /* @todo */
646 gen_topo_data
->num_attached_nodes
= cpu_to_be32(1);
650 bfa_fcs_lport_online_actions(struct bfa_fcs_lport_s
*port
)
652 struct bfad_s
*bfad
= (struct bfad_s
*)port
->fcs
->bfad
;
653 char lpwwn_buf
[BFA_STRING_32
];
655 bfa_trc(port
->fcs
, port
->fabric
->oper_type
);
657 __port_action
[port
->fabric
->fab_type
].init(port
);
658 __port_action
[port
->fabric
->fab_type
].online(port
);
660 wwn2str(lpwwn_buf
, bfa_fcs_lport_get_pwwn(port
));
661 BFA_LOG(KERN_WARNING
, bfad
, bfa_log_level
,
662 "Logical port online: WWN = %s Role = %s\n",
663 lpwwn_buf
, "Initiator");
664 bfa_fcs_lport_aen_post(port
, BFA_LPORT_AEN_ONLINE
);
666 bfad
->bfad_flags
|= BFAD_PORT_ONLINE
;
670 bfa_fcs_lport_offline_actions(struct bfa_fcs_lport_s
*port
)
672 struct list_head
*qe
, *qen
;
673 struct bfa_fcs_rport_s
*rport
;
674 struct bfad_s
*bfad
= (struct bfad_s
*)port
->fcs
->bfad
;
675 char lpwwn_buf
[BFA_STRING_32
];
677 bfa_trc(port
->fcs
, port
->fabric
->oper_type
);
679 __port_action
[port
->fabric
->fab_type
].offline(port
);
681 wwn2str(lpwwn_buf
, bfa_fcs_lport_get_pwwn(port
));
682 if (bfa_sm_cmp_state(port
->fabric
,
683 bfa_fcs_fabric_sm_online
) == BFA_TRUE
) {
684 BFA_LOG(KERN_WARNING
, bfad
, bfa_log_level
,
685 "Logical port lost fabric connectivity: WWN = %s Role = %s\n",
686 lpwwn_buf
, "Initiator");
687 bfa_fcs_lport_aen_post(port
, BFA_LPORT_AEN_DISCONNECT
);
689 BFA_LOG(KERN_WARNING
, bfad
, bfa_log_level
,
690 "Logical port taken offline: WWN = %s Role = %s\n",
691 lpwwn_buf
, "Initiator");
692 bfa_fcs_lport_aen_post(port
, BFA_LPORT_AEN_OFFLINE
);
695 list_for_each_safe(qe
, qen
, &port
->rport_q
) {
696 rport
= (struct bfa_fcs_rport_s
*) qe
;
697 bfa_sm_send_event(rport
, RPSM_EVENT_LOGO_IMP
);
702 bfa_fcs_lport_unknown_init(struct bfa_fcs_lport_s
*port
)
708 bfa_fcs_lport_unknown_online(struct bfa_fcs_lport_s
*port
)
714 bfa_fcs_lport_unknown_offline(struct bfa_fcs_lport_s
*port
)
720 bfa_fcs_lport_abts_acc(struct bfa_fcs_lport_s
*port
, struct fchs_s
*rx_fchs
)
723 struct bfa_fcxp_s
*fcxp
;
726 bfa_trc(port
->fcs
, rx_fchs
->d_id
);
727 bfa_trc(port
->fcs
, rx_fchs
->s_id
);
729 fcxp
= bfa_fcs_fcxp_alloc(port
->fcs
, BFA_FALSE
);
733 len
= fc_ba_acc_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
734 rx_fchs
->s_id
, bfa_fcs_lport_get_fcid(port
),
737 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
,
738 BFA_FALSE
, FC_CLASS_3
, len
, &fchs
, NULL
, NULL
,
742 bfa_fcs_lport_deleted(struct bfa_fcs_lport_s
*port
)
744 struct bfad_s
*bfad
= (struct bfad_s
*)port
->fcs
->bfad
;
745 char lpwwn_buf
[BFA_STRING_32
];
747 wwn2str(lpwwn_buf
, bfa_fcs_lport_get_pwwn(port
));
748 BFA_LOG(KERN_INFO
, bfad
, bfa_log_level
,
749 "Logical port deleted: WWN = %s Role = %s\n",
750 lpwwn_buf
, "Initiator");
751 bfa_fcs_lport_aen_post(port
, BFA_LPORT_AEN_DELETE
);
753 /* Base port will be deleted by the OS driver */
755 bfa_fcs_vport_delete_comp(port
->vport
);
757 bfa_wc_down(&port
->fabric
->wc
);
762 * Unsolicited frame receive handling.
765 bfa_fcs_lport_uf_recv(struct bfa_fcs_lport_s
*lport
,
766 struct fchs_s
*fchs
, u16 len
)
768 u32 pid
= fchs
->s_id
;
769 struct bfa_fcs_rport_s
*rport
= NULL
;
770 struct fc_els_cmd_s
*els_cmd
= (struct fc_els_cmd_s
*) (fchs
+ 1);
772 bfa_stats(lport
, uf_recvs
);
773 bfa_trc(lport
->fcs
, fchs
->type
);
775 if (!bfa_fcs_lport_is_online(lport
)) {
777 * In direct attach topology, it is possible to get a PLOGI
778 * before the lport is online due to port feature
779 * (QoS/Trunk/FEC/CR), so send a rjt
781 if ((fchs
->type
== FC_TYPE_ELS
) &&
782 (els_cmd
->els_code
== FC_ELS_PLOGI
)) {
783 bfa_fcs_lport_send_ls_rjt(lport
, fchs
,
784 FC_LS_RJT_RSN_UNABLE_TO_PERF_CMD
,
785 FC_LS_RJT_EXP_NO_ADDL_INFO
);
786 bfa_stats(lport
, plogi_rcvd
);
788 bfa_stats(lport
, uf_recv_drops
);
794 * First, handle ELSs that donot require a login.
799 if ((fchs
->type
== FC_TYPE_ELS
) &&
800 (els_cmd
->els_code
== FC_ELS_PLOGI
)) {
801 bfa_fcs_lport_plogi(lport
, fchs
, (struct fc_logi_s
*) els_cmd
);
806 * Handle ECHO separately.
808 if ((fchs
->type
== FC_TYPE_ELS
) && (els_cmd
->els_code
== FC_ELS_ECHO
)) {
809 bfa_fcs_lport_echo(lport
, fchs
,
810 (struct fc_echo_s
*)els_cmd
, len
);
815 * Handle RNID separately.
817 if ((fchs
->type
== FC_TYPE_ELS
) && (els_cmd
->els_code
== FC_ELS_RNID
)) {
818 bfa_fcs_lport_rnid(lport
, fchs
,
819 (struct fc_rnid_cmd_s
*) els_cmd
, len
);
823 if (fchs
->type
== FC_TYPE_BLS
) {
824 if ((fchs
->routing
== FC_RTG_BASIC_LINK
) &&
825 (fchs
->cat_info
== FC_CAT_ABTS
))
826 bfa_fcs_lport_abts_acc(lport
, fchs
);
830 if (fchs
->type
== FC_TYPE_SERVICES
) {
832 * Unhandled FC-GS frames. Send a FC-CT Reject
834 bfa_fcs_lport_send_fcgs_rjt(lport
, fchs
, CT_RSN_NOT_SUPP
,
835 CT_NS_EXP_NOADDITIONAL
);
840 * look for a matching remote port ID
842 rport
= bfa_fcs_lport_get_rport_by_pid(lport
, pid
);
844 bfa_trc(rport
->fcs
, fchs
->s_id
);
845 bfa_trc(rport
->fcs
, fchs
->d_id
);
846 bfa_trc(rport
->fcs
, fchs
->type
);
848 bfa_fcs_rport_uf_recv(rport
, fchs
, len
);
853 * Only handles ELS frames for now.
855 if (fchs
->type
!= FC_TYPE_ELS
) {
856 bfa_trc(lport
->fcs
, fchs
->s_id
);
857 bfa_trc(lport
->fcs
, fchs
->d_id
);
858 /* ignore type FC_TYPE_FC_FSS */
859 if (fchs
->type
!= FC_TYPE_FC_FSS
)
860 bfa_sm_fault(lport
->fcs
, fchs
->type
);
864 bfa_trc(lport
->fcs
, els_cmd
->els_code
);
865 if (els_cmd
->els_code
== FC_ELS_RSCN
) {
866 bfa_fcs_lport_scn_process_rscn(lport
, fchs
, len
);
870 if (els_cmd
->els_code
== FC_ELS_LOGO
) {
872 * @todo Handle LOGO frames received.
877 if (els_cmd
->els_code
== FC_ELS_PRLI
) {
879 * @todo Handle PRLI frames received.
885 * Unhandled ELS frames. Send a LS_RJT.
887 bfa_fcs_lport_send_ls_rjt(lport
, fchs
, FC_LS_RJT_RSN_CMD_NOT_SUPP
,
888 FC_LS_RJT_EXP_NO_ADDL_INFO
);
893 * PID based Lookup for a R-Port in the Port R-Port Queue
895 struct bfa_fcs_rport_s
*
896 bfa_fcs_lport_get_rport_by_pid(struct bfa_fcs_lport_s
*port
, u32 pid
)
898 struct bfa_fcs_rport_s
*rport
;
899 struct list_head
*qe
;
901 list_for_each(qe
, &port
->rport_q
) {
902 rport
= (struct bfa_fcs_rport_s
*) qe
;
903 if (rport
->pid
== pid
)
907 bfa_trc(port
->fcs
, pid
);
912 * OLD_PID based Lookup for a R-Port in the Port R-Port Queue
914 struct bfa_fcs_rport_s
*
915 bfa_fcs_lport_get_rport_by_old_pid(struct bfa_fcs_lport_s
*port
, u32 pid
)
917 struct bfa_fcs_rport_s
*rport
;
918 struct list_head
*qe
;
920 list_for_each(qe
, &port
->rport_q
) {
921 rport
= (struct bfa_fcs_rport_s
*) qe
;
922 if (rport
->old_pid
== pid
)
926 bfa_trc(port
->fcs
, pid
);
931 * PWWN based Lookup for a R-Port in the Port R-Port Queue
933 struct bfa_fcs_rport_s
*
934 bfa_fcs_lport_get_rport_by_pwwn(struct bfa_fcs_lport_s
*port
, wwn_t pwwn
)
936 struct bfa_fcs_rport_s
*rport
;
937 struct list_head
*qe
;
939 list_for_each(qe
, &port
->rport_q
) {
940 rport
= (struct bfa_fcs_rport_s
*) qe
;
941 if (wwn_is_equal(rport
->pwwn
, pwwn
))
945 bfa_trc(port
->fcs
, pwwn
);
950 * NWWN based Lookup for a R-Port in the Port R-Port Queue
952 struct bfa_fcs_rport_s
*
953 bfa_fcs_lport_get_rport_by_nwwn(struct bfa_fcs_lport_s
*port
, wwn_t nwwn
)
955 struct bfa_fcs_rport_s
*rport
;
956 struct list_head
*qe
;
958 list_for_each(qe
, &port
->rport_q
) {
959 rport
= (struct bfa_fcs_rport_s
*) qe
;
960 if (wwn_is_equal(rport
->nwwn
, nwwn
))
964 bfa_trc(port
->fcs
, nwwn
);
969 * PWWN & PID based Lookup for a R-Port in the Port R-Port Queue
971 struct bfa_fcs_rport_s
*
972 bfa_fcs_lport_get_rport_by_qualifier(struct bfa_fcs_lport_s
*port
,
975 struct bfa_fcs_rport_s
*rport
;
976 struct list_head
*qe
;
978 list_for_each(qe
, &port
->rport_q
) {
979 rport
= (struct bfa_fcs_rport_s
*) qe
;
980 if (wwn_is_equal(rport
->pwwn
, pwwn
) && rport
->pid
== pid
)
984 bfa_trc(port
->fcs
, pwwn
);
989 * Called by rport module when new rports are discovered.
992 bfa_fcs_lport_add_rport(
993 struct bfa_fcs_lport_s
*port
,
994 struct bfa_fcs_rport_s
*rport
)
996 list_add_tail(&rport
->qe
, &port
->rport_q
);
1001 * Called by rport module to when rports are deleted.
1004 bfa_fcs_lport_del_rport(
1005 struct bfa_fcs_lport_s
*port
,
1006 struct bfa_fcs_rport_s
*rport
)
1008 WARN_ON(!bfa_q_is_on_q(&port
->rport_q
, rport
));
1009 list_del(&rport
->qe
);
1012 bfa_sm_send_event(port
, BFA_FCS_PORT_SM_DELRPORT
);
1016 * Called by fabric for base port when fabric login is complete.
1017 * Called by vport for virtual ports when FDISC is complete.
1020 bfa_fcs_lport_online(struct bfa_fcs_lport_s
*port
)
1022 bfa_sm_send_event(port
, BFA_FCS_PORT_SM_ONLINE
);
1026 * Called by fabric for base port when fabric goes offline.
1027 * Called by vport for virtual ports when virtual port becomes offline.
1030 bfa_fcs_lport_offline(struct bfa_fcs_lport_s
*port
)
1032 bfa_sm_send_event(port
, BFA_FCS_PORT_SM_OFFLINE
);
1036 * Called by fabric for base port and by vport for virtual ports
1037 * when target mode driver is unloaded.
1040 bfa_fcs_lport_stop(struct bfa_fcs_lport_s
*port
)
1042 bfa_sm_send_event(port
, BFA_FCS_PORT_SM_STOP
);
1046 * Called by fabric to delete base lport and associated resources.
1048 * Called by vport to delete lport and associated resources. Should call
1049 * bfa_fcs_vport_delete_comp() for vports on completion.
1052 bfa_fcs_lport_delete(struct bfa_fcs_lport_s
*port
)
1054 bfa_sm_send_event(port
, BFA_FCS_PORT_SM_DELETE
);
1058 * Return TRUE if port is online, else return FALSE
1061 bfa_fcs_lport_is_online(struct bfa_fcs_lport_s
*port
)
1063 return bfa_sm_cmp_state(port
, bfa_fcs_lport_sm_online
);
1067 * Attach time initialization of logical ports.
1070 bfa_fcs_lport_attach(struct bfa_fcs_lport_s
*lport
, struct bfa_fcs_s
*fcs
,
1071 u16 vf_id
, struct bfa_fcs_vport_s
*vport
)
1074 lport
->fabric
= bfa_fcs_vf_lookup(fcs
, vf_id
);
1075 lport
->vport
= vport
;
1076 lport
->lp_tag
= (vport
) ? vport
->lps
->bfa_tag
:
1077 lport
->fabric
->lps
->bfa_tag
;
1079 INIT_LIST_HEAD(&lport
->rport_q
);
1080 lport
->num_rports
= 0;
1084 * Logical port initialization of base or virtual port.
1085 * Called by fabric for base port or by vport for virtual ports.
1089 bfa_fcs_lport_init(struct bfa_fcs_lport_s
*lport
,
1090 struct bfa_lport_cfg_s
*port_cfg
)
1092 struct bfa_fcs_vport_s
*vport
= lport
->vport
;
1093 struct bfad_s
*bfad
= (struct bfad_s
*)lport
->fcs
->bfad
;
1094 char lpwwn_buf
[BFA_STRING_32
];
1096 lport
->port_cfg
= *port_cfg
;
1098 lport
->bfad_port
= bfa_fcb_lport_new(lport
->fcs
->bfad
, lport
,
1099 lport
->port_cfg
.roles
,
1100 lport
->fabric
->vf_drv
,
1101 vport
? vport
->vport_drv
: NULL
);
1103 wwn2str(lpwwn_buf
, bfa_fcs_lport_get_pwwn(lport
));
1104 BFA_LOG(KERN_INFO
, bfad
, bfa_log_level
,
1105 "New logical port created: WWN = %s Role = %s\n",
1106 lpwwn_buf
, "Initiator");
1107 bfa_fcs_lport_aen_post(lport
, BFA_LPORT_AEN_NEW
);
1109 bfa_sm_set_state(lport
, bfa_fcs_lport_sm_uninit
);
1110 bfa_sm_send_event(lport
, BFA_FCS_PORT_SM_CREATE
);
1114 bfa_fcs_lport_set_symname(struct bfa_fcs_lport_s
*port
,
1117 strcpy(port
->port_cfg
.sym_name
.symname
, symname
);
1119 if (bfa_sm_cmp_state(port
, bfa_fcs_lport_sm_online
))
1120 bfa_fcs_lport_ns_util_send_rspn_id(
1121 BFA_FCS_GET_NS_FROM_PORT(port
), NULL
);
1129 bfa_fcs_lport_get_attr(
1130 struct bfa_fcs_lport_s
*port
,
1131 struct bfa_lport_attr_s
*port_attr
)
1133 if (bfa_sm_cmp_state(port
, bfa_fcs_lport_sm_online
))
1134 port_attr
->pid
= port
->pid
;
1138 port_attr
->port_cfg
= port
->port_cfg
;
1141 port_attr
->port_type
= port
->fabric
->oper_type
;
1142 port_attr
->loopback
= bfa_sm_cmp_state(port
->fabric
,
1143 bfa_fcs_fabric_sm_loopback
);
1144 port_attr
->authfail
=
1145 bfa_sm_cmp_state(port
->fabric
,
1146 bfa_fcs_fabric_sm_auth_failed
);
1147 port_attr
->fabric_name
= bfa_fcs_lport_get_fabric_name(port
);
1148 memcpy(port_attr
->fabric_ip_addr
,
1149 bfa_fcs_lport_get_fabric_ipaddr(port
),
1150 BFA_FCS_FABRIC_IPADDR_SZ
);
1152 if (port
->vport
!= NULL
) {
1153 port_attr
->port_type
= BFA_PORT_TYPE_VPORT
;
1154 port_attr
->fpma_mac
=
1155 port
->vport
->lps
->lp_mac
;
1157 port_attr
->fpma_mac
=
1158 port
->fabric
->lps
->lp_mac
;
1161 port_attr
->port_type
= BFA_PORT_TYPE_UNKNOWN
;
1162 port_attr
->state
= BFA_LPORT_UNINIT
;
1167 * bfa_fcs_lport_fab port fab functions
1171 * Called by port to initialize fabric services of the base port.
1174 bfa_fcs_lport_fab_init(struct bfa_fcs_lport_s
*port
)
1176 bfa_fcs_lport_ns_init(port
);
1177 bfa_fcs_lport_scn_init(port
);
1178 bfa_fcs_lport_ms_init(port
);
1182 * Called by port to notify transition to online state.
1185 bfa_fcs_lport_fab_online(struct bfa_fcs_lport_s
*port
)
1187 bfa_fcs_lport_ns_online(port
);
1188 bfa_fcs_lport_fab_scn_online(port
);
1192 * Called by port to notify transition to offline state.
1195 bfa_fcs_lport_fab_offline(struct bfa_fcs_lport_s
*port
)
1197 bfa_fcs_lport_ns_offline(port
);
1198 bfa_fcs_lport_scn_offline(port
);
1199 bfa_fcs_lport_ms_offline(port
);
1203 * bfa_fcs_lport_n2n functions
1207 * Called by fcs/port to initialize N2N topology.
1210 bfa_fcs_lport_n2n_init(struct bfa_fcs_lport_s
*port
)
1215 * Called by fcs/port to notify transition to online state.
1218 bfa_fcs_lport_n2n_online(struct bfa_fcs_lport_s
*port
)
1220 struct bfa_fcs_lport_n2n_s
*n2n_port
= &port
->port_topo
.pn2n
;
1221 struct bfa_lport_cfg_s
*pcfg
= &port
->port_cfg
;
1222 struct bfa_fcs_rport_s
*rport
;
1224 bfa_trc(port
->fcs
, pcfg
->pwwn
);
1227 * If our PWWN is > than that of the r-port, we have to initiate PLOGI
1228 * and assign an Address. if not, we need to wait for its PLOGI.
1230 * If our PWWN is < than that of the remote port, it will send a PLOGI
1231 * with the PIDs assigned. The rport state machine take care of this
1235 ((void *)&pcfg
->pwwn
, (void *)&n2n_port
->rem_port_wwn
,
1236 sizeof(wwn_t
)) > 0) {
1237 port
->pid
= N2N_LOCAL_PID
;
1238 bfa_lps_set_n2n_pid(port
->fabric
->lps
, N2N_LOCAL_PID
);
1240 * First, check if we know the device by pwwn.
1242 rport
= bfa_fcs_lport_get_rport_by_pwwn(port
,
1243 n2n_port
->rem_port_wwn
);
1245 bfa_trc(port
->fcs
, rport
->pid
);
1246 bfa_trc(port
->fcs
, rport
->pwwn
);
1247 rport
->pid
= N2N_REMOTE_PID
;
1248 bfa_sm_send_event(rport
, RPSM_EVENT_PLOGI_SEND
);
1253 * In n2n there can be only one rport. Delete the old one
1254 * whose pid should be zero, because it is offline.
1256 if (port
->num_rports
> 0) {
1257 rport
= bfa_fcs_lport_get_rport_by_pid(port
, 0);
1258 WARN_ON(rport
== NULL
);
1260 bfa_trc(port
->fcs
, rport
->pwwn
);
1261 bfa_sm_send_event(rport
, RPSM_EVENT_DELETE
);
1264 bfa_fcs_rport_create(port
, N2N_REMOTE_PID
);
1269 * Called by fcs/port to notify transition to offline state.
1272 bfa_fcs_lport_n2n_offline(struct bfa_fcs_lport_s
*port
)
1274 struct bfa_fcs_lport_n2n_s
*n2n_port
= &port
->port_topo
.pn2n
;
1276 bfa_trc(port
->fcs
, port
->pid
);
1278 n2n_port
->rem_port_wwn
= 0;
1279 n2n_port
->reply_oxid
= 0;
1283 bfa_fcport_get_loop_attr(struct bfa_fcs_lport_s
*port
)
1285 int i
= 0, j
= 0, bit
= 0, alpa_bit
= 0;
1287 struct bfa_fcport_s
*fcport
= BFA_FCPORT_MOD(port
->fcs
->bfa
);
1289 port
->port_topo
.ploop
.alpabm_valid
= fcport
->alpabm_valid
;
1290 port
->pid
= fcport
->myalpa
;
1291 port
->pid
= bfa_hton3b(port
->pid
);
1293 for (i
= 0; i
< (FC_ALPA_MAX
/ 8); i
++) {
1294 for (j
= 0, alpa_bit
= 0; j
< 8; j
++, alpa_bit
++) {
1295 bfa_trc(port
->fcs
->bfa
, fcport
->alpabm
.alpa_bm
[i
]);
1296 bit
= (fcport
->alpabm
.alpa_bm
[i
] & (1 << (7 - j
)));
1298 port
->port_topo
.ploop
.alpa_pos_map
[k
] =
1299 loop_alpa_map
[(i
* 8) + alpa_bit
];
1301 bfa_trc(port
->fcs
->bfa
, k
);
1302 bfa_trc(port
->fcs
->bfa
,
1303 port
->port_topo
.ploop
.alpa_pos_map
[k
]);
1307 port
->port_topo
.ploop
.num_alpa
= k
;
1311 * Called by fcs/port to initialize Loop topology.
1314 bfa_fcs_lport_loop_init(struct bfa_fcs_lport_s
*port
)
1319 * Called by fcs/port to notify transition to online state.
1322 bfa_fcs_lport_loop_online(struct bfa_fcs_lport_s
*port
)
1324 u8 num_alpa
= 0, alpabm_valid
= 0;
1325 struct bfa_fcs_rport_s
*rport
;
1326 u8
*alpa_map
= NULL
;
1330 bfa_fcport_get_loop_attr(port
);
1332 num_alpa
= port
->port_topo
.ploop
.num_alpa
;
1333 alpabm_valid
= port
->port_topo
.ploop
.alpabm_valid
;
1334 alpa_map
= port
->port_topo
.ploop
.alpa_pos_map
;
1336 bfa_trc(port
->fcs
->bfa
, port
->pid
);
1337 bfa_trc(port
->fcs
->bfa
, num_alpa
);
1338 if (alpabm_valid
== 1) {
1339 for (i
= 0; i
< num_alpa
; i
++) {
1340 bfa_trc(port
->fcs
->bfa
, alpa_map
[i
]);
1341 if (alpa_map
[i
] != bfa_hton3b(port
->pid
)) {
1343 bfa_trc(port
->fcs
->bfa
, pid
);
1344 rport
= bfa_fcs_lport_get_rport_by_pid(port
,
1347 rport
= bfa_fcs_rport_create(port
,
1352 for (i
= 0; i
< MAX_ALPA_COUNT
; i
++) {
1353 if (alpa_map
[i
] != port
->pid
) {
1354 pid
= loop_alpa_map
[i
];
1355 bfa_trc(port
->fcs
->bfa
, pid
);
1356 rport
= bfa_fcs_lport_get_rport_by_pid(port
,
1359 rport
= bfa_fcs_rport_create(port
,
1367 * Called by fcs/port to notify transition to offline state.
1370 bfa_fcs_lport_loop_offline(struct bfa_fcs_lport_s
*port
)
1374 #define BFA_FCS_FDMI_CMD_MAX_RETRIES 2
1377 * forward declarations
1379 static void bfa_fcs_lport_fdmi_send_rhba(void *fdmi_cbarg
,
1380 struct bfa_fcxp_s
*fcxp_alloced
);
1381 static void bfa_fcs_lport_fdmi_send_rprt(void *fdmi_cbarg
,
1382 struct bfa_fcxp_s
*fcxp_alloced
);
1383 static void bfa_fcs_lport_fdmi_send_rpa(void *fdmi_cbarg
,
1384 struct bfa_fcxp_s
*fcxp_alloced
);
1385 static void bfa_fcs_lport_fdmi_rhba_response(void *fcsarg
,
1386 struct bfa_fcxp_s
*fcxp
,
1388 bfa_status_t req_status
,
1391 struct fchs_s
*rsp_fchs
);
1392 static void bfa_fcs_lport_fdmi_rprt_response(void *fcsarg
,
1393 struct bfa_fcxp_s
*fcxp
,
1395 bfa_status_t req_status
,
1398 struct fchs_s
*rsp_fchs
);
1399 static void bfa_fcs_lport_fdmi_rpa_response(void *fcsarg
,
1400 struct bfa_fcxp_s
*fcxp
,
1402 bfa_status_t req_status
,
1405 struct fchs_s
*rsp_fchs
);
1406 static void bfa_fcs_lport_fdmi_timeout(void *arg
);
1407 static u16
bfa_fcs_lport_fdmi_build_rhba_pyld(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1409 static u16
bfa_fcs_lport_fdmi_build_rprt_pyld(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1411 static u16
bfa_fcs_lport_fdmi_build_rpa_pyld(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1413 static u16
bfa_fcs_lport_fdmi_build_portattr_block(struct bfa_fcs_lport_fdmi_s
*
1415 static void bfa_fcs_fdmi_get_hbaattr(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1416 struct bfa_fcs_fdmi_hba_attr_s
*hba_attr
);
1417 static void bfa_fcs_fdmi_get_portattr(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1418 struct bfa_fcs_fdmi_port_attr_s
*port_attr
);
1419 u32
bfa_fcs_fdmi_convert_speed(enum bfa_port_speed pport_speed
);
1422 * fcs_fdmi_sm FCS FDMI state machine
1426 * FDMI State Machine events
1428 enum port_fdmi_event
{
1429 FDMISM_EVENT_PORT_ONLINE
= 1,
1430 FDMISM_EVENT_PORT_OFFLINE
= 2,
1431 FDMISM_EVENT_RSP_OK
= 4,
1432 FDMISM_EVENT_RSP_ERROR
= 5,
1433 FDMISM_EVENT_TIMEOUT
= 6,
1434 FDMISM_EVENT_RHBA_SENT
= 7,
1435 FDMISM_EVENT_RPRT_SENT
= 8,
1436 FDMISM_EVENT_RPA_SENT
= 9,
1439 static void bfa_fcs_lport_fdmi_sm_offline(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1440 enum port_fdmi_event event
);
1441 static void bfa_fcs_lport_fdmi_sm_sending_rhba(
1442 struct bfa_fcs_lport_fdmi_s
*fdmi
,
1443 enum port_fdmi_event event
);
1444 static void bfa_fcs_lport_fdmi_sm_rhba(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1445 enum port_fdmi_event event
);
1446 static void bfa_fcs_lport_fdmi_sm_rhba_retry(
1447 struct bfa_fcs_lport_fdmi_s
*fdmi
,
1448 enum port_fdmi_event event
);
1449 static void bfa_fcs_lport_fdmi_sm_sending_rprt(
1450 struct bfa_fcs_lport_fdmi_s
*fdmi
,
1451 enum port_fdmi_event event
);
1452 static void bfa_fcs_lport_fdmi_sm_rprt(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1453 enum port_fdmi_event event
);
1454 static void bfa_fcs_lport_fdmi_sm_rprt_retry(
1455 struct bfa_fcs_lport_fdmi_s
*fdmi
,
1456 enum port_fdmi_event event
);
1457 static void bfa_fcs_lport_fdmi_sm_sending_rpa(
1458 struct bfa_fcs_lport_fdmi_s
*fdmi
,
1459 enum port_fdmi_event event
);
1460 static void bfa_fcs_lport_fdmi_sm_rpa(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1461 enum port_fdmi_event event
);
1462 static void bfa_fcs_lport_fdmi_sm_rpa_retry(
1463 struct bfa_fcs_lport_fdmi_s
*fdmi
,
1464 enum port_fdmi_event event
);
1465 static void bfa_fcs_lport_fdmi_sm_online(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1466 enum port_fdmi_event event
);
1467 static void bfa_fcs_lport_fdmi_sm_disabled(
1468 struct bfa_fcs_lport_fdmi_s
*fdmi
,
1469 enum port_fdmi_event event
);
1471 * Start in offline state - awaiting MS to send start.
1474 bfa_fcs_lport_fdmi_sm_offline(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1475 enum port_fdmi_event event
)
1477 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
1479 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
1480 bfa_trc(port
->fcs
, event
);
1482 fdmi
->retry_cnt
= 0;
1485 case FDMISM_EVENT_PORT_ONLINE
:
1488 * For Vports, register a new port.
1490 bfa_sm_set_state(fdmi
,
1491 bfa_fcs_lport_fdmi_sm_sending_rprt
);
1492 bfa_fcs_lport_fdmi_send_rprt(fdmi
, NULL
);
1495 * For a base port, we should first register the HBA
1496 * attribute. The HBA attribute also contains the base
1497 * port registration.
1499 bfa_sm_set_state(fdmi
,
1500 bfa_fcs_lport_fdmi_sm_sending_rhba
);
1501 bfa_fcs_lport_fdmi_send_rhba(fdmi
, NULL
);
1505 case FDMISM_EVENT_PORT_OFFLINE
:
1509 bfa_sm_fault(port
->fcs
, event
);
1514 bfa_fcs_lport_fdmi_sm_sending_rhba(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1515 enum port_fdmi_event event
)
1517 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
1519 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
1520 bfa_trc(port
->fcs
, event
);
1523 case FDMISM_EVENT_RHBA_SENT
:
1524 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_rhba
);
1527 case FDMISM_EVENT_PORT_OFFLINE
:
1528 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_offline
);
1529 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(port
),
1534 bfa_sm_fault(port
->fcs
, event
);
1539 bfa_fcs_lport_fdmi_sm_rhba(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1540 enum port_fdmi_event event
)
1542 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
1544 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
1545 bfa_trc(port
->fcs
, event
);
1548 case FDMISM_EVENT_RSP_ERROR
:
1550 * if max retries have not been reached, start timer for a
1553 if (fdmi
->retry_cnt
++ < BFA_FCS_FDMI_CMD_MAX_RETRIES
) {
1554 bfa_sm_set_state(fdmi
,
1555 bfa_fcs_lport_fdmi_sm_rhba_retry
);
1556 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(port
),
1558 bfa_fcs_lport_fdmi_timeout
, fdmi
,
1559 BFA_FCS_RETRY_TIMEOUT
);
1562 * set state to offline
1564 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_offline
);
1568 case FDMISM_EVENT_RSP_OK
:
1570 * Initiate Register Port Attributes
1572 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_sending_rpa
);
1573 fdmi
->retry_cnt
= 0;
1574 bfa_fcs_lport_fdmi_send_rpa(fdmi
, NULL
);
1577 case FDMISM_EVENT_PORT_OFFLINE
:
1578 bfa_fcxp_discard(fdmi
->fcxp
);
1579 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_offline
);
1583 bfa_sm_fault(port
->fcs
, event
);
1588 bfa_fcs_lport_fdmi_sm_rhba_retry(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1589 enum port_fdmi_event event
)
1591 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
1593 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
1594 bfa_trc(port
->fcs
, event
);
1597 case FDMISM_EVENT_TIMEOUT
:
1599 * Retry Timer Expired. Re-send
1601 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_sending_rhba
);
1602 bfa_fcs_lport_fdmi_send_rhba(fdmi
, NULL
);
1605 case FDMISM_EVENT_PORT_OFFLINE
:
1606 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_offline
);
1607 bfa_timer_stop(&fdmi
->timer
);
1611 bfa_sm_fault(port
->fcs
, event
);
1616 * RPRT : Register Port
1619 bfa_fcs_lport_fdmi_sm_sending_rprt(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1620 enum port_fdmi_event event
)
1622 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
1624 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
1625 bfa_trc(port
->fcs
, event
);
1628 case FDMISM_EVENT_RPRT_SENT
:
1629 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_rprt
);
1632 case FDMISM_EVENT_PORT_OFFLINE
:
1633 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_offline
);
1634 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(port
),
1639 bfa_sm_fault(port
->fcs
, event
);
1644 bfa_fcs_lport_fdmi_sm_rprt(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1645 enum port_fdmi_event event
)
1647 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
1649 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
1650 bfa_trc(port
->fcs
, event
);
1653 case FDMISM_EVENT_RSP_ERROR
:
1655 * if max retries have not been reached, start timer for a
1658 if (fdmi
->retry_cnt
++ < BFA_FCS_FDMI_CMD_MAX_RETRIES
) {
1659 bfa_sm_set_state(fdmi
,
1660 bfa_fcs_lport_fdmi_sm_rprt_retry
);
1661 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(port
),
1663 bfa_fcs_lport_fdmi_timeout
, fdmi
,
1664 BFA_FCS_RETRY_TIMEOUT
);
1668 * set state to offline
1670 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_offline
);
1671 fdmi
->retry_cnt
= 0;
1675 case FDMISM_EVENT_RSP_OK
:
1676 fdmi
->retry_cnt
= 0;
1677 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_online
);
1680 case FDMISM_EVENT_PORT_OFFLINE
:
1681 bfa_fcxp_discard(fdmi
->fcxp
);
1682 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_offline
);
1686 bfa_sm_fault(port
->fcs
, event
);
1691 bfa_fcs_lport_fdmi_sm_rprt_retry(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1692 enum port_fdmi_event event
)
1694 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
1696 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
1697 bfa_trc(port
->fcs
, event
);
1700 case FDMISM_EVENT_TIMEOUT
:
1702 * Retry Timer Expired. Re-send
1704 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_sending_rprt
);
1705 bfa_fcs_lport_fdmi_send_rprt(fdmi
, NULL
);
1708 case FDMISM_EVENT_PORT_OFFLINE
:
1709 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_offline
);
1710 bfa_timer_stop(&fdmi
->timer
);
1714 bfa_sm_fault(port
->fcs
, event
);
1719 * Register Port Attributes
1722 bfa_fcs_lport_fdmi_sm_sending_rpa(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1723 enum port_fdmi_event event
)
1725 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
1727 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
1728 bfa_trc(port
->fcs
, event
);
1731 case FDMISM_EVENT_RPA_SENT
:
1732 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_rpa
);
1735 case FDMISM_EVENT_PORT_OFFLINE
:
1736 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_offline
);
1737 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(port
),
1742 bfa_sm_fault(port
->fcs
, event
);
1747 bfa_fcs_lport_fdmi_sm_rpa(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1748 enum port_fdmi_event event
)
1750 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
1752 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
1753 bfa_trc(port
->fcs
, event
);
1756 case FDMISM_EVENT_RSP_ERROR
:
1758 * if max retries have not been reached, start timer for a
1761 if (fdmi
->retry_cnt
++ < BFA_FCS_FDMI_CMD_MAX_RETRIES
) {
1762 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_rpa_retry
);
1763 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(port
),
1765 bfa_fcs_lport_fdmi_timeout
, fdmi
,
1766 BFA_FCS_RETRY_TIMEOUT
);
1769 * set state to offline
1771 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_offline
);
1772 fdmi
->retry_cnt
= 0;
1776 case FDMISM_EVENT_RSP_OK
:
1777 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_online
);
1778 fdmi
->retry_cnt
= 0;
1781 case FDMISM_EVENT_PORT_OFFLINE
:
1782 bfa_fcxp_discard(fdmi
->fcxp
);
1783 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_offline
);
1787 bfa_sm_fault(port
->fcs
, event
);
1792 bfa_fcs_lport_fdmi_sm_rpa_retry(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1793 enum port_fdmi_event event
)
1795 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
1797 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
1798 bfa_trc(port
->fcs
, event
);
1801 case FDMISM_EVENT_TIMEOUT
:
1803 * Retry Timer Expired. Re-send
1805 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_sending_rpa
);
1806 bfa_fcs_lport_fdmi_send_rpa(fdmi
, NULL
);
1809 case FDMISM_EVENT_PORT_OFFLINE
:
1810 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_offline
);
1811 bfa_timer_stop(&fdmi
->timer
);
1815 bfa_sm_fault(port
->fcs
, event
);
1820 bfa_fcs_lport_fdmi_sm_online(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1821 enum port_fdmi_event event
)
1823 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
1825 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
1826 bfa_trc(port
->fcs
, event
);
1829 case FDMISM_EVENT_PORT_OFFLINE
:
1830 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_offline
);
1834 bfa_sm_fault(port
->fcs
, event
);
1838 * FDMI is disabled state.
1841 bfa_fcs_lport_fdmi_sm_disabled(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1842 enum port_fdmi_event event
)
1844 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
1846 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
1847 bfa_trc(port
->fcs
, event
);
1849 /* No op State. It can only be enabled at Driver Init. */
1853 * RHBA : Register HBA Attributes.
1856 bfa_fcs_lport_fdmi_send_rhba(void *fdmi_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
1858 struct bfa_fcs_lport_fdmi_s
*fdmi
= fdmi_cbarg
;
1859 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
1862 struct bfa_fcxp_s
*fcxp
;
1865 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
1867 fcxp
= fcxp_alloced
? fcxp_alloced
:
1868 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
1870 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &fdmi
->fcxp_wqe
,
1871 bfa_fcs_lport_fdmi_send_rhba
, fdmi
, BFA_TRUE
);
1876 pyld
= bfa_fcxp_get_reqbuf(fcxp
);
1877 memset(pyld
, 0, FC_MAX_PDUSZ
);
1879 len
= fc_fdmi_reqhdr_build(&fchs
, pyld
, bfa_fcs_lport_get_fcid(port
),
1883 bfa_fcs_lport_fdmi_build_rhba_pyld(fdmi
,
1884 (u8
*) ((struct ct_hdr_s
*) pyld
1887 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
1888 FC_CLASS_3
, (len
+ attr_len
), &fchs
,
1889 bfa_fcs_lport_fdmi_rhba_response
, (void *)fdmi
,
1890 FC_MAX_PDUSZ
, FC_FCCT_TOV
);
1892 bfa_sm_send_event(fdmi
, FDMISM_EVENT_RHBA_SENT
);
1896 bfa_fcs_lport_fdmi_build_rhba_pyld(struct bfa_fcs_lport_fdmi_s
*fdmi
, u8
*pyld
)
1898 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
1899 struct bfa_fcs_fdmi_hba_attr_s hba_attr
;
1900 struct bfa_fcs_fdmi_hba_attr_s
*fcs_hba_attr
= &hba_attr
;
1901 struct fdmi_rhba_s
*rhba
= (struct fdmi_rhba_s
*) pyld
;
1902 struct fdmi_attr_s
*attr
;
1908 * get hba attributes
1910 bfa_fcs_fdmi_get_hbaattr(fdmi
, fcs_hba_attr
);
1912 rhba
->hba_id
= bfa_fcs_lport_get_pwwn(port
);
1913 rhba
->port_list
.num_ports
= cpu_to_be32(1);
1914 rhba
->port_list
.port_entry
= bfa_fcs_lport_get_pwwn(port
);
1916 len
= sizeof(rhba
->hba_id
) + sizeof(rhba
->port_list
);
1919 len
+= sizeof(rhba
->hba_attr_blk
.attr_count
);
1922 * fill out the invididual entries of the HBA attrib Block
1924 curr_ptr
= (u8
*) &rhba
->hba_attr_blk
.hba_attr
;
1929 attr
= (struct fdmi_attr_s
*) curr_ptr
;
1930 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_NODENAME
);
1931 templen
= sizeof(wwn_t
);
1932 memcpy(attr
->value
, &bfa_fcs_lport_get_nwwn(port
), templen
);
1933 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
1936 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
1942 attr
= (struct fdmi_attr_s
*) curr_ptr
;
1943 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_MANUFACTURER
);
1944 templen
= (u16
) strlen(fcs_hba_attr
->manufacturer
);
1945 memcpy(attr
->value
, fcs_hba_attr
->manufacturer
, templen
);
1946 templen
= fc_roundup(templen
, sizeof(u32
));
1947 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
1950 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
1956 attr
= (struct fdmi_attr_s
*) curr_ptr
;
1957 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_SERIALNUM
);
1958 templen
= (u16
) strlen(fcs_hba_attr
->serial_num
);
1959 memcpy(attr
->value
, fcs_hba_attr
->serial_num
, templen
);
1960 templen
= fc_roundup(templen
, sizeof(u32
));
1961 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
1964 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
1970 attr
= (struct fdmi_attr_s
*) curr_ptr
;
1971 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_MODEL
);
1972 templen
= (u16
) strlen(fcs_hba_attr
->model
);
1973 memcpy(attr
->value
, fcs_hba_attr
->model
, templen
);
1974 templen
= fc_roundup(templen
, sizeof(u32
));
1975 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
1978 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
1984 attr
= (struct fdmi_attr_s
*) curr_ptr
;
1985 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_MODEL_DESC
);
1986 templen
= (u16
) strlen(fcs_hba_attr
->model_desc
);
1987 memcpy(attr
->value
, fcs_hba_attr
->model_desc
, templen
);
1988 templen
= fc_roundup(templen
, sizeof(u32
));
1989 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
1992 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
1998 if (fcs_hba_attr
->hw_version
[0] != '\0') {
1999 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2000 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_HW_VERSION
);
2001 templen
= (u16
) strlen(fcs_hba_attr
->hw_version
);
2002 memcpy(attr
->value
, fcs_hba_attr
->hw_version
, templen
);
2003 templen
= fc_roundup(templen
, sizeof(u32
));
2004 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2007 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2014 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2015 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_DRIVER_VERSION
);
2016 templen
= (u16
) strlen(fcs_hba_attr
->driver_version
);
2017 memcpy(attr
->value
, fcs_hba_attr
->driver_version
, templen
);
2018 templen
= fc_roundup(templen
, sizeof(u32
));
2019 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2022 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2026 * Option Rom Version
2028 if (fcs_hba_attr
->option_rom_ver
[0] != '\0') {
2029 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2030 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_ROM_VERSION
);
2031 templen
= (u16
) strlen(fcs_hba_attr
->option_rom_ver
);
2032 memcpy(attr
->value
, fcs_hba_attr
->option_rom_ver
, templen
);
2033 templen
= fc_roundup(templen
, sizeof(u32
));
2034 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2037 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2041 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2042 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_FW_VERSION
);
2043 templen
= (u16
) strlen(fcs_hba_attr
->fw_version
);
2044 memcpy(attr
->value
, fcs_hba_attr
->fw_version
, templen
);
2045 templen
= fc_roundup(templen
, sizeof(u32
));
2046 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2049 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2055 if (fcs_hba_attr
->os_name
[0] != '\0') {
2056 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2057 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_OS_NAME
);
2058 templen
= (u16
) strlen(fcs_hba_attr
->os_name
);
2059 memcpy(attr
->value
, fcs_hba_attr
->os_name
, templen
);
2060 templen
= fc_roundup(templen
, sizeof(u32
));
2061 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2064 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2071 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2072 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_MAX_CT
);
2073 templen
= sizeof(fcs_hba_attr
->max_ct_pyld
);
2074 memcpy(attr
->value
, &fcs_hba_attr
->max_ct_pyld
, templen
);
2075 templen
= fc_roundup(templen
, sizeof(u32
));
2076 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2079 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2082 * Send extended attributes ( FOS 7.1 support )
2084 if (fdmi
->retry_cnt
== 0) {
2085 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2086 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_NODE_SYM_NAME
);
2087 templen
= sizeof(fcs_hba_attr
->node_sym_name
);
2088 memcpy(attr
->value
, &fcs_hba_attr
->node_sym_name
, templen
);
2089 templen
= fc_roundup(templen
, sizeof(u32
));
2090 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2093 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2096 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2097 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_VENDOR_ID
);
2098 templen
= sizeof(fcs_hba_attr
->vendor_info
);
2099 memcpy(attr
->value
, &fcs_hba_attr
->vendor_info
, templen
);
2100 templen
= fc_roundup(templen
, sizeof(u32
));
2101 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2104 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2107 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2108 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_NUM_PORTS
);
2109 templen
= sizeof(fcs_hba_attr
->num_ports
);
2110 memcpy(attr
->value
, &fcs_hba_attr
->num_ports
, templen
);
2111 templen
= fc_roundup(templen
, sizeof(u32
));
2112 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2115 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2118 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2119 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_FABRIC_NAME
);
2120 templen
= sizeof(fcs_hba_attr
->fabric_name
);
2121 memcpy(attr
->value
, &fcs_hba_attr
->fabric_name
, templen
);
2122 templen
= fc_roundup(templen
, sizeof(u32
));
2123 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2126 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2129 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2130 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_BIOS_VER
);
2131 templen
= sizeof(fcs_hba_attr
->bios_ver
);
2132 memcpy(attr
->value
, &fcs_hba_attr
->bios_ver
, templen
);
2133 templen
= fc_roundup(attr
->len
, sizeof(u32
));
2134 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2137 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2142 * Update size of payload
2144 len
+= ((sizeof(attr
->type
) + sizeof(attr
->len
)) * count
);
2146 rhba
->hba_attr_blk
.attr_count
= cpu_to_be32(count
);
2151 bfa_fcs_lport_fdmi_rhba_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
,
2152 void *cbarg
, bfa_status_t req_status
,
2153 u32 rsp_len
, u32 resid_len
,
2154 struct fchs_s
*rsp_fchs
)
2156 struct bfa_fcs_lport_fdmi_s
*fdmi
=
2157 (struct bfa_fcs_lport_fdmi_s
*) cbarg
;
2158 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
2159 struct ct_hdr_s
*cthdr
= NULL
;
2161 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
2166 if (req_status
!= BFA_STATUS_OK
) {
2167 bfa_trc(port
->fcs
, req_status
);
2168 bfa_sm_send_event(fdmi
, FDMISM_EVENT_RSP_ERROR
);
2172 cthdr
= (struct ct_hdr_s
*) BFA_FCXP_RSP_PLD(fcxp
);
2173 cthdr
->cmd_rsp_code
= be16_to_cpu(cthdr
->cmd_rsp_code
);
2175 if (cthdr
->cmd_rsp_code
== CT_RSP_ACCEPT
) {
2176 bfa_sm_send_event(fdmi
, FDMISM_EVENT_RSP_OK
);
2180 bfa_trc(port
->fcs
, cthdr
->reason_code
);
2181 bfa_trc(port
->fcs
, cthdr
->exp_code
);
2182 bfa_sm_send_event(fdmi
, FDMISM_EVENT_RSP_ERROR
);
2186 * RPRT : Register Port
2189 bfa_fcs_lport_fdmi_send_rprt(void *fdmi_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
2191 struct bfa_fcs_lport_fdmi_s
*fdmi
= fdmi_cbarg
;
2192 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
2195 struct bfa_fcxp_s
*fcxp
;
2198 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
2200 fcxp
= fcxp_alloced
? fcxp_alloced
:
2201 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
2203 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &fdmi
->fcxp_wqe
,
2204 bfa_fcs_lport_fdmi_send_rprt
, fdmi
, BFA_TRUE
);
2209 pyld
= bfa_fcxp_get_reqbuf(fcxp
);
2210 memset(pyld
, 0, FC_MAX_PDUSZ
);
2212 len
= fc_fdmi_reqhdr_build(&fchs
, pyld
, bfa_fcs_lport_get_fcid(port
),
2216 bfa_fcs_lport_fdmi_build_rprt_pyld(fdmi
,
2217 (u8
*) ((struct ct_hdr_s
*) pyld
2220 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
2221 FC_CLASS_3
, len
+ attr_len
, &fchs
,
2222 bfa_fcs_lport_fdmi_rprt_response
, (void *)fdmi
,
2223 FC_MAX_PDUSZ
, FC_FCCT_TOV
);
2225 bfa_sm_send_event(fdmi
, FDMISM_EVENT_RPRT_SENT
);
2229 * This routine builds Port Attribute Block that used in RPA, RPRT commands.
2232 bfa_fcs_lport_fdmi_build_portattr_block(struct bfa_fcs_lport_fdmi_s
*fdmi
,
2235 struct bfa_fcs_fdmi_port_attr_s fcs_port_attr
;
2236 struct fdmi_port_attr_s
*port_attrib
= (struct fdmi_port_attr_s
*) pyld
;
2237 struct fdmi_attr_s
*attr
;
2244 * get port attributes
2246 bfa_fcs_fdmi_get_portattr(fdmi
, &fcs_port_attr
);
2248 len
= sizeof(port_attrib
->attr_count
);
2251 * fill out the invididual entries
2253 curr_ptr
= (u8
*) &port_attrib
->port_attr
;
2258 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2259 attr
->type
= cpu_to_be16(FDMI_PORT_ATTRIB_FC4_TYPES
);
2260 templen
= sizeof(fcs_port_attr
.supp_fc4_types
);
2261 memcpy(attr
->value
, fcs_port_attr
.supp_fc4_types
, templen
);
2262 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2266 cpu_to_be16(templen
+ sizeof(attr
->type
) +
2272 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2273 attr
->type
= cpu_to_be16(FDMI_PORT_ATTRIB_SUPP_SPEED
);
2274 templen
= sizeof(fcs_port_attr
.supp_speed
);
2275 memcpy(attr
->value
, &fcs_port_attr
.supp_speed
, templen
);
2276 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2280 cpu_to_be16(templen
+ sizeof(attr
->type
) +
2284 * current Port Speed
2286 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2287 attr
->type
= cpu_to_be16(FDMI_PORT_ATTRIB_PORT_SPEED
);
2288 templen
= sizeof(fcs_port_attr
.curr_speed
);
2289 memcpy(attr
->value
, &fcs_port_attr
.curr_speed
, templen
);
2290 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2293 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2299 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2300 attr
->type
= cpu_to_be16(FDMI_PORT_ATTRIB_FRAME_SIZE
);
2301 templen
= sizeof(fcs_port_attr
.max_frm_size
);
2302 memcpy(attr
->value
, &fcs_port_attr
.max_frm_size
, templen
);
2303 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2306 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2312 if (fcs_port_attr
.os_device_name
[0] != '\0') {
2313 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2314 attr
->type
= cpu_to_be16(FDMI_PORT_ATTRIB_DEV_NAME
);
2315 templen
= (u16
) strlen(fcs_port_attr
.os_device_name
);
2316 memcpy(attr
->value
, fcs_port_attr
.os_device_name
, templen
);
2317 templen
= fc_roundup(templen
, sizeof(u32
));
2318 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2321 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2327 if (fcs_port_attr
.host_name
[0] != '\0') {
2328 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2329 attr
->type
= cpu_to_be16(FDMI_PORT_ATTRIB_HOST_NAME
);
2330 templen
= (u16
) strlen(fcs_port_attr
.host_name
);
2331 memcpy(attr
->value
, fcs_port_attr
.host_name
, templen
);
2332 templen
= fc_roundup(templen
, sizeof(u32
));
2333 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2336 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2340 if (fdmi
->retry_cnt
== 0) {
2341 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2342 attr
->type
= cpu_to_be16(FDMI_PORT_ATTRIB_NODE_NAME
);
2343 templen
= sizeof(fcs_port_attr
.node_name
);
2344 memcpy(attr
->value
, &fcs_port_attr
.node_name
, templen
);
2345 templen
= fc_roundup(templen
, sizeof(u32
));
2346 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2349 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2352 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2353 attr
->type
= cpu_to_be16(FDMI_PORT_ATTRIB_PORT_NAME
);
2354 templen
= sizeof(fcs_port_attr
.port_name
);
2355 memcpy(attr
->value
, &fcs_port_attr
.port_name
, templen
);
2356 templen
= fc_roundup(templen
, sizeof(u32
));
2357 curr_ptr
+= sizeof(attr
->type
) + sizeof(attr
->len
) + templen
;
2360 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2363 if (fcs_port_attr
.port_sym_name
.symname
[0] != '\0') {
2364 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2366 cpu_to_be16(FDMI_PORT_ATTRIB_PORT_SYM_NAME
);
2367 templen
= sizeof(fcs_port_attr
.port_sym_name
);
2369 &fcs_port_attr
.port_sym_name
, templen
);
2370 templen
= fc_roundup(templen
, sizeof(u32
));
2371 curr_ptr
+= sizeof(attr
->type
) +
2372 sizeof(templen
) + templen
;
2375 attr
->len
= cpu_to_be16(templen
+
2376 sizeof(attr
->type
) + sizeof(templen
));
2379 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2380 attr
->type
= cpu_to_be16(FDMI_PORT_ATTRIB_PORT_TYPE
);
2381 templen
= sizeof(fcs_port_attr
.port_type
);
2382 memcpy(attr
->value
, &fcs_port_attr
.port_type
, templen
);
2383 templen
= fc_roundup(templen
, sizeof(u32
));
2384 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2387 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2390 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2391 attr
->type
= cpu_to_be16(FDMI_PORT_ATTRIB_SUPP_COS
);
2392 templen
= sizeof(fcs_port_attr
.scos
);
2393 memcpy(attr
->value
, &fcs_port_attr
.scos
, templen
);
2394 templen
= fc_roundup(templen
, sizeof(u32
));
2395 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2398 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2401 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2402 attr
->type
= cpu_to_be16(FDMI_PORT_ATTRIB_PORT_FAB_NAME
);
2403 templen
= sizeof(fcs_port_attr
.port_fabric_name
);
2404 memcpy(attr
->value
, &fcs_port_attr
.port_fabric_name
, templen
);
2405 templen
= fc_roundup(templen
, sizeof(u32
));
2406 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2409 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2412 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2413 attr
->type
= cpu_to_be16(FDMI_PORT_ATTRIB_PORT_FC4_TYPE
);
2414 templen
= sizeof(fcs_port_attr
.port_act_fc4_type
);
2415 memcpy(attr
->value
, fcs_port_attr
.port_act_fc4_type
,
2417 templen
= fc_roundup(templen
, sizeof(u32
));
2418 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2421 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2424 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2425 attr
->type
= cpu_to_be16(FDMI_PORT_ATTRIB_PORT_STATE
);
2426 templen
= sizeof(fcs_port_attr
.port_state
);
2427 memcpy(attr
->value
, &fcs_port_attr
.port_state
, templen
);
2428 templen
= fc_roundup(templen
, sizeof(u32
));
2429 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2432 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2435 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2436 attr
->type
= cpu_to_be16(FDMI_PORT_ATTRIB_PORT_NUM_RPRT
);
2437 templen
= sizeof(fcs_port_attr
.num_ports
);
2438 memcpy(attr
->value
, &fcs_port_attr
.num_ports
, templen
);
2439 templen
= fc_roundup(templen
, sizeof(u32
));
2440 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2443 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2448 * Update size of payload
2450 port_attrib
->attr_count
= cpu_to_be32(count
);
2451 len
+= ((sizeof(attr
->type
) + sizeof(attr
->len
)) * count
);
2456 bfa_fcs_lport_fdmi_build_rprt_pyld(struct bfa_fcs_lport_fdmi_s
*fdmi
, u8
*pyld
)
2458 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
2459 struct fdmi_rprt_s
*rprt
= (struct fdmi_rprt_s
*) pyld
;
2462 rprt
->hba_id
= bfa_fcs_lport_get_pwwn(bfa_fcs_get_base_port(port
->fcs
));
2463 rprt
->port_name
= bfa_fcs_lport_get_pwwn(port
);
2465 len
= bfa_fcs_lport_fdmi_build_portattr_block(fdmi
,
2466 (u8
*) &rprt
->port_attr_blk
);
2468 len
+= sizeof(rprt
->hba_id
) + sizeof(rprt
->port_name
);
2474 bfa_fcs_lport_fdmi_rprt_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
,
2475 void *cbarg
, bfa_status_t req_status
,
2476 u32 rsp_len
, u32 resid_len
,
2477 struct fchs_s
*rsp_fchs
)
2479 struct bfa_fcs_lport_fdmi_s
*fdmi
=
2480 (struct bfa_fcs_lport_fdmi_s
*) cbarg
;
2481 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
2482 struct ct_hdr_s
*cthdr
= NULL
;
2484 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
2489 if (req_status
!= BFA_STATUS_OK
) {
2490 bfa_trc(port
->fcs
, req_status
);
2491 bfa_sm_send_event(fdmi
, FDMISM_EVENT_RSP_ERROR
);
2495 cthdr
= (struct ct_hdr_s
*) BFA_FCXP_RSP_PLD(fcxp
);
2496 cthdr
->cmd_rsp_code
= be16_to_cpu(cthdr
->cmd_rsp_code
);
2498 if (cthdr
->cmd_rsp_code
== CT_RSP_ACCEPT
) {
2499 bfa_sm_send_event(fdmi
, FDMISM_EVENT_RSP_OK
);
2503 bfa_trc(port
->fcs
, cthdr
->reason_code
);
2504 bfa_trc(port
->fcs
, cthdr
->exp_code
);
2505 bfa_sm_send_event(fdmi
, FDMISM_EVENT_RSP_ERROR
);
2509 * RPA : Register Port Attributes.
2512 bfa_fcs_lport_fdmi_send_rpa(void *fdmi_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
2514 struct bfa_fcs_lport_fdmi_s
*fdmi
= fdmi_cbarg
;
2515 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
2518 struct bfa_fcxp_s
*fcxp
;
2521 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
2523 fcxp
= fcxp_alloced
? fcxp_alloced
:
2524 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
2526 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &fdmi
->fcxp_wqe
,
2527 bfa_fcs_lport_fdmi_send_rpa
, fdmi
, BFA_TRUE
);
2532 pyld
= bfa_fcxp_get_reqbuf(fcxp
);
2533 memset(pyld
, 0, FC_MAX_PDUSZ
);
2535 len
= fc_fdmi_reqhdr_build(&fchs
, pyld
, bfa_fcs_lport_get_fcid(port
),
2538 attr_len
= bfa_fcs_lport_fdmi_build_rpa_pyld(fdmi
,
2539 (u8
*) ((struct ct_hdr_s
*) pyld
+ 1));
2541 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
2542 FC_CLASS_3
, len
+ attr_len
, &fchs
,
2543 bfa_fcs_lport_fdmi_rpa_response
, (void *)fdmi
,
2544 FC_MAX_PDUSZ
, FC_FCCT_TOV
);
2546 bfa_sm_send_event(fdmi
, FDMISM_EVENT_RPA_SENT
);
2550 bfa_fcs_lport_fdmi_build_rpa_pyld(struct bfa_fcs_lport_fdmi_s
*fdmi
, u8
*pyld
)
2552 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
2553 struct fdmi_rpa_s
*rpa
= (struct fdmi_rpa_s
*) pyld
;
2556 rpa
->port_name
= bfa_fcs_lport_get_pwwn(port
);
2558 len
= bfa_fcs_lport_fdmi_build_portattr_block(fdmi
,
2559 (u8
*) &rpa
->port_attr_blk
);
2561 len
+= sizeof(rpa
->port_name
);
2567 bfa_fcs_lport_fdmi_rpa_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
,
2568 void *cbarg
, bfa_status_t req_status
, u32 rsp_len
,
2569 u32 resid_len
, struct fchs_s
*rsp_fchs
)
2571 struct bfa_fcs_lport_fdmi_s
*fdmi
=
2572 (struct bfa_fcs_lport_fdmi_s
*) cbarg
;
2573 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
2574 struct ct_hdr_s
*cthdr
= NULL
;
2576 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
2581 if (req_status
!= BFA_STATUS_OK
) {
2582 bfa_trc(port
->fcs
, req_status
);
2583 bfa_sm_send_event(fdmi
, FDMISM_EVENT_RSP_ERROR
);
2587 cthdr
= (struct ct_hdr_s
*) BFA_FCXP_RSP_PLD(fcxp
);
2588 cthdr
->cmd_rsp_code
= be16_to_cpu(cthdr
->cmd_rsp_code
);
2590 if (cthdr
->cmd_rsp_code
== CT_RSP_ACCEPT
) {
2591 bfa_sm_send_event(fdmi
, FDMISM_EVENT_RSP_OK
);
2595 bfa_trc(port
->fcs
, cthdr
->reason_code
);
2596 bfa_trc(port
->fcs
, cthdr
->exp_code
);
2597 bfa_sm_send_event(fdmi
, FDMISM_EVENT_RSP_ERROR
);
2601 bfa_fcs_lport_fdmi_timeout(void *arg
)
2603 struct bfa_fcs_lport_fdmi_s
*fdmi
= (struct bfa_fcs_lport_fdmi_s
*) arg
;
2605 bfa_sm_send_event(fdmi
, FDMISM_EVENT_TIMEOUT
);
2609 bfa_fcs_fdmi_get_hbaattr(struct bfa_fcs_lport_fdmi_s
*fdmi
,
2610 struct bfa_fcs_fdmi_hba_attr_s
*hba_attr
)
2612 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
2613 struct bfa_fcs_driver_info_s
*driver_info
= &port
->fcs
->driver_info
;
2614 struct bfa_fcs_fdmi_port_attr_s fcs_port_attr
;
2616 memset(hba_attr
, 0, sizeof(struct bfa_fcs_fdmi_hba_attr_s
));
2618 bfa_ioc_get_adapter_manufacturer(&port
->fcs
->bfa
->ioc
,
2619 hba_attr
->manufacturer
);
2620 bfa_ioc_get_adapter_serial_num(&port
->fcs
->bfa
->ioc
,
2621 hba_attr
->serial_num
);
2622 bfa_ioc_get_adapter_model(&port
->fcs
->bfa
->ioc
,
2624 bfa_ioc_get_adapter_model(&port
->fcs
->bfa
->ioc
,
2625 hba_attr
->model_desc
);
2626 bfa_ioc_get_pci_chip_rev(&port
->fcs
->bfa
->ioc
,
2627 hba_attr
->hw_version
);
2628 bfa_ioc_get_adapter_optrom_ver(&port
->fcs
->bfa
->ioc
,
2629 hba_attr
->option_rom_ver
);
2630 bfa_ioc_get_adapter_fw_ver(&port
->fcs
->bfa
->ioc
,
2631 hba_attr
->fw_version
);
2633 strlcpy(hba_attr
->driver_version
, (char *)driver_info
->version
,
2634 sizeof(hba_attr
->driver_version
));
2636 strlcpy(hba_attr
->os_name
, driver_info
->host_os_name
,
2637 sizeof(hba_attr
->os_name
));
2640 * If there is a patch level, append it
2641 * to the os name along with a separator
2643 if (driver_info
->host_os_patch
[0] != '\0') {
2644 strlcat(hba_attr
->os_name
, BFA_FCS_PORT_SYMBNAME_SEPARATOR
,
2645 sizeof(hba_attr
->os_name
));
2646 strlcat(hba_attr
->os_name
, driver_info
->host_os_patch
,
2647 sizeof(hba_attr
->os_name
));
2650 /* Retrieve the max frame size from the port attr */
2651 bfa_fcs_fdmi_get_portattr(fdmi
, &fcs_port_attr
);
2652 hba_attr
->max_ct_pyld
= fcs_port_attr
.max_frm_size
;
2654 strlcpy(hba_attr
->node_sym_name
.symname
,
2655 port
->port_cfg
.node_sym_name
.symname
, BFA_SYMNAME_MAXLEN
);
2656 strcpy(hba_attr
->vendor_info
, "BROCADE");
2657 hba_attr
->num_ports
=
2658 cpu_to_be32(bfa_ioc_get_nports(&port
->fcs
->bfa
->ioc
));
2659 hba_attr
->fabric_name
= port
->fabric
->lps
->pr_nwwn
;
2660 strlcpy(hba_attr
->bios_ver
, hba_attr
->option_rom_ver
, BFA_VERSION_LEN
);
2665 bfa_fcs_fdmi_get_portattr(struct bfa_fcs_lport_fdmi_s
*fdmi
,
2666 struct bfa_fcs_fdmi_port_attr_s
*port_attr
)
2668 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
2669 struct bfa_fcs_driver_info_s
*driver_info
= &port
->fcs
->driver_info
;
2670 struct bfa_port_attr_s pport_attr
;
2671 struct bfa_lport_attr_s lport_attr
;
2673 memset(port_attr
, 0, sizeof(struct bfa_fcs_fdmi_port_attr_s
));
2676 * get pport attributes from hal
2678 bfa_fcport_get_attr(port
->fcs
->bfa
, &pport_attr
);
2681 * get FC4 type Bitmask
2683 fc_get_fc4type_bitmask(FC_TYPE_FCP
, port_attr
->supp_fc4_types
);
2688 switch (pport_attr
.speed_supported
) {
2689 case BFA_PORT_SPEED_16GBPS
:
2690 port_attr
->supp_speed
=
2691 cpu_to_be32(BFA_FCS_FDMI_SUPP_SPEEDS_16G
);
2694 case BFA_PORT_SPEED_10GBPS
:
2695 port_attr
->supp_speed
=
2696 cpu_to_be32(BFA_FCS_FDMI_SUPP_SPEEDS_10G
);
2699 case BFA_PORT_SPEED_8GBPS
:
2700 port_attr
->supp_speed
=
2701 cpu_to_be32(BFA_FCS_FDMI_SUPP_SPEEDS_8G
);
2704 case BFA_PORT_SPEED_4GBPS
:
2705 port_attr
->supp_speed
=
2706 cpu_to_be32(BFA_FCS_FDMI_SUPP_SPEEDS_4G
);
2710 bfa_sm_fault(port
->fcs
, pport_attr
.speed_supported
);
2716 port_attr
->curr_speed
= cpu_to_be32(
2717 bfa_fcs_fdmi_convert_speed(pport_attr
.speed
));
2722 port_attr
->max_frm_size
= cpu_to_be32(pport_attr
.pport_cfg
.maxfrsize
);
2727 strlcpy(port_attr
->os_device_name
, driver_info
->os_device_name
,
2728 sizeof(port_attr
->os_device_name
));
2733 strlcpy(port_attr
->host_name
, driver_info
->host_machine_name
,
2734 sizeof(port_attr
->host_name
));
2736 port_attr
->node_name
= bfa_fcs_lport_get_nwwn(port
);
2737 port_attr
->port_name
= bfa_fcs_lport_get_pwwn(port
);
2739 strlcpy(port_attr
->port_sym_name
.symname
,
2740 bfa_fcs_lport_get_psym_name(port
).symname
, BFA_SYMNAME_MAXLEN
);
2741 bfa_fcs_lport_get_attr(port
, &lport_attr
);
2742 port_attr
->port_type
= cpu_to_be32(lport_attr
.port_type
);
2743 port_attr
->scos
= pport_attr
.cos_supported
;
2744 port_attr
->port_fabric_name
= port
->fabric
->lps
->pr_nwwn
;
2745 fc_get_fc4type_bitmask(FC_TYPE_FCP
, port_attr
->port_act_fc4_type
);
2746 port_attr
->port_state
= cpu_to_be32(pport_attr
.port_state
);
2747 port_attr
->num_ports
= cpu_to_be32(port
->num_rports
);
2751 * Convert BFA speed to FDMI format.
2754 bfa_fcs_fdmi_convert_speed(bfa_port_speed_t pport_speed
)
2758 switch (pport_speed
) {
2759 case BFA_PORT_SPEED_1GBPS
:
2760 case BFA_PORT_SPEED_2GBPS
:
2764 case BFA_PORT_SPEED_4GBPS
:
2765 ret
= FDMI_TRANS_SPEED_4G
;
2768 case BFA_PORT_SPEED_8GBPS
:
2769 ret
= FDMI_TRANS_SPEED_8G
;
2772 case BFA_PORT_SPEED_10GBPS
:
2773 ret
= FDMI_TRANS_SPEED_10G
;
2776 case BFA_PORT_SPEED_16GBPS
:
2777 ret
= FDMI_TRANS_SPEED_16G
;
2781 ret
= FDMI_TRANS_SPEED_UNKNOWN
;
2787 bfa_fcs_lport_fdmi_init(struct bfa_fcs_lport_ms_s
*ms
)
2789 struct bfa_fcs_lport_fdmi_s
*fdmi
= &ms
->fdmi
;
2792 if (ms
->port
->fcs
->fdmi_enabled
)
2793 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_offline
);
2795 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_disabled
);
2799 bfa_fcs_lport_fdmi_offline(struct bfa_fcs_lport_ms_s
*ms
)
2801 struct bfa_fcs_lport_fdmi_s
*fdmi
= &ms
->fdmi
;
2804 bfa_sm_send_event(fdmi
, FDMISM_EVENT_PORT_OFFLINE
);
2808 bfa_fcs_lport_fdmi_online(struct bfa_fcs_lport_ms_s
*ms
)
2810 struct bfa_fcs_lport_fdmi_s
*fdmi
= &ms
->fdmi
;
2813 bfa_sm_send_event(fdmi
, FDMISM_EVENT_PORT_ONLINE
);
2816 #define BFA_FCS_MS_CMD_MAX_RETRIES 2
2819 * forward declarations
2821 static void bfa_fcs_lport_ms_send_plogi(void *ms_cbarg
,
2822 struct bfa_fcxp_s
*fcxp_alloced
);
2823 static void bfa_fcs_lport_ms_timeout(void *arg
);
2824 static void bfa_fcs_lport_ms_plogi_response(void *fcsarg
,
2825 struct bfa_fcxp_s
*fcxp
,
2827 bfa_status_t req_status
,
2830 struct fchs_s
*rsp_fchs
);
2832 static void bfa_fcs_lport_ms_send_gmal(void *ms_cbarg
,
2833 struct bfa_fcxp_s
*fcxp_alloced
);
2834 static void bfa_fcs_lport_ms_gmal_response(void *fcsarg
,
2835 struct bfa_fcxp_s
*fcxp
,
2837 bfa_status_t req_status
,
2840 struct fchs_s
*rsp_fchs
);
2841 static void bfa_fcs_lport_ms_send_gfn(void *ms_cbarg
,
2842 struct bfa_fcxp_s
*fcxp_alloced
);
2843 static void bfa_fcs_lport_ms_gfn_response(void *fcsarg
,
2844 struct bfa_fcxp_s
*fcxp
,
2846 bfa_status_t req_status
,
2849 struct fchs_s
*rsp_fchs
);
2851 * fcs_ms_sm FCS MS state machine
2855 * MS State Machine events
2857 enum port_ms_event
{
2858 MSSM_EVENT_PORT_ONLINE
= 1,
2859 MSSM_EVENT_PORT_OFFLINE
= 2,
2860 MSSM_EVENT_RSP_OK
= 3,
2861 MSSM_EVENT_RSP_ERROR
= 4,
2862 MSSM_EVENT_TIMEOUT
= 5,
2863 MSSM_EVENT_FCXP_SENT
= 6,
2864 MSSM_EVENT_PORT_FABRIC_RSCN
= 7
2867 static void bfa_fcs_lport_ms_sm_offline(struct bfa_fcs_lport_ms_s
*ms
,
2868 enum port_ms_event event
);
2869 static void bfa_fcs_lport_ms_sm_plogi_sending(struct bfa_fcs_lport_ms_s
*ms
,
2870 enum port_ms_event event
);
2871 static void bfa_fcs_lport_ms_sm_plogi(struct bfa_fcs_lport_ms_s
*ms
,
2872 enum port_ms_event event
);
2873 static void bfa_fcs_lport_ms_sm_plogi_retry(struct bfa_fcs_lport_ms_s
*ms
,
2874 enum port_ms_event event
);
2875 static void bfa_fcs_lport_ms_sm_gmal_sending(struct bfa_fcs_lport_ms_s
*ms
,
2876 enum port_ms_event event
);
2877 static void bfa_fcs_lport_ms_sm_gmal(struct bfa_fcs_lport_ms_s
*ms
,
2878 enum port_ms_event event
);
2879 static void bfa_fcs_lport_ms_sm_gmal_retry(struct bfa_fcs_lport_ms_s
*ms
,
2880 enum port_ms_event event
);
2881 static void bfa_fcs_lport_ms_sm_gfn_sending(struct bfa_fcs_lport_ms_s
*ms
,
2882 enum port_ms_event event
);
2883 static void bfa_fcs_lport_ms_sm_gfn(struct bfa_fcs_lport_ms_s
*ms
,
2884 enum port_ms_event event
);
2885 static void bfa_fcs_lport_ms_sm_gfn_retry(struct bfa_fcs_lport_ms_s
*ms
,
2886 enum port_ms_event event
);
2887 static void bfa_fcs_lport_ms_sm_online(struct bfa_fcs_lport_ms_s
*ms
,
2888 enum port_ms_event event
);
2890 * Start in offline state - awaiting NS to send start.
2893 bfa_fcs_lport_ms_sm_offline(struct bfa_fcs_lport_ms_s
*ms
,
2894 enum port_ms_event event
)
2896 bfa_trc(ms
->port
->fcs
, ms
->port
->port_cfg
.pwwn
);
2897 bfa_trc(ms
->port
->fcs
, event
);
2900 case MSSM_EVENT_PORT_ONLINE
:
2901 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_plogi_sending
);
2902 bfa_fcs_lport_ms_send_plogi(ms
, NULL
);
2905 case MSSM_EVENT_PORT_OFFLINE
:
2909 bfa_sm_fault(ms
->port
->fcs
, event
);
2914 bfa_fcs_lport_ms_sm_plogi_sending(struct bfa_fcs_lport_ms_s
*ms
,
2915 enum port_ms_event event
)
2917 bfa_trc(ms
->port
->fcs
, ms
->port
->port_cfg
.pwwn
);
2918 bfa_trc(ms
->port
->fcs
, event
);
2921 case MSSM_EVENT_FCXP_SENT
:
2922 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_plogi
);
2925 case MSSM_EVENT_PORT_OFFLINE
:
2926 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_offline
);
2927 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ms
->port
),
2932 bfa_sm_fault(ms
->port
->fcs
, event
);
2937 bfa_fcs_lport_ms_sm_plogi(struct bfa_fcs_lport_ms_s
*ms
,
2938 enum port_ms_event event
)
2940 bfa_trc(ms
->port
->fcs
, ms
->port
->port_cfg
.pwwn
);
2941 bfa_trc(ms
->port
->fcs
, event
);
2944 case MSSM_EVENT_RSP_ERROR
:
2946 * Start timer for a delayed retry
2948 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_plogi_retry
);
2949 ms
->port
->stats
.ms_retries
++;
2950 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ms
->port
),
2951 &ms
->timer
, bfa_fcs_lport_ms_timeout
, ms
,
2952 BFA_FCS_RETRY_TIMEOUT
);
2955 case MSSM_EVENT_RSP_OK
:
2957 * since plogi is done, now invoke MS related sub-modules
2959 bfa_fcs_lport_fdmi_online(ms
);
2962 * if this is a Vport, go to online state.
2964 if (ms
->port
->vport
) {
2965 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_online
);
2970 * For a base port we need to get the
2971 * switch's IP address.
2973 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_gmal_sending
);
2974 bfa_fcs_lport_ms_send_gmal(ms
, NULL
);
2977 case MSSM_EVENT_PORT_OFFLINE
:
2978 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_offline
);
2979 bfa_fcxp_discard(ms
->fcxp
);
2983 bfa_sm_fault(ms
->port
->fcs
, event
);
2988 bfa_fcs_lport_ms_sm_plogi_retry(struct bfa_fcs_lport_ms_s
*ms
,
2989 enum port_ms_event event
)
2991 bfa_trc(ms
->port
->fcs
, ms
->port
->port_cfg
.pwwn
);
2992 bfa_trc(ms
->port
->fcs
, event
);
2995 case MSSM_EVENT_TIMEOUT
:
2997 * Retry Timer Expired. Re-send
2999 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_plogi_sending
);
3000 bfa_fcs_lport_ms_send_plogi(ms
, NULL
);
3003 case MSSM_EVENT_PORT_OFFLINE
:
3004 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_offline
);
3005 bfa_timer_stop(&ms
->timer
);
3009 bfa_sm_fault(ms
->port
->fcs
, event
);
3014 bfa_fcs_lport_ms_sm_online(struct bfa_fcs_lport_ms_s
*ms
,
3015 enum port_ms_event event
)
3017 bfa_trc(ms
->port
->fcs
, ms
->port
->port_cfg
.pwwn
);
3018 bfa_trc(ms
->port
->fcs
, event
);
3021 case MSSM_EVENT_PORT_OFFLINE
:
3022 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_offline
);
3025 case MSSM_EVENT_PORT_FABRIC_RSCN
:
3026 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_gfn_sending
);
3028 bfa_fcs_lport_ms_send_gfn(ms
, NULL
);
3032 bfa_sm_fault(ms
->port
->fcs
, event
);
3037 bfa_fcs_lport_ms_sm_gmal_sending(struct bfa_fcs_lport_ms_s
*ms
,
3038 enum port_ms_event event
)
3040 bfa_trc(ms
->port
->fcs
, ms
->port
->port_cfg
.pwwn
);
3041 bfa_trc(ms
->port
->fcs
, event
);
3044 case MSSM_EVENT_FCXP_SENT
:
3045 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_gmal
);
3048 case MSSM_EVENT_PORT_OFFLINE
:
3049 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_offline
);
3050 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ms
->port
),
3055 bfa_sm_fault(ms
->port
->fcs
, event
);
3060 bfa_fcs_lport_ms_sm_gmal(struct bfa_fcs_lport_ms_s
*ms
,
3061 enum port_ms_event event
)
3063 bfa_trc(ms
->port
->fcs
, ms
->port
->port_cfg
.pwwn
);
3064 bfa_trc(ms
->port
->fcs
, event
);
3067 case MSSM_EVENT_RSP_ERROR
:
3069 * Start timer for a delayed retry
3071 if (ms
->retry_cnt
++ < BFA_FCS_MS_CMD_MAX_RETRIES
) {
3072 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_gmal_retry
);
3073 ms
->port
->stats
.ms_retries
++;
3074 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ms
->port
),
3075 &ms
->timer
, bfa_fcs_lport_ms_timeout
, ms
,
3076 BFA_FCS_RETRY_TIMEOUT
);
3078 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_gfn_sending
);
3079 bfa_fcs_lport_ms_send_gfn(ms
, NULL
);
3084 case MSSM_EVENT_RSP_OK
:
3085 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_gfn_sending
);
3086 bfa_fcs_lport_ms_send_gfn(ms
, NULL
);
3089 case MSSM_EVENT_PORT_OFFLINE
:
3090 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_offline
);
3091 bfa_fcxp_discard(ms
->fcxp
);
3095 bfa_sm_fault(ms
->port
->fcs
, event
);
3100 bfa_fcs_lport_ms_sm_gmal_retry(struct bfa_fcs_lport_ms_s
*ms
,
3101 enum port_ms_event event
)
3103 bfa_trc(ms
->port
->fcs
, ms
->port
->port_cfg
.pwwn
);
3104 bfa_trc(ms
->port
->fcs
, event
);
3107 case MSSM_EVENT_TIMEOUT
:
3109 * Retry Timer Expired. Re-send
3111 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_gmal_sending
);
3112 bfa_fcs_lport_ms_send_gmal(ms
, NULL
);
3115 case MSSM_EVENT_PORT_OFFLINE
:
3116 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_offline
);
3117 bfa_timer_stop(&ms
->timer
);
3121 bfa_sm_fault(ms
->port
->fcs
, event
);
3125 * ms_pvt MS local functions
3129 bfa_fcs_lport_ms_send_gmal(void *ms_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
3131 struct bfa_fcs_lport_ms_s
*ms
= ms_cbarg
;
3132 bfa_fcs_lport_t
*port
= ms
->port
;
3135 struct bfa_fcxp_s
*fcxp
;
3137 bfa_trc(port
->fcs
, port
->pid
);
3139 fcxp
= fcxp_alloced
? fcxp_alloced
:
3140 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
3142 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &ms
->fcxp_wqe
,
3143 bfa_fcs_lport_ms_send_gmal
, ms
, BFA_TRUE
);
3148 len
= fc_gmal_req_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
3149 bfa_fcs_lport_get_fcid(port
),
3150 port
->fabric
->lps
->pr_nwwn
);
3152 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
3153 FC_CLASS_3
, len
, &fchs
,
3154 bfa_fcs_lport_ms_gmal_response
, (void *)ms
,
3155 FC_MAX_PDUSZ
, FC_FCCT_TOV
);
3157 bfa_sm_send_event(ms
, MSSM_EVENT_FCXP_SENT
);
3161 bfa_fcs_lport_ms_gmal_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
,
3162 void *cbarg
, bfa_status_t req_status
,
3163 u32 rsp_len
, u32 resid_len
,
3164 struct fchs_s
*rsp_fchs
)
3166 struct bfa_fcs_lport_ms_s
*ms
= (struct bfa_fcs_lport_ms_s
*) cbarg
;
3167 bfa_fcs_lport_t
*port
= ms
->port
;
3168 struct ct_hdr_s
*cthdr
= NULL
;
3169 struct fcgs_gmal_resp_s
*gmal_resp
;
3170 struct fcgs_gmal_entry_s
*gmal_entry
;
3174 bfa_trc(port
->fcs
, req_status
);
3175 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
3180 if (req_status
!= BFA_STATUS_OK
) {
3181 bfa_trc(port
->fcs
, req_status
);
3182 bfa_sm_send_event(ms
, MSSM_EVENT_RSP_ERROR
);
3186 cthdr
= (struct ct_hdr_s
*) BFA_FCXP_RSP_PLD(fcxp
);
3187 cthdr
->cmd_rsp_code
= be16_to_cpu(cthdr
->cmd_rsp_code
);
3189 if (cthdr
->cmd_rsp_code
== CT_RSP_ACCEPT
) {
3190 gmal_resp
= (struct fcgs_gmal_resp_s
*)(cthdr
+ 1);
3192 num_entries
= be32_to_cpu(gmal_resp
->ms_len
);
3193 if (num_entries
== 0) {
3194 bfa_sm_send_event(ms
, MSSM_EVENT_RSP_ERROR
);
3198 * The response could contain multiple Entries.
3199 * Entries for SNMP interface, etc.
3200 * We look for the entry with a telnet prefix.
3201 * First "http://" entry refers to IP addr
3204 gmal_entry
= (struct fcgs_gmal_entry_s
*)gmal_resp
->ms_ma
;
3205 while (num_entries
> 0) {
3206 if (strncmp(gmal_entry
->prefix
,
3207 CT_GMAL_RESP_PREFIX_HTTP
,
3208 sizeof(gmal_entry
->prefix
)) == 0) {
3211 * if the IP address is terminating with a '/',
3213 * Byte 0 consists of the length of the string.
3215 rsp_str
= &(gmal_entry
->prefix
[0]);
3216 if (rsp_str
[gmal_entry
->len
-1] == '/')
3217 rsp_str
[gmal_entry
->len
-1] = 0;
3219 /* copy IP Address to fabric */
3220 strlcpy(bfa_fcs_lport_get_fabric_ipaddr(port
),
3221 gmal_entry
->ip_addr
,
3222 BFA_FCS_FABRIC_IPADDR_SZ
);
3230 bfa_sm_send_event(ms
, MSSM_EVENT_RSP_OK
);
3234 bfa_trc(port
->fcs
, cthdr
->reason_code
);
3235 bfa_trc(port
->fcs
, cthdr
->exp_code
);
3236 bfa_sm_send_event(ms
, MSSM_EVENT_RSP_ERROR
);
3240 bfa_fcs_lport_ms_sm_gfn_sending(struct bfa_fcs_lport_ms_s
*ms
,
3241 enum port_ms_event event
)
3243 bfa_trc(ms
->port
->fcs
, ms
->port
->port_cfg
.pwwn
);
3244 bfa_trc(ms
->port
->fcs
, event
);
3247 case MSSM_EVENT_FCXP_SENT
:
3248 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_gfn
);
3251 case MSSM_EVENT_PORT_OFFLINE
:
3252 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_offline
);
3253 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ms
->port
),
3258 bfa_sm_fault(ms
->port
->fcs
, event
);
3263 bfa_fcs_lport_ms_sm_gfn(struct bfa_fcs_lport_ms_s
*ms
,
3264 enum port_ms_event event
)
3266 bfa_trc(ms
->port
->fcs
, ms
->port
->port_cfg
.pwwn
);
3267 bfa_trc(ms
->port
->fcs
, event
);
3270 case MSSM_EVENT_RSP_ERROR
:
3272 * Start timer for a delayed retry
3274 if (ms
->retry_cnt
++ < BFA_FCS_MS_CMD_MAX_RETRIES
) {
3275 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_gfn_retry
);
3276 ms
->port
->stats
.ms_retries
++;
3277 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ms
->port
),
3278 &ms
->timer
, bfa_fcs_lport_ms_timeout
, ms
,
3279 BFA_FCS_RETRY_TIMEOUT
);
3281 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_online
);
3286 case MSSM_EVENT_RSP_OK
:
3287 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_online
);
3290 case MSSM_EVENT_PORT_OFFLINE
:
3291 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_offline
);
3292 bfa_fcxp_discard(ms
->fcxp
);
3296 bfa_sm_fault(ms
->port
->fcs
, event
);
3301 bfa_fcs_lport_ms_sm_gfn_retry(struct bfa_fcs_lport_ms_s
*ms
,
3302 enum port_ms_event event
)
3304 bfa_trc(ms
->port
->fcs
, ms
->port
->port_cfg
.pwwn
);
3305 bfa_trc(ms
->port
->fcs
, event
);
3308 case MSSM_EVENT_TIMEOUT
:
3310 * Retry Timer Expired. Re-send
3312 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_gfn_sending
);
3313 bfa_fcs_lport_ms_send_gfn(ms
, NULL
);
3316 case MSSM_EVENT_PORT_OFFLINE
:
3317 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_offline
);
3318 bfa_timer_stop(&ms
->timer
);
3322 bfa_sm_fault(ms
->port
->fcs
, event
);
3326 * ms_pvt MS local functions
3330 bfa_fcs_lport_ms_send_gfn(void *ms_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
3332 struct bfa_fcs_lport_ms_s
*ms
= ms_cbarg
;
3333 bfa_fcs_lport_t
*port
= ms
->port
;
3336 struct bfa_fcxp_s
*fcxp
;
3338 bfa_trc(port
->fcs
, port
->pid
);
3340 fcxp
= fcxp_alloced
? fcxp_alloced
:
3341 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
3343 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &ms
->fcxp_wqe
,
3344 bfa_fcs_lport_ms_send_gfn
, ms
, BFA_TRUE
);
3349 len
= fc_gfn_req_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
3350 bfa_fcs_lport_get_fcid(port
),
3351 port
->fabric
->lps
->pr_nwwn
);
3353 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
3354 FC_CLASS_3
, len
, &fchs
,
3355 bfa_fcs_lport_ms_gfn_response
, (void *)ms
,
3356 FC_MAX_PDUSZ
, FC_FCCT_TOV
);
3358 bfa_sm_send_event(ms
, MSSM_EVENT_FCXP_SENT
);
3362 bfa_fcs_lport_ms_gfn_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
,
3363 void *cbarg
, bfa_status_t req_status
, u32 rsp_len
,
3364 u32 resid_len
, struct fchs_s
*rsp_fchs
)
3366 struct bfa_fcs_lport_ms_s
*ms
= (struct bfa_fcs_lport_ms_s
*) cbarg
;
3367 bfa_fcs_lport_t
*port
= ms
->port
;
3368 struct ct_hdr_s
*cthdr
= NULL
;
3371 bfa_trc(port
->fcs
, req_status
);
3372 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
3377 if (req_status
!= BFA_STATUS_OK
) {
3378 bfa_trc(port
->fcs
, req_status
);
3379 bfa_sm_send_event(ms
, MSSM_EVENT_RSP_ERROR
);
3383 cthdr
= (struct ct_hdr_s
*) BFA_FCXP_RSP_PLD(fcxp
);
3384 cthdr
->cmd_rsp_code
= be16_to_cpu(cthdr
->cmd_rsp_code
);
3386 if (cthdr
->cmd_rsp_code
== CT_RSP_ACCEPT
) {
3387 gfn_resp
= (wwn_t
*)(cthdr
+ 1);
3388 /* check if it has actually changed */
3389 if ((memcmp((void *)&bfa_fcs_lport_get_fabric_name(port
),
3390 gfn_resp
, sizeof(wwn_t
)) != 0)) {
3391 bfa_fcs_fabric_set_fabric_name(port
->fabric
, *gfn_resp
);
3393 bfa_sm_send_event(ms
, MSSM_EVENT_RSP_OK
);
3397 bfa_trc(port
->fcs
, cthdr
->reason_code
);
3398 bfa_trc(port
->fcs
, cthdr
->exp_code
);
3399 bfa_sm_send_event(ms
, MSSM_EVENT_RSP_ERROR
);
3403 * ms_pvt MS local functions
3407 bfa_fcs_lport_ms_send_plogi(void *ms_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
3409 struct bfa_fcs_lport_ms_s
*ms
= ms_cbarg
;
3410 struct bfa_fcs_lport_s
*port
= ms
->port
;
3413 struct bfa_fcxp_s
*fcxp
;
3415 bfa_trc(port
->fcs
, port
->pid
);
3417 fcxp
= fcxp_alloced
? fcxp_alloced
:
3418 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
3420 port
->stats
.ms_plogi_alloc_wait
++;
3421 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &ms
->fcxp_wqe
,
3422 bfa_fcs_lport_ms_send_plogi
, ms
, BFA_TRUE
);
3427 len
= fc_plogi_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
3428 bfa_hton3b(FC_MGMT_SERVER
),
3429 bfa_fcs_lport_get_fcid(port
), 0,
3430 port
->port_cfg
.pwwn
, port
->port_cfg
.nwwn
,
3431 bfa_fcport_get_maxfrsize(port
->fcs
->bfa
),
3432 bfa_fcport_get_rx_bbcredit(port
->fcs
->bfa
));
3434 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
3435 FC_CLASS_3
, len
, &fchs
,
3436 bfa_fcs_lport_ms_plogi_response
, (void *)ms
,
3437 FC_MAX_PDUSZ
, FC_ELS_TOV
);
3439 port
->stats
.ms_plogi_sent
++;
3440 bfa_sm_send_event(ms
, MSSM_EVENT_FCXP_SENT
);
3444 bfa_fcs_lport_ms_plogi_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
,
3445 void *cbarg
, bfa_status_t req_status
,
3446 u32 rsp_len
, u32 resid_len
, struct fchs_s
*rsp_fchs
)
3448 struct bfa_fcs_lport_ms_s
*ms
= (struct bfa_fcs_lport_ms_s
*) cbarg
;
3449 struct bfa_fcs_lport_s
*port
= ms
->port
;
3450 struct fc_els_cmd_s
*els_cmd
;
3451 struct fc_ls_rjt_s
*ls_rjt
;
3453 bfa_trc(port
->fcs
, req_status
);
3454 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
3459 if (req_status
!= BFA_STATUS_OK
) {
3460 port
->stats
.ms_plogi_rsp_err
++;
3461 bfa_trc(port
->fcs
, req_status
);
3462 bfa_sm_send_event(ms
, MSSM_EVENT_RSP_ERROR
);
3466 els_cmd
= (struct fc_els_cmd_s
*) BFA_FCXP_RSP_PLD(fcxp
);
3468 switch (els_cmd
->els_code
) {
3471 if (rsp_len
< sizeof(struct fc_logi_s
)) {
3472 bfa_trc(port
->fcs
, rsp_len
);
3473 port
->stats
.ms_plogi_acc_err
++;
3474 bfa_sm_send_event(ms
, MSSM_EVENT_RSP_ERROR
);
3477 port
->stats
.ms_plogi_accepts
++;
3478 bfa_sm_send_event(ms
, MSSM_EVENT_RSP_OK
);
3482 ls_rjt
= (struct fc_ls_rjt_s
*) BFA_FCXP_RSP_PLD(fcxp
);
3484 bfa_trc(port
->fcs
, ls_rjt
->reason_code
);
3485 bfa_trc(port
->fcs
, ls_rjt
->reason_code_expl
);
3487 port
->stats
.ms_rejects
++;
3488 bfa_sm_send_event(ms
, MSSM_EVENT_RSP_ERROR
);
3492 port
->stats
.ms_plogi_unknown_rsp
++;
3493 bfa_trc(port
->fcs
, els_cmd
->els_code
);
3494 bfa_sm_send_event(ms
, MSSM_EVENT_RSP_ERROR
);
3499 bfa_fcs_lport_ms_timeout(void *arg
)
3501 struct bfa_fcs_lport_ms_s
*ms
= (struct bfa_fcs_lport_ms_s
*) arg
;
3503 ms
->port
->stats
.ms_timeouts
++;
3504 bfa_sm_send_event(ms
, MSSM_EVENT_TIMEOUT
);
3509 bfa_fcs_lport_ms_init(struct bfa_fcs_lport_s
*port
)
3511 struct bfa_fcs_lport_ms_s
*ms
= BFA_FCS_GET_MS_FROM_PORT(port
);
3514 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_offline
);
3517 * Invoke init routines of sub modules.
3519 bfa_fcs_lport_fdmi_init(ms
);
3523 bfa_fcs_lport_ms_offline(struct bfa_fcs_lport_s
*port
)
3525 struct bfa_fcs_lport_ms_s
*ms
= BFA_FCS_GET_MS_FROM_PORT(port
);
3528 bfa_sm_send_event(ms
, MSSM_EVENT_PORT_OFFLINE
);
3529 bfa_fcs_lport_fdmi_offline(ms
);
3533 bfa_fcs_lport_ms_online(struct bfa_fcs_lport_s
*port
)
3535 struct bfa_fcs_lport_ms_s
*ms
= BFA_FCS_GET_MS_FROM_PORT(port
);
3538 bfa_sm_send_event(ms
, MSSM_EVENT_PORT_ONLINE
);
3541 bfa_fcs_lport_ms_fabric_rscn(struct bfa_fcs_lport_s
*port
)
3543 struct bfa_fcs_lport_ms_s
*ms
= BFA_FCS_GET_MS_FROM_PORT(port
);
3545 /* todo. Handle this only when in Online state */
3546 if (bfa_sm_cmp_state(ms
, bfa_fcs_lport_ms_sm_online
))
3547 bfa_sm_send_event(ms
, MSSM_EVENT_PORT_FABRIC_RSCN
);
3551 * @page ns_sm_info VPORT NS State Machine
3553 * @section ns_sm_interactions VPORT NS State Machine Interactions
3555 * @section ns_sm VPORT NS State Machine
3560 * forward declarations
3562 static void bfa_fcs_lport_ns_send_plogi(void *ns_cbarg
,
3563 struct bfa_fcxp_s
*fcxp_alloced
);
3564 static void bfa_fcs_lport_ns_send_rspn_id(void *ns_cbarg
,
3565 struct bfa_fcxp_s
*fcxp_alloced
);
3566 static void bfa_fcs_lport_ns_send_rft_id(void *ns_cbarg
,
3567 struct bfa_fcxp_s
*fcxp_alloced
);
3568 static void bfa_fcs_lport_ns_send_rff_id(void *ns_cbarg
,
3569 struct bfa_fcxp_s
*fcxp_alloced
);
3570 static void bfa_fcs_lport_ns_send_gid_ft(void *ns_cbarg
,
3571 struct bfa_fcxp_s
*fcxp_alloced
);
3572 static void bfa_fcs_lport_ns_send_rnn_id(void *ns_cbarg
,
3573 struct bfa_fcxp_s
*fcxp_alloced
);
3574 static void bfa_fcs_lport_ns_send_rsnn_nn(void *ns_cbarg
,
3575 struct bfa_fcxp_s
*fcxp_alloced
);
3576 static void bfa_fcs_lport_ns_timeout(void *arg
);
3577 static void bfa_fcs_lport_ns_plogi_response(void *fcsarg
,
3578 struct bfa_fcxp_s
*fcxp
,
3580 bfa_status_t req_status
,
3583 struct fchs_s
*rsp_fchs
);
3584 static void bfa_fcs_lport_ns_rspn_id_response(void *fcsarg
,
3585 struct bfa_fcxp_s
*fcxp
,
3587 bfa_status_t req_status
,
3590 struct fchs_s
*rsp_fchs
);
3591 static void bfa_fcs_lport_ns_rft_id_response(void *fcsarg
,
3592 struct bfa_fcxp_s
*fcxp
,
3594 bfa_status_t req_status
,
3597 struct fchs_s
*rsp_fchs
);
3598 static void bfa_fcs_lport_ns_rff_id_response(void *fcsarg
,
3599 struct bfa_fcxp_s
*fcxp
,
3601 bfa_status_t req_status
,
3604 struct fchs_s
*rsp_fchs
);
3605 static void bfa_fcs_lport_ns_gid_ft_response(void *fcsarg
,
3606 struct bfa_fcxp_s
*fcxp
,
3608 bfa_status_t req_status
,
3611 struct fchs_s
*rsp_fchs
);
3612 static void bfa_fcs_lport_ns_rnn_id_response(void *fcsarg
,
3613 struct bfa_fcxp_s
*fcxp
,
3615 bfa_status_t req_status
,
3618 struct fchs_s
*rsp_fchs
);
3619 static void bfa_fcs_lport_ns_rsnn_nn_response(void *fcsarg
,
3620 struct bfa_fcxp_s
*fcxp
,
3622 bfa_status_t req_status
,
3625 struct fchs_s
*rsp_fchs
);
3626 static void bfa_fcs_lport_ns_process_gidft_pids(
3627 struct bfa_fcs_lport_s
*port
,
3628 u32
*pid_buf
, u32 n_pids
);
3630 static void bfa_fcs_lport_ns_boot_target_disc(bfa_fcs_lport_t
*port
);
3632 * fcs_ns_sm FCS nameserver interface state machine
3636 * VPort NS State Machine events
3638 enum vport_ns_event
{
3639 NSSM_EVENT_PORT_ONLINE
= 1,
3640 NSSM_EVENT_PORT_OFFLINE
= 2,
3641 NSSM_EVENT_PLOGI_SENT
= 3,
3642 NSSM_EVENT_RSP_OK
= 4,
3643 NSSM_EVENT_RSP_ERROR
= 5,
3644 NSSM_EVENT_TIMEOUT
= 6,
3645 NSSM_EVENT_NS_QUERY
= 7,
3646 NSSM_EVENT_RSPNID_SENT
= 8,
3647 NSSM_EVENT_RFTID_SENT
= 9,
3648 NSSM_EVENT_RFFID_SENT
= 10,
3649 NSSM_EVENT_GIDFT_SENT
= 11,
3650 NSSM_EVENT_RNNID_SENT
= 12,
3651 NSSM_EVENT_RSNN_NN_SENT
= 13,
3654 static void bfa_fcs_lport_ns_sm_offline(struct bfa_fcs_lport_ns_s
*ns
,
3655 enum vport_ns_event event
);
3656 static void bfa_fcs_lport_ns_sm_plogi_sending(struct bfa_fcs_lport_ns_s
*ns
,
3657 enum vport_ns_event event
);
3658 static void bfa_fcs_lport_ns_sm_plogi(struct bfa_fcs_lport_ns_s
*ns
,
3659 enum vport_ns_event event
);
3660 static void bfa_fcs_lport_ns_sm_plogi_retry(struct bfa_fcs_lport_ns_s
*ns
,
3661 enum vport_ns_event event
);
3662 static void bfa_fcs_lport_ns_sm_sending_rspn_id(
3663 struct bfa_fcs_lport_ns_s
*ns
,
3664 enum vport_ns_event event
);
3665 static void bfa_fcs_lport_ns_sm_rspn_id(struct bfa_fcs_lport_ns_s
*ns
,
3666 enum vport_ns_event event
);
3667 static void bfa_fcs_lport_ns_sm_rspn_id_retry(struct bfa_fcs_lport_ns_s
*ns
,
3668 enum vport_ns_event event
);
3669 static void bfa_fcs_lport_ns_sm_sending_rft_id(
3670 struct bfa_fcs_lport_ns_s
*ns
,
3671 enum vport_ns_event event
);
3672 static void bfa_fcs_lport_ns_sm_rft_id_retry(struct bfa_fcs_lport_ns_s
*ns
,
3673 enum vport_ns_event event
);
3674 static void bfa_fcs_lport_ns_sm_rft_id(struct bfa_fcs_lport_ns_s
*ns
,
3675 enum vport_ns_event event
);
3676 static void bfa_fcs_lport_ns_sm_sending_rff_id(
3677 struct bfa_fcs_lport_ns_s
*ns
,
3678 enum vport_ns_event event
);
3679 static void bfa_fcs_lport_ns_sm_rff_id_retry(struct bfa_fcs_lport_ns_s
*ns
,
3680 enum vport_ns_event event
);
3681 static void bfa_fcs_lport_ns_sm_rff_id(struct bfa_fcs_lport_ns_s
*ns
,
3682 enum vport_ns_event event
);
3683 static void bfa_fcs_lport_ns_sm_sending_gid_ft(
3684 struct bfa_fcs_lport_ns_s
*ns
,
3685 enum vport_ns_event event
);
3686 static void bfa_fcs_lport_ns_sm_gid_ft(struct bfa_fcs_lport_ns_s
*ns
,
3687 enum vport_ns_event event
);
3688 static void bfa_fcs_lport_ns_sm_gid_ft_retry(struct bfa_fcs_lport_ns_s
*ns
,
3689 enum vport_ns_event event
);
3690 static void bfa_fcs_lport_ns_sm_online(struct bfa_fcs_lport_ns_s
*ns
,
3691 enum vport_ns_event event
);
3692 static void bfa_fcs_lport_ns_sm_sending_rnn_id(
3693 struct bfa_fcs_lport_ns_s
*ns
,
3694 enum vport_ns_event event
);
3695 static void bfa_fcs_lport_ns_sm_rnn_id(struct bfa_fcs_lport_ns_s
*ns
,
3696 enum vport_ns_event event
);
3697 static void bfa_fcs_lport_ns_sm_rnn_id_retry(struct bfa_fcs_lport_ns_s
*ns
,
3698 enum vport_ns_event event
);
3699 static void bfa_fcs_lport_ns_sm_sending_rsnn_nn(
3700 struct bfa_fcs_lport_ns_s
*ns
,
3701 enum vport_ns_event event
);
3702 static void bfa_fcs_lport_ns_sm_rsnn_nn(struct bfa_fcs_lport_ns_s
*ns
,
3703 enum vport_ns_event event
);
3704 static void bfa_fcs_lport_ns_sm_rsnn_nn_retry(
3705 struct bfa_fcs_lport_ns_s
*ns
,
3706 enum vport_ns_event event
);
3708 * Start in offline state - awaiting linkup
3711 bfa_fcs_lport_ns_sm_offline(struct bfa_fcs_lport_ns_s
*ns
,
3712 enum vport_ns_event event
)
3714 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
3715 bfa_trc(ns
->port
->fcs
, event
);
3718 case NSSM_EVENT_PORT_ONLINE
:
3719 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_plogi_sending
);
3720 bfa_fcs_lport_ns_send_plogi(ns
, NULL
);
3723 case NSSM_EVENT_PORT_OFFLINE
:
3727 bfa_sm_fault(ns
->port
->fcs
, event
);
3732 bfa_fcs_lport_ns_sm_plogi_sending(struct bfa_fcs_lport_ns_s
*ns
,
3733 enum vport_ns_event event
)
3735 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
3736 bfa_trc(ns
->port
->fcs
, event
);
3739 case NSSM_EVENT_PLOGI_SENT
:
3740 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_plogi
);
3743 case NSSM_EVENT_PORT_OFFLINE
:
3744 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
3745 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns
->port
),
3750 bfa_sm_fault(ns
->port
->fcs
, event
);
3755 bfa_fcs_lport_ns_sm_plogi(struct bfa_fcs_lport_ns_s
*ns
,
3756 enum vport_ns_event event
)
3758 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
3759 bfa_trc(ns
->port
->fcs
, event
);
3762 case NSSM_EVENT_RSP_ERROR
:
3764 * Start timer for a delayed retry
3766 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_plogi_retry
);
3767 ns
->port
->stats
.ns_retries
++;
3768 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns
->port
),
3769 &ns
->timer
, bfa_fcs_lport_ns_timeout
, ns
,
3770 BFA_FCS_RETRY_TIMEOUT
);
3773 case NSSM_EVENT_RSP_OK
:
3774 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_sending_rnn_id
);
3775 ns
->num_rnnid_retries
= 0;
3776 bfa_fcs_lport_ns_send_rnn_id(ns
, NULL
);
3779 case NSSM_EVENT_PORT_OFFLINE
:
3780 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
3781 bfa_fcxp_discard(ns
->fcxp
);
3785 bfa_sm_fault(ns
->port
->fcs
, event
);
3790 bfa_fcs_lport_ns_sm_plogi_retry(struct bfa_fcs_lport_ns_s
*ns
,
3791 enum vport_ns_event event
)
3793 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
3794 bfa_trc(ns
->port
->fcs
, event
);
3797 case NSSM_EVENT_TIMEOUT
:
3799 * Retry Timer Expired. Re-send
3801 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_plogi_sending
);
3802 bfa_fcs_lport_ns_send_plogi(ns
, NULL
);
3805 case NSSM_EVENT_PORT_OFFLINE
:
3806 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
3807 bfa_timer_stop(&ns
->timer
);
3811 bfa_sm_fault(ns
->port
->fcs
, event
);
3816 bfa_fcs_lport_ns_sm_sending_rnn_id(struct bfa_fcs_lport_ns_s
*ns
,
3817 enum vport_ns_event event
)
3819 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
3820 bfa_trc(ns
->port
->fcs
, event
);
3823 case NSSM_EVENT_RNNID_SENT
:
3824 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_rnn_id
);
3827 case NSSM_EVENT_PORT_OFFLINE
:
3828 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
3829 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns
->port
),
3833 bfa_sm_fault(ns
->port
->fcs
, event
);
3838 bfa_fcs_lport_ns_sm_rnn_id(struct bfa_fcs_lport_ns_s
*ns
,
3839 enum vport_ns_event event
)
3841 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
3842 bfa_trc(ns
->port
->fcs
, event
);
3845 case NSSM_EVENT_RSP_OK
:
3846 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_sending_rsnn_nn
);
3847 ns
->num_rnnid_retries
= 0;
3848 ns
->num_rsnn_nn_retries
= 0;
3849 bfa_fcs_lport_ns_send_rsnn_nn(ns
, NULL
);
3852 case NSSM_EVENT_RSP_ERROR
:
3853 if (ns
->num_rnnid_retries
< BFA_FCS_MAX_NS_RETRIES
) {
3854 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_rnn_id_retry
);
3855 ns
->port
->stats
.ns_retries
++;
3856 ns
->num_rnnid_retries
++;
3857 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns
->port
),
3858 &ns
->timer
, bfa_fcs_lport_ns_timeout
, ns
,
3859 BFA_FCS_RETRY_TIMEOUT
);
3861 bfa_sm_set_state(ns
,
3862 bfa_fcs_lport_ns_sm_sending_rspn_id
);
3863 bfa_fcs_lport_ns_send_rspn_id(ns
, NULL
);
3867 case NSSM_EVENT_PORT_OFFLINE
:
3868 bfa_fcxp_discard(ns
->fcxp
);
3869 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
3873 bfa_sm_fault(ns
->port
->fcs
, event
);
3878 bfa_fcs_lport_ns_sm_rnn_id_retry(struct bfa_fcs_lport_ns_s
*ns
,
3879 enum vport_ns_event event
)
3881 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
3882 bfa_trc(ns
->port
->fcs
, event
);
3885 case NSSM_EVENT_TIMEOUT
:
3886 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_sending_rnn_id
);
3887 bfa_fcs_lport_ns_send_rnn_id(ns
, NULL
);
3890 case NSSM_EVENT_PORT_OFFLINE
:
3891 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
3892 bfa_timer_stop(&ns
->timer
);
3896 bfa_sm_fault(ns
->port
->fcs
, event
);
3901 bfa_fcs_lport_ns_sm_sending_rsnn_nn(struct bfa_fcs_lport_ns_s
*ns
,
3902 enum vport_ns_event event
)
3904 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
3905 bfa_trc(ns
->port
->fcs
, event
);
3908 case NSSM_EVENT_RSNN_NN_SENT
:
3909 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_rsnn_nn
);
3912 case NSSM_EVENT_PORT_OFFLINE
:
3913 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
3914 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns
->port
),
3919 bfa_sm_fault(ns
->port
->fcs
, event
);
3924 bfa_fcs_lport_ns_sm_rsnn_nn(struct bfa_fcs_lport_ns_s
*ns
,
3925 enum vport_ns_event event
)
3927 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
3928 bfa_trc(ns
->port
->fcs
, event
);
3931 case NSSM_EVENT_RSP_OK
:
3932 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_sending_rspn_id
);
3933 ns
->num_rsnn_nn_retries
= 0;
3934 bfa_fcs_lport_ns_send_rspn_id(ns
, NULL
);
3937 case NSSM_EVENT_RSP_ERROR
:
3938 if (ns
->num_rsnn_nn_retries
< BFA_FCS_MAX_NS_RETRIES
) {
3939 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_rsnn_nn_retry
);
3940 ns
->port
->stats
.ns_retries
++;
3941 ns
->num_rsnn_nn_retries
++;
3942 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns
->port
),
3943 &ns
->timer
, bfa_fcs_lport_ns_timeout
,
3944 ns
, BFA_FCS_RETRY_TIMEOUT
);
3946 bfa_sm_set_state(ns
,
3947 bfa_fcs_lport_ns_sm_sending_rspn_id
);
3948 bfa_fcs_lport_ns_send_rspn_id(ns
, NULL
);
3952 case NSSM_EVENT_PORT_OFFLINE
:
3953 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
3954 bfa_fcxp_discard(ns
->fcxp
);
3958 bfa_sm_fault(ns
->port
->fcs
, event
);
3963 bfa_fcs_lport_ns_sm_rsnn_nn_retry(struct bfa_fcs_lport_ns_s
*ns
,
3964 enum vport_ns_event event
)
3966 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
3967 bfa_trc(ns
->port
->fcs
, event
);
3970 case NSSM_EVENT_TIMEOUT
:
3971 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_sending_rsnn_nn
);
3972 bfa_fcs_lport_ns_send_rsnn_nn(ns
, NULL
);
3975 case NSSM_EVENT_PORT_OFFLINE
:
3976 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
3977 bfa_timer_stop(&ns
->timer
);
3981 bfa_sm_fault(ns
->port
->fcs
, event
);
3986 bfa_fcs_lport_ns_sm_sending_rspn_id(struct bfa_fcs_lport_ns_s
*ns
,
3987 enum vport_ns_event event
)
3989 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
3990 bfa_trc(ns
->port
->fcs
, event
);
3993 case NSSM_EVENT_RSPNID_SENT
:
3994 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_rspn_id
);
3997 case NSSM_EVENT_PORT_OFFLINE
:
3998 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
3999 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns
->port
),
4004 bfa_sm_fault(ns
->port
->fcs
, event
);
4009 bfa_fcs_lport_ns_sm_rspn_id(struct bfa_fcs_lport_ns_s
*ns
,
4010 enum vport_ns_event event
)
4012 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
4013 bfa_trc(ns
->port
->fcs
, event
);
4016 case NSSM_EVENT_RSP_ERROR
:
4018 * Start timer for a delayed retry
4020 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_rspn_id_retry
);
4021 ns
->port
->stats
.ns_retries
++;
4022 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns
->port
),
4023 &ns
->timer
, bfa_fcs_lport_ns_timeout
, ns
,
4024 BFA_FCS_RETRY_TIMEOUT
);
4027 case NSSM_EVENT_RSP_OK
:
4028 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_sending_rft_id
);
4029 bfa_fcs_lport_ns_send_rft_id(ns
, NULL
);
4032 case NSSM_EVENT_PORT_OFFLINE
:
4033 bfa_fcxp_discard(ns
->fcxp
);
4034 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
4038 bfa_sm_fault(ns
->port
->fcs
, event
);
4043 bfa_fcs_lport_ns_sm_rspn_id_retry(struct bfa_fcs_lport_ns_s
*ns
,
4044 enum vport_ns_event event
)
4046 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
4047 bfa_trc(ns
->port
->fcs
, event
);
4050 case NSSM_EVENT_TIMEOUT
:
4052 * Retry Timer Expired. Re-send
4054 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_sending_rspn_id
);
4055 bfa_fcs_lport_ns_send_rspn_id(ns
, NULL
);
4058 case NSSM_EVENT_PORT_OFFLINE
:
4059 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
4060 bfa_timer_stop(&ns
->timer
);
4064 bfa_sm_fault(ns
->port
->fcs
, event
);
4069 bfa_fcs_lport_ns_sm_sending_rft_id(struct bfa_fcs_lport_ns_s
*ns
,
4070 enum vport_ns_event event
)
4072 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
4073 bfa_trc(ns
->port
->fcs
, event
);
4076 case NSSM_EVENT_RFTID_SENT
:
4077 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_rft_id
);
4080 case NSSM_EVENT_PORT_OFFLINE
:
4081 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
4082 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns
->port
),
4087 bfa_sm_fault(ns
->port
->fcs
, event
);
4092 bfa_fcs_lport_ns_sm_rft_id(struct bfa_fcs_lport_ns_s
*ns
,
4093 enum vport_ns_event event
)
4095 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
4096 bfa_trc(ns
->port
->fcs
, event
);
4099 case NSSM_EVENT_RSP_OK
:
4100 /* Now move to register FC4 Features */
4101 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_sending_rff_id
);
4102 bfa_fcs_lport_ns_send_rff_id(ns
, NULL
);
4105 case NSSM_EVENT_RSP_ERROR
:
4107 * Start timer for a delayed retry
4109 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_rft_id_retry
);
4110 ns
->port
->stats
.ns_retries
++;
4111 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns
->port
),
4112 &ns
->timer
, bfa_fcs_lport_ns_timeout
, ns
,
4113 BFA_FCS_RETRY_TIMEOUT
);
4116 case NSSM_EVENT_PORT_OFFLINE
:
4117 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
4118 bfa_fcxp_discard(ns
->fcxp
);
4122 bfa_sm_fault(ns
->port
->fcs
, event
);
4127 bfa_fcs_lport_ns_sm_rft_id_retry(struct bfa_fcs_lport_ns_s
*ns
,
4128 enum vport_ns_event event
)
4130 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
4131 bfa_trc(ns
->port
->fcs
, event
);
4134 case NSSM_EVENT_TIMEOUT
:
4135 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_sending_rft_id
);
4136 bfa_fcs_lport_ns_send_rft_id(ns
, NULL
);
4139 case NSSM_EVENT_PORT_OFFLINE
:
4140 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
4141 bfa_timer_stop(&ns
->timer
);
4145 bfa_sm_fault(ns
->port
->fcs
, event
);
4150 bfa_fcs_lport_ns_sm_sending_rff_id(struct bfa_fcs_lport_ns_s
*ns
,
4151 enum vport_ns_event event
)
4153 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
4154 bfa_trc(ns
->port
->fcs
, event
);
4157 case NSSM_EVENT_RFFID_SENT
:
4158 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_rff_id
);
4161 case NSSM_EVENT_PORT_OFFLINE
:
4162 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
4163 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns
->port
),
4168 bfa_sm_fault(ns
->port
->fcs
, event
);
4173 bfa_fcs_lport_ns_sm_rff_id(struct bfa_fcs_lport_ns_s
*ns
,
4174 enum vport_ns_event event
)
4176 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
4177 bfa_trc(ns
->port
->fcs
, event
);
4180 case NSSM_EVENT_RSP_OK
:
4183 * If min cfg mode is enabled, we donot initiate rport
4184 * discovery with the fabric. Instead, we will retrieve the
4185 * boot targets from HAL/FW.
4187 if (__fcs_min_cfg(ns
->port
->fcs
)) {
4188 bfa_fcs_lport_ns_boot_target_disc(ns
->port
);
4189 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_online
);
4194 * If the port role is Initiator Mode issue NS query.
4195 * If it is Target Mode, skip this and go to online.
4197 if (BFA_FCS_VPORT_IS_INITIATOR_MODE(ns
->port
)) {
4198 bfa_sm_set_state(ns
,
4199 bfa_fcs_lport_ns_sm_sending_gid_ft
);
4200 bfa_fcs_lport_ns_send_gid_ft(ns
, NULL
);
4203 * kick off mgmt srvr state machine
4205 bfa_fcs_lport_ms_online(ns
->port
);
4208 case NSSM_EVENT_RSP_ERROR
:
4210 * Start timer for a delayed retry
4212 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_rff_id_retry
);
4213 ns
->port
->stats
.ns_retries
++;
4214 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns
->port
),
4215 &ns
->timer
, bfa_fcs_lport_ns_timeout
, ns
,
4216 BFA_FCS_RETRY_TIMEOUT
);
4219 case NSSM_EVENT_PORT_OFFLINE
:
4220 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
4221 bfa_fcxp_discard(ns
->fcxp
);
4225 bfa_sm_fault(ns
->port
->fcs
, event
);
4230 bfa_fcs_lport_ns_sm_rff_id_retry(struct bfa_fcs_lport_ns_s
*ns
,
4231 enum vport_ns_event event
)
4233 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
4234 bfa_trc(ns
->port
->fcs
, event
);
4237 case NSSM_EVENT_TIMEOUT
:
4238 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_sending_rff_id
);
4239 bfa_fcs_lport_ns_send_rff_id(ns
, NULL
);
4242 case NSSM_EVENT_PORT_OFFLINE
:
4243 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
4244 bfa_timer_stop(&ns
->timer
);
4248 bfa_sm_fault(ns
->port
->fcs
, event
);
4252 bfa_fcs_lport_ns_sm_sending_gid_ft(struct bfa_fcs_lport_ns_s
*ns
,
4253 enum vport_ns_event event
)
4255 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
4256 bfa_trc(ns
->port
->fcs
, event
);
4259 case NSSM_EVENT_GIDFT_SENT
:
4260 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_gid_ft
);
4263 case NSSM_EVENT_PORT_OFFLINE
:
4264 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
4265 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns
->port
),
4270 bfa_sm_fault(ns
->port
->fcs
, event
);
4275 bfa_fcs_lport_ns_sm_gid_ft(struct bfa_fcs_lport_ns_s
*ns
,
4276 enum vport_ns_event event
)
4278 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
4279 bfa_trc(ns
->port
->fcs
, event
);
4282 case NSSM_EVENT_RSP_OK
:
4283 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_online
);
4286 case NSSM_EVENT_RSP_ERROR
:
4288 * TBD: for certain reject codes, we don't need to retry
4291 * Start timer for a delayed retry
4293 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_gid_ft_retry
);
4294 ns
->port
->stats
.ns_retries
++;
4295 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns
->port
),
4296 &ns
->timer
, bfa_fcs_lport_ns_timeout
, ns
,
4297 BFA_FCS_RETRY_TIMEOUT
);
4300 case NSSM_EVENT_PORT_OFFLINE
:
4301 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
4302 bfa_fcxp_discard(ns
->fcxp
);
4305 case NSSM_EVENT_NS_QUERY
:
4309 bfa_sm_fault(ns
->port
->fcs
, event
);
4314 bfa_fcs_lport_ns_sm_gid_ft_retry(struct bfa_fcs_lport_ns_s
*ns
,
4315 enum vport_ns_event event
)
4317 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
4318 bfa_trc(ns
->port
->fcs
, event
);
4321 case NSSM_EVENT_TIMEOUT
:
4322 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_sending_gid_ft
);
4323 bfa_fcs_lport_ns_send_gid_ft(ns
, NULL
);
4326 case NSSM_EVENT_PORT_OFFLINE
:
4327 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
4328 bfa_timer_stop(&ns
->timer
);
4332 bfa_sm_fault(ns
->port
->fcs
, event
);
4337 bfa_fcs_lport_ns_sm_online(struct bfa_fcs_lport_ns_s
*ns
,
4338 enum vport_ns_event event
)
4340 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
4341 bfa_trc(ns
->port
->fcs
, event
);
4344 case NSSM_EVENT_PORT_OFFLINE
:
4345 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
4348 case NSSM_EVENT_NS_QUERY
:
4350 * If the port role is Initiator Mode issue NS query.
4351 * If it is Target Mode, skip this and go to online.
4353 if (BFA_FCS_VPORT_IS_INITIATOR_MODE(ns
->port
)) {
4354 bfa_sm_set_state(ns
,
4355 bfa_fcs_lport_ns_sm_sending_gid_ft
);
4356 bfa_fcs_lport_ns_send_gid_ft(ns
, NULL
);
4361 bfa_sm_fault(ns
->port
->fcs
, event
);
4368 * ns_pvt Nameserver local functions
4372 bfa_fcs_lport_ns_send_plogi(void *ns_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
4374 struct bfa_fcs_lport_ns_s
*ns
= ns_cbarg
;
4375 struct bfa_fcs_lport_s
*port
= ns
->port
;
4378 struct bfa_fcxp_s
*fcxp
;
4380 bfa_trc(port
->fcs
, port
->pid
);
4382 fcxp
= fcxp_alloced
? fcxp_alloced
:
4383 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
4385 port
->stats
.ns_plogi_alloc_wait
++;
4386 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &ns
->fcxp_wqe
,
4387 bfa_fcs_lport_ns_send_plogi
, ns
, BFA_TRUE
);
4392 len
= fc_plogi_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
4393 bfa_hton3b(FC_NAME_SERVER
),
4394 bfa_fcs_lport_get_fcid(port
), 0,
4395 port
->port_cfg
.pwwn
, port
->port_cfg
.nwwn
,
4396 bfa_fcport_get_maxfrsize(port
->fcs
->bfa
),
4397 bfa_fcport_get_rx_bbcredit(port
->fcs
->bfa
));
4399 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
4400 FC_CLASS_3
, len
, &fchs
,
4401 bfa_fcs_lport_ns_plogi_response
, (void *)ns
,
4402 FC_MAX_PDUSZ
, FC_ELS_TOV
);
4403 port
->stats
.ns_plogi_sent
++;
4405 bfa_sm_send_event(ns
, NSSM_EVENT_PLOGI_SENT
);
4409 bfa_fcs_lport_ns_plogi_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
,
4410 void *cbarg
, bfa_status_t req_status
, u32 rsp_len
,
4411 u32 resid_len
, struct fchs_s
*rsp_fchs
)
4413 struct bfa_fcs_lport_ns_s
*ns
= (struct bfa_fcs_lport_ns_s
*) cbarg
;
4414 struct bfa_fcs_lport_s
*port
= ns
->port
;
4415 /* struct fc_logi_s *plogi_resp; */
4416 struct fc_els_cmd_s
*els_cmd
;
4417 struct fc_ls_rjt_s
*ls_rjt
;
4419 bfa_trc(port
->fcs
, req_status
);
4420 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
4425 if (req_status
!= BFA_STATUS_OK
) {
4426 bfa_trc(port
->fcs
, req_status
);
4427 port
->stats
.ns_plogi_rsp_err
++;
4428 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4432 els_cmd
= (struct fc_els_cmd_s
*) BFA_FCXP_RSP_PLD(fcxp
);
4434 switch (els_cmd
->els_code
) {
4437 if (rsp_len
< sizeof(struct fc_logi_s
)) {
4438 bfa_trc(port
->fcs
, rsp_len
);
4439 port
->stats
.ns_plogi_acc_err
++;
4440 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4443 port
->stats
.ns_plogi_accepts
++;
4444 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_OK
);
4448 ls_rjt
= (struct fc_ls_rjt_s
*) BFA_FCXP_RSP_PLD(fcxp
);
4450 bfa_trc(port
->fcs
, ls_rjt
->reason_code
);
4451 bfa_trc(port
->fcs
, ls_rjt
->reason_code_expl
);
4453 port
->stats
.ns_rejects
++;
4455 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4459 port
->stats
.ns_plogi_unknown_rsp
++;
4460 bfa_trc(port
->fcs
, els_cmd
->els_code
);
4461 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4466 * Register node name for port_id
4469 bfa_fcs_lport_ns_send_rnn_id(void *ns_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
4471 struct bfa_fcs_lport_ns_s
*ns
= ns_cbarg
;
4472 struct bfa_fcs_lport_s
*port
= ns
->port
;
4475 struct bfa_fcxp_s
*fcxp
;
4477 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
4479 fcxp
= fcxp_alloced
? fcxp_alloced
:
4480 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
4482 port
->stats
.ns_rnnid_alloc_wait
++;
4483 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &ns
->fcxp_wqe
,
4484 bfa_fcs_lport_ns_send_rnn_id
, ns
, BFA_TRUE
);
4490 len
= fc_rnnid_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
4491 bfa_fcs_lport_get_fcid(port
),
4492 bfa_fcs_lport_get_fcid(port
),
4493 bfa_fcs_lport_get_nwwn(port
));
4495 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
4496 FC_CLASS_3
, len
, &fchs
,
4497 bfa_fcs_lport_ns_rnn_id_response
, (void *)ns
,
4498 FC_MAX_PDUSZ
, FC_FCCT_TOV
);
4500 port
->stats
.ns_rnnid_sent
++;
4501 bfa_sm_send_event(ns
, NSSM_EVENT_RNNID_SENT
);
4505 bfa_fcs_lport_ns_rnn_id_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
,
4506 void *cbarg
, bfa_status_t req_status
,
4507 u32 rsp_len
, u32 resid_len
,
4508 struct fchs_s
*rsp_fchs
)
4511 struct bfa_fcs_lport_ns_s
*ns
= (struct bfa_fcs_lport_ns_s
*) cbarg
;
4512 struct bfa_fcs_lport_s
*port
= ns
->port
;
4513 struct ct_hdr_s
*cthdr
= NULL
;
4515 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
4520 if (req_status
!= BFA_STATUS_OK
) {
4521 bfa_trc(port
->fcs
, req_status
);
4522 port
->stats
.ns_rnnid_rsp_err
++;
4523 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4527 cthdr
= (struct ct_hdr_s
*) BFA_FCXP_RSP_PLD(fcxp
);
4528 cthdr
->cmd_rsp_code
= be16_to_cpu(cthdr
->cmd_rsp_code
);
4530 if (cthdr
->cmd_rsp_code
== CT_RSP_ACCEPT
) {
4531 port
->stats
.ns_rnnid_accepts
++;
4532 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_OK
);
4536 port
->stats
.ns_rnnid_rejects
++;
4537 bfa_trc(port
->fcs
, cthdr
->reason_code
);
4538 bfa_trc(port
->fcs
, cthdr
->exp_code
);
4539 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4543 * Register the symbolic node name for a given node name.
4546 bfa_fcs_lport_ns_send_rsnn_nn(void *ns_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
4548 struct bfa_fcs_lport_ns_s
*ns
= ns_cbarg
;
4549 struct bfa_fcs_lport_s
*port
= ns
->port
;
4552 struct bfa_fcxp_s
*fcxp
;
4555 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
4557 fcxp
= fcxp_alloced
? fcxp_alloced
:
4558 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
4560 port
->stats
.ns_rsnn_nn_alloc_wait
++;
4561 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &ns
->fcxp_wqe
,
4562 bfa_fcs_lport_ns_send_rsnn_nn
, ns
, BFA_TRUE
);
4567 nsymbl
= (u8
*) &(bfa_fcs_lport_get_nsym_name(
4568 bfa_fcs_get_base_port(port
->fcs
)));
4570 len
= fc_rsnn_nn_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
4571 bfa_fcs_lport_get_fcid(port
),
4572 bfa_fcs_lport_get_nwwn(port
), nsymbl
);
4574 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
4575 FC_CLASS_3
, len
, &fchs
,
4576 bfa_fcs_lport_ns_rsnn_nn_response
, (void *)ns
,
4577 FC_MAX_PDUSZ
, FC_FCCT_TOV
);
4579 port
->stats
.ns_rsnn_nn_sent
++;
4581 bfa_sm_send_event(ns
, NSSM_EVENT_RSNN_NN_SENT
);
4585 bfa_fcs_lport_ns_rsnn_nn_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
,
4586 void *cbarg
, bfa_status_t req_status
,
4587 u32 rsp_len
, u32 resid_len
,
4588 struct fchs_s
*rsp_fchs
)
4590 struct bfa_fcs_lport_ns_s
*ns
= (struct bfa_fcs_lport_ns_s
*) cbarg
;
4591 struct bfa_fcs_lport_s
*port
= ns
->port
;
4592 struct ct_hdr_s
*cthdr
= NULL
;
4594 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
4599 if (req_status
!= BFA_STATUS_OK
) {
4600 bfa_trc(port
->fcs
, req_status
);
4601 port
->stats
.ns_rsnn_nn_rsp_err
++;
4602 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4606 cthdr
= (struct ct_hdr_s
*) BFA_FCXP_RSP_PLD(fcxp
);
4607 cthdr
->cmd_rsp_code
= be16_to_cpu(cthdr
->cmd_rsp_code
);
4609 if (cthdr
->cmd_rsp_code
== CT_RSP_ACCEPT
) {
4610 port
->stats
.ns_rsnn_nn_accepts
++;
4611 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_OK
);
4615 port
->stats
.ns_rsnn_nn_rejects
++;
4616 bfa_trc(port
->fcs
, cthdr
->reason_code
);
4617 bfa_trc(port
->fcs
, cthdr
->exp_code
);
4618 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4622 * Register the symbolic port name.
4625 bfa_fcs_lport_ns_send_rspn_id(void *ns_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
4627 struct bfa_fcs_lport_ns_s
*ns
= ns_cbarg
;
4628 struct bfa_fcs_lport_s
*port
= ns
->port
;
4631 struct bfa_fcxp_s
*fcxp
;
4633 u8
*psymbl
= &symbl
[0];
4635 memset(symbl
, 0, sizeof(symbl
));
4637 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
4639 fcxp
= fcxp_alloced
? fcxp_alloced
:
4640 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
4642 port
->stats
.ns_rspnid_alloc_wait
++;
4643 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &ns
->fcxp_wqe
,
4644 bfa_fcs_lport_ns_send_rspn_id
, ns
, BFA_TRUE
);
4650 * for V-Port, form a Port Symbolic Name
4654 * For Vports, we append the vport's port symbolic name
4655 * to that of the base port.
4659 (char *)&(bfa_fcs_lport_get_psym_name
4660 (bfa_fcs_get_base_port(port
->fcs
))),
4663 strlcat(symbl
, (char *)&(bfa_fcs_lport_get_psym_name(port
)),
4666 psymbl
= (u8
*) &(bfa_fcs_lport_get_psym_name(port
));
4669 len
= fc_rspnid_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
4670 bfa_fcs_lport_get_fcid(port
), 0, psymbl
);
4672 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
4673 FC_CLASS_3
, len
, &fchs
,
4674 bfa_fcs_lport_ns_rspn_id_response
, (void *)ns
,
4675 FC_MAX_PDUSZ
, FC_FCCT_TOV
);
4677 port
->stats
.ns_rspnid_sent
++;
4679 bfa_sm_send_event(ns
, NSSM_EVENT_RSPNID_SENT
);
4683 bfa_fcs_lport_ns_rspn_id_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
,
4684 void *cbarg
, bfa_status_t req_status
,
4685 u32 rsp_len
, u32 resid_len
,
4686 struct fchs_s
*rsp_fchs
)
4688 struct bfa_fcs_lport_ns_s
*ns
= (struct bfa_fcs_lport_ns_s
*) cbarg
;
4689 struct bfa_fcs_lport_s
*port
= ns
->port
;
4690 struct ct_hdr_s
*cthdr
= NULL
;
4692 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
4697 if (req_status
!= BFA_STATUS_OK
) {
4698 bfa_trc(port
->fcs
, req_status
);
4699 port
->stats
.ns_rspnid_rsp_err
++;
4700 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4704 cthdr
= (struct ct_hdr_s
*) BFA_FCXP_RSP_PLD(fcxp
);
4705 cthdr
->cmd_rsp_code
= be16_to_cpu(cthdr
->cmd_rsp_code
);
4707 if (cthdr
->cmd_rsp_code
== CT_RSP_ACCEPT
) {
4708 port
->stats
.ns_rspnid_accepts
++;
4709 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_OK
);
4713 port
->stats
.ns_rspnid_rejects
++;
4714 bfa_trc(port
->fcs
, cthdr
->reason_code
);
4715 bfa_trc(port
->fcs
, cthdr
->exp_code
);
4716 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4720 * Register FC4-Types
4723 bfa_fcs_lport_ns_send_rft_id(void *ns_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
4725 struct bfa_fcs_lport_ns_s
*ns
= ns_cbarg
;
4726 struct bfa_fcs_lport_s
*port
= ns
->port
;
4729 struct bfa_fcxp_s
*fcxp
;
4731 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
4733 fcxp
= fcxp_alloced
? fcxp_alloced
:
4734 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
4736 port
->stats
.ns_rftid_alloc_wait
++;
4737 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &ns
->fcxp_wqe
,
4738 bfa_fcs_lport_ns_send_rft_id
, ns
, BFA_TRUE
);
4743 len
= fc_rftid_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
4744 bfa_fcs_lport_get_fcid(port
), 0, port
->port_cfg
.roles
);
4746 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
4747 FC_CLASS_3
, len
, &fchs
,
4748 bfa_fcs_lport_ns_rft_id_response
, (void *)ns
,
4749 FC_MAX_PDUSZ
, FC_FCCT_TOV
);
4751 port
->stats
.ns_rftid_sent
++;
4752 bfa_sm_send_event(ns
, NSSM_EVENT_RFTID_SENT
);
4756 bfa_fcs_lport_ns_rft_id_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
,
4757 void *cbarg
, bfa_status_t req_status
,
4758 u32 rsp_len
, u32 resid_len
,
4759 struct fchs_s
*rsp_fchs
)
4761 struct bfa_fcs_lport_ns_s
*ns
= (struct bfa_fcs_lport_ns_s
*) cbarg
;
4762 struct bfa_fcs_lport_s
*port
= ns
->port
;
4763 struct ct_hdr_s
*cthdr
= NULL
;
4765 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
4770 if (req_status
!= BFA_STATUS_OK
) {
4771 bfa_trc(port
->fcs
, req_status
);
4772 port
->stats
.ns_rftid_rsp_err
++;
4773 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4777 cthdr
= (struct ct_hdr_s
*) BFA_FCXP_RSP_PLD(fcxp
);
4778 cthdr
->cmd_rsp_code
= be16_to_cpu(cthdr
->cmd_rsp_code
);
4780 if (cthdr
->cmd_rsp_code
== CT_RSP_ACCEPT
) {
4781 port
->stats
.ns_rftid_accepts
++;
4782 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_OK
);
4786 port
->stats
.ns_rftid_rejects
++;
4787 bfa_trc(port
->fcs
, cthdr
->reason_code
);
4788 bfa_trc(port
->fcs
, cthdr
->exp_code
);
4789 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4793 * Register FC4-Features : Should be done after RFT_ID
4796 bfa_fcs_lport_ns_send_rff_id(void *ns_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
4798 struct bfa_fcs_lport_ns_s
*ns
= ns_cbarg
;
4799 struct bfa_fcs_lport_s
*port
= ns
->port
;
4802 struct bfa_fcxp_s
*fcxp
;
4805 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
4807 fcxp
= fcxp_alloced
? fcxp_alloced
:
4808 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
4810 port
->stats
.ns_rffid_alloc_wait
++;
4811 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &ns
->fcxp_wqe
,
4812 bfa_fcs_lport_ns_send_rff_id
, ns
, BFA_TRUE
);
4817 if (BFA_FCS_VPORT_IS_INITIATOR_MODE(ns
->port
))
4818 fc4_ftrs
= FC_GS_FCP_FC4_FEATURE_INITIATOR
;
4820 len
= fc_rffid_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
4821 bfa_fcs_lport_get_fcid(port
), 0,
4822 FC_TYPE_FCP
, fc4_ftrs
);
4824 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
4825 FC_CLASS_3
, len
, &fchs
,
4826 bfa_fcs_lport_ns_rff_id_response
, (void *)ns
,
4827 FC_MAX_PDUSZ
, FC_FCCT_TOV
);
4829 port
->stats
.ns_rffid_sent
++;
4830 bfa_sm_send_event(ns
, NSSM_EVENT_RFFID_SENT
);
4834 bfa_fcs_lport_ns_rff_id_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
,
4835 void *cbarg
, bfa_status_t req_status
,
4836 u32 rsp_len
, u32 resid_len
,
4837 struct fchs_s
*rsp_fchs
)
4839 struct bfa_fcs_lport_ns_s
*ns
= (struct bfa_fcs_lport_ns_s
*) cbarg
;
4840 struct bfa_fcs_lport_s
*port
= ns
->port
;
4841 struct ct_hdr_s
*cthdr
= NULL
;
4843 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
4848 if (req_status
!= BFA_STATUS_OK
) {
4849 bfa_trc(port
->fcs
, req_status
);
4850 port
->stats
.ns_rffid_rsp_err
++;
4851 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4855 cthdr
= (struct ct_hdr_s
*) BFA_FCXP_RSP_PLD(fcxp
);
4856 cthdr
->cmd_rsp_code
= be16_to_cpu(cthdr
->cmd_rsp_code
);
4858 if (cthdr
->cmd_rsp_code
== CT_RSP_ACCEPT
) {
4859 port
->stats
.ns_rffid_accepts
++;
4860 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_OK
);
4864 port
->stats
.ns_rffid_rejects
++;
4865 bfa_trc(port
->fcs
, cthdr
->reason_code
);
4866 bfa_trc(port
->fcs
, cthdr
->exp_code
);
4868 if (cthdr
->reason_code
== CT_RSN_NOT_SUPP
) {
4869 /* if this command is not supported, we don't retry */
4870 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_OK
);
4872 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4875 * Query Fabric for FC4-Types Devices.
4877 * TBD : Need to use a local (FCS private) response buffer, since the response
4878 * can be larger than 2K.
4881 bfa_fcs_lport_ns_send_gid_ft(void *ns_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
4883 struct bfa_fcs_lport_ns_s
*ns
= ns_cbarg
;
4884 struct bfa_fcs_lport_s
*port
= ns
->port
;
4887 struct bfa_fcxp_s
*fcxp
;
4889 bfa_trc(port
->fcs
, port
->pid
);
4891 fcxp
= fcxp_alloced
? fcxp_alloced
:
4892 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
4894 port
->stats
.ns_gidft_alloc_wait
++;
4895 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &ns
->fcxp_wqe
,
4896 bfa_fcs_lport_ns_send_gid_ft
, ns
, BFA_TRUE
);
4902 * This query is only initiated for FCP initiator mode.
4904 len
= fc_gid_ft_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
4905 ns
->port
->pid
, FC_TYPE_FCP
);
4907 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
4908 FC_CLASS_3
, len
, &fchs
,
4909 bfa_fcs_lport_ns_gid_ft_response
, (void *)ns
,
4910 bfa_fcxp_get_maxrsp(port
->fcs
->bfa
), FC_FCCT_TOV
);
4912 port
->stats
.ns_gidft_sent
++;
4914 bfa_sm_send_event(ns
, NSSM_EVENT_GIDFT_SENT
);
4918 bfa_fcs_lport_ns_gid_ft_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
,
4919 void *cbarg
, bfa_status_t req_status
,
4920 u32 rsp_len
, u32 resid_len
,
4921 struct fchs_s
*rsp_fchs
)
4923 struct bfa_fcs_lport_ns_s
*ns
= (struct bfa_fcs_lport_ns_s
*) cbarg
;
4924 struct bfa_fcs_lport_s
*port
= ns
->port
;
4925 struct ct_hdr_s
*cthdr
= NULL
;
4928 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
4933 if (req_status
!= BFA_STATUS_OK
) {
4934 bfa_trc(port
->fcs
, req_status
);
4935 port
->stats
.ns_gidft_rsp_err
++;
4936 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4940 if (resid_len
!= 0) {
4942 * TBD : we will need to allocate a larger buffer & retry the
4945 bfa_trc(port
->fcs
, rsp_len
);
4946 bfa_trc(port
->fcs
, resid_len
);
4950 cthdr
= (struct ct_hdr_s
*) BFA_FCXP_RSP_PLD(fcxp
);
4951 cthdr
->cmd_rsp_code
= be16_to_cpu(cthdr
->cmd_rsp_code
);
4953 switch (cthdr
->cmd_rsp_code
) {
4957 port
->stats
.ns_gidft_accepts
++;
4958 n_pids
= (fc_get_ctresp_pyld_len(rsp_len
) / sizeof(u32
));
4959 bfa_trc(port
->fcs
, n_pids
);
4960 bfa_fcs_lport_ns_process_gidft_pids(port
,
4961 (u32
*) (cthdr
+ 1),
4963 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_OK
);
4969 * Check the reason code & explanation.
4970 * There may not have been any FC4 devices in the fabric
4972 port
->stats
.ns_gidft_rejects
++;
4973 bfa_trc(port
->fcs
, cthdr
->reason_code
);
4974 bfa_trc(port
->fcs
, cthdr
->exp_code
);
4976 if ((cthdr
->reason_code
== CT_RSN_UNABLE_TO_PERF
)
4977 && (cthdr
->exp_code
== CT_NS_EXP_FT_NOT_REG
)) {
4979 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_OK
);
4982 * for all other errors, retry
4984 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4989 port
->stats
.ns_gidft_unknown_rsp
++;
4990 bfa_trc(port
->fcs
, cthdr
->cmd_rsp_code
);
4991 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4996 * This routine will be called by bfa_timer on timer timeouts.
4998 * param[in] port - pointer to bfa_fcs_lport_t.
5003 * Special Considerations:
5008 bfa_fcs_lport_ns_timeout(void *arg
)
5010 struct bfa_fcs_lport_ns_s
*ns
= (struct bfa_fcs_lport_ns_s
*) arg
;
5012 ns
->port
->stats
.ns_timeouts
++;
5013 bfa_sm_send_event(ns
, NSSM_EVENT_TIMEOUT
);
5017 * Process the PID list in GID_FT response
5020 bfa_fcs_lport_ns_process_gidft_pids(struct bfa_fcs_lport_s
*port
, u32
*pid_buf
,
5023 struct fcgs_gidft_resp_s
*gidft_entry
;
5024 struct bfa_fcs_rport_s
*rport
;
5026 struct bfa_fcs_fabric_s
*fabric
= port
->fabric
;
5027 struct bfa_fcs_vport_s
*vport
;
5028 struct list_head
*qe
;
5031 for (ii
= 0; ii
< n_pids
; ii
++) {
5032 gidft_entry
= (struct fcgs_gidft_resp_s
*) &pid_buf
[ii
];
5034 if (gidft_entry
->pid
== port
->pid
)
5038 * Ignore PID if it is of base port
5039 * (Avoid vports discovering base port as remote port)
5041 if (gidft_entry
->pid
== fabric
->bport
.pid
)
5045 * Ignore PID if it is of vport created on the same base port
5046 * (Avoid vport discovering every other vport created on the
5047 * same port as remote port)
5049 list_for_each(qe
, &fabric
->vport_q
) {
5050 vport
= (struct bfa_fcs_vport_s
*) qe
;
5051 if (vport
->lport
.pid
== gidft_entry
->pid
)
5061 * Check if this rport already exists
5063 rport
= bfa_fcs_lport_get_rport_by_pid(port
, gidft_entry
->pid
);
5064 if (rport
== NULL
) {
5066 * this is a new device. create rport
5068 rport
= bfa_fcs_rport_create(port
, gidft_entry
->pid
);
5071 * this rport already exists
5073 bfa_fcs_rport_scn(rport
);
5076 bfa_trc(port
->fcs
, gidft_entry
->pid
);
5079 * if the last entry bit is set, bail out.
5081 if (gidft_entry
->last
)
5087 * fcs_ns_public FCS nameserver public interfaces
5091 * Functions called by port/fab.
5092 * These will send relevant Events to the ns state machine.
5095 bfa_fcs_lport_ns_init(struct bfa_fcs_lport_s
*port
)
5097 struct bfa_fcs_lport_ns_s
*ns
= BFA_FCS_GET_NS_FROM_PORT(port
);
5100 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
5104 bfa_fcs_lport_ns_offline(struct bfa_fcs_lport_s
*port
)
5106 struct bfa_fcs_lport_ns_s
*ns
= BFA_FCS_GET_NS_FROM_PORT(port
);
5109 bfa_sm_send_event(ns
, NSSM_EVENT_PORT_OFFLINE
);
5113 bfa_fcs_lport_ns_online(struct bfa_fcs_lport_s
*port
)
5115 struct bfa_fcs_lport_ns_s
*ns
= BFA_FCS_GET_NS_FROM_PORT(port
);
5118 bfa_sm_send_event(ns
, NSSM_EVENT_PORT_ONLINE
);
5122 bfa_fcs_lport_ns_query(struct bfa_fcs_lport_s
*port
)
5124 struct bfa_fcs_lport_ns_s
*ns
= BFA_FCS_GET_NS_FROM_PORT(port
);
5126 bfa_trc(port
->fcs
, port
->pid
);
5127 if (bfa_sm_cmp_state(ns
, bfa_fcs_lport_ns_sm_online
))
5128 bfa_sm_send_event(ns
, NSSM_EVENT_NS_QUERY
);
5132 bfa_fcs_lport_ns_boot_target_disc(bfa_fcs_lport_t
*port
)
5135 struct bfa_fcs_rport_s
*rport
;
5137 wwn_t wwns
[BFA_PREBOOT_BOOTLUN_MAX
];
5140 bfa_iocfc_get_bootwwns(port
->fcs
->bfa
, &nwwns
, wwns
);
5142 for (ii
= 0 ; ii
< nwwns
; ++ii
) {
5143 rport
= bfa_fcs_rport_create_by_wwn(port
, wwns
[ii
]);
5149 bfa_fcs_lport_ns_util_send_rspn_id(void *cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
5151 struct bfa_fcs_lport_ns_s
*ns
= cbarg
;
5152 struct bfa_fcs_lport_s
*port
= ns
->port
;
5154 struct bfa_fcxp_s
*fcxp
;
5158 /* Avoid sending RSPN in the following states. */
5159 if (bfa_sm_cmp_state(ns
, bfa_fcs_lport_ns_sm_offline
) ||
5160 bfa_sm_cmp_state(ns
, bfa_fcs_lport_ns_sm_plogi_sending
) ||
5161 bfa_sm_cmp_state(ns
, bfa_fcs_lport_ns_sm_plogi
) ||
5162 bfa_sm_cmp_state(ns
, bfa_fcs_lport_ns_sm_plogi_retry
) ||
5163 bfa_sm_cmp_state(ns
, bfa_fcs_lport_ns_sm_rspn_id_retry
))
5166 memset(symbl
, 0, sizeof(symbl
));
5167 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
5169 fcxp
= fcxp_alloced
? fcxp_alloced
:
5170 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_FALSE
);
5172 port
->stats
.ns_rspnid_alloc_wait
++;
5173 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &ns
->fcxp_wqe
,
5174 bfa_fcs_lport_ns_util_send_rspn_id
, ns
, BFA_FALSE
);
5182 * For Vports, we append the vport's port symbolic name
5183 * to that of the base port.
5185 strlcpy(symbl
, (char *)&(bfa_fcs_lport_get_psym_name
5186 (bfa_fcs_get_base_port(port
->fcs
))),
5190 (char *)&(bfa_fcs_lport_get_psym_name(port
)),
5194 len
= fc_rspnid_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
5195 bfa_fcs_lport_get_fcid(port
), 0, symbl
);
5197 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
5198 FC_CLASS_3
, len
, &fchs
, NULL
, NULL
, FC_MAX_PDUSZ
, 0);
5200 port
->stats
.ns_rspnid_sent
++;
5207 #define FC_QOS_RSCN_EVENT 0x0c
5208 #define FC_FABRIC_NAME_RSCN_EVENT 0x0d
5211 * forward declarations
5213 static void bfa_fcs_lport_scn_send_scr(void *scn_cbarg
,
5214 struct bfa_fcxp_s
*fcxp_alloced
);
5215 static void bfa_fcs_lport_scn_scr_response(void *fcsarg
,
5216 struct bfa_fcxp_s
*fcxp
,
5218 bfa_status_t req_status
,
5221 struct fchs_s
*rsp_fchs
);
5222 static void bfa_fcs_lport_scn_send_ls_acc(struct bfa_fcs_lport_s
*port
,
5223 struct fchs_s
*rx_fchs
);
5224 static void bfa_fcs_lport_scn_timeout(void *arg
);
5227 * fcs_scm_sm FCS SCN state machine
5231 * VPort SCN State Machine events
5233 enum port_scn_event
{
5234 SCNSM_EVENT_PORT_ONLINE
= 1,
5235 SCNSM_EVENT_PORT_OFFLINE
= 2,
5236 SCNSM_EVENT_RSP_OK
= 3,
5237 SCNSM_EVENT_RSP_ERROR
= 4,
5238 SCNSM_EVENT_TIMEOUT
= 5,
5239 SCNSM_EVENT_SCR_SENT
= 6,
5242 static void bfa_fcs_lport_scn_sm_offline(struct bfa_fcs_lport_scn_s
*scn
,
5243 enum port_scn_event event
);
5244 static void bfa_fcs_lport_scn_sm_sending_scr(
5245 struct bfa_fcs_lport_scn_s
*scn
,
5246 enum port_scn_event event
);
5247 static void bfa_fcs_lport_scn_sm_scr(struct bfa_fcs_lport_scn_s
*scn
,
5248 enum port_scn_event event
);
5249 static void bfa_fcs_lport_scn_sm_scr_retry(struct bfa_fcs_lport_scn_s
*scn
,
5250 enum port_scn_event event
);
5251 static void bfa_fcs_lport_scn_sm_online(struct bfa_fcs_lport_scn_s
*scn
,
5252 enum port_scn_event event
);
5255 * Starting state - awaiting link up.
5258 bfa_fcs_lport_scn_sm_offline(struct bfa_fcs_lport_scn_s
*scn
,
5259 enum port_scn_event event
)
5262 case SCNSM_EVENT_PORT_ONLINE
:
5263 bfa_sm_set_state(scn
, bfa_fcs_lport_scn_sm_sending_scr
);
5264 bfa_fcs_lport_scn_send_scr(scn
, NULL
);
5267 case SCNSM_EVENT_PORT_OFFLINE
:
5271 bfa_sm_fault(scn
->port
->fcs
, event
);
5276 bfa_fcs_lport_scn_sm_sending_scr(struct bfa_fcs_lport_scn_s
*scn
,
5277 enum port_scn_event event
)
5280 case SCNSM_EVENT_SCR_SENT
:
5281 bfa_sm_set_state(scn
, bfa_fcs_lport_scn_sm_scr
);
5284 case SCNSM_EVENT_PORT_OFFLINE
:
5285 bfa_sm_set_state(scn
, bfa_fcs_lport_scn_sm_offline
);
5286 bfa_fcxp_walloc_cancel(scn
->port
->fcs
->bfa
, &scn
->fcxp_wqe
);
5290 bfa_sm_fault(scn
->port
->fcs
, event
);
5295 bfa_fcs_lport_scn_sm_scr(struct bfa_fcs_lport_scn_s
*scn
,
5296 enum port_scn_event event
)
5298 struct bfa_fcs_lport_s
*port
= scn
->port
;
5301 case SCNSM_EVENT_RSP_OK
:
5302 bfa_sm_set_state(scn
, bfa_fcs_lport_scn_sm_online
);
5305 case SCNSM_EVENT_RSP_ERROR
:
5306 bfa_sm_set_state(scn
, bfa_fcs_lport_scn_sm_scr_retry
);
5307 bfa_timer_start(port
->fcs
->bfa
, &scn
->timer
,
5308 bfa_fcs_lport_scn_timeout
, scn
,
5309 BFA_FCS_RETRY_TIMEOUT
);
5312 case SCNSM_EVENT_PORT_OFFLINE
:
5313 bfa_sm_set_state(scn
, bfa_fcs_lport_scn_sm_offline
);
5314 bfa_fcxp_discard(scn
->fcxp
);
5318 bfa_sm_fault(port
->fcs
, event
);
5323 bfa_fcs_lport_scn_sm_scr_retry(struct bfa_fcs_lport_scn_s
*scn
,
5324 enum port_scn_event event
)
5327 case SCNSM_EVENT_TIMEOUT
:
5328 bfa_sm_set_state(scn
, bfa_fcs_lport_scn_sm_sending_scr
);
5329 bfa_fcs_lport_scn_send_scr(scn
, NULL
);
5332 case SCNSM_EVENT_PORT_OFFLINE
:
5333 bfa_sm_set_state(scn
, bfa_fcs_lport_scn_sm_offline
);
5334 bfa_timer_stop(&scn
->timer
);
5338 bfa_sm_fault(scn
->port
->fcs
, event
);
5343 bfa_fcs_lport_scn_sm_online(struct bfa_fcs_lport_scn_s
*scn
,
5344 enum port_scn_event event
)
5347 case SCNSM_EVENT_PORT_OFFLINE
:
5348 bfa_sm_set_state(scn
, bfa_fcs_lport_scn_sm_offline
);
5352 bfa_sm_fault(scn
->port
->fcs
, event
);
5359 * fcs_scn_private FCS SCN private functions
5363 * This routine will be called to send a SCR command.
5366 bfa_fcs_lport_scn_send_scr(void *scn_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
5368 struct bfa_fcs_lport_scn_s
*scn
= scn_cbarg
;
5369 struct bfa_fcs_lport_s
*port
= scn
->port
;
5372 struct bfa_fcxp_s
*fcxp
;
5374 bfa_trc(port
->fcs
, port
->pid
);
5375 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
5377 fcxp
= fcxp_alloced
? fcxp_alloced
:
5378 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
5380 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &scn
->fcxp_wqe
,
5381 bfa_fcs_lport_scn_send_scr
, scn
, BFA_TRUE
);
5386 /* Handle VU registrations for Base port only */
5387 if ((!port
->vport
) && bfa_ioc_get_fcmode(&port
->fcs
->bfa
->ioc
)) {
5388 len
= fc_scr_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
5389 port
->fabric
->lps
->brcd_switch
,
5392 len
= fc_scr_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
5397 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
5398 FC_CLASS_3
, len
, &fchs
,
5399 bfa_fcs_lport_scn_scr_response
,
5400 (void *)scn
, FC_MAX_PDUSZ
, FC_ELS_TOV
);
5402 bfa_sm_send_event(scn
, SCNSM_EVENT_SCR_SENT
);
5406 bfa_fcs_lport_scn_scr_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
,
5407 void *cbarg
, bfa_status_t req_status
, u32 rsp_len
,
5408 u32 resid_len
, struct fchs_s
*rsp_fchs
)
5410 struct bfa_fcs_lport_scn_s
*scn
= (struct bfa_fcs_lport_scn_s
*) cbarg
;
5411 struct bfa_fcs_lport_s
*port
= scn
->port
;
5412 struct fc_els_cmd_s
*els_cmd
;
5413 struct fc_ls_rjt_s
*ls_rjt
;
5415 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
5420 if (req_status
!= BFA_STATUS_OK
) {
5421 bfa_trc(port
->fcs
, req_status
);
5422 bfa_sm_send_event(scn
, SCNSM_EVENT_RSP_ERROR
);
5426 els_cmd
= (struct fc_els_cmd_s
*) BFA_FCXP_RSP_PLD(fcxp
);
5428 switch (els_cmd
->els_code
) {
5431 bfa_sm_send_event(scn
, SCNSM_EVENT_RSP_OK
);
5436 ls_rjt
= (struct fc_ls_rjt_s
*) BFA_FCXP_RSP_PLD(fcxp
);
5438 bfa_trc(port
->fcs
, ls_rjt
->reason_code
);
5439 bfa_trc(port
->fcs
, ls_rjt
->reason_code_expl
);
5441 bfa_sm_send_event(scn
, SCNSM_EVENT_RSP_ERROR
);
5445 bfa_sm_send_event(scn
, SCNSM_EVENT_RSP_ERROR
);
5453 bfa_fcs_lport_scn_send_ls_acc(struct bfa_fcs_lport_s
*port
,
5454 struct fchs_s
*rx_fchs
)
5457 struct bfa_fcxp_s
*fcxp
;
5458 struct bfa_rport_s
*bfa_rport
= NULL
;
5461 bfa_trc(port
->fcs
, rx_fchs
->s_id
);
5463 fcxp
= bfa_fcs_fcxp_alloc(port
->fcs
, BFA_FALSE
);
5467 len
= fc_ls_acc_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
5468 rx_fchs
->s_id
, bfa_fcs_lport_get_fcid(port
),
5471 bfa_fcxp_send(fcxp
, bfa_rport
, port
->fabric
->vf_id
, port
->lp_tag
,
5472 BFA_FALSE
, FC_CLASS_3
, len
, &fchs
, NULL
, NULL
,
5477 * This routine will be called by bfa_timer on timer timeouts.
5479 * param[in] vport - pointer to bfa_fcs_lport_t.
5480 * param[out] vport_status - pointer to return vport status in
5485 * Special Considerations:
5490 bfa_fcs_lport_scn_timeout(void *arg
)
5492 struct bfa_fcs_lport_scn_s
*scn
= (struct bfa_fcs_lport_scn_s
*) arg
;
5494 bfa_sm_send_event(scn
, SCNSM_EVENT_TIMEOUT
);
5500 * fcs_scn_public FCS state change notification public interfaces
5504 * Functions called by port/fab
5507 bfa_fcs_lport_scn_init(struct bfa_fcs_lport_s
*port
)
5509 struct bfa_fcs_lport_scn_s
*scn
= BFA_FCS_GET_SCN_FROM_PORT(port
);
5512 bfa_sm_set_state(scn
, bfa_fcs_lport_scn_sm_offline
);
5516 bfa_fcs_lport_scn_offline(struct bfa_fcs_lport_s
*port
)
5518 struct bfa_fcs_lport_scn_s
*scn
= BFA_FCS_GET_SCN_FROM_PORT(port
);
5521 bfa_sm_send_event(scn
, SCNSM_EVENT_PORT_OFFLINE
);
5525 bfa_fcs_lport_fab_scn_online(struct bfa_fcs_lport_s
*port
)
5527 struct bfa_fcs_lport_scn_s
*scn
= BFA_FCS_GET_SCN_FROM_PORT(port
);
5530 bfa_sm_send_event(scn
, SCNSM_EVENT_PORT_ONLINE
);
5534 bfa_fcs_lport_scn_portid_rscn(struct bfa_fcs_lport_s
*port
, u32 rpid
)
5536 struct bfa_fcs_rport_s
*rport
;
5537 struct bfa_fcs_fabric_s
*fabric
= port
->fabric
;
5538 struct bfa_fcs_vport_s
*vport
;
5539 struct list_head
*qe
;
5541 bfa_trc(port
->fcs
, rpid
);
5544 * Ignore PID if it is of base port or of vports created on the
5545 * same base port. It is to avoid vports discovering base port or
5546 * other vports created on same base port as remote port
5548 if (rpid
== fabric
->bport
.pid
)
5551 list_for_each(qe
, &fabric
->vport_q
) {
5552 vport
= (struct bfa_fcs_vport_s
*) qe
;
5553 if (vport
->lport
.pid
== rpid
)
5557 * If this is an unknown device, then it just came online.
5558 * Otherwise let rport handle the RSCN event.
5560 rport
= bfa_fcs_lport_get_rport_by_pid(port
, rpid
);
5562 rport
= bfa_fcs_lport_get_rport_by_old_pid(port
, rpid
);
5564 if (rport
== NULL
) {
5566 * If min cfg mode is enabled, we donot need to
5567 * discover any new rports.
5569 if (!__fcs_min_cfg(port
->fcs
))
5570 rport
= bfa_fcs_rport_create(port
, rpid
);
5572 bfa_fcs_rport_scn(rport
);
5576 * rscn format based PID comparison
5578 #define __fc_pid_match(__c0, __c1, __fmt) \
5579 (((__fmt) == FC_RSCN_FORMAT_FABRIC) || \
5580 (((__fmt) == FC_RSCN_FORMAT_DOMAIN) && \
5581 ((__c0)[0] == (__c1)[0])) || \
5582 (((__fmt) == FC_RSCN_FORMAT_AREA) && \
5583 ((__c0)[0] == (__c1)[0]) && \
5584 ((__c0)[1] == (__c1)[1])))
5587 bfa_fcs_lport_scn_multiport_rscn(struct bfa_fcs_lport_s
*port
,
5588 enum fc_rscn_format format
,
5591 struct bfa_fcs_rport_s
*rport
;
5592 struct list_head
*qe
, *qe_next
;
5595 bfa_trc(port
->fcs
, format
);
5596 bfa_trc(port
->fcs
, rscn_pid
);
5598 c0
= (u8
*) &rscn_pid
;
5600 list_for_each_safe(qe
, qe_next
, &port
->rport_q
) {
5601 rport
= (struct bfa_fcs_rport_s
*) qe
;
5602 c1
= (u8
*) &rport
->pid
;
5603 if (__fc_pid_match(c0
, c1
, format
))
5604 bfa_fcs_rport_scn(rport
);
5610 bfa_fcs_lport_scn_process_rscn(struct bfa_fcs_lport_s
*port
,
5611 struct fchs_s
*fchs
, u32 len
)
5613 struct fc_rscn_pl_s
*rscn
= (struct fc_rscn_pl_s
*) (fchs
+ 1);
5616 bfa_boolean_t nsquery
= BFA_FALSE
, found
;
5620 (be16_to_cpu(rscn
->payldlen
) -
5621 sizeof(u32
)) / sizeof(rscn
->event
[0]);
5623 bfa_trc(port
->fcs
, num_entries
);
5625 port
->stats
.num_rscn
++;
5627 bfa_fcs_lport_scn_send_ls_acc(port
, fchs
);
5629 for (i
= 0; i
< num_entries
; i
++) {
5630 rscn_pid
= rscn
->event
[i
].portid
;
5632 bfa_trc(port
->fcs
, rscn
->event
[i
].format
);
5633 bfa_trc(port
->fcs
, rscn_pid
);
5635 /* check for duplicate entries in the list */
5637 for (j
= 0; j
< i
; j
++) {
5638 if (rscn
->event
[j
].portid
== rscn_pid
) {
5644 /* if found in down the list, pid has been already processed */
5646 bfa_trc(port
->fcs
, rscn_pid
);
5650 switch (rscn
->event
[i
].format
) {
5651 case FC_RSCN_FORMAT_PORTID
:
5652 if (rscn
->event
[i
].qualifier
== FC_QOS_RSCN_EVENT
) {
5654 * Ignore this event.
5655 * f/w would have processed it
5657 bfa_trc(port
->fcs
, rscn_pid
);
5659 port
->stats
.num_portid_rscn
++;
5660 bfa_fcs_lport_scn_portid_rscn(port
, rscn_pid
);
5664 case FC_RSCN_FORMAT_FABRIC
:
5665 if (rscn
->event
[i
].qualifier
==
5666 FC_FABRIC_NAME_RSCN_EVENT
) {
5667 bfa_fcs_lport_ms_fabric_rscn(port
);
5670 /* !!!!!!!!! Fall Through !!!!!!!!!!!!! */
5672 case FC_RSCN_FORMAT_AREA
:
5673 case FC_RSCN_FORMAT_DOMAIN
:
5675 bfa_fcs_lport_scn_multiport_rscn(port
,
5676 rscn
->event
[i
].format
,
5688 * If any of area, domain or fabric RSCN is received, do a fresh
5689 * discovery to find new devices.
5692 bfa_fcs_lport_ns_query(port
);
5699 * fcs_port_api BFA FCS port API
5701 struct bfa_fcs_lport_s
*
5702 bfa_fcs_get_base_port(struct bfa_fcs_s
*fcs
)
5704 return &fcs
->fabric
.bport
;
5708 bfa_fcs_lport_get_rport(struct bfa_fcs_lport_s
*port
, wwn_t wwn
, int index
,
5709 int nrports
, bfa_boolean_t bwwn
)
5711 struct list_head
*qh
, *qe
;
5712 struct bfa_fcs_rport_s
*rport
= NULL
;
5714 struct bfa_fcs_s
*fcs
;
5716 if (port
== NULL
|| nrports
== 0)
5720 bfa_trc(fcs
, (u32
) nrports
);
5723 qh
= &port
->rport_q
;
5724 qe
= bfa_q_first(qh
);
5726 while ((qe
!= qh
) && (i
< nrports
)) {
5727 rport
= (struct bfa_fcs_rport_s
*) qe
;
5728 if (bfa_ntoh3b(rport
->pid
) > 0xFFF000) {
5729 qe
= bfa_q_next(qe
);
5730 bfa_trc(fcs
, (u32
) rport
->pwwn
);
5731 bfa_trc(fcs
, rport
->pid
);
5737 if (!memcmp(&wwn
, &rport
->pwwn
, 8))
5745 qe
= bfa_q_next(qe
);
5756 bfa_fcs_lport_get_rport_quals(struct bfa_fcs_lport_s
*port
,
5757 struct bfa_rport_qualifier_s rports
[], int *nrports
)
5759 struct list_head
*qh
, *qe
;
5760 struct bfa_fcs_rport_s
*rport
= NULL
;
5762 struct bfa_fcs_s
*fcs
;
5764 if (port
== NULL
|| rports
== NULL
|| *nrports
== 0)
5768 bfa_trc(fcs
, (u32
) *nrports
);
5771 qh
= &port
->rport_q
;
5772 qe
= bfa_q_first(qh
);
5774 while ((qe
!= qh
) && (i
< *nrports
)) {
5775 rport
= (struct bfa_fcs_rport_s
*) qe
;
5776 if (bfa_ntoh3b(rport
->pid
) > 0xFFF000) {
5777 qe
= bfa_q_next(qe
);
5778 bfa_trc(fcs
, (u32
) rport
->pwwn
);
5779 bfa_trc(fcs
, rport
->pid
);
5784 if (!rport
->pwwn
&& !rport
->pid
) {
5785 qe
= bfa_q_next(qe
);
5789 rports
[i
].pwwn
= rport
->pwwn
;
5790 rports
[i
].pid
= rport
->pid
;
5793 qe
= bfa_q_next(qe
);
5801 * Iterate's through all the rport's in the given port to
5802 * determine the maximum operating speed.
5804 * !!!! To be used in TRL Functionality only !!!!
5807 bfa_fcs_lport_get_rport_max_speed(bfa_fcs_lport_t
*port
)
5809 struct list_head
*qh
, *qe
;
5810 struct bfa_fcs_rport_s
*rport
= NULL
;
5811 struct bfa_fcs_s
*fcs
;
5812 bfa_port_speed_t max_speed
= 0;
5813 struct bfa_port_attr_s port_attr
;
5814 bfa_port_speed_t port_speed
, rport_speed
;
5815 bfa_boolean_t trl_enabled
= bfa_fcport_is_ratelim(port
->fcs
->bfa
);
5823 /* Get Physical port's current speed */
5824 bfa_fcport_get_attr(port
->fcs
->bfa
, &port_attr
);
5825 port_speed
= port_attr
.speed
;
5826 bfa_trc(fcs
, port_speed
);
5828 qh
= &port
->rport_q
;
5829 qe
= bfa_q_first(qh
);
5832 rport
= (struct bfa_fcs_rport_s
*) qe
;
5833 if ((bfa_ntoh3b(rport
->pid
) > 0xFFF000) ||
5834 (bfa_fcs_rport_get_state(rport
) == BFA_RPORT_OFFLINE
) ||
5835 (rport
->scsi_function
!= BFA_RPORT_TARGET
)) {
5836 qe
= bfa_q_next(qe
);
5840 rport_speed
= rport
->rpf
.rpsc_speed
;
5841 if ((trl_enabled
) && (rport_speed
==
5842 BFA_PORT_SPEED_UNKNOWN
)) {
5843 /* Use default ratelim speed setting */
5845 bfa_fcport_get_ratelim_speed(port
->fcs
->bfa
);
5848 if (rport_speed
> max_speed
)
5849 max_speed
= rport_speed
;
5851 qe
= bfa_q_next(qe
);
5854 if (max_speed
> port_speed
)
5855 max_speed
= port_speed
;
5857 bfa_trc(fcs
, max_speed
);
5861 struct bfa_fcs_lport_s
*
5862 bfa_fcs_lookup_port(struct bfa_fcs_s
*fcs
, u16 vf_id
, wwn_t lpwwn
)
5864 struct bfa_fcs_vport_s
*vport
;
5867 WARN_ON(fcs
== NULL
);
5869 vf
= bfa_fcs_vf_lookup(fcs
, vf_id
);
5871 bfa_trc(fcs
, vf_id
);
5875 if (!lpwwn
|| (vf
->bport
.port_cfg
.pwwn
== lpwwn
))
5878 vport
= bfa_fcs_fabric_vport_lookup(vf
, lpwwn
);
5880 return &vport
->lport
;
5886 * API corresponding to NPIV_VPORT_GETINFO.
5889 bfa_fcs_lport_get_info(struct bfa_fcs_lport_s
*port
,
5890 struct bfa_lport_info_s
*port_info
)
5893 bfa_trc(port
->fcs
, port
->fabric
->fabric_name
);
5895 if (port
->vport
== NULL
) {
5897 * This is a Physical port
5899 port_info
->port_type
= BFA_LPORT_TYPE_PHYSICAL
;
5902 * @todo : need to fix the state & reason
5904 port_info
->port_state
= 0;
5905 port_info
->offline_reason
= 0;
5907 port_info
->port_wwn
= bfa_fcs_lport_get_pwwn(port
);
5908 port_info
->node_wwn
= bfa_fcs_lport_get_nwwn(port
);
5910 port_info
->max_vports_supp
=
5911 bfa_lps_get_max_vport(port
->fcs
->bfa
);
5912 port_info
->num_vports_inuse
=
5913 port
->fabric
->num_vports
;
5914 port_info
->max_rports_supp
= BFA_FCS_MAX_RPORTS_SUPP
;
5915 port_info
->num_rports_inuse
= port
->num_rports
;
5918 * This is a virtual port
5920 port_info
->port_type
= BFA_LPORT_TYPE_VIRTUAL
;
5923 * @todo : need to fix the state & reason
5925 port_info
->port_state
= 0;
5926 port_info
->offline_reason
= 0;
5928 port_info
->port_wwn
= bfa_fcs_lport_get_pwwn(port
);
5929 port_info
->node_wwn
= bfa_fcs_lport_get_nwwn(port
);
5934 bfa_fcs_lport_get_stats(struct bfa_fcs_lport_s
*fcs_port
,
5935 struct bfa_lport_stats_s
*port_stats
)
5937 *port_stats
= fcs_port
->stats
;
5941 bfa_fcs_lport_clear_stats(struct bfa_fcs_lport_s
*fcs_port
)
5943 memset(&fcs_port
->stats
, 0, sizeof(struct bfa_lport_stats_s
));
5947 * Let new loop map create missing rports
5950 bfa_fcs_lport_lip_scn_online(struct bfa_fcs_lport_s
*port
)
5952 bfa_fcs_lport_loop_online(port
);
5956 * FCS virtual port state machine
5959 #define __vport_fcs(__vp) ((__vp)->lport.fcs)
5960 #define __vport_pwwn(__vp) ((__vp)->lport.port_cfg.pwwn)
5961 #define __vport_nwwn(__vp) ((__vp)->lport.port_cfg.nwwn)
5962 #define __vport_bfa(__vp) ((__vp)->lport.fcs->bfa)
5963 #define __vport_fcid(__vp) ((__vp)->lport.pid)
5964 #define __vport_fabric(__vp) ((__vp)->lport.fabric)
5965 #define __vport_vfid(__vp) ((__vp)->lport.fabric->vf_id)
5967 #define BFA_FCS_VPORT_MAX_RETRIES 5
5969 * Forward declarations
5971 static void bfa_fcs_vport_do_fdisc(struct bfa_fcs_vport_s
*vport
);
5972 static void bfa_fcs_vport_timeout(void *vport_arg
);
5973 static void bfa_fcs_vport_do_logo(struct bfa_fcs_vport_s
*vport
);
5974 static void bfa_fcs_vport_free(struct bfa_fcs_vport_s
*vport
);
5977 * fcs_vport_sm FCS virtual port state machine
5981 * VPort State Machine events
5983 enum bfa_fcs_vport_event
{
5984 BFA_FCS_VPORT_SM_CREATE
= 1, /* vport create event */
5985 BFA_FCS_VPORT_SM_DELETE
= 2, /* vport delete event */
5986 BFA_FCS_VPORT_SM_START
= 3, /* vport start request */
5987 BFA_FCS_VPORT_SM_STOP
= 4, /* stop: unsupported */
5988 BFA_FCS_VPORT_SM_ONLINE
= 5, /* fabric online */
5989 BFA_FCS_VPORT_SM_OFFLINE
= 6, /* fabric offline event */
5990 BFA_FCS_VPORT_SM_FRMSENT
= 7, /* fdisc/logo sent events */
5991 BFA_FCS_VPORT_SM_RSP_OK
= 8, /* good response */
5992 BFA_FCS_VPORT_SM_RSP_ERROR
= 9, /* error/bad response */
5993 BFA_FCS_VPORT_SM_TIMEOUT
= 10, /* delay timer event */
5994 BFA_FCS_VPORT_SM_DELCOMP
= 11, /* lport delete completion */
5995 BFA_FCS_VPORT_SM_RSP_DUP_WWN
= 12, /* Dup wnn error*/
5996 BFA_FCS_VPORT_SM_RSP_FAILED
= 13, /* non-retryable failure */
5997 BFA_FCS_VPORT_SM_STOPCOMP
= 14, /* vport delete completion */
5998 BFA_FCS_VPORT_SM_FABRIC_MAX
= 15, /* max vports on fabric */
6001 static void bfa_fcs_vport_sm_uninit(struct bfa_fcs_vport_s
*vport
,
6002 enum bfa_fcs_vport_event event
);
6003 static void bfa_fcs_vport_sm_created(struct bfa_fcs_vport_s
*vport
,
6004 enum bfa_fcs_vport_event event
);
6005 static void bfa_fcs_vport_sm_offline(struct bfa_fcs_vport_s
*vport
,
6006 enum bfa_fcs_vport_event event
);
6007 static void bfa_fcs_vport_sm_fdisc(struct bfa_fcs_vport_s
*vport
,
6008 enum bfa_fcs_vport_event event
);
6009 static void bfa_fcs_vport_sm_fdisc_retry(struct bfa_fcs_vport_s
*vport
,
6010 enum bfa_fcs_vport_event event
);
6011 static void bfa_fcs_vport_sm_fdisc_rsp_wait(struct bfa_fcs_vport_s
*vport
,
6012 enum bfa_fcs_vport_event event
);
6013 static void bfa_fcs_vport_sm_online(struct bfa_fcs_vport_s
*vport
,
6014 enum bfa_fcs_vport_event event
);
6015 static void bfa_fcs_vport_sm_deleting(struct bfa_fcs_vport_s
*vport
,
6016 enum bfa_fcs_vport_event event
);
6017 static void bfa_fcs_vport_sm_cleanup(struct bfa_fcs_vport_s
*vport
,
6018 enum bfa_fcs_vport_event event
);
6019 static void bfa_fcs_vport_sm_logo(struct bfa_fcs_vport_s
*vport
,
6020 enum bfa_fcs_vport_event event
);
6021 static void bfa_fcs_vport_sm_error(struct bfa_fcs_vport_s
*vport
,
6022 enum bfa_fcs_vport_event event
);
6023 static void bfa_fcs_vport_sm_stopping(struct bfa_fcs_vport_s
*vport
,
6024 enum bfa_fcs_vport_event event
);
6025 static void bfa_fcs_vport_sm_logo_for_stop(struct bfa_fcs_vport_s
*vport
,
6026 enum bfa_fcs_vport_event event
);
6028 static struct bfa_sm_table_s vport_sm_table
[] = {
6029 {BFA_SM(bfa_fcs_vport_sm_uninit
), BFA_FCS_VPORT_UNINIT
},
6030 {BFA_SM(bfa_fcs_vport_sm_created
), BFA_FCS_VPORT_CREATED
},
6031 {BFA_SM(bfa_fcs_vport_sm_offline
), BFA_FCS_VPORT_OFFLINE
},
6032 {BFA_SM(bfa_fcs_vport_sm_fdisc
), BFA_FCS_VPORT_FDISC
},
6033 {BFA_SM(bfa_fcs_vport_sm_fdisc_retry
), BFA_FCS_VPORT_FDISC_RETRY
},
6034 {BFA_SM(bfa_fcs_vport_sm_fdisc_rsp_wait
), BFA_FCS_VPORT_FDISC_RSP_WAIT
},
6035 {BFA_SM(bfa_fcs_vport_sm_online
), BFA_FCS_VPORT_ONLINE
},
6036 {BFA_SM(bfa_fcs_vport_sm_deleting
), BFA_FCS_VPORT_DELETING
},
6037 {BFA_SM(bfa_fcs_vport_sm_cleanup
), BFA_FCS_VPORT_CLEANUP
},
6038 {BFA_SM(bfa_fcs_vport_sm_logo
), BFA_FCS_VPORT_LOGO
},
6039 {BFA_SM(bfa_fcs_vport_sm_error
), BFA_FCS_VPORT_ERROR
}
6046 bfa_fcs_vport_sm_uninit(struct bfa_fcs_vport_s
*vport
,
6047 enum bfa_fcs_vport_event event
)
6049 bfa_trc(__vport_fcs(vport
), __vport_pwwn(vport
));
6050 bfa_trc(__vport_fcs(vport
), event
);
6053 case BFA_FCS_VPORT_SM_CREATE
:
6054 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_created
);
6055 bfa_fcs_fabric_addvport(__vport_fabric(vport
), vport
);
6059 bfa_sm_fault(__vport_fcs(vport
), event
);
6064 * Created state - a start event is required to start up the state machine.
6067 bfa_fcs_vport_sm_created(struct bfa_fcs_vport_s
*vport
,
6068 enum bfa_fcs_vport_event event
)
6070 bfa_trc(__vport_fcs(vport
), __vport_pwwn(vport
));
6071 bfa_trc(__vport_fcs(vport
), event
);
6074 case BFA_FCS_VPORT_SM_START
:
6075 if (bfa_sm_cmp_state(__vport_fabric(vport
),
6076 bfa_fcs_fabric_sm_online
)
6077 && bfa_fcs_fabric_npiv_capable(__vport_fabric(vport
))) {
6078 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_fdisc
);
6079 bfa_fcs_vport_do_fdisc(vport
);
6082 * Fabric is offline or not NPIV capable, stay in
6085 vport
->vport_stats
.fab_no_npiv
++;
6086 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_offline
);
6090 case BFA_FCS_VPORT_SM_DELETE
:
6091 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_cleanup
);
6092 bfa_fcs_lport_delete(&vport
->lport
);
6095 case BFA_FCS_VPORT_SM_ONLINE
:
6096 case BFA_FCS_VPORT_SM_OFFLINE
:
6098 * Ignore ONLINE/OFFLINE events from fabric
6099 * till vport is started.
6104 bfa_sm_fault(__vport_fcs(vport
), event
);
6109 * Offline state - awaiting ONLINE event from fabric SM.
6112 bfa_fcs_vport_sm_offline(struct bfa_fcs_vport_s
*vport
,
6113 enum bfa_fcs_vport_event event
)
6115 bfa_trc(__vport_fcs(vport
), __vport_pwwn(vport
));
6116 bfa_trc(__vport_fcs(vport
), event
);
6119 case BFA_FCS_VPORT_SM_DELETE
:
6120 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_cleanup
);
6121 bfa_fcs_lport_delete(&vport
->lport
);
6124 case BFA_FCS_VPORT_SM_ONLINE
:
6125 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_fdisc
);
6126 vport
->fdisc_retries
= 0;
6127 bfa_fcs_vport_do_fdisc(vport
);
6130 case BFA_FCS_VPORT_SM_STOP
:
6131 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_cleanup
);
6132 bfa_sm_send_event(&vport
->lport
, BFA_FCS_PORT_SM_STOP
);
6135 case BFA_FCS_VPORT_SM_OFFLINE
:
6137 * This can happen if the vport couldn't be initialzied
6138 * due the fact that the npiv was not enabled on the switch.
6139 * In that case we will put the vport in offline state.
6140 * However, the link can go down and cause the this event to
6141 * be sent when we are already offline. Ignore it.
6146 bfa_sm_fault(__vport_fcs(vport
), event
);
6152 * FDISC is sent and awaiting reply from fabric.
6155 bfa_fcs_vport_sm_fdisc(struct bfa_fcs_vport_s
*vport
,
6156 enum bfa_fcs_vport_event event
)
6158 bfa_trc(__vport_fcs(vport
), __vport_pwwn(vport
));
6159 bfa_trc(__vport_fcs(vport
), event
);
6162 case BFA_FCS_VPORT_SM_DELETE
:
6163 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_fdisc_rsp_wait
);
6166 case BFA_FCS_VPORT_SM_OFFLINE
:
6167 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_offline
);
6168 bfa_sm_send_event(vport
->lps
, BFA_LPS_SM_OFFLINE
);
6171 case BFA_FCS_VPORT_SM_RSP_OK
:
6172 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_online
);
6173 bfa_fcs_lport_online(&vport
->lport
);
6176 case BFA_FCS_VPORT_SM_RSP_ERROR
:
6177 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_fdisc_retry
);
6178 bfa_timer_start(__vport_bfa(vport
), &vport
->timer
,
6179 bfa_fcs_vport_timeout
, vport
,
6180 BFA_FCS_RETRY_TIMEOUT
);
6183 case BFA_FCS_VPORT_SM_RSP_FAILED
:
6184 case BFA_FCS_VPORT_SM_FABRIC_MAX
:
6185 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_offline
);
6188 case BFA_FCS_VPORT_SM_RSP_DUP_WWN
:
6189 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_error
);
6193 bfa_sm_fault(__vport_fcs(vport
), event
);
6198 * FDISC attempt failed - a timer is active to retry FDISC.
6201 bfa_fcs_vport_sm_fdisc_retry(struct bfa_fcs_vport_s
*vport
,
6202 enum bfa_fcs_vport_event event
)
6204 bfa_trc(__vport_fcs(vport
), __vport_pwwn(vport
));
6205 bfa_trc(__vport_fcs(vport
), event
);
6208 case BFA_FCS_VPORT_SM_DELETE
:
6209 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_cleanup
);
6210 bfa_timer_stop(&vport
->timer
);
6211 bfa_fcs_lport_delete(&vport
->lport
);
6214 case BFA_FCS_VPORT_SM_OFFLINE
:
6215 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_offline
);
6216 bfa_timer_stop(&vport
->timer
);
6219 case BFA_FCS_VPORT_SM_TIMEOUT
:
6220 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_fdisc
);
6221 vport
->vport_stats
.fdisc_retries
++;
6222 vport
->fdisc_retries
++;
6223 bfa_fcs_vport_do_fdisc(vport
);
6227 bfa_sm_fault(__vport_fcs(vport
), event
);
6232 * FDISC is in progress and we got a vport delete request -
6233 * this is a wait state while we wait for fdisc response and
6234 * we will transition to the appropriate state - on rsp status.
6237 bfa_fcs_vport_sm_fdisc_rsp_wait(struct bfa_fcs_vport_s
*vport
,
6238 enum bfa_fcs_vport_event event
)
6240 bfa_trc(__vport_fcs(vport
), __vport_pwwn(vport
));
6241 bfa_trc(__vport_fcs(vport
), event
);
6244 case BFA_FCS_VPORT_SM_RSP_OK
:
6245 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_deleting
);
6246 bfa_fcs_lport_delete(&vport
->lport
);
6249 case BFA_FCS_VPORT_SM_DELETE
:
6252 case BFA_FCS_VPORT_SM_OFFLINE
:
6253 case BFA_FCS_VPORT_SM_RSP_ERROR
:
6254 case BFA_FCS_VPORT_SM_RSP_FAILED
:
6255 case BFA_FCS_VPORT_SM_FABRIC_MAX
:
6256 case BFA_FCS_VPORT_SM_RSP_DUP_WWN
:
6257 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_cleanup
);
6258 bfa_sm_send_event(vport
->lps
, BFA_LPS_SM_OFFLINE
);
6259 bfa_fcs_lport_delete(&vport
->lport
);
6263 bfa_sm_fault(__vport_fcs(vport
), event
);
6268 * Vport is online (FDISC is complete).
6271 bfa_fcs_vport_sm_online(struct bfa_fcs_vport_s
*vport
,
6272 enum bfa_fcs_vport_event event
)
6274 bfa_trc(__vport_fcs(vport
), __vport_pwwn(vport
));
6275 bfa_trc(__vport_fcs(vport
), event
);
6278 case BFA_FCS_VPORT_SM_DELETE
:
6279 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_deleting
);
6280 bfa_fcs_lport_delete(&vport
->lport
);
6283 case BFA_FCS_VPORT_SM_STOP
:
6284 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_stopping
);
6285 bfa_sm_send_event(&vport
->lport
, BFA_FCS_PORT_SM_STOP
);
6288 case BFA_FCS_VPORT_SM_OFFLINE
:
6289 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_offline
);
6290 bfa_sm_send_event(vport
->lps
, BFA_LPS_SM_OFFLINE
);
6291 bfa_fcs_lport_offline(&vport
->lport
);
6295 bfa_sm_fault(__vport_fcs(vport
), event
);
6300 * Vport is being stopped - awaiting lport stop completion to send
6304 bfa_fcs_vport_sm_stopping(struct bfa_fcs_vport_s
*vport
,
6305 enum bfa_fcs_vport_event event
)
6307 bfa_trc(__vport_fcs(vport
), __vport_pwwn(vport
));
6308 bfa_trc(__vport_fcs(vport
), event
);
6311 case BFA_FCS_VPORT_SM_STOPCOMP
:
6312 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_logo_for_stop
);
6313 bfa_fcs_vport_do_logo(vport
);
6316 case BFA_FCS_VPORT_SM_OFFLINE
:
6317 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_cleanup
);
6321 bfa_sm_fault(__vport_fcs(vport
), event
);
6326 * Vport is being deleted - awaiting lport delete completion to send
6330 bfa_fcs_vport_sm_deleting(struct bfa_fcs_vport_s
*vport
,
6331 enum bfa_fcs_vport_event event
)
6333 bfa_trc(__vport_fcs(vport
), __vport_pwwn(vport
));
6334 bfa_trc(__vport_fcs(vport
), event
);
6337 case BFA_FCS_VPORT_SM_DELETE
:
6340 case BFA_FCS_VPORT_SM_DELCOMP
:
6341 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_logo
);
6342 bfa_fcs_vport_do_logo(vport
);
6345 case BFA_FCS_VPORT_SM_OFFLINE
:
6346 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_cleanup
);
6350 bfa_sm_fault(__vport_fcs(vport
), event
);
6356 * This state will be set when the Vport Creation fails due
6357 * to errors like Dup WWN. In this state only operation allowed
6358 * is a Vport Delete.
6361 bfa_fcs_vport_sm_error(struct bfa_fcs_vport_s
*vport
,
6362 enum bfa_fcs_vport_event event
)
6364 bfa_trc(__vport_fcs(vport
), __vport_pwwn(vport
));
6365 bfa_trc(__vport_fcs(vport
), event
);
6368 case BFA_FCS_VPORT_SM_DELETE
:
6369 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_cleanup
);
6370 bfa_fcs_lport_delete(&vport
->lport
);
6374 bfa_trc(__vport_fcs(vport
), event
);
6379 * Lport cleanup is in progress since vport is being deleted. Fabric is
6380 * offline, so no LOGO is needed to complete vport deletion.
6383 bfa_fcs_vport_sm_cleanup(struct bfa_fcs_vport_s
*vport
,
6384 enum bfa_fcs_vport_event event
)
6386 bfa_trc(__vport_fcs(vport
), __vport_pwwn(vport
));
6387 bfa_trc(__vport_fcs(vport
), event
);
6390 case BFA_FCS_VPORT_SM_DELCOMP
:
6391 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_uninit
);
6392 bfa_fcs_vport_free(vport
);
6395 case BFA_FCS_VPORT_SM_STOPCOMP
:
6396 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_created
);
6399 case BFA_FCS_VPORT_SM_DELETE
:
6403 bfa_sm_fault(__vport_fcs(vport
), event
);
6408 * LOGO is sent to fabric. Vport stop is in progress. Lport stop cleanup
6412 bfa_fcs_vport_sm_logo_for_stop(struct bfa_fcs_vport_s
*vport
,
6413 enum bfa_fcs_vport_event event
)
6415 bfa_trc(__vport_fcs(vport
), __vport_pwwn(vport
));
6416 bfa_trc(__vport_fcs(vport
), event
);
6419 case BFA_FCS_VPORT_SM_OFFLINE
:
6420 bfa_sm_send_event(vport
->lps
, BFA_LPS_SM_OFFLINE
);
6422 * !!! fall through !!!
6425 case BFA_FCS_VPORT_SM_RSP_OK
:
6426 case BFA_FCS_VPORT_SM_RSP_ERROR
:
6427 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_created
);
6431 bfa_sm_fault(__vport_fcs(vport
), event
);
6436 * LOGO is sent to fabric. Vport delete is in progress. Lport delete cleanup
6440 bfa_fcs_vport_sm_logo(struct bfa_fcs_vport_s
*vport
,
6441 enum bfa_fcs_vport_event event
)
6443 bfa_trc(__vport_fcs(vport
), __vport_pwwn(vport
));
6444 bfa_trc(__vport_fcs(vport
), event
);
6447 case BFA_FCS_VPORT_SM_OFFLINE
:
6448 bfa_sm_send_event(vport
->lps
, BFA_LPS_SM_OFFLINE
);
6450 * !!! fall through !!!
6453 case BFA_FCS_VPORT_SM_RSP_OK
:
6454 case BFA_FCS_VPORT_SM_RSP_ERROR
:
6455 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_uninit
);
6456 bfa_fcs_vport_free(vport
);
6459 case BFA_FCS_VPORT_SM_DELETE
:
6463 bfa_sm_fault(__vport_fcs(vport
), event
);
6470 * fcs_vport_private FCS virtual port private functions
6473 * Send AEN notification
6476 bfa_fcs_vport_aen_post(struct bfa_fcs_lport_s
*port
,
6477 enum bfa_lport_aen_event event
)
6479 struct bfad_s
*bfad
= (struct bfad_s
*)port
->fabric
->fcs
->bfad
;
6480 struct bfa_aen_entry_s
*aen_entry
;
6482 bfad_get_aen_entry(bfad
, aen_entry
);
6486 aen_entry
->aen_data
.lport
.vf_id
= port
->fabric
->vf_id
;
6487 aen_entry
->aen_data
.lport
.roles
= port
->port_cfg
.roles
;
6488 aen_entry
->aen_data
.lport
.ppwwn
= bfa_fcs_lport_get_pwwn(
6489 bfa_fcs_get_base_port(port
->fcs
));
6490 aen_entry
->aen_data
.lport
.lpwwn
= bfa_fcs_lport_get_pwwn(port
);
6492 /* Send the AEN notification */
6493 bfad_im_post_vendor_event(aen_entry
, bfad
, ++port
->fcs
->fcs_aen_seq
,
6494 BFA_AEN_CAT_LPORT
, event
);
6498 * This routine will be called to send a FDISC command.
6501 bfa_fcs_vport_do_fdisc(struct bfa_fcs_vport_s
*vport
)
6503 bfa_lps_fdisc(vport
->lps
, vport
,
6504 bfa_fcport_get_maxfrsize(__vport_bfa(vport
)),
6505 __vport_pwwn(vport
), __vport_nwwn(vport
));
6506 vport
->vport_stats
.fdisc_sent
++;
6510 bfa_fcs_vport_fdisc_rejected(struct bfa_fcs_vport_s
*vport
)
6512 u8 lsrjt_rsn
= vport
->lps
->lsrjt_rsn
;
6513 u8 lsrjt_expl
= vport
->lps
->lsrjt_expl
;
6515 bfa_trc(__vport_fcs(vport
), lsrjt_rsn
);
6516 bfa_trc(__vport_fcs(vport
), lsrjt_expl
);
6518 /* For certain reason codes, we don't want to retry. */
6519 switch (vport
->lps
->lsrjt_expl
) {
6520 case FC_LS_RJT_EXP_INV_PORT_NAME
: /* by brocade */
6521 case FC_LS_RJT_EXP_INVALID_NPORT_ID
: /* by Cisco */
6522 if (vport
->fdisc_retries
< BFA_FCS_VPORT_MAX_RETRIES
)
6523 bfa_sm_send_event(vport
, BFA_FCS_VPORT_SM_RSP_ERROR
);
6525 bfa_fcs_vport_aen_post(&vport
->lport
,
6526 BFA_LPORT_AEN_NPIV_DUP_WWN
);
6527 bfa_sm_send_event(vport
, BFA_FCS_VPORT_SM_RSP_DUP_WWN
);
6531 case FC_LS_RJT_EXP_INSUFF_RES
:
6533 * This means max logins per port/switch setting on the
6534 * switch was exceeded.
6536 if (vport
->fdisc_retries
< BFA_FCS_VPORT_MAX_RETRIES
)
6537 bfa_sm_send_event(vport
, BFA_FCS_VPORT_SM_RSP_ERROR
);
6539 bfa_fcs_vport_aen_post(&vport
->lport
,
6540 BFA_LPORT_AEN_NPIV_FABRIC_MAX
);
6541 bfa_sm_send_event(vport
, BFA_FCS_VPORT_SM_FABRIC_MAX
);
6546 if (vport
->fdisc_retries
== 0)
6547 bfa_fcs_vport_aen_post(&vport
->lport
,
6548 BFA_LPORT_AEN_NPIV_UNKNOWN
);
6549 bfa_sm_send_event(vport
, BFA_FCS_VPORT_SM_RSP_ERROR
);
6554 * Called to send a logout to the fabric. Used when a V-Port is
6558 bfa_fcs_vport_do_logo(struct bfa_fcs_vport_s
*vport
)
6560 bfa_trc(__vport_fcs(vport
), __vport_pwwn(vport
));
6562 vport
->vport_stats
.logo_sent
++;
6563 bfa_lps_fdisclogo(vport
->lps
);
6568 * This routine will be called by bfa_timer on timer timeouts.
6570 * param[in] vport - pointer to bfa_fcs_vport_t.
6571 * param[out] vport_status - pointer to return vport status in
6576 * Special Considerations:
6581 bfa_fcs_vport_timeout(void *vport_arg
)
6583 struct bfa_fcs_vport_s
*vport
= (struct bfa_fcs_vport_s
*) vport_arg
;
6585 vport
->vport_stats
.fdisc_timeouts
++;
6586 bfa_sm_send_event(vport
, BFA_FCS_VPORT_SM_TIMEOUT
);
6590 bfa_fcs_vport_free(struct bfa_fcs_vport_s
*vport
)
6592 struct bfad_vport_s
*vport_drv
=
6593 (struct bfad_vport_s
*)vport
->vport_drv
;
6595 bfa_fcs_fabric_delvport(__vport_fabric(vport
), vport
);
6596 bfa_lps_delete(vport
->lps
);
6598 if (vport_drv
->comp_del
) {
6599 complete(vport_drv
->comp_del
);
6604 * We queue the vport delete work to the IM work_q from here.
6605 * The memory for the bfad_vport_s is freed from the FC function
6606 * template vport_delete entry point.
6608 bfad_im_port_delete(vport_drv
->drv_port
.bfad
, &vport_drv
->drv_port
);
6612 * fcs_vport_public FCS virtual port public interfaces
6616 * Online notification from fabric SM.
6619 bfa_fcs_vport_online(struct bfa_fcs_vport_s
*vport
)
6621 vport
->vport_stats
.fab_online
++;
6622 if (bfa_fcs_fabric_npiv_capable(__vport_fabric(vport
)))
6623 bfa_sm_send_event(vport
, BFA_FCS_VPORT_SM_ONLINE
);
6625 vport
->vport_stats
.fab_no_npiv
++;
6629 * Offline notification from fabric SM.
6632 bfa_fcs_vport_offline(struct bfa_fcs_vport_s
*vport
)
6634 vport
->vport_stats
.fab_offline
++;
6635 bfa_sm_send_event(vport
, BFA_FCS_VPORT_SM_OFFLINE
);
6639 * Cleanup notification from fabric SM on link timer expiry.
6642 bfa_fcs_vport_cleanup(struct bfa_fcs_vport_s
*vport
)
6644 vport
->vport_stats
.fab_cleanup
++;
6648 * Stop notification from fabric SM. To be invoked from within FCS.
6651 bfa_fcs_vport_fcs_stop(struct bfa_fcs_vport_s
*vport
)
6653 bfa_sm_send_event(vport
, BFA_FCS_VPORT_SM_STOP
);
6657 * delete notification from fabric SM. To be invoked from within FCS.
6660 bfa_fcs_vport_fcs_delete(struct bfa_fcs_vport_s
*vport
)
6662 bfa_sm_send_event(vport
, BFA_FCS_VPORT_SM_DELETE
);
6666 * Stop completion callback from associated lport
6669 bfa_fcs_vport_stop_comp(struct bfa_fcs_vport_s
*vport
)
6671 bfa_sm_send_event(vport
, BFA_FCS_VPORT_SM_STOPCOMP
);
6675 * Delete completion callback from associated lport
6678 bfa_fcs_vport_delete_comp(struct bfa_fcs_vport_s
*vport
)
6680 bfa_sm_send_event(vport
, BFA_FCS_VPORT_SM_DELCOMP
);
6686 * fcs_vport_api Virtual port API
6690 * Use this function to instantiate a new FCS vport object. This
6691 * function will not trigger any HW initialization process (which will be
6692 * done in vport_start() call)
6694 * param[in] vport - pointer to bfa_fcs_vport_t. This space
6695 * needs to be allocated by the driver.
6696 * param[in] fcs - FCS instance
6697 * param[in] vport_cfg - vport configuration
6698 * param[in] vf_id - VF_ID if vport is created within a VF.
6699 * FC_VF_ID_NULL to specify base fabric.
6700 * param[in] vport_drv - Opaque handle back to the driver's vport
6703 * retval BFA_STATUS_OK - on success.
6704 * retval BFA_STATUS_FAILED - on failure.
6707 bfa_fcs_vport_create(struct bfa_fcs_vport_s
*vport
, struct bfa_fcs_s
*fcs
,
6708 u16 vf_id
, struct bfa_lport_cfg_s
*vport_cfg
,
6709 struct bfad_vport_s
*vport_drv
)
6711 if (vport_cfg
->pwwn
== 0)
6712 return BFA_STATUS_INVALID_WWN
;
6714 if (bfa_fcs_lport_get_pwwn(&fcs
->fabric
.bport
) == vport_cfg
->pwwn
)
6715 return BFA_STATUS_VPORT_WWN_BP
;
6717 if (bfa_fcs_vport_lookup(fcs
, vf_id
, vport_cfg
->pwwn
) != NULL
)
6718 return BFA_STATUS_VPORT_EXISTS
;
6720 if (fcs
->fabric
.num_vports
==
6721 bfa_lps_get_max_vport(fcs
->bfa
))
6722 return BFA_STATUS_VPORT_MAX
;
6724 vport
->lps
= bfa_lps_alloc(fcs
->bfa
);
6726 return BFA_STATUS_VPORT_MAX
;
6728 vport
->vport_drv
= vport_drv
;
6729 vport_cfg
->preboot_vp
= BFA_FALSE
;
6731 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_uninit
);
6732 bfa_fcs_lport_attach(&vport
->lport
, fcs
, vf_id
, vport
);
6733 bfa_fcs_lport_init(&vport
->lport
, vport_cfg
);
6734 bfa_sm_send_event(vport
, BFA_FCS_VPORT_SM_CREATE
);
6736 return BFA_STATUS_OK
;
6740 * Use this function to instantiate a new FCS PBC vport object. This
6741 * function will not trigger any HW initialization process (which will be
6742 * done in vport_start() call)
6744 * param[in] vport - pointer to bfa_fcs_vport_t. This space
6745 * needs to be allocated by the driver.
6746 * param[in] fcs - FCS instance
6747 * param[in] vport_cfg - vport configuration
6748 * param[in] vf_id - VF_ID if vport is created within a VF.
6749 * FC_VF_ID_NULL to specify base fabric.
6750 * param[in] vport_drv - Opaque handle back to the driver's vport
6753 * retval BFA_STATUS_OK - on success.
6754 * retval BFA_STATUS_FAILED - on failure.
6757 bfa_fcs_pbc_vport_create(struct bfa_fcs_vport_s
*vport
, struct bfa_fcs_s
*fcs
,
6758 u16 vf_id
, struct bfa_lport_cfg_s
*vport_cfg
,
6759 struct bfad_vport_s
*vport_drv
)
6763 rc
= bfa_fcs_vport_create(vport
, fcs
, vf_id
, vport_cfg
, vport_drv
);
6764 vport
->lport
.port_cfg
.preboot_vp
= BFA_TRUE
;
6770 * Use this function to findout if this is a pbc vport or not.
6772 * @param[in] vport - pointer to bfa_fcs_vport_t.
6777 bfa_fcs_is_pbc_vport(struct bfa_fcs_vport_s
*vport
)
6780 if (vport
&& (vport
->lport
.port_cfg
.preboot_vp
== BFA_TRUE
))
6788 * Use this function initialize the vport.
6790 * @param[in] vport - pointer to bfa_fcs_vport_t.
6795 bfa_fcs_vport_start(struct bfa_fcs_vport_s
*vport
)
6797 bfa_sm_send_event(vport
, BFA_FCS_VPORT_SM_START
);
6799 return BFA_STATUS_OK
;
6803 * Use this function quiese the vport object. This function will return
6804 * immediately, when the vport is actually stopped, the
6805 * bfa_drv_vport_stop_cb() will be called.
6807 * param[in] vport - pointer to bfa_fcs_vport_t.
6812 bfa_fcs_vport_stop(struct bfa_fcs_vport_s
*vport
)
6814 bfa_sm_send_event(vport
, BFA_FCS_VPORT_SM_STOP
);
6816 return BFA_STATUS_OK
;
6820 * Use this function to delete a vport object. Fabric object should
6821 * be stopped before this function call.
6823 * !!!!!!! Donot invoke this from within FCS !!!!!!!
6825 * param[in] vport - pointer to bfa_fcs_vport_t.
6830 bfa_fcs_vport_delete(struct bfa_fcs_vport_s
*vport
)
6833 if (vport
->lport
.port_cfg
.preboot_vp
)
6834 return BFA_STATUS_PBC
;
6836 bfa_sm_send_event(vport
, BFA_FCS_VPORT_SM_DELETE
);
6838 return BFA_STATUS_OK
;
6842 * Use this function to get vport's current status info.
6844 * param[in] vport pointer to bfa_fcs_vport_t.
6845 * param[out] attr pointer to return vport attributes
6850 bfa_fcs_vport_get_attr(struct bfa_fcs_vport_s
*vport
,
6851 struct bfa_vport_attr_s
*attr
)
6853 if (vport
== NULL
|| attr
== NULL
)
6856 memset(attr
, 0, sizeof(struct bfa_vport_attr_s
));
6858 bfa_fcs_lport_get_attr(&vport
->lport
, &attr
->port_attr
);
6859 attr
->vport_state
= bfa_sm_to_state(vport_sm_table
, vport
->sm
);
6864 * Lookup a virtual port. Excludes base port from lookup.
6866 struct bfa_fcs_vport_s
*
6867 bfa_fcs_vport_lookup(struct bfa_fcs_s
*fcs
, u16 vf_id
, wwn_t vpwwn
)
6869 struct bfa_fcs_vport_s
*vport
;
6870 struct bfa_fcs_fabric_s
*fabric
;
6872 bfa_trc(fcs
, vf_id
);
6873 bfa_trc(fcs
, vpwwn
);
6875 fabric
= bfa_fcs_vf_lookup(fcs
, vf_id
);
6877 bfa_trc(fcs
, vf_id
);
6881 vport
= bfa_fcs_fabric_vport_lookup(fabric
, vpwwn
);
6889 bfa_cb_lps_fdisc_comp(void *bfad
, void *uarg
, bfa_status_t status
)
6891 struct bfa_fcs_vport_s
*vport
= uarg
;
6893 bfa_trc(__vport_fcs(vport
), __vport_pwwn(vport
));
6894 bfa_trc(__vport_fcs(vport
), status
);
6899 * Initialize the V-Port fields
6901 __vport_fcid(vport
) = vport
->lps
->lp_pid
;
6902 vport
->vport_stats
.fdisc_accepts
++;
6903 bfa_sm_send_event(vport
, BFA_FCS_VPORT_SM_RSP_OK
);
6906 case BFA_STATUS_INVALID_MAC
:
6908 vport
->vport_stats
.fdisc_acc_bad
++;
6909 bfa_sm_send_event(vport
, BFA_FCS_VPORT_SM_RSP_ERROR
);
6913 case BFA_STATUS_EPROTOCOL
:
6914 switch (vport
->lps
->ext_status
) {
6915 case BFA_EPROTO_BAD_ACCEPT
:
6916 vport
->vport_stats
.fdisc_acc_bad
++;
6919 case BFA_EPROTO_UNKNOWN_RSP
:
6920 vport
->vport_stats
.fdisc_unknown_rsp
++;
6927 if (vport
->fdisc_retries
< BFA_FCS_VPORT_MAX_RETRIES
)
6928 bfa_sm_send_event(vport
, BFA_FCS_VPORT_SM_RSP_ERROR
);
6930 bfa_sm_send_event(vport
, BFA_FCS_VPORT_SM_RSP_FAILED
);
6934 case BFA_STATUS_ETIMER
:
6935 vport
->vport_stats
.fdisc_timeouts
++;
6936 if (vport
->fdisc_retries
< BFA_FCS_VPORT_MAX_RETRIES
)
6937 bfa_sm_send_event(vport
, BFA_FCS_VPORT_SM_RSP_ERROR
);
6939 bfa_sm_send_event(vport
, BFA_FCS_VPORT_SM_RSP_FAILED
);
6942 case BFA_STATUS_FABRIC_RJT
:
6943 vport
->vport_stats
.fdisc_rejects
++;
6944 bfa_fcs_vport_fdisc_rejected(vport
);
6948 vport
->vport_stats
.fdisc_rsp_err
++;
6949 bfa_sm_send_event(vport
, BFA_FCS_VPORT_SM_RSP_ERROR
);
6957 bfa_cb_lps_fdisclogo_comp(void *bfad
, void *uarg
)
6959 struct bfa_fcs_vport_s
*vport
= uarg
;
6960 bfa_sm_send_event(vport
, BFA_FCS_VPORT_SM_RSP_OK
);
6964 * Received clear virtual link
6967 bfa_cb_lps_cvl_event(void *bfad
, void *uarg
)
6969 struct bfa_fcs_vport_s
*vport
= uarg
;
6971 /* Send an Offline followed by an ONLINE */
6972 bfa_sm_send_event(vport
, BFA_FCS_VPORT_SM_OFFLINE
);
6973 bfa_sm_send_event(vport
, BFA_FCS_VPORT_SM_ONLINE
);