1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
4 * Copyright (c) 2014- QLogic Corporation.
8 * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
14 #include "bfa_fcbuild.h"
17 BFA_TRC_FILE(FCS
, PORT
);
20 * ALPA to LIXA bitmap mapping
22 * ALPA 0x00 (Word 0, Bit 30) is invalid for N_Ports. Also Word 0 Bit 31
23 * is for L_bit (login required) and is filled as ALPA 0x00 here.
25 static const u8 loop_alpa_map
[] = {
26 0x00, 0x00, 0x01, 0x02, 0x04, 0x08, 0x0F, 0x10, /* Word 0 Bits 31..24 */
27 0x17, 0x18, 0x1B, 0x1D, 0x1E, 0x1F, 0x23, 0x25, /* Word 0 Bits 23..16 */
28 0x26, 0x27, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, /* Word 0 Bits 15..08 */
29 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x39, 0x3A, /* Word 0 Bits 07..00 */
31 0x3C, 0x43, 0x45, 0x46, 0x47, 0x49, 0x4A, 0x4B, /* Word 1 Bits 31..24 */
32 0x4C, 0x4D, 0x4E, 0x51, 0x52, 0x53, 0x54, 0x55, /* Word 1 Bits 23..16 */
33 0x56, 0x59, 0x5A, 0x5C, 0x63, 0x65, 0x66, 0x67, /* Word 1 Bits 15..08 */
34 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x71, 0x72, /* Word 1 Bits 07..00 */
36 0x73, 0x74, 0x75, 0x76, 0x79, 0x7A, 0x7C, 0x80, /* Word 2 Bits 31..24 */
37 0x81, 0x82, 0x84, 0x88, 0x8F, 0x90, 0x97, 0x98, /* Word 2 Bits 23..16 */
38 0x9B, 0x9D, 0x9E, 0x9F, 0xA3, 0xA5, 0xA6, 0xA7, /* Word 2 Bits 15..08 */
39 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xB1, 0xB2, /* Word 2 Bits 07..00 */
41 0xB3, 0xB4, 0xB5, 0xB6, 0xB9, 0xBA, 0xBC, 0xC3, /* Word 3 Bits 31..24 */
42 0xC5, 0xC6, 0xC7, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, /* Word 3 Bits 23..16 */
43 0xCE, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD9, /* Word 3 Bits 15..08 */
44 0xDA, 0xDC, 0xE0, 0xE1, 0xE2, 0xE4, 0xE8, 0xEF, /* Word 3 Bits 07..00 */
47 static void bfa_fcs_lport_send_ls_rjt(struct bfa_fcs_lport_s
*port
,
48 struct fchs_s
*rx_fchs
, u8 reason_code
,
50 static void bfa_fcs_lport_plogi(struct bfa_fcs_lport_s
*port
,
51 struct fchs_s
*rx_fchs
, struct fc_logi_s
*plogi
);
52 static void bfa_fcs_lport_online_actions(struct bfa_fcs_lport_s
*port
);
53 static void bfa_fcs_lport_offline_actions(struct bfa_fcs_lport_s
*port
);
54 static void bfa_fcs_lport_unknown_init(struct bfa_fcs_lport_s
*port
);
55 static void bfa_fcs_lport_unknown_online(struct bfa_fcs_lport_s
*port
);
56 static void bfa_fcs_lport_unknown_offline(struct bfa_fcs_lport_s
*port
);
57 static void bfa_fcs_lport_deleted(struct bfa_fcs_lport_s
*port
);
58 static void bfa_fcs_lport_echo(struct bfa_fcs_lport_s
*port
,
59 struct fchs_s
*rx_fchs
,
60 struct fc_echo_s
*echo
, u16 len
);
61 static void bfa_fcs_lport_rnid(struct bfa_fcs_lport_s
*port
,
62 struct fchs_s
*rx_fchs
,
63 struct fc_rnid_cmd_s
*rnid
, u16 len
);
64 static void bfa_fs_port_get_gen_topo_data(struct bfa_fcs_lport_s
*port
,
65 struct fc_rnid_general_topology_data_s
*gen_topo_data
);
67 static void bfa_fcs_lport_fab_init(struct bfa_fcs_lport_s
*port
);
68 static void bfa_fcs_lport_fab_online(struct bfa_fcs_lport_s
*port
);
69 static void bfa_fcs_lport_fab_offline(struct bfa_fcs_lport_s
*port
);
71 static void bfa_fcs_lport_n2n_init(struct bfa_fcs_lport_s
*port
);
72 static void bfa_fcs_lport_n2n_online(struct bfa_fcs_lport_s
*port
);
73 static void bfa_fcs_lport_n2n_offline(struct bfa_fcs_lport_s
*port
);
75 static void bfa_fcs_lport_loop_init(struct bfa_fcs_lport_s
*port
);
76 static void bfa_fcs_lport_loop_online(struct bfa_fcs_lport_s
*port
);
77 static void bfa_fcs_lport_loop_offline(struct bfa_fcs_lport_s
*port
);
80 void (*init
) (struct bfa_fcs_lport_s
*port
);
81 void (*online
) (struct bfa_fcs_lport_s
*port
);
82 void (*offline
) (struct bfa_fcs_lport_s
*port
);
84 [BFA_FCS_FABRIC_UNKNOWN
] = {
85 .init
= bfa_fcs_lport_unknown_init
,
86 .online
= bfa_fcs_lport_unknown_online
,
87 .offline
= bfa_fcs_lport_unknown_offline
89 [BFA_FCS_FABRIC_SWITCHED
] = {
90 .init
= bfa_fcs_lport_fab_init
,
91 .online
= bfa_fcs_lport_fab_online
,
92 .offline
= bfa_fcs_lport_fab_offline
94 [BFA_FCS_FABRIC_N2N
] = {
95 .init
= bfa_fcs_lport_n2n_init
,
96 .online
= bfa_fcs_lport_n2n_online
,
97 .offline
= bfa_fcs_lport_n2n_offline
99 [BFA_FCS_FABRIC_LOOP
] = {
100 .init
= bfa_fcs_lport_loop_init
,
101 .online
= bfa_fcs_lport_loop_online
,
102 .offline
= bfa_fcs_lport_loop_offline
107 * fcs_port_sm FCS logical port state machine
110 enum bfa_fcs_lport_event
{
111 BFA_FCS_PORT_SM_CREATE
= 1,
112 BFA_FCS_PORT_SM_ONLINE
= 2,
113 BFA_FCS_PORT_SM_OFFLINE
= 3,
114 BFA_FCS_PORT_SM_DELETE
= 4,
115 BFA_FCS_PORT_SM_DELRPORT
= 5,
116 BFA_FCS_PORT_SM_STOP
= 6,
119 static void bfa_fcs_lport_sm_uninit(struct bfa_fcs_lport_s
*port
,
120 enum bfa_fcs_lport_event event
);
121 static void bfa_fcs_lport_sm_init(struct bfa_fcs_lport_s
*port
,
122 enum bfa_fcs_lport_event event
);
123 static void bfa_fcs_lport_sm_online(struct bfa_fcs_lport_s
*port
,
124 enum bfa_fcs_lport_event event
);
125 static void bfa_fcs_lport_sm_offline(struct bfa_fcs_lport_s
*port
,
126 enum bfa_fcs_lport_event event
);
127 static void bfa_fcs_lport_sm_deleting(struct bfa_fcs_lport_s
*port
,
128 enum bfa_fcs_lport_event event
);
129 static void bfa_fcs_lport_sm_stopping(struct bfa_fcs_lport_s
*port
,
130 enum bfa_fcs_lport_event event
);
133 bfa_fcs_lport_sm_uninit(
134 struct bfa_fcs_lport_s
*port
,
135 enum bfa_fcs_lport_event event
)
137 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
138 bfa_trc(port
->fcs
, event
);
141 case BFA_FCS_PORT_SM_CREATE
:
142 bfa_sm_set_state(port
, bfa_fcs_lport_sm_init
);
146 bfa_sm_fault(port
->fcs
, event
);
151 bfa_fcs_lport_sm_init(struct bfa_fcs_lport_s
*port
,
152 enum bfa_fcs_lport_event event
)
154 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
155 bfa_trc(port
->fcs
, event
);
158 case BFA_FCS_PORT_SM_ONLINE
:
159 bfa_sm_set_state(port
, bfa_fcs_lport_sm_online
);
160 bfa_fcs_lport_online_actions(port
);
163 case BFA_FCS_PORT_SM_DELETE
:
164 bfa_sm_set_state(port
, bfa_fcs_lport_sm_uninit
);
165 bfa_fcs_lport_deleted(port
);
168 case BFA_FCS_PORT_SM_STOP
:
169 /* If vport - send completion call back */
171 bfa_fcs_vport_stop_comp(port
->vport
);
173 bfa_wc_down(&(port
->fabric
->stop_wc
));
176 case BFA_FCS_PORT_SM_OFFLINE
:
180 bfa_sm_fault(port
->fcs
, event
);
185 bfa_fcs_lport_sm_online(
186 struct bfa_fcs_lport_s
*port
,
187 enum bfa_fcs_lport_event event
)
189 struct bfa_fcs_rport_s
*rport
;
190 struct list_head
*qe
, *qen
;
192 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
193 bfa_trc(port
->fcs
, event
);
196 case BFA_FCS_PORT_SM_OFFLINE
:
197 bfa_sm_set_state(port
, bfa_fcs_lport_sm_offline
);
198 bfa_fcs_lport_offline_actions(port
);
201 case BFA_FCS_PORT_SM_STOP
:
202 __port_action
[port
->fabric
->fab_type
].offline(port
);
204 if (port
->num_rports
== 0) {
205 bfa_sm_set_state(port
, bfa_fcs_lport_sm_init
);
206 /* If vport - send completion call back */
208 bfa_fcs_vport_stop_comp(port
->vport
);
210 bfa_wc_down(&(port
->fabric
->stop_wc
));
212 bfa_sm_set_state(port
, bfa_fcs_lport_sm_stopping
);
213 list_for_each_safe(qe
, qen
, &port
->rport_q
) {
214 rport
= (struct bfa_fcs_rport_s
*) qe
;
215 bfa_sm_send_event(rport
, RPSM_EVENT_DELETE
);
220 case BFA_FCS_PORT_SM_DELETE
:
222 __port_action
[port
->fabric
->fab_type
].offline(port
);
224 if (port
->num_rports
== 0) {
225 bfa_sm_set_state(port
, bfa_fcs_lport_sm_uninit
);
226 bfa_fcs_lport_deleted(port
);
228 bfa_sm_set_state(port
, bfa_fcs_lport_sm_deleting
);
229 list_for_each_safe(qe
, qen
, &port
->rport_q
) {
230 rport
= (struct bfa_fcs_rport_s
*) qe
;
231 bfa_sm_send_event(rport
, RPSM_EVENT_DELETE
);
236 case BFA_FCS_PORT_SM_DELRPORT
:
240 bfa_sm_fault(port
->fcs
, event
);
245 bfa_fcs_lport_sm_offline(
246 struct bfa_fcs_lport_s
*port
,
247 enum bfa_fcs_lport_event event
)
249 struct bfa_fcs_rport_s
*rport
;
250 struct list_head
*qe
, *qen
;
252 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
253 bfa_trc(port
->fcs
, event
);
256 case BFA_FCS_PORT_SM_ONLINE
:
257 bfa_sm_set_state(port
, bfa_fcs_lport_sm_online
);
258 bfa_fcs_lport_online_actions(port
);
261 case BFA_FCS_PORT_SM_STOP
:
262 if (port
->num_rports
== 0) {
263 bfa_sm_set_state(port
, bfa_fcs_lport_sm_init
);
264 /* If vport - send completion call back */
266 bfa_fcs_vport_stop_comp(port
->vport
);
268 bfa_wc_down(&(port
->fabric
->stop_wc
));
270 bfa_sm_set_state(port
, bfa_fcs_lport_sm_stopping
);
271 list_for_each_safe(qe
, qen
, &port
->rport_q
) {
272 rport
= (struct bfa_fcs_rport_s
*) qe
;
273 bfa_sm_send_event(rport
, RPSM_EVENT_DELETE
);
278 case BFA_FCS_PORT_SM_DELETE
:
279 if (port
->num_rports
== 0) {
280 bfa_sm_set_state(port
, bfa_fcs_lport_sm_uninit
);
281 bfa_fcs_lport_deleted(port
);
283 bfa_sm_set_state(port
, bfa_fcs_lport_sm_deleting
);
284 list_for_each_safe(qe
, qen
, &port
->rport_q
) {
285 rport
= (struct bfa_fcs_rport_s
*) qe
;
286 bfa_sm_send_event(rport
, RPSM_EVENT_DELETE
);
291 case BFA_FCS_PORT_SM_DELRPORT
:
292 case BFA_FCS_PORT_SM_OFFLINE
:
296 bfa_sm_fault(port
->fcs
, event
);
301 bfa_fcs_lport_sm_stopping(struct bfa_fcs_lport_s
*port
,
302 enum bfa_fcs_lport_event event
)
304 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
305 bfa_trc(port
->fcs
, event
);
308 case BFA_FCS_PORT_SM_DELRPORT
:
309 if (port
->num_rports
== 0) {
310 bfa_sm_set_state(port
, bfa_fcs_lport_sm_init
);
311 /* If vport - send completion call back */
313 bfa_fcs_vport_stop_comp(port
->vport
);
315 bfa_wc_down(&(port
->fabric
->stop_wc
));
320 bfa_sm_fault(port
->fcs
, event
);
325 bfa_fcs_lport_sm_deleting(
326 struct bfa_fcs_lport_s
*port
,
327 enum bfa_fcs_lport_event event
)
329 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
330 bfa_trc(port
->fcs
, event
);
333 case BFA_FCS_PORT_SM_DELRPORT
:
334 if (port
->num_rports
== 0) {
335 bfa_sm_set_state(port
, bfa_fcs_lport_sm_uninit
);
336 bfa_fcs_lport_deleted(port
);
341 bfa_sm_fault(port
->fcs
, event
);
350 * Send AEN notification
353 bfa_fcs_lport_aen_post(struct bfa_fcs_lport_s
*port
,
354 enum bfa_lport_aen_event event
)
356 struct bfad_s
*bfad
= (struct bfad_s
*)port
->fabric
->fcs
->bfad
;
357 struct bfa_aen_entry_s
*aen_entry
;
359 bfad_get_aen_entry(bfad
, aen_entry
);
363 aen_entry
->aen_data
.lport
.vf_id
= port
->fabric
->vf_id
;
364 aen_entry
->aen_data
.lport
.roles
= port
->port_cfg
.roles
;
365 aen_entry
->aen_data
.lport
.ppwwn
= bfa_fcs_lport_get_pwwn(
366 bfa_fcs_get_base_port(port
->fcs
));
367 aen_entry
->aen_data
.lport
.lpwwn
= bfa_fcs_lport_get_pwwn(port
);
369 /* Send the AEN notification */
370 bfad_im_post_vendor_event(aen_entry
, bfad
, ++port
->fcs
->fcs_aen_seq
,
371 BFA_AEN_CAT_LPORT
, event
);
378 bfa_fcs_lport_send_ls_rjt(struct bfa_fcs_lport_s
*port
, struct fchs_s
*rx_fchs
,
379 u8 reason_code
, u8 reason_code_expl
)
382 struct bfa_fcxp_s
*fcxp
;
383 struct bfa_rport_s
*bfa_rport
= NULL
;
386 bfa_trc(port
->fcs
, rx_fchs
->d_id
);
387 bfa_trc(port
->fcs
, rx_fchs
->s_id
);
389 fcxp
= bfa_fcs_fcxp_alloc(port
->fcs
, BFA_FALSE
);
393 len
= fc_ls_rjt_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
394 rx_fchs
->s_id
, bfa_fcs_lport_get_fcid(port
),
395 rx_fchs
->ox_id
, reason_code
, reason_code_expl
);
397 bfa_fcxp_send(fcxp
, bfa_rport
, port
->fabric
->vf_id
, port
->lp_tag
,
398 BFA_FALSE
, FC_CLASS_3
, len
, &fchs
, NULL
, NULL
,
406 bfa_fcs_lport_send_fcgs_rjt(struct bfa_fcs_lport_s
*port
,
407 struct fchs_s
*rx_fchs
, u8 reason_code
, u8 reason_code_expl
)
410 struct bfa_fcxp_s
*fcxp
;
411 struct bfa_rport_s
*bfa_rport
= NULL
;
413 struct ct_hdr_s
*rx_cthdr
= (struct ct_hdr_s
*)(rx_fchs
+ 1);
414 struct ct_hdr_s
*ct_hdr
;
416 bfa_trc(port
->fcs
, rx_fchs
->d_id
);
417 bfa_trc(port
->fcs
, rx_fchs
->s_id
);
419 fcxp
= bfa_fcs_fcxp_alloc(port
->fcs
, BFA_FALSE
);
423 ct_hdr
= bfa_fcxp_get_reqbuf(fcxp
);
424 ct_hdr
->gs_type
= rx_cthdr
->gs_type
;
425 ct_hdr
->gs_sub_type
= rx_cthdr
->gs_sub_type
;
427 len
= fc_gs_rjt_build(&fchs
, ct_hdr
, rx_fchs
->s_id
,
428 bfa_fcs_lport_get_fcid(port
),
429 rx_fchs
->ox_id
, reason_code
, reason_code_expl
);
431 bfa_fcxp_send(fcxp
, bfa_rport
, port
->fabric
->vf_id
, port
->lp_tag
,
432 BFA_FALSE
, FC_CLASS_3
, len
, &fchs
, NULL
, NULL
,
437 * Process incoming plogi from a remote port.
440 bfa_fcs_lport_plogi(struct bfa_fcs_lport_s
*port
,
441 struct fchs_s
*rx_fchs
, struct fc_logi_s
*plogi
)
443 struct bfa_fcs_rport_s
*rport
;
445 bfa_trc(port
->fcs
, rx_fchs
->d_id
);
446 bfa_trc(port
->fcs
, rx_fchs
->s_id
);
449 * If min cfg mode is enabled, drop any incoming PLOGIs
451 if (__fcs_min_cfg(port
->fcs
)) {
452 bfa_trc(port
->fcs
, rx_fchs
->s_id
);
456 if (fc_plogi_parse(rx_fchs
) != FC_PARSE_OK
) {
457 bfa_trc(port
->fcs
, rx_fchs
->s_id
);
461 bfa_fcs_lport_send_ls_rjt(port
, rx_fchs
,
462 FC_LS_RJT_RSN_PROTOCOL_ERROR
,
463 FC_LS_RJT_EXP_SPARMS_ERR_OPTIONS
);
468 * Direct Attach P2P mode : verify address assigned by the r-port.
470 if ((!bfa_fcs_fabric_is_switched(port
->fabric
)) &&
471 (memcmp((void *)&bfa_fcs_lport_get_pwwn(port
),
472 (void *)&plogi
->port_name
, sizeof(wwn_t
)) < 0)) {
473 if (BFA_FCS_PID_IS_WKA(rx_fchs
->d_id
)) {
474 /* Address assigned to us cannot be a WKA */
475 bfa_fcs_lport_send_ls_rjt(port
, rx_fchs
,
476 FC_LS_RJT_RSN_PROTOCOL_ERROR
,
477 FC_LS_RJT_EXP_INVALID_NPORT_ID
);
480 port
->pid
= rx_fchs
->d_id
;
481 bfa_lps_set_n2n_pid(port
->fabric
->lps
, rx_fchs
->d_id
);
485 * First, check if we know the device by pwwn.
487 rport
= bfa_fcs_lport_get_rport_by_pwwn(port
, plogi
->port_name
);
490 * Direct Attach P2P mode : handle address assigned by r-port.
492 if ((!bfa_fcs_fabric_is_switched(port
->fabric
)) &&
493 (memcmp((void *)&bfa_fcs_lport_get_pwwn(port
),
494 (void *)&plogi
->port_name
, sizeof(wwn_t
)) < 0)) {
495 port
->pid
= rx_fchs
->d_id
;
496 bfa_lps_set_n2n_pid(port
->fabric
->lps
, rx_fchs
->d_id
);
497 rport
->pid
= rx_fchs
->s_id
;
499 bfa_fcs_rport_plogi(rport
, rx_fchs
, plogi
);
504 * Next, lookup rport by PID.
506 rport
= bfa_fcs_lport_get_rport_by_pid(port
, rx_fchs
->s_id
);
509 * Inbound PLOGI from a new device.
511 bfa_fcs_rport_plogi_create(port
, rx_fchs
, plogi
);
516 * Rport is known only by PID.
520 * This is a different device with the same pid. Old device
521 * disappeared. Send implicit LOGO to old device.
523 WARN_ON(rport
->pwwn
== plogi
->port_name
);
524 bfa_sm_send_event(rport
, RPSM_EVENT_LOGO_IMP
);
527 * Inbound PLOGI from a new device (with old PID).
529 bfa_fcs_rport_plogi_create(port
, rx_fchs
, plogi
);
534 * PLOGI crossing each other.
536 WARN_ON(rport
->pwwn
!= WWN_NULL
);
537 bfa_fcs_rport_plogi(rport
, rx_fchs
, plogi
);
541 * Process incoming ECHO.
542 * Since it does not require a login, it is processed here.
545 bfa_fcs_lport_echo(struct bfa_fcs_lport_s
*port
, struct fchs_s
*rx_fchs
,
546 struct fc_echo_s
*echo
, u16 rx_len
)
549 struct bfa_fcxp_s
*fcxp
;
550 struct bfa_rport_s
*bfa_rport
= NULL
;
553 bfa_trc(port
->fcs
, rx_fchs
->s_id
);
554 bfa_trc(port
->fcs
, rx_fchs
->d_id
);
556 fcxp
= bfa_fcs_fcxp_alloc(port
->fcs
, BFA_FALSE
);
560 len
= fc_ls_acc_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
561 rx_fchs
->s_id
, bfa_fcs_lport_get_fcid(port
),
565 * Copy the payload (if any) from the echo frame
567 pyld_len
= rx_len
- sizeof(struct fchs_s
);
568 bfa_trc(port
->fcs
, rx_len
);
569 bfa_trc(port
->fcs
, pyld_len
);
572 memcpy(((u8
*) bfa_fcxp_get_reqbuf(fcxp
)) +
573 sizeof(struct fc_echo_s
), (echo
+ 1),
574 (pyld_len
- sizeof(struct fc_echo_s
)));
576 bfa_fcxp_send(fcxp
, bfa_rport
, port
->fabric
->vf_id
, port
->lp_tag
,
577 BFA_FALSE
, FC_CLASS_3
, pyld_len
, &fchs
, NULL
, NULL
,
582 * Process incoming RNID.
583 * Since it does not require a login, it is processed here.
586 bfa_fcs_lport_rnid(struct bfa_fcs_lport_s
*port
, struct fchs_s
*rx_fchs
,
587 struct fc_rnid_cmd_s
*rnid
, u16 rx_len
)
589 struct fc_rnid_common_id_data_s common_id_data
;
590 struct fc_rnid_general_topology_data_s gen_topo_data
;
592 struct bfa_fcxp_s
*fcxp
;
593 struct bfa_rport_s
*bfa_rport
= NULL
;
597 bfa_trc(port
->fcs
, rx_fchs
->s_id
);
598 bfa_trc(port
->fcs
, rx_fchs
->d_id
);
599 bfa_trc(port
->fcs
, rx_len
);
601 fcxp
= bfa_fcs_fcxp_alloc(port
->fcs
, BFA_FALSE
);
606 * Check Node Indentification Data Format
607 * We only support General Topology Discovery Format.
608 * For any other requested Data Formats, we return Common Node Id Data
609 * only, as per FC-LS.
611 bfa_trc(port
->fcs
, rnid
->node_id_data_format
);
612 if (rnid
->node_id_data_format
== RNID_NODEID_DATA_FORMAT_DISCOVERY
) {
613 data_format
= RNID_NODEID_DATA_FORMAT_DISCOVERY
;
615 * Get General topology data for this port
617 bfa_fs_port_get_gen_topo_data(port
, &gen_topo_data
);
619 data_format
= RNID_NODEID_DATA_FORMAT_COMMON
;
623 * Copy the Node Id Info
625 common_id_data
.port_name
= bfa_fcs_lport_get_pwwn(port
);
626 common_id_data
.node_name
= bfa_fcs_lport_get_nwwn(port
);
628 len
= fc_rnid_acc_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
629 rx_fchs
->s_id
, bfa_fcs_lport_get_fcid(port
),
630 rx_fchs
->ox_id
, data_format
, &common_id_data
,
633 bfa_fcxp_send(fcxp
, bfa_rport
, port
->fabric
->vf_id
, port
->lp_tag
,
634 BFA_FALSE
, FC_CLASS_3
, len
, &fchs
, NULL
, NULL
,
639 * Fill out General Topolpgy Discovery Data for RNID ELS.
642 bfa_fs_port_get_gen_topo_data(struct bfa_fcs_lport_s
*port
,
643 struct fc_rnid_general_topology_data_s
*gen_topo_data
)
645 memset(gen_topo_data
, 0,
646 sizeof(struct fc_rnid_general_topology_data_s
));
648 gen_topo_data
->asso_type
= cpu_to_be32(RNID_ASSOCIATED_TYPE_HOST
);
649 gen_topo_data
->phy_port_num
= 0; /* @todo */
650 gen_topo_data
->num_attached_nodes
= cpu_to_be32(1);
654 bfa_fcs_lport_online_actions(struct bfa_fcs_lport_s
*port
)
656 struct bfad_s
*bfad
= (struct bfad_s
*)port
->fcs
->bfad
;
657 char lpwwn_buf
[BFA_STRING_32
];
659 bfa_trc(port
->fcs
, port
->fabric
->oper_type
);
661 __port_action
[port
->fabric
->fab_type
].init(port
);
662 __port_action
[port
->fabric
->fab_type
].online(port
);
664 wwn2str(lpwwn_buf
, bfa_fcs_lport_get_pwwn(port
));
665 BFA_LOG(KERN_WARNING
, bfad
, bfa_log_level
,
666 "Logical port online: WWN = %s Role = %s\n",
667 lpwwn_buf
, "Initiator");
668 bfa_fcs_lport_aen_post(port
, BFA_LPORT_AEN_ONLINE
);
670 bfad
->bfad_flags
|= BFAD_PORT_ONLINE
;
674 bfa_fcs_lport_offline_actions(struct bfa_fcs_lport_s
*port
)
676 struct list_head
*qe
, *qen
;
677 struct bfa_fcs_rport_s
*rport
;
678 struct bfad_s
*bfad
= (struct bfad_s
*)port
->fcs
->bfad
;
679 char lpwwn_buf
[BFA_STRING_32
];
681 bfa_trc(port
->fcs
, port
->fabric
->oper_type
);
683 __port_action
[port
->fabric
->fab_type
].offline(port
);
685 wwn2str(lpwwn_buf
, bfa_fcs_lport_get_pwwn(port
));
686 if (bfa_sm_cmp_state(port
->fabric
,
687 bfa_fcs_fabric_sm_online
) == BFA_TRUE
) {
688 BFA_LOG(KERN_WARNING
, bfad
, bfa_log_level
,
689 "Logical port lost fabric connectivity: WWN = %s Role = %s\n",
690 lpwwn_buf
, "Initiator");
691 bfa_fcs_lport_aen_post(port
, BFA_LPORT_AEN_DISCONNECT
);
693 BFA_LOG(KERN_WARNING
, bfad
, bfa_log_level
,
694 "Logical port taken offline: WWN = %s Role = %s\n",
695 lpwwn_buf
, "Initiator");
696 bfa_fcs_lport_aen_post(port
, BFA_LPORT_AEN_OFFLINE
);
699 list_for_each_safe(qe
, qen
, &port
->rport_q
) {
700 rport
= (struct bfa_fcs_rport_s
*) qe
;
701 bfa_sm_send_event(rport
, RPSM_EVENT_LOGO_IMP
);
706 bfa_fcs_lport_unknown_init(struct bfa_fcs_lport_s
*port
)
712 bfa_fcs_lport_unknown_online(struct bfa_fcs_lport_s
*port
)
718 bfa_fcs_lport_unknown_offline(struct bfa_fcs_lport_s
*port
)
724 bfa_fcs_lport_abts_acc(struct bfa_fcs_lport_s
*port
, struct fchs_s
*rx_fchs
)
727 struct bfa_fcxp_s
*fcxp
;
730 bfa_trc(port
->fcs
, rx_fchs
->d_id
);
731 bfa_trc(port
->fcs
, rx_fchs
->s_id
);
733 fcxp
= bfa_fcs_fcxp_alloc(port
->fcs
, BFA_FALSE
);
737 len
= fc_ba_acc_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
738 rx_fchs
->s_id
, bfa_fcs_lport_get_fcid(port
),
741 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
,
742 BFA_FALSE
, FC_CLASS_3
, len
, &fchs
, NULL
, NULL
,
746 bfa_fcs_lport_deleted(struct bfa_fcs_lport_s
*port
)
748 struct bfad_s
*bfad
= (struct bfad_s
*)port
->fcs
->bfad
;
749 char lpwwn_buf
[BFA_STRING_32
];
751 wwn2str(lpwwn_buf
, bfa_fcs_lport_get_pwwn(port
));
752 BFA_LOG(KERN_INFO
, bfad
, bfa_log_level
,
753 "Logical port deleted: WWN = %s Role = %s\n",
754 lpwwn_buf
, "Initiator");
755 bfa_fcs_lport_aen_post(port
, BFA_LPORT_AEN_DELETE
);
757 /* Base port will be deleted by the OS driver */
759 bfa_fcs_vport_delete_comp(port
->vport
);
761 bfa_wc_down(&port
->fabric
->wc
);
766 * Unsolicited frame receive handling.
769 bfa_fcs_lport_uf_recv(struct bfa_fcs_lport_s
*lport
,
770 struct fchs_s
*fchs
, u16 len
)
772 u32 pid
= fchs
->s_id
;
773 struct bfa_fcs_rport_s
*rport
= NULL
;
774 struct fc_els_cmd_s
*els_cmd
= (struct fc_els_cmd_s
*) (fchs
+ 1);
776 bfa_stats(lport
, uf_recvs
);
777 bfa_trc(lport
->fcs
, fchs
->type
);
779 if (!bfa_fcs_lport_is_online(lport
)) {
781 * In direct attach topology, it is possible to get a PLOGI
782 * before the lport is online due to port feature
783 * (QoS/Trunk/FEC/CR), so send a rjt
785 if ((fchs
->type
== FC_TYPE_ELS
) &&
786 (els_cmd
->els_code
== FC_ELS_PLOGI
)) {
787 bfa_fcs_lport_send_ls_rjt(lport
, fchs
,
788 FC_LS_RJT_RSN_UNABLE_TO_PERF_CMD
,
789 FC_LS_RJT_EXP_NO_ADDL_INFO
);
790 bfa_stats(lport
, plogi_rcvd
);
792 bfa_stats(lport
, uf_recv_drops
);
798 * First, handle ELSs that donot require a login.
803 if ((fchs
->type
== FC_TYPE_ELS
) &&
804 (els_cmd
->els_code
== FC_ELS_PLOGI
)) {
805 bfa_fcs_lport_plogi(lport
, fchs
, (struct fc_logi_s
*) els_cmd
);
810 * Handle ECHO separately.
812 if ((fchs
->type
== FC_TYPE_ELS
) && (els_cmd
->els_code
== FC_ELS_ECHO
)) {
813 bfa_fcs_lport_echo(lport
, fchs
,
814 (struct fc_echo_s
*)els_cmd
, len
);
819 * Handle RNID separately.
821 if ((fchs
->type
== FC_TYPE_ELS
) && (els_cmd
->els_code
== FC_ELS_RNID
)) {
822 bfa_fcs_lport_rnid(lport
, fchs
,
823 (struct fc_rnid_cmd_s
*) els_cmd
, len
);
827 if (fchs
->type
== FC_TYPE_BLS
) {
828 if ((fchs
->routing
== FC_RTG_BASIC_LINK
) &&
829 (fchs
->cat_info
== FC_CAT_ABTS
))
830 bfa_fcs_lport_abts_acc(lport
, fchs
);
834 if (fchs
->type
== FC_TYPE_SERVICES
) {
836 * Unhandled FC-GS frames. Send a FC-CT Reject
838 bfa_fcs_lport_send_fcgs_rjt(lport
, fchs
, CT_RSN_NOT_SUPP
,
839 CT_NS_EXP_NOADDITIONAL
);
844 * look for a matching remote port ID
846 rport
= bfa_fcs_lport_get_rport_by_pid(lport
, pid
);
848 bfa_trc(rport
->fcs
, fchs
->s_id
);
849 bfa_trc(rport
->fcs
, fchs
->d_id
);
850 bfa_trc(rport
->fcs
, fchs
->type
);
852 bfa_fcs_rport_uf_recv(rport
, fchs
, len
);
857 * Only handles ELS frames for now.
859 if (fchs
->type
!= FC_TYPE_ELS
) {
860 bfa_trc(lport
->fcs
, fchs
->s_id
);
861 bfa_trc(lport
->fcs
, fchs
->d_id
);
862 /* ignore type FC_TYPE_FC_FSS */
863 if (fchs
->type
!= FC_TYPE_FC_FSS
)
864 bfa_sm_fault(lport
->fcs
, fchs
->type
);
868 bfa_trc(lport
->fcs
, els_cmd
->els_code
);
869 if (els_cmd
->els_code
== FC_ELS_RSCN
) {
870 bfa_fcs_lport_scn_process_rscn(lport
, fchs
, len
);
874 if (els_cmd
->els_code
== FC_ELS_LOGO
) {
876 * @todo Handle LOGO frames received.
881 if (els_cmd
->els_code
== FC_ELS_PRLI
) {
883 * @todo Handle PRLI frames received.
889 * Unhandled ELS frames. Send a LS_RJT.
891 bfa_fcs_lport_send_ls_rjt(lport
, fchs
, FC_LS_RJT_RSN_CMD_NOT_SUPP
,
892 FC_LS_RJT_EXP_NO_ADDL_INFO
);
897 * PID based Lookup for a R-Port in the Port R-Port Queue
899 struct bfa_fcs_rport_s
*
900 bfa_fcs_lport_get_rport_by_pid(struct bfa_fcs_lport_s
*port
, u32 pid
)
902 struct bfa_fcs_rport_s
*rport
;
903 struct list_head
*qe
;
905 list_for_each(qe
, &port
->rport_q
) {
906 rport
= (struct bfa_fcs_rport_s
*) qe
;
907 if (rport
->pid
== pid
)
911 bfa_trc(port
->fcs
, pid
);
916 * OLD_PID based Lookup for a R-Port in the Port R-Port Queue
918 struct bfa_fcs_rport_s
*
919 bfa_fcs_lport_get_rport_by_old_pid(struct bfa_fcs_lport_s
*port
, u32 pid
)
921 struct bfa_fcs_rport_s
*rport
;
922 struct list_head
*qe
;
924 list_for_each(qe
, &port
->rport_q
) {
925 rport
= (struct bfa_fcs_rport_s
*) qe
;
926 if (rport
->old_pid
== pid
)
930 bfa_trc(port
->fcs
, pid
);
935 * PWWN based Lookup for a R-Port in the Port R-Port Queue
937 struct bfa_fcs_rport_s
*
938 bfa_fcs_lport_get_rport_by_pwwn(struct bfa_fcs_lport_s
*port
, wwn_t pwwn
)
940 struct bfa_fcs_rport_s
*rport
;
941 struct list_head
*qe
;
943 list_for_each(qe
, &port
->rport_q
) {
944 rport
= (struct bfa_fcs_rport_s
*) qe
;
945 if (wwn_is_equal(rport
->pwwn
, pwwn
))
949 bfa_trc(port
->fcs
, pwwn
);
954 * NWWN based Lookup for a R-Port in the Port R-Port Queue
956 struct bfa_fcs_rport_s
*
957 bfa_fcs_lport_get_rport_by_nwwn(struct bfa_fcs_lport_s
*port
, wwn_t nwwn
)
959 struct bfa_fcs_rport_s
*rport
;
960 struct list_head
*qe
;
962 list_for_each(qe
, &port
->rport_q
) {
963 rport
= (struct bfa_fcs_rport_s
*) qe
;
964 if (wwn_is_equal(rport
->nwwn
, nwwn
))
968 bfa_trc(port
->fcs
, nwwn
);
973 * PWWN & PID based Lookup for a R-Port in the Port R-Port Queue
975 struct bfa_fcs_rport_s
*
976 bfa_fcs_lport_get_rport_by_qualifier(struct bfa_fcs_lport_s
*port
,
979 struct bfa_fcs_rport_s
*rport
;
980 struct list_head
*qe
;
982 list_for_each(qe
, &port
->rport_q
) {
983 rport
= (struct bfa_fcs_rport_s
*) qe
;
984 if (wwn_is_equal(rport
->pwwn
, pwwn
) && rport
->pid
== pid
)
988 bfa_trc(port
->fcs
, pwwn
);
993 * Called by rport module when new rports are discovered.
996 bfa_fcs_lport_add_rport(
997 struct bfa_fcs_lport_s
*port
,
998 struct bfa_fcs_rport_s
*rport
)
1000 list_add_tail(&rport
->qe
, &port
->rport_q
);
1005 * Called by rport module to when rports are deleted.
1008 bfa_fcs_lport_del_rport(
1009 struct bfa_fcs_lport_s
*port
,
1010 struct bfa_fcs_rport_s
*rport
)
1012 WARN_ON(!bfa_q_is_on_q(&port
->rport_q
, rport
));
1013 list_del(&rport
->qe
);
1016 bfa_sm_send_event(port
, BFA_FCS_PORT_SM_DELRPORT
);
1020 * Called by fabric for base port when fabric login is complete.
1021 * Called by vport for virtual ports when FDISC is complete.
1024 bfa_fcs_lport_online(struct bfa_fcs_lport_s
*port
)
1026 bfa_sm_send_event(port
, BFA_FCS_PORT_SM_ONLINE
);
1030 * Called by fabric for base port when fabric goes offline.
1031 * Called by vport for virtual ports when virtual port becomes offline.
1034 bfa_fcs_lport_offline(struct bfa_fcs_lport_s
*port
)
1036 bfa_sm_send_event(port
, BFA_FCS_PORT_SM_OFFLINE
);
1040 * Called by fabric for base port and by vport for virtual ports
1041 * when target mode driver is unloaded.
1044 bfa_fcs_lport_stop(struct bfa_fcs_lport_s
*port
)
1046 bfa_sm_send_event(port
, BFA_FCS_PORT_SM_STOP
);
1050 * Called by fabric to delete base lport and associated resources.
1052 * Called by vport to delete lport and associated resources. Should call
1053 * bfa_fcs_vport_delete_comp() for vports on completion.
1056 bfa_fcs_lport_delete(struct bfa_fcs_lport_s
*port
)
1058 bfa_sm_send_event(port
, BFA_FCS_PORT_SM_DELETE
);
1062 * Return TRUE if port is online, else return FALSE
1065 bfa_fcs_lport_is_online(struct bfa_fcs_lport_s
*port
)
1067 return bfa_sm_cmp_state(port
, bfa_fcs_lport_sm_online
);
1071 * Attach time initialization of logical ports.
1074 bfa_fcs_lport_attach(struct bfa_fcs_lport_s
*lport
, struct bfa_fcs_s
*fcs
,
1075 u16 vf_id
, struct bfa_fcs_vport_s
*vport
)
1078 lport
->fabric
= bfa_fcs_vf_lookup(fcs
, vf_id
);
1079 lport
->vport
= vport
;
1080 lport
->lp_tag
= (vport
) ? vport
->lps
->bfa_tag
:
1081 lport
->fabric
->lps
->bfa_tag
;
1083 INIT_LIST_HEAD(&lport
->rport_q
);
1084 lport
->num_rports
= 0;
1088 * Logical port initialization of base or virtual port.
1089 * Called by fabric for base port or by vport for virtual ports.
1093 bfa_fcs_lport_init(struct bfa_fcs_lport_s
*lport
,
1094 struct bfa_lport_cfg_s
*port_cfg
)
1096 struct bfa_fcs_vport_s
*vport
= lport
->vport
;
1097 struct bfad_s
*bfad
= (struct bfad_s
*)lport
->fcs
->bfad
;
1098 char lpwwn_buf
[BFA_STRING_32
];
1100 lport
->port_cfg
= *port_cfg
;
1102 lport
->bfad_port
= bfa_fcb_lport_new(lport
->fcs
->bfad
, lport
,
1103 lport
->port_cfg
.roles
,
1104 lport
->fabric
->vf_drv
,
1105 vport
? vport
->vport_drv
: NULL
);
1107 wwn2str(lpwwn_buf
, bfa_fcs_lport_get_pwwn(lport
));
1108 BFA_LOG(KERN_INFO
, bfad
, bfa_log_level
,
1109 "New logical port created: WWN = %s Role = %s\n",
1110 lpwwn_buf
, "Initiator");
1111 bfa_fcs_lport_aen_post(lport
, BFA_LPORT_AEN_NEW
);
1113 bfa_sm_set_state(lport
, bfa_fcs_lport_sm_uninit
);
1114 bfa_sm_send_event(lport
, BFA_FCS_PORT_SM_CREATE
);
1118 bfa_fcs_lport_set_symname(struct bfa_fcs_lport_s
*port
,
1121 strcpy(port
->port_cfg
.sym_name
.symname
, symname
);
1123 if (bfa_sm_cmp_state(port
, bfa_fcs_lport_sm_online
))
1124 bfa_fcs_lport_ns_util_send_rspn_id(
1125 BFA_FCS_GET_NS_FROM_PORT(port
), NULL
);
1133 bfa_fcs_lport_get_attr(
1134 struct bfa_fcs_lport_s
*port
,
1135 struct bfa_lport_attr_s
*port_attr
)
1137 if (bfa_sm_cmp_state(port
, bfa_fcs_lport_sm_online
))
1138 port_attr
->pid
= port
->pid
;
1142 port_attr
->port_cfg
= port
->port_cfg
;
1145 port_attr
->port_type
= port
->fabric
->oper_type
;
1146 port_attr
->loopback
= bfa_sm_cmp_state(port
->fabric
,
1147 bfa_fcs_fabric_sm_loopback
);
1148 port_attr
->authfail
=
1149 bfa_sm_cmp_state(port
->fabric
,
1150 bfa_fcs_fabric_sm_auth_failed
);
1151 port_attr
->fabric_name
= bfa_fcs_lport_get_fabric_name(port
);
1152 memcpy(port_attr
->fabric_ip_addr
,
1153 bfa_fcs_lport_get_fabric_ipaddr(port
),
1154 BFA_FCS_FABRIC_IPADDR_SZ
);
1156 if (port
->vport
!= NULL
) {
1157 port_attr
->port_type
= BFA_PORT_TYPE_VPORT
;
1158 port_attr
->fpma_mac
=
1159 port
->vport
->lps
->lp_mac
;
1161 port_attr
->fpma_mac
=
1162 port
->fabric
->lps
->lp_mac
;
1165 port_attr
->port_type
= BFA_PORT_TYPE_UNKNOWN
;
1166 port_attr
->state
= BFA_LPORT_UNINIT
;
1171 * bfa_fcs_lport_fab port fab functions
1175 * Called by port to initialize fabric services of the base port.
1178 bfa_fcs_lport_fab_init(struct bfa_fcs_lport_s
*port
)
1180 bfa_fcs_lport_ns_init(port
);
1181 bfa_fcs_lport_scn_init(port
);
1182 bfa_fcs_lport_ms_init(port
);
1186 * Called by port to notify transition to online state.
1189 bfa_fcs_lport_fab_online(struct bfa_fcs_lport_s
*port
)
1191 bfa_fcs_lport_ns_online(port
);
1192 bfa_fcs_lport_fab_scn_online(port
);
1196 * Called by port to notify transition to offline state.
1199 bfa_fcs_lport_fab_offline(struct bfa_fcs_lport_s
*port
)
1201 bfa_fcs_lport_ns_offline(port
);
1202 bfa_fcs_lport_scn_offline(port
);
1203 bfa_fcs_lport_ms_offline(port
);
1207 * bfa_fcs_lport_n2n functions
1211 * Called by fcs/port to initialize N2N topology.
1214 bfa_fcs_lport_n2n_init(struct bfa_fcs_lport_s
*port
)
1219 * Called by fcs/port to notify transition to online state.
1222 bfa_fcs_lport_n2n_online(struct bfa_fcs_lport_s
*port
)
1224 struct bfa_fcs_lport_n2n_s
*n2n_port
= &port
->port_topo
.pn2n
;
1225 struct bfa_lport_cfg_s
*pcfg
= &port
->port_cfg
;
1226 struct bfa_fcs_rport_s
*rport
;
1228 bfa_trc(port
->fcs
, pcfg
->pwwn
);
1231 * If our PWWN is > than that of the r-port, we have to initiate PLOGI
1232 * and assign an Address. if not, we need to wait for its PLOGI.
1234 * If our PWWN is < than that of the remote port, it will send a PLOGI
1235 * with the PIDs assigned. The rport state machine take care of this
1239 ((void *)&pcfg
->pwwn
, (void *)&n2n_port
->rem_port_wwn
,
1240 sizeof(wwn_t
)) > 0) {
1241 port
->pid
= N2N_LOCAL_PID
;
1242 bfa_lps_set_n2n_pid(port
->fabric
->lps
, N2N_LOCAL_PID
);
1244 * First, check if we know the device by pwwn.
1246 rport
= bfa_fcs_lport_get_rport_by_pwwn(port
,
1247 n2n_port
->rem_port_wwn
);
1249 bfa_trc(port
->fcs
, rport
->pid
);
1250 bfa_trc(port
->fcs
, rport
->pwwn
);
1251 rport
->pid
= N2N_REMOTE_PID
;
1252 bfa_sm_send_event(rport
, RPSM_EVENT_PLOGI_SEND
);
1257 * In n2n there can be only one rport. Delete the old one
1258 * whose pid should be zero, because it is offline.
1260 if (port
->num_rports
> 0) {
1261 rport
= bfa_fcs_lport_get_rport_by_pid(port
, 0);
1262 WARN_ON(rport
== NULL
);
1264 bfa_trc(port
->fcs
, rport
->pwwn
);
1265 bfa_sm_send_event(rport
, RPSM_EVENT_DELETE
);
1268 bfa_fcs_rport_create(port
, N2N_REMOTE_PID
);
1273 * Called by fcs/port to notify transition to offline state.
1276 bfa_fcs_lport_n2n_offline(struct bfa_fcs_lport_s
*port
)
1278 struct bfa_fcs_lport_n2n_s
*n2n_port
= &port
->port_topo
.pn2n
;
1280 bfa_trc(port
->fcs
, port
->pid
);
1282 n2n_port
->rem_port_wwn
= 0;
1283 n2n_port
->reply_oxid
= 0;
1287 bfa_fcport_get_loop_attr(struct bfa_fcs_lport_s
*port
)
1289 int i
= 0, j
= 0, bit
= 0, alpa_bit
= 0;
1291 struct bfa_fcport_s
*fcport
= BFA_FCPORT_MOD(port
->fcs
->bfa
);
1293 port
->port_topo
.ploop
.alpabm_valid
= fcport
->alpabm_valid
;
1294 port
->pid
= fcport
->myalpa
;
1295 port
->pid
= bfa_hton3b(port
->pid
);
1297 for (i
= 0; i
< (FC_ALPA_MAX
/ 8); i
++) {
1298 for (j
= 0, alpa_bit
= 0; j
< 8; j
++, alpa_bit
++) {
1299 bfa_trc(port
->fcs
->bfa
, fcport
->alpabm
.alpa_bm
[i
]);
1300 bit
= (fcport
->alpabm
.alpa_bm
[i
] & (1 << (7 - j
)));
1302 port
->port_topo
.ploop
.alpa_pos_map
[k
] =
1303 loop_alpa_map
[(i
* 8) + alpa_bit
];
1305 bfa_trc(port
->fcs
->bfa
, k
);
1306 bfa_trc(port
->fcs
->bfa
,
1307 port
->port_topo
.ploop
.alpa_pos_map
[k
]);
1311 port
->port_topo
.ploop
.num_alpa
= k
;
1315 * Called by fcs/port to initialize Loop topology.
1318 bfa_fcs_lport_loop_init(struct bfa_fcs_lport_s
*port
)
1323 * Called by fcs/port to notify transition to online state.
1326 bfa_fcs_lport_loop_online(struct bfa_fcs_lport_s
*port
)
1328 u8 num_alpa
= 0, alpabm_valid
= 0;
1329 struct bfa_fcs_rport_s
*rport
;
1330 u8
*alpa_map
= NULL
;
1334 bfa_fcport_get_loop_attr(port
);
1336 num_alpa
= port
->port_topo
.ploop
.num_alpa
;
1337 alpabm_valid
= port
->port_topo
.ploop
.alpabm_valid
;
1338 alpa_map
= port
->port_topo
.ploop
.alpa_pos_map
;
1340 bfa_trc(port
->fcs
->bfa
, port
->pid
);
1341 bfa_trc(port
->fcs
->bfa
, num_alpa
);
1342 if (alpabm_valid
== 1) {
1343 for (i
= 0; i
< num_alpa
; i
++) {
1344 bfa_trc(port
->fcs
->bfa
, alpa_map
[i
]);
1345 if (alpa_map
[i
] != bfa_hton3b(port
->pid
)) {
1347 bfa_trc(port
->fcs
->bfa
, pid
);
1348 rport
= bfa_fcs_lport_get_rport_by_pid(port
,
1351 rport
= bfa_fcs_rport_create(port
,
1356 for (i
= 0; i
< MAX_ALPA_COUNT
; i
++) {
1357 if (alpa_map
[i
] != port
->pid
) {
1358 pid
= loop_alpa_map
[i
];
1359 bfa_trc(port
->fcs
->bfa
, pid
);
1360 rport
= bfa_fcs_lport_get_rport_by_pid(port
,
1363 rport
= bfa_fcs_rport_create(port
,
1371 * Called by fcs/port to notify transition to offline state.
1374 bfa_fcs_lport_loop_offline(struct bfa_fcs_lport_s
*port
)
1378 #define BFA_FCS_FDMI_CMD_MAX_RETRIES 2
1381 * forward declarations
1383 static void bfa_fcs_lport_fdmi_send_rhba(void *fdmi_cbarg
,
1384 struct bfa_fcxp_s
*fcxp_alloced
);
1385 static void bfa_fcs_lport_fdmi_send_rprt(void *fdmi_cbarg
,
1386 struct bfa_fcxp_s
*fcxp_alloced
);
1387 static void bfa_fcs_lport_fdmi_send_rpa(void *fdmi_cbarg
,
1388 struct bfa_fcxp_s
*fcxp_alloced
);
1389 static void bfa_fcs_lport_fdmi_rhba_response(void *fcsarg
,
1390 struct bfa_fcxp_s
*fcxp
,
1392 bfa_status_t req_status
,
1395 struct fchs_s
*rsp_fchs
);
1396 static void bfa_fcs_lport_fdmi_rprt_response(void *fcsarg
,
1397 struct bfa_fcxp_s
*fcxp
,
1399 bfa_status_t req_status
,
1402 struct fchs_s
*rsp_fchs
);
1403 static void bfa_fcs_lport_fdmi_rpa_response(void *fcsarg
,
1404 struct bfa_fcxp_s
*fcxp
,
1406 bfa_status_t req_status
,
1409 struct fchs_s
*rsp_fchs
);
1410 static void bfa_fcs_lport_fdmi_timeout(void *arg
);
1411 static u16
bfa_fcs_lport_fdmi_build_rhba_pyld(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1413 static u16
bfa_fcs_lport_fdmi_build_rprt_pyld(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1415 static u16
bfa_fcs_lport_fdmi_build_rpa_pyld(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1417 static u16
bfa_fcs_lport_fdmi_build_portattr_block(struct bfa_fcs_lport_fdmi_s
*
1419 static void bfa_fcs_fdmi_get_hbaattr(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1420 struct bfa_fcs_fdmi_hba_attr_s
*hba_attr
);
1421 static void bfa_fcs_fdmi_get_portattr(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1422 struct bfa_fcs_fdmi_port_attr_s
*port_attr
);
1423 u32
bfa_fcs_fdmi_convert_speed(enum bfa_port_speed pport_speed
);
1426 * fcs_fdmi_sm FCS FDMI state machine
1430 * FDMI State Machine events
1432 enum port_fdmi_event
{
1433 FDMISM_EVENT_PORT_ONLINE
= 1,
1434 FDMISM_EVENT_PORT_OFFLINE
= 2,
1435 FDMISM_EVENT_RSP_OK
= 4,
1436 FDMISM_EVENT_RSP_ERROR
= 5,
1437 FDMISM_EVENT_TIMEOUT
= 6,
1438 FDMISM_EVENT_RHBA_SENT
= 7,
1439 FDMISM_EVENT_RPRT_SENT
= 8,
1440 FDMISM_EVENT_RPA_SENT
= 9,
1443 static void bfa_fcs_lport_fdmi_sm_offline(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1444 enum port_fdmi_event event
);
1445 static void bfa_fcs_lport_fdmi_sm_sending_rhba(
1446 struct bfa_fcs_lport_fdmi_s
*fdmi
,
1447 enum port_fdmi_event event
);
1448 static void bfa_fcs_lport_fdmi_sm_rhba(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1449 enum port_fdmi_event event
);
1450 static void bfa_fcs_lport_fdmi_sm_rhba_retry(
1451 struct bfa_fcs_lport_fdmi_s
*fdmi
,
1452 enum port_fdmi_event event
);
1453 static void bfa_fcs_lport_fdmi_sm_sending_rprt(
1454 struct bfa_fcs_lport_fdmi_s
*fdmi
,
1455 enum port_fdmi_event event
);
1456 static void bfa_fcs_lport_fdmi_sm_rprt(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1457 enum port_fdmi_event event
);
1458 static void bfa_fcs_lport_fdmi_sm_rprt_retry(
1459 struct bfa_fcs_lport_fdmi_s
*fdmi
,
1460 enum port_fdmi_event event
);
1461 static void bfa_fcs_lport_fdmi_sm_sending_rpa(
1462 struct bfa_fcs_lport_fdmi_s
*fdmi
,
1463 enum port_fdmi_event event
);
1464 static void bfa_fcs_lport_fdmi_sm_rpa(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1465 enum port_fdmi_event event
);
1466 static void bfa_fcs_lport_fdmi_sm_rpa_retry(
1467 struct bfa_fcs_lport_fdmi_s
*fdmi
,
1468 enum port_fdmi_event event
);
1469 static void bfa_fcs_lport_fdmi_sm_online(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1470 enum port_fdmi_event event
);
1471 static void bfa_fcs_lport_fdmi_sm_disabled(
1472 struct bfa_fcs_lport_fdmi_s
*fdmi
,
1473 enum port_fdmi_event event
);
1475 * Start in offline state - awaiting MS to send start.
1478 bfa_fcs_lport_fdmi_sm_offline(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1479 enum port_fdmi_event event
)
1481 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
1483 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
1484 bfa_trc(port
->fcs
, event
);
1486 fdmi
->retry_cnt
= 0;
1489 case FDMISM_EVENT_PORT_ONLINE
:
1492 * For Vports, register a new port.
1494 bfa_sm_set_state(fdmi
,
1495 bfa_fcs_lport_fdmi_sm_sending_rprt
);
1496 bfa_fcs_lport_fdmi_send_rprt(fdmi
, NULL
);
1499 * For a base port, we should first register the HBA
1500 * attribute. The HBA attribute also contains the base
1501 * port registration.
1503 bfa_sm_set_state(fdmi
,
1504 bfa_fcs_lport_fdmi_sm_sending_rhba
);
1505 bfa_fcs_lport_fdmi_send_rhba(fdmi
, NULL
);
1509 case FDMISM_EVENT_PORT_OFFLINE
:
1513 bfa_sm_fault(port
->fcs
, event
);
1518 bfa_fcs_lport_fdmi_sm_sending_rhba(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1519 enum port_fdmi_event event
)
1521 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
1523 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
1524 bfa_trc(port
->fcs
, event
);
1527 case FDMISM_EVENT_RHBA_SENT
:
1528 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_rhba
);
1531 case FDMISM_EVENT_PORT_OFFLINE
:
1532 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_offline
);
1533 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(port
),
1538 bfa_sm_fault(port
->fcs
, event
);
1543 bfa_fcs_lport_fdmi_sm_rhba(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1544 enum port_fdmi_event event
)
1546 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
1548 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
1549 bfa_trc(port
->fcs
, event
);
1552 case FDMISM_EVENT_RSP_ERROR
:
1554 * if max retries have not been reached, start timer for a
1557 if (fdmi
->retry_cnt
++ < BFA_FCS_FDMI_CMD_MAX_RETRIES
) {
1558 bfa_sm_set_state(fdmi
,
1559 bfa_fcs_lport_fdmi_sm_rhba_retry
);
1560 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(port
),
1562 bfa_fcs_lport_fdmi_timeout
, fdmi
,
1563 BFA_FCS_RETRY_TIMEOUT
);
1566 * set state to offline
1568 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_offline
);
1572 case FDMISM_EVENT_RSP_OK
:
1574 * Initiate Register Port Attributes
1576 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_sending_rpa
);
1577 fdmi
->retry_cnt
= 0;
1578 bfa_fcs_lport_fdmi_send_rpa(fdmi
, NULL
);
1581 case FDMISM_EVENT_PORT_OFFLINE
:
1582 bfa_fcxp_discard(fdmi
->fcxp
);
1583 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_offline
);
1587 bfa_sm_fault(port
->fcs
, event
);
1592 bfa_fcs_lport_fdmi_sm_rhba_retry(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1593 enum port_fdmi_event event
)
1595 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
1597 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
1598 bfa_trc(port
->fcs
, event
);
1601 case FDMISM_EVENT_TIMEOUT
:
1603 * Retry Timer Expired. Re-send
1605 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_sending_rhba
);
1606 bfa_fcs_lport_fdmi_send_rhba(fdmi
, NULL
);
1609 case FDMISM_EVENT_PORT_OFFLINE
:
1610 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_offline
);
1611 bfa_timer_stop(&fdmi
->timer
);
1615 bfa_sm_fault(port
->fcs
, event
);
1620 * RPRT : Register Port
1623 bfa_fcs_lport_fdmi_sm_sending_rprt(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1624 enum port_fdmi_event event
)
1626 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
1628 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
1629 bfa_trc(port
->fcs
, event
);
1632 case FDMISM_EVENT_RPRT_SENT
:
1633 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_rprt
);
1636 case FDMISM_EVENT_PORT_OFFLINE
:
1637 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_offline
);
1638 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(port
),
1643 bfa_sm_fault(port
->fcs
, event
);
1648 bfa_fcs_lport_fdmi_sm_rprt(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1649 enum port_fdmi_event event
)
1651 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
1653 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
1654 bfa_trc(port
->fcs
, event
);
1657 case FDMISM_EVENT_RSP_ERROR
:
1659 * if max retries have not been reached, start timer for a
1662 if (fdmi
->retry_cnt
++ < BFA_FCS_FDMI_CMD_MAX_RETRIES
) {
1663 bfa_sm_set_state(fdmi
,
1664 bfa_fcs_lport_fdmi_sm_rprt_retry
);
1665 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(port
),
1667 bfa_fcs_lport_fdmi_timeout
, fdmi
,
1668 BFA_FCS_RETRY_TIMEOUT
);
1672 * set state to offline
1674 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_offline
);
1675 fdmi
->retry_cnt
= 0;
1679 case FDMISM_EVENT_RSP_OK
:
1680 fdmi
->retry_cnt
= 0;
1681 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_online
);
1684 case FDMISM_EVENT_PORT_OFFLINE
:
1685 bfa_fcxp_discard(fdmi
->fcxp
);
1686 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_offline
);
1690 bfa_sm_fault(port
->fcs
, event
);
1695 bfa_fcs_lport_fdmi_sm_rprt_retry(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1696 enum port_fdmi_event event
)
1698 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
1700 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
1701 bfa_trc(port
->fcs
, event
);
1704 case FDMISM_EVENT_TIMEOUT
:
1706 * Retry Timer Expired. Re-send
1708 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_sending_rprt
);
1709 bfa_fcs_lport_fdmi_send_rprt(fdmi
, NULL
);
1712 case FDMISM_EVENT_PORT_OFFLINE
:
1713 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_offline
);
1714 bfa_timer_stop(&fdmi
->timer
);
1718 bfa_sm_fault(port
->fcs
, event
);
1723 * Register Port Attributes
1726 bfa_fcs_lport_fdmi_sm_sending_rpa(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1727 enum port_fdmi_event event
)
1729 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
1731 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
1732 bfa_trc(port
->fcs
, event
);
1735 case FDMISM_EVENT_RPA_SENT
:
1736 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_rpa
);
1739 case FDMISM_EVENT_PORT_OFFLINE
:
1740 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_offline
);
1741 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(port
),
1746 bfa_sm_fault(port
->fcs
, event
);
1751 bfa_fcs_lport_fdmi_sm_rpa(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1752 enum port_fdmi_event event
)
1754 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
1756 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
1757 bfa_trc(port
->fcs
, event
);
1760 case FDMISM_EVENT_RSP_ERROR
:
1762 * if max retries have not been reached, start timer for a
1765 if (fdmi
->retry_cnt
++ < BFA_FCS_FDMI_CMD_MAX_RETRIES
) {
1766 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_rpa_retry
);
1767 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(port
),
1769 bfa_fcs_lport_fdmi_timeout
, fdmi
,
1770 BFA_FCS_RETRY_TIMEOUT
);
1773 * set state to offline
1775 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_offline
);
1776 fdmi
->retry_cnt
= 0;
1780 case FDMISM_EVENT_RSP_OK
:
1781 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_online
);
1782 fdmi
->retry_cnt
= 0;
1785 case FDMISM_EVENT_PORT_OFFLINE
:
1786 bfa_fcxp_discard(fdmi
->fcxp
);
1787 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_offline
);
1791 bfa_sm_fault(port
->fcs
, event
);
1796 bfa_fcs_lport_fdmi_sm_rpa_retry(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1797 enum port_fdmi_event event
)
1799 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
1801 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
1802 bfa_trc(port
->fcs
, event
);
1805 case FDMISM_EVENT_TIMEOUT
:
1807 * Retry Timer Expired. Re-send
1809 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_sending_rpa
);
1810 bfa_fcs_lport_fdmi_send_rpa(fdmi
, NULL
);
1813 case FDMISM_EVENT_PORT_OFFLINE
:
1814 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_offline
);
1815 bfa_timer_stop(&fdmi
->timer
);
1819 bfa_sm_fault(port
->fcs
, event
);
1824 bfa_fcs_lport_fdmi_sm_online(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1825 enum port_fdmi_event event
)
1827 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
1829 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
1830 bfa_trc(port
->fcs
, event
);
1833 case FDMISM_EVENT_PORT_OFFLINE
:
1834 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_offline
);
1838 bfa_sm_fault(port
->fcs
, event
);
1842 * FDMI is disabled state.
1845 bfa_fcs_lport_fdmi_sm_disabled(struct bfa_fcs_lport_fdmi_s
*fdmi
,
1846 enum port_fdmi_event event
)
1848 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
1850 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
1851 bfa_trc(port
->fcs
, event
);
1853 /* No op State. It can only be enabled at Driver Init. */
1857 * RHBA : Register HBA Attributes.
1860 bfa_fcs_lport_fdmi_send_rhba(void *fdmi_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
1862 struct bfa_fcs_lport_fdmi_s
*fdmi
= fdmi_cbarg
;
1863 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
1866 struct bfa_fcxp_s
*fcxp
;
1869 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
1871 fcxp
= fcxp_alloced
? fcxp_alloced
:
1872 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
1874 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &fdmi
->fcxp_wqe
,
1875 bfa_fcs_lport_fdmi_send_rhba
, fdmi
, BFA_TRUE
);
1880 pyld
= bfa_fcxp_get_reqbuf(fcxp
);
1881 memset(pyld
, 0, FC_MAX_PDUSZ
);
1883 len
= fc_fdmi_reqhdr_build(&fchs
, pyld
, bfa_fcs_lport_get_fcid(port
),
1887 bfa_fcs_lport_fdmi_build_rhba_pyld(fdmi
,
1888 (u8
*) ((struct ct_hdr_s
*) pyld
1891 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
1892 FC_CLASS_3
, (len
+ attr_len
), &fchs
,
1893 bfa_fcs_lport_fdmi_rhba_response
, (void *)fdmi
,
1894 FC_MAX_PDUSZ
, FC_FCCT_TOV
);
1896 bfa_sm_send_event(fdmi
, FDMISM_EVENT_RHBA_SENT
);
1900 bfa_fcs_lport_fdmi_build_rhba_pyld(struct bfa_fcs_lport_fdmi_s
*fdmi
, u8
*pyld
)
1902 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
1903 struct bfa_fcs_fdmi_hba_attr_s hba_attr
;
1904 struct bfa_fcs_fdmi_hba_attr_s
*fcs_hba_attr
= &hba_attr
;
1905 struct fdmi_rhba_s
*rhba
= (struct fdmi_rhba_s
*) pyld
;
1906 struct fdmi_attr_s
*attr
;
1912 * get hba attributes
1914 bfa_fcs_fdmi_get_hbaattr(fdmi
, fcs_hba_attr
);
1916 rhba
->hba_id
= bfa_fcs_lport_get_pwwn(port
);
1917 rhba
->port_list
.num_ports
= cpu_to_be32(1);
1918 rhba
->port_list
.port_entry
= bfa_fcs_lport_get_pwwn(port
);
1920 len
= sizeof(rhba
->hba_id
) + sizeof(rhba
->port_list
);
1923 len
+= sizeof(rhba
->hba_attr_blk
.attr_count
);
1926 * fill out the invididual entries of the HBA attrib Block
1928 curr_ptr
= (u8
*) &rhba
->hba_attr_blk
.hba_attr
;
1933 attr
= (struct fdmi_attr_s
*) curr_ptr
;
1934 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_NODENAME
);
1935 templen
= sizeof(wwn_t
);
1936 memcpy(attr
->value
, &bfa_fcs_lport_get_nwwn(port
), templen
);
1937 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
1940 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
1946 attr
= (struct fdmi_attr_s
*) curr_ptr
;
1947 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_MANUFACTURER
);
1948 templen
= (u16
) strlen(fcs_hba_attr
->manufacturer
);
1949 memcpy(attr
->value
, fcs_hba_attr
->manufacturer
, templen
);
1950 templen
= fc_roundup(templen
, sizeof(u32
));
1951 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
1954 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
1960 attr
= (struct fdmi_attr_s
*) curr_ptr
;
1961 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_SERIALNUM
);
1962 templen
= (u16
) strlen(fcs_hba_attr
->serial_num
);
1963 memcpy(attr
->value
, fcs_hba_attr
->serial_num
, templen
);
1964 templen
= fc_roundup(templen
, sizeof(u32
));
1965 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
1968 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
1974 attr
= (struct fdmi_attr_s
*) curr_ptr
;
1975 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_MODEL
);
1976 templen
= (u16
) strlen(fcs_hba_attr
->model
);
1977 memcpy(attr
->value
, fcs_hba_attr
->model
, templen
);
1978 templen
= fc_roundup(templen
, sizeof(u32
));
1979 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
1982 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
1988 attr
= (struct fdmi_attr_s
*) curr_ptr
;
1989 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_MODEL_DESC
);
1990 templen
= (u16
) strlen(fcs_hba_attr
->model_desc
);
1991 memcpy(attr
->value
, fcs_hba_attr
->model_desc
, templen
);
1992 templen
= fc_roundup(templen
, sizeof(u32
));
1993 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
1996 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2002 if (fcs_hba_attr
->hw_version
[0] != '\0') {
2003 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2004 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_HW_VERSION
);
2005 templen
= (u16
) strlen(fcs_hba_attr
->hw_version
);
2006 memcpy(attr
->value
, fcs_hba_attr
->hw_version
, templen
);
2007 templen
= fc_roundup(templen
, sizeof(u32
));
2008 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2011 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2018 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2019 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_DRIVER_VERSION
);
2020 templen
= (u16
) strlen(fcs_hba_attr
->driver_version
);
2021 memcpy(attr
->value
, fcs_hba_attr
->driver_version
, templen
);
2022 templen
= fc_roundup(templen
, sizeof(u32
));
2023 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2026 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2030 * Option Rom Version
2032 if (fcs_hba_attr
->option_rom_ver
[0] != '\0') {
2033 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2034 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_ROM_VERSION
);
2035 templen
= (u16
) strlen(fcs_hba_attr
->option_rom_ver
);
2036 memcpy(attr
->value
, fcs_hba_attr
->option_rom_ver
, templen
);
2037 templen
= fc_roundup(templen
, sizeof(u32
));
2038 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2041 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2045 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2046 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_FW_VERSION
);
2047 templen
= (u16
) strlen(fcs_hba_attr
->fw_version
);
2048 memcpy(attr
->value
, fcs_hba_attr
->fw_version
, templen
);
2049 templen
= fc_roundup(templen
, sizeof(u32
));
2050 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2053 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2059 if (fcs_hba_attr
->os_name
[0] != '\0') {
2060 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2061 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_OS_NAME
);
2062 templen
= (u16
) strlen(fcs_hba_attr
->os_name
);
2063 memcpy(attr
->value
, fcs_hba_attr
->os_name
, templen
);
2064 templen
= fc_roundup(templen
, sizeof(u32
));
2065 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2068 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2075 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2076 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_MAX_CT
);
2077 templen
= sizeof(fcs_hba_attr
->max_ct_pyld
);
2078 memcpy(attr
->value
, &fcs_hba_attr
->max_ct_pyld
, templen
);
2079 templen
= fc_roundup(templen
, sizeof(u32
));
2080 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2083 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2086 * Send extended attributes ( FOS 7.1 support )
2088 if (fdmi
->retry_cnt
== 0) {
2089 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2090 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_NODE_SYM_NAME
);
2091 templen
= sizeof(fcs_hba_attr
->node_sym_name
);
2092 memcpy(attr
->value
, &fcs_hba_attr
->node_sym_name
, templen
);
2093 templen
= fc_roundup(templen
, sizeof(u32
));
2094 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2097 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2100 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2101 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_VENDOR_ID
);
2102 templen
= sizeof(fcs_hba_attr
->vendor_info
);
2103 memcpy(attr
->value
, &fcs_hba_attr
->vendor_info
, templen
);
2104 templen
= fc_roundup(templen
, sizeof(u32
));
2105 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2108 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2111 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2112 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_NUM_PORTS
);
2113 templen
= sizeof(fcs_hba_attr
->num_ports
);
2114 memcpy(attr
->value
, &fcs_hba_attr
->num_ports
, templen
);
2115 templen
= fc_roundup(templen
, sizeof(u32
));
2116 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2119 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2122 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2123 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_FABRIC_NAME
);
2124 templen
= sizeof(fcs_hba_attr
->fabric_name
);
2125 memcpy(attr
->value
, &fcs_hba_attr
->fabric_name
, templen
);
2126 templen
= fc_roundup(templen
, sizeof(u32
));
2127 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2130 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2133 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2134 attr
->type
= cpu_to_be16(FDMI_HBA_ATTRIB_BIOS_VER
);
2135 templen
= sizeof(fcs_hba_attr
->bios_ver
);
2136 memcpy(attr
->value
, &fcs_hba_attr
->bios_ver
, templen
);
2137 templen
= fc_roundup(attr
->len
, sizeof(u32
));
2138 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2141 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2146 * Update size of payload
2148 len
+= ((sizeof(attr
->type
) + sizeof(attr
->len
)) * count
);
2150 rhba
->hba_attr_blk
.attr_count
= cpu_to_be32(count
);
2155 bfa_fcs_lport_fdmi_rhba_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
,
2156 void *cbarg
, bfa_status_t req_status
,
2157 u32 rsp_len
, u32 resid_len
,
2158 struct fchs_s
*rsp_fchs
)
2160 struct bfa_fcs_lport_fdmi_s
*fdmi
=
2161 (struct bfa_fcs_lport_fdmi_s
*) cbarg
;
2162 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
2163 struct ct_hdr_s
*cthdr
= NULL
;
2165 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
2170 if (req_status
!= BFA_STATUS_OK
) {
2171 bfa_trc(port
->fcs
, req_status
);
2172 bfa_sm_send_event(fdmi
, FDMISM_EVENT_RSP_ERROR
);
2176 cthdr
= (struct ct_hdr_s
*) BFA_FCXP_RSP_PLD(fcxp
);
2177 cthdr
->cmd_rsp_code
= be16_to_cpu(cthdr
->cmd_rsp_code
);
2179 if (cthdr
->cmd_rsp_code
== CT_RSP_ACCEPT
) {
2180 bfa_sm_send_event(fdmi
, FDMISM_EVENT_RSP_OK
);
2184 bfa_trc(port
->fcs
, cthdr
->reason_code
);
2185 bfa_trc(port
->fcs
, cthdr
->exp_code
);
2186 bfa_sm_send_event(fdmi
, FDMISM_EVENT_RSP_ERROR
);
2190 * RPRT : Register Port
2193 bfa_fcs_lport_fdmi_send_rprt(void *fdmi_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
2195 struct bfa_fcs_lport_fdmi_s
*fdmi
= fdmi_cbarg
;
2196 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
2199 struct bfa_fcxp_s
*fcxp
;
2202 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
2204 fcxp
= fcxp_alloced
? fcxp_alloced
:
2205 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
2207 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &fdmi
->fcxp_wqe
,
2208 bfa_fcs_lport_fdmi_send_rprt
, fdmi
, BFA_TRUE
);
2213 pyld
= bfa_fcxp_get_reqbuf(fcxp
);
2214 memset(pyld
, 0, FC_MAX_PDUSZ
);
2216 len
= fc_fdmi_reqhdr_build(&fchs
, pyld
, bfa_fcs_lport_get_fcid(port
),
2220 bfa_fcs_lport_fdmi_build_rprt_pyld(fdmi
,
2221 (u8
*) ((struct ct_hdr_s
*) pyld
2224 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
2225 FC_CLASS_3
, len
+ attr_len
, &fchs
,
2226 bfa_fcs_lport_fdmi_rprt_response
, (void *)fdmi
,
2227 FC_MAX_PDUSZ
, FC_FCCT_TOV
);
2229 bfa_sm_send_event(fdmi
, FDMISM_EVENT_RPRT_SENT
);
2233 * This routine builds Port Attribute Block that used in RPA, RPRT commands.
2236 bfa_fcs_lport_fdmi_build_portattr_block(struct bfa_fcs_lport_fdmi_s
*fdmi
,
2239 struct bfa_fcs_fdmi_port_attr_s fcs_port_attr
;
2240 struct fdmi_port_attr_s
*port_attrib
= (struct fdmi_port_attr_s
*) pyld
;
2241 struct fdmi_attr_s
*attr
;
2248 * get port attributes
2250 bfa_fcs_fdmi_get_portattr(fdmi
, &fcs_port_attr
);
2252 len
= sizeof(port_attrib
->attr_count
);
2255 * fill out the invididual entries
2257 curr_ptr
= (u8
*) &port_attrib
->port_attr
;
2262 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2263 attr
->type
= cpu_to_be16(FDMI_PORT_ATTRIB_FC4_TYPES
);
2264 templen
= sizeof(fcs_port_attr
.supp_fc4_types
);
2265 memcpy(attr
->value
, fcs_port_attr
.supp_fc4_types
, templen
);
2266 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2270 cpu_to_be16(templen
+ sizeof(attr
->type
) +
2276 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2277 attr
->type
= cpu_to_be16(FDMI_PORT_ATTRIB_SUPP_SPEED
);
2278 templen
= sizeof(fcs_port_attr
.supp_speed
);
2279 memcpy(attr
->value
, &fcs_port_attr
.supp_speed
, templen
);
2280 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2284 cpu_to_be16(templen
+ sizeof(attr
->type
) +
2288 * current Port Speed
2290 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2291 attr
->type
= cpu_to_be16(FDMI_PORT_ATTRIB_PORT_SPEED
);
2292 templen
= sizeof(fcs_port_attr
.curr_speed
);
2293 memcpy(attr
->value
, &fcs_port_attr
.curr_speed
, templen
);
2294 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2297 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2303 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2304 attr
->type
= cpu_to_be16(FDMI_PORT_ATTRIB_FRAME_SIZE
);
2305 templen
= sizeof(fcs_port_attr
.max_frm_size
);
2306 memcpy(attr
->value
, &fcs_port_attr
.max_frm_size
, templen
);
2307 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2310 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2316 if (fcs_port_attr
.os_device_name
[0] != '\0') {
2317 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2318 attr
->type
= cpu_to_be16(FDMI_PORT_ATTRIB_DEV_NAME
);
2319 templen
= (u16
) strlen(fcs_port_attr
.os_device_name
);
2320 memcpy(attr
->value
, fcs_port_attr
.os_device_name
, templen
);
2321 templen
= fc_roundup(templen
, sizeof(u32
));
2322 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2325 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2331 if (fcs_port_attr
.host_name
[0] != '\0') {
2332 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2333 attr
->type
= cpu_to_be16(FDMI_PORT_ATTRIB_HOST_NAME
);
2334 templen
= (u16
) strlen(fcs_port_attr
.host_name
);
2335 memcpy(attr
->value
, fcs_port_attr
.host_name
, templen
);
2336 templen
= fc_roundup(templen
, sizeof(u32
));
2337 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2340 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2344 if (fdmi
->retry_cnt
== 0) {
2345 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2346 attr
->type
= cpu_to_be16(FDMI_PORT_ATTRIB_NODE_NAME
);
2347 templen
= sizeof(fcs_port_attr
.node_name
);
2348 memcpy(attr
->value
, &fcs_port_attr
.node_name
, templen
);
2349 templen
= fc_roundup(templen
, sizeof(u32
));
2350 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2353 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2356 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2357 attr
->type
= cpu_to_be16(FDMI_PORT_ATTRIB_PORT_NAME
);
2358 templen
= sizeof(fcs_port_attr
.port_name
);
2359 memcpy(attr
->value
, &fcs_port_attr
.port_name
, templen
);
2360 templen
= fc_roundup(templen
, sizeof(u32
));
2361 curr_ptr
+= sizeof(attr
->type
) + sizeof(attr
->len
) + templen
;
2364 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2367 if (fcs_port_attr
.port_sym_name
.symname
[0] != '\0') {
2368 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2370 cpu_to_be16(FDMI_PORT_ATTRIB_PORT_SYM_NAME
);
2371 templen
= sizeof(fcs_port_attr
.port_sym_name
);
2373 &fcs_port_attr
.port_sym_name
, templen
);
2374 templen
= fc_roundup(templen
, sizeof(u32
));
2375 curr_ptr
+= sizeof(attr
->type
) +
2376 sizeof(templen
) + templen
;
2379 attr
->len
= cpu_to_be16(templen
+
2380 sizeof(attr
->type
) + sizeof(templen
));
2383 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2384 attr
->type
= cpu_to_be16(FDMI_PORT_ATTRIB_PORT_TYPE
);
2385 templen
= sizeof(fcs_port_attr
.port_type
);
2386 memcpy(attr
->value
, &fcs_port_attr
.port_type
, templen
);
2387 templen
= fc_roundup(templen
, sizeof(u32
));
2388 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2391 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2394 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2395 attr
->type
= cpu_to_be16(FDMI_PORT_ATTRIB_SUPP_COS
);
2396 templen
= sizeof(fcs_port_attr
.scos
);
2397 memcpy(attr
->value
, &fcs_port_attr
.scos
, templen
);
2398 templen
= fc_roundup(templen
, sizeof(u32
));
2399 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2402 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2405 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2406 attr
->type
= cpu_to_be16(FDMI_PORT_ATTRIB_PORT_FAB_NAME
);
2407 templen
= sizeof(fcs_port_attr
.port_fabric_name
);
2408 memcpy(attr
->value
, &fcs_port_attr
.port_fabric_name
, templen
);
2409 templen
= fc_roundup(templen
, sizeof(u32
));
2410 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2413 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2416 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2417 attr
->type
= cpu_to_be16(FDMI_PORT_ATTRIB_PORT_FC4_TYPE
);
2418 templen
= sizeof(fcs_port_attr
.port_act_fc4_type
);
2419 memcpy(attr
->value
, fcs_port_attr
.port_act_fc4_type
,
2421 templen
= fc_roundup(templen
, sizeof(u32
));
2422 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2425 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2428 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2429 attr
->type
= cpu_to_be16(FDMI_PORT_ATTRIB_PORT_STATE
);
2430 templen
= sizeof(fcs_port_attr
.port_state
);
2431 memcpy(attr
->value
, &fcs_port_attr
.port_state
, templen
);
2432 templen
= fc_roundup(templen
, sizeof(u32
));
2433 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2436 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2439 attr
= (struct fdmi_attr_s
*) curr_ptr
;
2440 attr
->type
= cpu_to_be16(FDMI_PORT_ATTRIB_PORT_NUM_RPRT
);
2441 templen
= sizeof(fcs_port_attr
.num_ports
);
2442 memcpy(attr
->value
, &fcs_port_attr
.num_ports
, templen
);
2443 templen
= fc_roundup(templen
, sizeof(u32
));
2444 curr_ptr
+= sizeof(attr
->type
) + sizeof(templen
) + templen
;
2447 attr
->len
= cpu_to_be16(templen
+ sizeof(attr
->type
) +
2452 * Update size of payload
2454 port_attrib
->attr_count
= cpu_to_be32(count
);
2455 len
+= ((sizeof(attr
->type
) + sizeof(attr
->len
)) * count
);
2460 bfa_fcs_lport_fdmi_build_rprt_pyld(struct bfa_fcs_lport_fdmi_s
*fdmi
, u8
*pyld
)
2462 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
2463 struct fdmi_rprt_s
*rprt
= (struct fdmi_rprt_s
*) pyld
;
2466 rprt
->hba_id
= bfa_fcs_lport_get_pwwn(bfa_fcs_get_base_port(port
->fcs
));
2467 rprt
->port_name
= bfa_fcs_lport_get_pwwn(port
);
2469 len
= bfa_fcs_lport_fdmi_build_portattr_block(fdmi
,
2470 (u8
*) &rprt
->port_attr_blk
);
2472 len
+= sizeof(rprt
->hba_id
) + sizeof(rprt
->port_name
);
2478 bfa_fcs_lport_fdmi_rprt_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
,
2479 void *cbarg
, bfa_status_t req_status
,
2480 u32 rsp_len
, u32 resid_len
,
2481 struct fchs_s
*rsp_fchs
)
2483 struct bfa_fcs_lport_fdmi_s
*fdmi
=
2484 (struct bfa_fcs_lport_fdmi_s
*) cbarg
;
2485 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
2486 struct ct_hdr_s
*cthdr
= NULL
;
2488 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
2493 if (req_status
!= BFA_STATUS_OK
) {
2494 bfa_trc(port
->fcs
, req_status
);
2495 bfa_sm_send_event(fdmi
, FDMISM_EVENT_RSP_ERROR
);
2499 cthdr
= (struct ct_hdr_s
*) BFA_FCXP_RSP_PLD(fcxp
);
2500 cthdr
->cmd_rsp_code
= be16_to_cpu(cthdr
->cmd_rsp_code
);
2502 if (cthdr
->cmd_rsp_code
== CT_RSP_ACCEPT
) {
2503 bfa_sm_send_event(fdmi
, FDMISM_EVENT_RSP_OK
);
2507 bfa_trc(port
->fcs
, cthdr
->reason_code
);
2508 bfa_trc(port
->fcs
, cthdr
->exp_code
);
2509 bfa_sm_send_event(fdmi
, FDMISM_EVENT_RSP_ERROR
);
2513 * RPA : Register Port Attributes.
2516 bfa_fcs_lport_fdmi_send_rpa(void *fdmi_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
2518 struct bfa_fcs_lport_fdmi_s
*fdmi
= fdmi_cbarg
;
2519 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
2522 struct bfa_fcxp_s
*fcxp
;
2525 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
2527 fcxp
= fcxp_alloced
? fcxp_alloced
:
2528 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
2530 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &fdmi
->fcxp_wqe
,
2531 bfa_fcs_lport_fdmi_send_rpa
, fdmi
, BFA_TRUE
);
2536 pyld
= bfa_fcxp_get_reqbuf(fcxp
);
2537 memset(pyld
, 0, FC_MAX_PDUSZ
);
2539 len
= fc_fdmi_reqhdr_build(&fchs
, pyld
, bfa_fcs_lport_get_fcid(port
),
2542 attr_len
= bfa_fcs_lport_fdmi_build_rpa_pyld(fdmi
,
2543 (u8
*) ((struct ct_hdr_s
*) pyld
+ 1));
2545 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
2546 FC_CLASS_3
, len
+ attr_len
, &fchs
,
2547 bfa_fcs_lport_fdmi_rpa_response
, (void *)fdmi
,
2548 FC_MAX_PDUSZ
, FC_FCCT_TOV
);
2550 bfa_sm_send_event(fdmi
, FDMISM_EVENT_RPA_SENT
);
2554 bfa_fcs_lport_fdmi_build_rpa_pyld(struct bfa_fcs_lport_fdmi_s
*fdmi
, u8
*pyld
)
2556 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
2557 struct fdmi_rpa_s
*rpa
= (struct fdmi_rpa_s
*) pyld
;
2560 rpa
->port_name
= bfa_fcs_lport_get_pwwn(port
);
2562 len
= bfa_fcs_lport_fdmi_build_portattr_block(fdmi
,
2563 (u8
*) &rpa
->port_attr_blk
);
2565 len
+= sizeof(rpa
->port_name
);
2571 bfa_fcs_lport_fdmi_rpa_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
,
2572 void *cbarg
, bfa_status_t req_status
, u32 rsp_len
,
2573 u32 resid_len
, struct fchs_s
*rsp_fchs
)
2575 struct bfa_fcs_lport_fdmi_s
*fdmi
=
2576 (struct bfa_fcs_lport_fdmi_s
*) cbarg
;
2577 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
2578 struct ct_hdr_s
*cthdr
= NULL
;
2580 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
2585 if (req_status
!= BFA_STATUS_OK
) {
2586 bfa_trc(port
->fcs
, req_status
);
2587 bfa_sm_send_event(fdmi
, FDMISM_EVENT_RSP_ERROR
);
2591 cthdr
= (struct ct_hdr_s
*) BFA_FCXP_RSP_PLD(fcxp
);
2592 cthdr
->cmd_rsp_code
= be16_to_cpu(cthdr
->cmd_rsp_code
);
2594 if (cthdr
->cmd_rsp_code
== CT_RSP_ACCEPT
) {
2595 bfa_sm_send_event(fdmi
, FDMISM_EVENT_RSP_OK
);
2599 bfa_trc(port
->fcs
, cthdr
->reason_code
);
2600 bfa_trc(port
->fcs
, cthdr
->exp_code
);
2601 bfa_sm_send_event(fdmi
, FDMISM_EVENT_RSP_ERROR
);
2605 bfa_fcs_lport_fdmi_timeout(void *arg
)
2607 struct bfa_fcs_lport_fdmi_s
*fdmi
= (struct bfa_fcs_lport_fdmi_s
*) arg
;
2609 bfa_sm_send_event(fdmi
, FDMISM_EVENT_TIMEOUT
);
2613 bfa_fcs_fdmi_get_hbaattr(struct bfa_fcs_lport_fdmi_s
*fdmi
,
2614 struct bfa_fcs_fdmi_hba_attr_s
*hba_attr
)
2616 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
2617 struct bfa_fcs_driver_info_s
*driver_info
= &port
->fcs
->driver_info
;
2618 struct bfa_fcs_fdmi_port_attr_s fcs_port_attr
;
2620 memset(hba_attr
, 0, sizeof(struct bfa_fcs_fdmi_hba_attr_s
));
2622 bfa_ioc_get_adapter_manufacturer(&port
->fcs
->bfa
->ioc
,
2623 hba_attr
->manufacturer
);
2624 bfa_ioc_get_adapter_serial_num(&port
->fcs
->bfa
->ioc
,
2625 hba_attr
->serial_num
);
2626 bfa_ioc_get_adapter_model(&port
->fcs
->bfa
->ioc
,
2628 bfa_ioc_get_adapter_model(&port
->fcs
->bfa
->ioc
,
2629 hba_attr
->model_desc
);
2630 bfa_ioc_get_pci_chip_rev(&port
->fcs
->bfa
->ioc
,
2631 hba_attr
->hw_version
);
2632 bfa_ioc_get_adapter_optrom_ver(&port
->fcs
->bfa
->ioc
,
2633 hba_attr
->option_rom_ver
);
2634 bfa_ioc_get_adapter_fw_ver(&port
->fcs
->bfa
->ioc
,
2635 hba_attr
->fw_version
);
2637 strlcpy(hba_attr
->driver_version
, (char *)driver_info
->version
,
2638 sizeof(hba_attr
->driver_version
));
2640 strlcpy(hba_attr
->os_name
, driver_info
->host_os_name
,
2641 sizeof(hba_attr
->os_name
));
2644 * If there is a patch level, append it
2645 * to the os name along with a separator
2647 if (driver_info
->host_os_patch
[0] != '\0') {
2648 strlcat(hba_attr
->os_name
, BFA_FCS_PORT_SYMBNAME_SEPARATOR
,
2649 sizeof(hba_attr
->os_name
));
2650 strlcat(hba_attr
->os_name
, driver_info
->host_os_patch
,
2651 sizeof(hba_attr
->os_name
));
2654 /* Retrieve the max frame size from the port attr */
2655 bfa_fcs_fdmi_get_portattr(fdmi
, &fcs_port_attr
);
2656 hba_attr
->max_ct_pyld
= fcs_port_attr
.max_frm_size
;
2658 strlcpy(hba_attr
->node_sym_name
.symname
,
2659 port
->port_cfg
.node_sym_name
.symname
, BFA_SYMNAME_MAXLEN
);
2660 strcpy(hba_attr
->vendor_info
, "QLogic");
2661 hba_attr
->num_ports
=
2662 cpu_to_be32(bfa_ioc_get_nports(&port
->fcs
->bfa
->ioc
));
2663 hba_attr
->fabric_name
= port
->fabric
->lps
->pr_nwwn
;
2664 strlcpy(hba_attr
->bios_ver
, hba_attr
->option_rom_ver
, BFA_VERSION_LEN
);
2669 bfa_fcs_fdmi_get_portattr(struct bfa_fcs_lport_fdmi_s
*fdmi
,
2670 struct bfa_fcs_fdmi_port_attr_s
*port_attr
)
2672 struct bfa_fcs_lport_s
*port
= fdmi
->ms
->port
;
2673 struct bfa_fcs_driver_info_s
*driver_info
= &port
->fcs
->driver_info
;
2674 struct bfa_port_attr_s pport_attr
;
2675 struct bfa_lport_attr_s lport_attr
;
2677 memset(port_attr
, 0, sizeof(struct bfa_fcs_fdmi_port_attr_s
));
2680 * get pport attributes from hal
2682 bfa_fcport_get_attr(port
->fcs
->bfa
, &pport_attr
);
2685 * get FC4 type Bitmask
2687 fc_get_fc4type_bitmask(FC_TYPE_FCP
, port_attr
->supp_fc4_types
);
2692 switch (pport_attr
.speed_supported
) {
2693 case BFA_PORT_SPEED_16GBPS
:
2694 port_attr
->supp_speed
=
2695 cpu_to_be32(BFA_FCS_FDMI_SUPP_SPEEDS_16G
);
2698 case BFA_PORT_SPEED_10GBPS
:
2699 port_attr
->supp_speed
=
2700 cpu_to_be32(BFA_FCS_FDMI_SUPP_SPEEDS_10G
);
2703 case BFA_PORT_SPEED_8GBPS
:
2704 port_attr
->supp_speed
=
2705 cpu_to_be32(BFA_FCS_FDMI_SUPP_SPEEDS_8G
);
2708 case BFA_PORT_SPEED_4GBPS
:
2709 port_attr
->supp_speed
=
2710 cpu_to_be32(BFA_FCS_FDMI_SUPP_SPEEDS_4G
);
2714 bfa_sm_fault(port
->fcs
, pport_attr
.speed_supported
);
2720 port_attr
->curr_speed
= cpu_to_be32(
2721 bfa_fcs_fdmi_convert_speed(pport_attr
.speed
));
2726 port_attr
->max_frm_size
= cpu_to_be32(pport_attr
.pport_cfg
.maxfrsize
);
2731 strlcpy(port_attr
->os_device_name
, driver_info
->os_device_name
,
2732 sizeof(port_attr
->os_device_name
));
2737 strlcpy(port_attr
->host_name
, driver_info
->host_machine_name
,
2738 sizeof(port_attr
->host_name
));
2740 port_attr
->node_name
= bfa_fcs_lport_get_nwwn(port
);
2741 port_attr
->port_name
= bfa_fcs_lport_get_pwwn(port
);
2743 strlcpy(port_attr
->port_sym_name
.symname
,
2744 bfa_fcs_lport_get_psym_name(port
).symname
, BFA_SYMNAME_MAXLEN
);
2745 bfa_fcs_lport_get_attr(port
, &lport_attr
);
2746 port_attr
->port_type
= cpu_to_be32(lport_attr
.port_type
);
2747 port_attr
->scos
= pport_attr
.cos_supported
;
2748 port_attr
->port_fabric_name
= port
->fabric
->lps
->pr_nwwn
;
2749 fc_get_fc4type_bitmask(FC_TYPE_FCP
, port_attr
->port_act_fc4_type
);
2750 port_attr
->port_state
= cpu_to_be32(pport_attr
.port_state
);
2751 port_attr
->num_ports
= cpu_to_be32(port
->num_rports
);
2755 * Convert BFA speed to FDMI format.
2758 bfa_fcs_fdmi_convert_speed(bfa_port_speed_t pport_speed
)
2762 switch (pport_speed
) {
2763 case BFA_PORT_SPEED_1GBPS
:
2764 case BFA_PORT_SPEED_2GBPS
:
2768 case BFA_PORT_SPEED_4GBPS
:
2769 ret
= FDMI_TRANS_SPEED_4G
;
2772 case BFA_PORT_SPEED_8GBPS
:
2773 ret
= FDMI_TRANS_SPEED_8G
;
2776 case BFA_PORT_SPEED_10GBPS
:
2777 ret
= FDMI_TRANS_SPEED_10G
;
2780 case BFA_PORT_SPEED_16GBPS
:
2781 ret
= FDMI_TRANS_SPEED_16G
;
2785 ret
= FDMI_TRANS_SPEED_UNKNOWN
;
2791 bfa_fcs_lport_fdmi_init(struct bfa_fcs_lport_ms_s
*ms
)
2793 struct bfa_fcs_lport_fdmi_s
*fdmi
= &ms
->fdmi
;
2796 if (ms
->port
->fcs
->fdmi_enabled
)
2797 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_offline
);
2799 bfa_sm_set_state(fdmi
, bfa_fcs_lport_fdmi_sm_disabled
);
2803 bfa_fcs_lport_fdmi_offline(struct bfa_fcs_lport_ms_s
*ms
)
2805 struct bfa_fcs_lport_fdmi_s
*fdmi
= &ms
->fdmi
;
2808 bfa_sm_send_event(fdmi
, FDMISM_EVENT_PORT_OFFLINE
);
2812 bfa_fcs_lport_fdmi_online(struct bfa_fcs_lport_ms_s
*ms
)
2814 struct bfa_fcs_lport_fdmi_s
*fdmi
= &ms
->fdmi
;
2817 bfa_sm_send_event(fdmi
, FDMISM_EVENT_PORT_ONLINE
);
2820 #define BFA_FCS_MS_CMD_MAX_RETRIES 2
2823 * forward declarations
2825 static void bfa_fcs_lport_ms_send_plogi(void *ms_cbarg
,
2826 struct bfa_fcxp_s
*fcxp_alloced
);
2827 static void bfa_fcs_lport_ms_timeout(void *arg
);
2828 static void bfa_fcs_lport_ms_plogi_response(void *fcsarg
,
2829 struct bfa_fcxp_s
*fcxp
,
2831 bfa_status_t req_status
,
2834 struct fchs_s
*rsp_fchs
);
2836 static void bfa_fcs_lport_ms_send_gmal(void *ms_cbarg
,
2837 struct bfa_fcxp_s
*fcxp_alloced
);
2838 static void bfa_fcs_lport_ms_gmal_response(void *fcsarg
,
2839 struct bfa_fcxp_s
*fcxp
,
2841 bfa_status_t req_status
,
2844 struct fchs_s
*rsp_fchs
);
2845 static void bfa_fcs_lport_ms_send_gfn(void *ms_cbarg
,
2846 struct bfa_fcxp_s
*fcxp_alloced
);
2847 static void bfa_fcs_lport_ms_gfn_response(void *fcsarg
,
2848 struct bfa_fcxp_s
*fcxp
,
2850 bfa_status_t req_status
,
2853 struct fchs_s
*rsp_fchs
);
2855 * fcs_ms_sm FCS MS state machine
2859 * MS State Machine events
2861 enum port_ms_event
{
2862 MSSM_EVENT_PORT_ONLINE
= 1,
2863 MSSM_EVENT_PORT_OFFLINE
= 2,
2864 MSSM_EVENT_RSP_OK
= 3,
2865 MSSM_EVENT_RSP_ERROR
= 4,
2866 MSSM_EVENT_TIMEOUT
= 5,
2867 MSSM_EVENT_FCXP_SENT
= 6,
2868 MSSM_EVENT_PORT_FABRIC_RSCN
= 7
2871 static void bfa_fcs_lport_ms_sm_offline(struct bfa_fcs_lport_ms_s
*ms
,
2872 enum port_ms_event event
);
2873 static void bfa_fcs_lport_ms_sm_plogi_sending(struct bfa_fcs_lport_ms_s
*ms
,
2874 enum port_ms_event event
);
2875 static void bfa_fcs_lport_ms_sm_plogi(struct bfa_fcs_lport_ms_s
*ms
,
2876 enum port_ms_event event
);
2877 static void bfa_fcs_lport_ms_sm_plogi_retry(struct bfa_fcs_lport_ms_s
*ms
,
2878 enum port_ms_event event
);
2879 static void bfa_fcs_lport_ms_sm_gmal_sending(struct bfa_fcs_lport_ms_s
*ms
,
2880 enum port_ms_event event
);
2881 static void bfa_fcs_lport_ms_sm_gmal(struct bfa_fcs_lport_ms_s
*ms
,
2882 enum port_ms_event event
);
2883 static void bfa_fcs_lport_ms_sm_gmal_retry(struct bfa_fcs_lport_ms_s
*ms
,
2884 enum port_ms_event event
);
2885 static void bfa_fcs_lport_ms_sm_gfn_sending(struct bfa_fcs_lport_ms_s
*ms
,
2886 enum port_ms_event event
);
2887 static void bfa_fcs_lport_ms_sm_gfn(struct bfa_fcs_lport_ms_s
*ms
,
2888 enum port_ms_event event
);
2889 static void bfa_fcs_lport_ms_sm_gfn_retry(struct bfa_fcs_lport_ms_s
*ms
,
2890 enum port_ms_event event
);
2891 static void bfa_fcs_lport_ms_sm_online(struct bfa_fcs_lport_ms_s
*ms
,
2892 enum port_ms_event event
);
2894 * Start in offline state - awaiting NS to send start.
2897 bfa_fcs_lport_ms_sm_offline(struct bfa_fcs_lport_ms_s
*ms
,
2898 enum port_ms_event event
)
2900 bfa_trc(ms
->port
->fcs
, ms
->port
->port_cfg
.pwwn
);
2901 bfa_trc(ms
->port
->fcs
, event
);
2904 case MSSM_EVENT_PORT_ONLINE
:
2905 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_plogi_sending
);
2906 bfa_fcs_lport_ms_send_plogi(ms
, NULL
);
2909 case MSSM_EVENT_PORT_OFFLINE
:
2913 bfa_sm_fault(ms
->port
->fcs
, event
);
2918 bfa_fcs_lport_ms_sm_plogi_sending(struct bfa_fcs_lport_ms_s
*ms
,
2919 enum port_ms_event event
)
2921 bfa_trc(ms
->port
->fcs
, ms
->port
->port_cfg
.pwwn
);
2922 bfa_trc(ms
->port
->fcs
, event
);
2925 case MSSM_EVENT_FCXP_SENT
:
2926 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_plogi
);
2929 case MSSM_EVENT_PORT_OFFLINE
:
2930 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_offline
);
2931 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ms
->port
),
2936 bfa_sm_fault(ms
->port
->fcs
, event
);
2941 bfa_fcs_lport_ms_sm_plogi(struct bfa_fcs_lport_ms_s
*ms
,
2942 enum port_ms_event event
)
2944 bfa_trc(ms
->port
->fcs
, ms
->port
->port_cfg
.pwwn
);
2945 bfa_trc(ms
->port
->fcs
, event
);
2948 case MSSM_EVENT_RSP_ERROR
:
2950 * Start timer for a delayed retry
2952 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_plogi_retry
);
2953 ms
->port
->stats
.ms_retries
++;
2954 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ms
->port
),
2955 &ms
->timer
, bfa_fcs_lport_ms_timeout
, ms
,
2956 BFA_FCS_RETRY_TIMEOUT
);
2959 case MSSM_EVENT_RSP_OK
:
2961 * since plogi is done, now invoke MS related sub-modules
2963 bfa_fcs_lport_fdmi_online(ms
);
2966 * if this is a Vport, go to online state.
2968 if (ms
->port
->vport
) {
2969 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_online
);
2974 * For a base port we need to get the
2975 * switch's IP address.
2977 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_gmal_sending
);
2978 bfa_fcs_lport_ms_send_gmal(ms
, NULL
);
2981 case MSSM_EVENT_PORT_OFFLINE
:
2982 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_offline
);
2983 bfa_fcxp_discard(ms
->fcxp
);
2987 bfa_sm_fault(ms
->port
->fcs
, event
);
2992 bfa_fcs_lport_ms_sm_plogi_retry(struct bfa_fcs_lport_ms_s
*ms
,
2993 enum port_ms_event event
)
2995 bfa_trc(ms
->port
->fcs
, ms
->port
->port_cfg
.pwwn
);
2996 bfa_trc(ms
->port
->fcs
, event
);
2999 case MSSM_EVENT_TIMEOUT
:
3001 * Retry Timer Expired. Re-send
3003 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_plogi_sending
);
3004 bfa_fcs_lport_ms_send_plogi(ms
, NULL
);
3007 case MSSM_EVENT_PORT_OFFLINE
:
3008 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_offline
);
3009 bfa_timer_stop(&ms
->timer
);
3013 bfa_sm_fault(ms
->port
->fcs
, event
);
3018 bfa_fcs_lport_ms_sm_online(struct bfa_fcs_lport_ms_s
*ms
,
3019 enum port_ms_event event
)
3021 bfa_trc(ms
->port
->fcs
, ms
->port
->port_cfg
.pwwn
);
3022 bfa_trc(ms
->port
->fcs
, event
);
3025 case MSSM_EVENT_PORT_OFFLINE
:
3026 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_offline
);
3029 case MSSM_EVENT_PORT_FABRIC_RSCN
:
3030 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_gfn_sending
);
3032 bfa_fcs_lport_ms_send_gfn(ms
, NULL
);
3036 bfa_sm_fault(ms
->port
->fcs
, event
);
3041 bfa_fcs_lport_ms_sm_gmal_sending(struct bfa_fcs_lport_ms_s
*ms
,
3042 enum port_ms_event event
)
3044 bfa_trc(ms
->port
->fcs
, ms
->port
->port_cfg
.pwwn
);
3045 bfa_trc(ms
->port
->fcs
, event
);
3048 case MSSM_EVENT_FCXP_SENT
:
3049 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_gmal
);
3052 case MSSM_EVENT_PORT_OFFLINE
:
3053 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_offline
);
3054 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ms
->port
),
3059 bfa_sm_fault(ms
->port
->fcs
, event
);
3064 bfa_fcs_lport_ms_sm_gmal(struct bfa_fcs_lport_ms_s
*ms
,
3065 enum port_ms_event event
)
3067 bfa_trc(ms
->port
->fcs
, ms
->port
->port_cfg
.pwwn
);
3068 bfa_trc(ms
->port
->fcs
, event
);
3071 case MSSM_EVENT_RSP_ERROR
:
3073 * Start timer for a delayed retry
3075 if (ms
->retry_cnt
++ < BFA_FCS_MS_CMD_MAX_RETRIES
) {
3076 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_gmal_retry
);
3077 ms
->port
->stats
.ms_retries
++;
3078 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ms
->port
),
3079 &ms
->timer
, bfa_fcs_lport_ms_timeout
, ms
,
3080 BFA_FCS_RETRY_TIMEOUT
);
3082 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_gfn_sending
);
3083 bfa_fcs_lport_ms_send_gfn(ms
, NULL
);
3088 case MSSM_EVENT_RSP_OK
:
3089 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_gfn_sending
);
3090 bfa_fcs_lport_ms_send_gfn(ms
, NULL
);
3093 case MSSM_EVENT_PORT_OFFLINE
:
3094 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_offline
);
3095 bfa_fcxp_discard(ms
->fcxp
);
3099 bfa_sm_fault(ms
->port
->fcs
, event
);
3104 bfa_fcs_lport_ms_sm_gmal_retry(struct bfa_fcs_lport_ms_s
*ms
,
3105 enum port_ms_event event
)
3107 bfa_trc(ms
->port
->fcs
, ms
->port
->port_cfg
.pwwn
);
3108 bfa_trc(ms
->port
->fcs
, event
);
3111 case MSSM_EVENT_TIMEOUT
:
3113 * Retry Timer Expired. Re-send
3115 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_gmal_sending
);
3116 bfa_fcs_lport_ms_send_gmal(ms
, NULL
);
3119 case MSSM_EVENT_PORT_OFFLINE
:
3120 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_offline
);
3121 bfa_timer_stop(&ms
->timer
);
3125 bfa_sm_fault(ms
->port
->fcs
, event
);
3129 * ms_pvt MS local functions
3133 bfa_fcs_lport_ms_send_gmal(void *ms_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
3135 struct bfa_fcs_lport_ms_s
*ms
= ms_cbarg
;
3136 bfa_fcs_lport_t
*port
= ms
->port
;
3139 struct bfa_fcxp_s
*fcxp
;
3141 bfa_trc(port
->fcs
, port
->pid
);
3143 fcxp
= fcxp_alloced
? fcxp_alloced
:
3144 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
3146 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &ms
->fcxp_wqe
,
3147 bfa_fcs_lport_ms_send_gmal
, ms
, BFA_TRUE
);
3152 len
= fc_gmal_req_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
3153 bfa_fcs_lport_get_fcid(port
),
3154 port
->fabric
->lps
->pr_nwwn
);
3156 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
3157 FC_CLASS_3
, len
, &fchs
,
3158 bfa_fcs_lport_ms_gmal_response
, (void *)ms
,
3159 FC_MAX_PDUSZ
, FC_FCCT_TOV
);
3161 bfa_sm_send_event(ms
, MSSM_EVENT_FCXP_SENT
);
3165 bfa_fcs_lport_ms_gmal_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
,
3166 void *cbarg
, bfa_status_t req_status
,
3167 u32 rsp_len
, u32 resid_len
,
3168 struct fchs_s
*rsp_fchs
)
3170 struct bfa_fcs_lport_ms_s
*ms
= (struct bfa_fcs_lport_ms_s
*) cbarg
;
3171 bfa_fcs_lport_t
*port
= ms
->port
;
3172 struct ct_hdr_s
*cthdr
= NULL
;
3173 struct fcgs_gmal_resp_s
*gmal_resp
;
3174 struct fcgs_gmal_entry_s
*gmal_entry
;
3178 bfa_trc(port
->fcs
, req_status
);
3179 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
3184 if (req_status
!= BFA_STATUS_OK
) {
3185 bfa_trc(port
->fcs
, req_status
);
3186 bfa_sm_send_event(ms
, MSSM_EVENT_RSP_ERROR
);
3190 cthdr
= (struct ct_hdr_s
*) BFA_FCXP_RSP_PLD(fcxp
);
3191 cthdr
->cmd_rsp_code
= be16_to_cpu(cthdr
->cmd_rsp_code
);
3193 if (cthdr
->cmd_rsp_code
== CT_RSP_ACCEPT
) {
3194 gmal_resp
= (struct fcgs_gmal_resp_s
*)(cthdr
+ 1);
3196 num_entries
= be32_to_cpu(gmal_resp
->ms_len
);
3197 if (num_entries
== 0) {
3198 bfa_sm_send_event(ms
, MSSM_EVENT_RSP_ERROR
);
3202 * The response could contain multiple Entries.
3203 * Entries for SNMP interface, etc.
3204 * We look for the entry with a telnet prefix.
3205 * First "http://" entry refers to IP addr
3208 gmal_entry
= (struct fcgs_gmal_entry_s
*)gmal_resp
->ms_ma
;
3209 while (num_entries
> 0) {
3210 if (strncmp(gmal_entry
->prefix
,
3211 CT_GMAL_RESP_PREFIX_HTTP
,
3212 sizeof(gmal_entry
->prefix
)) == 0) {
3215 * if the IP address is terminating with a '/',
3217 * Byte 0 consists of the length of the string.
3219 rsp_str
= &(gmal_entry
->prefix
[0]);
3220 if (rsp_str
[gmal_entry
->len
-1] == '/')
3221 rsp_str
[gmal_entry
->len
-1] = 0;
3223 /* copy IP Address to fabric */
3224 strlcpy(bfa_fcs_lport_get_fabric_ipaddr(port
),
3225 gmal_entry
->ip_addr
,
3226 BFA_FCS_FABRIC_IPADDR_SZ
);
3234 bfa_sm_send_event(ms
, MSSM_EVENT_RSP_OK
);
3238 bfa_trc(port
->fcs
, cthdr
->reason_code
);
3239 bfa_trc(port
->fcs
, cthdr
->exp_code
);
3240 bfa_sm_send_event(ms
, MSSM_EVENT_RSP_ERROR
);
3244 bfa_fcs_lport_ms_sm_gfn_sending(struct bfa_fcs_lport_ms_s
*ms
,
3245 enum port_ms_event event
)
3247 bfa_trc(ms
->port
->fcs
, ms
->port
->port_cfg
.pwwn
);
3248 bfa_trc(ms
->port
->fcs
, event
);
3251 case MSSM_EVENT_FCXP_SENT
:
3252 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_gfn
);
3255 case MSSM_EVENT_PORT_OFFLINE
:
3256 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_offline
);
3257 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ms
->port
),
3262 bfa_sm_fault(ms
->port
->fcs
, event
);
3267 bfa_fcs_lport_ms_sm_gfn(struct bfa_fcs_lport_ms_s
*ms
,
3268 enum port_ms_event event
)
3270 bfa_trc(ms
->port
->fcs
, ms
->port
->port_cfg
.pwwn
);
3271 bfa_trc(ms
->port
->fcs
, event
);
3274 case MSSM_EVENT_RSP_ERROR
:
3276 * Start timer for a delayed retry
3278 if (ms
->retry_cnt
++ < BFA_FCS_MS_CMD_MAX_RETRIES
) {
3279 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_gfn_retry
);
3280 ms
->port
->stats
.ms_retries
++;
3281 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ms
->port
),
3282 &ms
->timer
, bfa_fcs_lport_ms_timeout
, ms
,
3283 BFA_FCS_RETRY_TIMEOUT
);
3285 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_online
);
3290 case MSSM_EVENT_RSP_OK
:
3291 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_online
);
3294 case MSSM_EVENT_PORT_OFFLINE
:
3295 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_offline
);
3296 bfa_fcxp_discard(ms
->fcxp
);
3300 bfa_sm_fault(ms
->port
->fcs
, event
);
3305 bfa_fcs_lport_ms_sm_gfn_retry(struct bfa_fcs_lport_ms_s
*ms
,
3306 enum port_ms_event event
)
3308 bfa_trc(ms
->port
->fcs
, ms
->port
->port_cfg
.pwwn
);
3309 bfa_trc(ms
->port
->fcs
, event
);
3312 case MSSM_EVENT_TIMEOUT
:
3314 * Retry Timer Expired. Re-send
3316 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_gfn_sending
);
3317 bfa_fcs_lport_ms_send_gfn(ms
, NULL
);
3320 case MSSM_EVENT_PORT_OFFLINE
:
3321 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_offline
);
3322 bfa_timer_stop(&ms
->timer
);
3326 bfa_sm_fault(ms
->port
->fcs
, event
);
3330 * ms_pvt MS local functions
3334 bfa_fcs_lport_ms_send_gfn(void *ms_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
3336 struct bfa_fcs_lport_ms_s
*ms
= ms_cbarg
;
3337 bfa_fcs_lport_t
*port
= ms
->port
;
3340 struct bfa_fcxp_s
*fcxp
;
3342 bfa_trc(port
->fcs
, port
->pid
);
3344 fcxp
= fcxp_alloced
? fcxp_alloced
:
3345 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
3347 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &ms
->fcxp_wqe
,
3348 bfa_fcs_lport_ms_send_gfn
, ms
, BFA_TRUE
);
3353 len
= fc_gfn_req_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
3354 bfa_fcs_lport_get_fcid(port
),
3355 port
->fabric
->lps
->pr_nwwn
);
3357 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
3358 FC_CLASS_3
, len
, &fchs
,
3359 bfa_fcs_lport_ms_gfn_response
, (void *)ms
,
3360 FC_MAX_PDUSZ
, FC_FCCT_TOV
);
3362 bfa_sm_send_event(ms
, MSSM_EVENT_FCXP_SENT
);
3366 bfa_fcs_lport_ms_gfn_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
,
3367 void *cbarg
, bfa_status_t req_status
, u32 rsp_len
,
3368 u32 resid_len
, struct fchs_s
*rsp_fchs
)
3370 struct bfa_fcs_lport_ms_s
*ms
= (struct bfa_fcs_lport_ms_s
*) cbarg
;
3371 bfa_fcs_lport_t
*port
= ms
->port
;
3372 struct ct_hdr_s
*cthdr
= NULL
;
3375 bfa_trc(port
->fcs
, req_status
);
3376 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
3381 if (req_status
!= BFA_STATUS_OK
) {
3382 bfa_trc(port
->fcs
, req_status
);
3383 bfa_sm_send_event(ms
, MSSM_EVENT_RSP_ERROR
);
3387 cthdr
= (struct ct_hdr_s
*) BFA_FCXP_RSP_PLD(fcxp
);
3388 cthdr
->cmd_rsp_code
= be16_to_cpu(cthdr
->cmd_rsp_code
);
3390 if (cthdr
->cmd_rsp_code
== CT_RSP_ACCEPT
) {
3391 gfn_resp
= (wwn_t
*)(cthdr
+ 1);
3392 /* check if it has actually changed */
3393 if ((memcmp((void *)&bfa_fcs_lport_get_fabric_name(port
),
3394 gfn_resp
, sizeof(wwn_t
)) != 0)) {
3395 bfa_fcs_fabric_set_fabric_name(port
->fabric
, *gfn_resp
);
3397 bfa_sm_send_event(ms
, MSSM_EVENT_RSP_OK
);
3401 bfa_trc(port
->fcs
, cthdr
->reason_code
);
3402 bfa_trc(port
->fcs
, cthdr
->exp_code
);
3403 bfa_sm_send_event(ms
, MSSM_EVENT_RSP_ERROR
);
3407 * ms_pvt MS local functions
3411 bfa_fcs_lport_ms_send_plogi(void *ms_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
3413 struct bfa_fcs_lport_ms_s
*ms
= ms_cbarg
;
3414 struct bfa_fcs_lport_s
*port
= ms
->port
;
3417 struct bfa_fcxp_s
*fcxp
;
3419 bfa_trc(port
->fcs
, port
->pid
);
3421 fcxp
= fcxp_alloced
? fcxp_alloced
:
3422 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
3424 port
->stats
.ms_plogi_alloc_wait
++;
3425 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &ms
->fcxp_wqe
,
3426 bfa_fcs_lport_ms_send_plogi
, ms
, BFA_TRUE
);
3431 len
= fc_plogi_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
3432 bfa_hton3b(FC_MGMT_SERVER
),
3433 bfa_fcs_lport_get_fcid(port
), 0,
3434 port
->port_cfg
.pwwn
, port
->port_cfg
.nwwn
,
3435 bfa_fcport_get_maxfrsize(port
->fcs
->bfa
),
3436 bfa_fcport_get_rx_bbcredit(port
->fcs
->bfa
));
3438 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
3439 FC_CLASS_3
, len
, &fchs
,
3440 bfa_fcs_lport_ms_plogi_response
, (void *)ms
,
3441 FC_MAX_PDUSZ
, FC_ELS_TOV
);
3443 port
->stats
.ms_plogi_sent
++;
3444 bfa_sm_send_event(ms
, MSSM_EVENT_FCXP_SENT
);
3448 bfa_fcs_lport_ms_plogi_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
,
3449 void *cbarg
, bfa_status_t req_status
,
3450 u32 rsp_len
, u32 resid_len
, struct fchs_s
*rsp_fchs
)
3452 struct bfa_fcs_lport_ms_s
*ms
= (struct bfa_fcs_lport_ms_s
*) cbarg
;
3453 struct bfa_fcs_lport_s
*port
= ms
->port
;
3454 struct fc_els_cmd_s
*els_cmd
;
3455 struct fc_ls_rjt_s
*ls_rjt
;
3457 bfa_trc(port
->fcs
, req_status
);
3458 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
3463 if (req_status
!= BFA_STATUS_OK
) {
3464 port
->stats
.ms_plogi_rsp_err
++;
3465 bfa_trc(port
->fcs
, req_status
);
3466 bfa_sm_send_event(ms
, MSSM_EVENT_RSP_ERROR
);
3470 els_cmd
= (struct fc_els_cmd_s
*) BFA_FCXP_RSP_PLD(fcxp
);
3472 switch (els_cmd
->els_code
) {
3475 if (rsp_len
< sizeof(struct fc_logi_s
)) {
3476 bfa_trc(port
->fcs
, rsp_len
);
3477 port
->stats
.ms_plogi_acc_err
++;
3478 bfa_sm_send_event(ms
, MSSM_EVENT_RSP_ERROR
);
3481 port
->stats
.ms_plogi_accepts
++;
3482 bfa_sm_send_event(ms
, MSSM_EVENT_RSP_OK
);
3486 ls_rjt
= (struct fc_ls_rjt_s
*) BFA_FCXP_RSP_PLD(fcxp
);
3488 bfa_trc(port
->fcs
, ls_rjt
->reason_code
);
3489 bfa_trc(port
->fcs
, ls_rjt
->reason_code_expl
);
3491 port
->stats
.ms_rejects
++;
3492 bfa_sm_send_event(ms
, MSSM_EVENT_RSP_ERROR
);
3496 port
->stats
.ms_plogi_unknown_rsp
++;
3497 bfa_trc(port
->fcs
, els_cmd
->els_code
);
3498 bfa_sm_send_event(ms
, MSSM_EVENT_RSP_ERROR
);
3503 bfa_fcs_lport_ms_timeout(void *arg
)
3505 struct bfa_fcs_lport_ms_s
*ms
= (struct bfa_fcs_lport_ms_s
*) arg
;
3507 ms
->port
->stats
.ms_timeouts
++;
3508 bfa_sm_send_event(ms
, MSSM_EVENT_TIMEOUT
);
3513 bfa_fcs_lport_ms_init(struct bfa_fcs_lport_s
*port
)
3515 struct bfa_fcs_lport_ms_s
*ms
= BFA_FCS_GET_MS_FROM_PORT(port
);
3518 bfa_sm_set_state(ms
, bfa_fcs_lport_ms_sm_offline
);
3521 * Invoke init routines of sub modules.
3523 bfa_fcs_lport_fdmi_init(ms
);
3527 bfa_fcs_lport_ms_offline(struct bfa_fcs_lport_s
*port
)
3529 struct bfa_fcs_lport_ms_s
*ms
= BFA_FCS_GET_MS_FROM_PORT(port
);
3532 bfa_sm_send_event(ms
, MSSM_EVENT_PORT_OFFLINE
);
3533 bfa_fcs_lport_fdmi_offline(ms
);
3537 bfa_fcs_lport_ms_online(struct bfa_fcs_lport_s
*port
)
3539 struct bfa_fcs_lport_ms_s
*ms
= BFA_FCS_GET_MS_FROM_PORT(port
);
3542 bfa_sm_send_event(ms
, MSSM_EVENT_PORT_ONLINE
);
3545 bfa_fcs_lport_ms_fabric_rscn(struct bfa_fcs_lport_s
*port
)
3547 struct bfa_fcs_lport_ms_s
*ms
= BFA_FCS_GET_MS_FROM_PORT(port
);
3549 /* todo. Handle this only when in Online state */
3550 if (bfa_sm_cmp_state(ms
, bfa_fcs_lport_ms_sm_online
))
3551 bfa_sm_send_event(ms
, MSSM_EVENT_PORT_FABRIC_RSCN
);
3555 * @page ns_sm_info VPORT NS State Machine
3557 * @section ns_sm_interactions VPORT NS State Machine Interactions
3559 * @section ns_sm VPORT NS State Machine
3564 * forward declarations
3566 static void bfa_fcs_lport_ns_send_plogi(void *ns_cbarg
,
3567 struct bfa_fcxp_s
*fcxp_alloced
);
3568 static void bfa_fcs_lport_ns_send_rspn_id(void *ns_cbarg
,
3569 struct bfa_fcxp_s
*fcxp_alloced
);
3570 static void bfa_fcs_lport_ns_send_rft_id(void *ns_cbarg
,
3571 struct bfa_fcxp_s
*fcxp_alloced
);
3572 static void bfa_fcs_lport_ns_send_rff_id(void *ns_cbarg
,
3573 struct bfa_fcxp_s
*fcxp_alloced
);
3574 static void bfa_fcs_lport_ns_send_gid_ft(void *ns_cbarg
,
3575 struct bfa_fcxp_s
*fcxp_alloced
);
3576 static void bfa_fcs_lport_ns_send_rnn_id(void *ns_cbarg
,
3577 struct bfa_fcxp_s
*fcxp_alloced
);
3578 static void bfa_fcs_lport_ns_send_rsnn_nn(void *ns_cbarg
,
3579 struct bfa_fcxp_s
*fcxp_alloced
);
3580 static void bfa_fcs_lport_ns_timeout(void *arg
);
3581 static void bfa_fcs_lport_ns_plogi_response(void *fcsarg
,
3582 struct bfa_fcxp_s
*fcxp
,
3584 bfa_status_t req_status
,
3587 struct fchs_s
*rsp_fchs
);
3588 static void bfa_fcs_lport_ns_rspn_id_response(void *fcsarg
,
3589 struct bfa_fcxp_s
*fcxp
,
3591 bfa_status_t req_status
,
3594 struct fchs_s
*rsp_fchs
);
3595 static void bfa_fcs_lport_ns_rft_id_response(void *fcsarg
,
3596 struct bfa_fcxp_s
*fcxp
,
3598 bfa_status_t req_status
,
3601 struct fchs_s
*rsp_fchs
);
3602 static void bfa_fcs_lport_ns_rff_id_response(void *fcsarg
,
3603 struct bfa_fcxp_s
*fcxp
,
3605 bfa_status_t req_status
,
3608 struct fchs_s
*rsp_fchs
);
3609 static void bfa_fcs_lport_ns_gid_ft_response(void *fcsarg
,
3610 struct bfa_fcxp_s
*fcxp
,
3612 bfa_status_t req_status
,
3615 struct fchs_s
*rsp_fchs
);
3616 static void bfa_fcs_lport_ns_rnn_id_response(void *fcsarg
,
3617 struct bfa_fcxp_s
*fcxp
,
3619 bfa_status_t req_status
,
3622 struct fchs_s
*rsp_fchs
);
3623 static void bfa_fcs_lport_ns_rsnn_nn_response(void *fcsarg
,
3624 struct bfa_fcxp_s
*fcxp
,
3626 bfa_status_t req_status
,
3629 struct fchs_s
*rsp_fchs
);
3630 static void bfa_fcs_lport_ns_process_gidft_pids(
3631 struct bfa_fcs_lport_s
*port
,
3632 u32
*pid_buf
, u32 n_pids
);
3634 static void bfa_fcs_lport_ns_boot_target_disc(bfa_fcs_lport_t
*port
);
3636 * fcs_ns_sm FCS nameserver interface state machine
3640 * VPort NS State Machine events
3642 enum vport_ns_event
{
3643 NSSM_EVENT_PORT_ONLINE
= 1,
3644 NSSM_EVENT_PORT_OFFLINE
= 2,
3645 NSSM_EVENT_PLOGI_SENT
= 3,
3646 NSSM_EVENT_RSP_OK
= 4,
3647 NSSM_EVENT_RSP_ERROR
= 5,
3648 NSSM_EVENT_TIMEOUT
= 6,
3649 NSSM_EVENT_NS_QUERY
= 7,
3650 NSSM_EVENT_RSPNID_SENT
= 8,
3651 NSSM_EVENT_RFTID_SENT
= 9,
3652 NSSM_EVENT_RFFID_SENT
= 10,
3653 NSSM_EVENT_GIDFT_SENT
= 11,
3654 NSSM_EVENT_RNNID_SENT
= 12,
3655 NSSM_EVENT_RSNN_NN_SENT
= 13,
3658 static void bfa_fcs_lport_ns_sm_offline(struct bfa_fcs_lport_ns_s
*ns
,
3659 enum vport_ns_event event
);
3660 static void bfa_fcs_lport_ns_sm_plogi_sending(struct bfa_fcs_lport_ns_s
*ns
,
3661 enum vport_ns_event event
);
3662 static void bfa_fcs_lport_ns_sm_plogi(struct bfa_fcs_lport_ns_s
*ns
,
3663 enum vport_ns_event event
);
3664 static void bfa_fcs_lport_ns_sm_plogi_retry(struct bfa_fcs_lport_ns_s
*ns
,
3665 enum vport_ns_event event
);
3666 static void bfa_fcs_lport_ns_sm_sending_rspn_id(
3667 struct bfa_fcs_lport_ns_s
*ns
,
3668 enum vport_ns_event event
);
3669 static void bfa_fcs_lport_ns_sm_rspn_id(struct bfa_fcs_lport_ns_s
*ns
,
3670 enum vport_ns_event event
);
3671 static void bfa_fcs_lport_ns_sm_rspn_id_retry(struct bfa_fcs_lport_ns_s
*ns
,
3672 enum vport_ns_event event
);
3673 static void bfa_fcs_lport_ns_sm_sending_rft_id(
3674 struct bfa_fcs_lport_ns_s
*ns
,
3675 enum vport_ns_event event
);
3676 static void bfa_fcs_lport_ns_sm_rft_id_retry(struct bfa_fcs_lport_ns_s
*ns
,
3677 enum vport_ns_event event
);
3678 static void bfa_fcs_lport_ns_sm_rft_id(struct bfa_fcs_lport_ns_s
*ns
,
3679 enum vport_ns_event event
);
3680 static void bfa_fcs_lport_ns_sm_sending_rff_id(
3681 struct bfa_fcs_lport_ns_s
*ns
,
3682 enum vport_ns_event event
);
3683 static void bfa_fcs_lport_ns_sm_rff_id_retry(struct bfa_fcs_lport_ns_s
*ns
,
3684 enum vport_ns_event event
);
3685 static void bfa_fcs_lport_ns_sm_rff_id(struct bfa_fcs_lport_ns_s
*ns
,
3686 enum vport_ns_event event
);
3687 static void bfa_fcs_lport_ns_sm_sending_gid_ft(
3688 struct bfa_fcs_lport_ns_s
*ns
,
3689 enum vport_ns_event event
);
3690 static void bfa_fcs_lport_ns_sm_gid_ft(struct bfa_fcs_lport_ns_s
*ns
,
3691 enum vport_ns_event event
);
3692 static void bfa_fcs_lport_ns_sm_gid_ft_retry(struct bfa_fcs_lport_ns_s
*ns
,
3693 enum vport_ns_event event
);
3694 static void bfa_fcs_lport_ns_sm_online(struct bfa_fcs_lport_ns_s
*ns
,
3695 enum vport_ns_event event
);
3696 static void bfa_fcs_lport_ns_sm_sending_rnn_id(
3697 struct bfa_fcs_lport_ns_s
*ns
,
3698 enum vport_ns_event event
);
3699 static void bfa_fcs_lport_ns_sm_rnn_id(struct bfa_fcs_lport_ns_s
*ns
,
3700 enum vport_ns_event event
);
3701 static void bfa_fcs_lport_ns_sm_rnn_id_retry(struct bfa_fcs_lport_ns_s
*ns
,
3702 enum vport_ns_event event
);
3703 static void bfa_fcs_lport_ns_sm_sending_rsnn_nn(
3704 struct bfa_fcs_lport_ns_s
*ns
,
3705 enum vport_ns_event event
);
3706 static void bfa_fcs_lport_ns_sm_rsnn_nn(struct bfa_fcs_lport_ns_s
*ns
,
3707 enum vport_ns_event event
);
3708 static void bfa_fcs_lport_ns_sm_rsnn_nn_retry(
3709 struct bfa_fcs_lport_ns_s
*ns
,
3710 enum vport_ns_event event
);
3712 * Start in offline state - awaiting linkup
3715 bfa_fcs_lport_ns_sm_offline(struct bfa_fcs_lport_ns_s
*ns
,
3716 enum vport_ns_event event
)
3718 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
3719 bfa_trc(ns
->port
->fcs
, event
);
3722 case NSSM_EVENT_PORT_ONLINE
:
3723 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_plogi_sending
);
3724 bfa_fcs_lport_ns_send_plogi(ns
, NULL
);
3727 case NSSM_EVENT_PORT_OFFLINE
:
3731 bfa_sm_fault(ns
->port
->fcs
, event
);
3736 bfa_fcs_lport_ns_sm_plogi_sending(struct bfa_fcs_lport_ns_s
*ns
,
3737 enum vport_ns_event event
)
3739 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
3740 bfa_trc(ns
->port
->fcs
, event
);
3743 case NSSM_EVENT_PLOGI_SENT
:
3744 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_plogi
);
3747 case NSSM_EVENT_PORT_OFFLINE
:
3748 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
3749 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns
->port
),
3754 bfa_sm_fault(ns
->port
->fcs
, event
);
3759 bfa_fcs_lport_ns_sm_plogi(struct bfa_fcs_lport_ns_s
*ns
,
3760 enum vport_ns_event event
)
3762 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
3763 bfa_trc(ns
->port
->fcs
, event
);
3766 case NSSM_EVENT_RSP_ERROR
:
3768 * Start timer for a delayed retry
3770 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_plogi_retry
);
3771 ns
->port
->stats
.ns_retries
++;
3772 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns
->port
),
3773 &ns
->timer
, bfa_fcs_lport_ns_timeout
, ns
,
3774 BFA_FCS_RETRY_TIMEOUT
);
3777 case NSSM_EVENT_RSP_OK
:
3778 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_sending_rnn_id
);
3779 ns
->num_rnnid_retries
= 0;
3780 bfa_fcs_lport_ns_send_rnn_id(ns
, NULL
);
3783 case NSSM_EVENT_PORT_OFFLINE
:
3784 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
3785 bfa_fcxp_discard(ns
->fcxp
);
3789 bfa_sm_fault(ns
->port
->fcs
, event
);
3794 bfa_fcs_lport_ns_sm_plogi_retry(struct bfa_fcs_lport_ns_s
*ns
,
3795 enum vport_ns_event event
)
3797 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
3798 bfa_trc(ns
->port
->fcs
, event
);
3801 case NSSM_EVENT_TIMEOUT
:
3803 * Retry Timer Expired. Re-send
3805 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_plogi_sending
);
3806 bfa_fcs_lport_ns_send_plogi(ns
, NULL
);
3809 case NSSM_EVENT_PORT_OFFLINE
:
3810 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
3811 bfa_timer_stop(&ns
->timer
);
3815 bfa_sm_fault(ns
->port
->fcs
, event
);
3820 bfa_fcs_lport_ns_sm_sending_rnn_id(struct bfa_fcs_lport_ns_s
*ns
,
3821 enum vport_ns_event event
)
3823 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
3824 bfa_trc(ns
->port
->fcs
, event
);
3827 case NSSM_EVENT_RNNID_SENT
:
3828 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_rnn_id
);
3831 case NSSM_EVENT_PORT_OFFLINE
:
3832 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
3833 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns
->port
),
3837 bfa_sm_fault(ns
->port
->fcs
, event
);
3842 bfa_fcs_lport_ns_sm_rnn_id(struct bfa_fcs_lport_ns_s
*ns
,
3843 enum vport_ns_event event
)
3845 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
3846 bfa_trc(ns
->port
->fcs
, event
);
3849 case NSSM_EVENT_RSP_OK
:
3850 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_sending_rsnn_nn
);
3851 ns
->num_rnnid_retries
= 0;
3852 ns
->num_rsnn_nn_retries
= 0;
3853 bfa_fcs_lport_ns_send_rsnn_nn(ns
, NULL
);
3856 case NSSM_EVENT_RSP_ERROR
:
3857 if (ns
->num_rnnid_retries
< BFA_FCS_MAX_NS_RETRIES
) {
3858 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_rnn_id_retry
);
3859 ns
->port
->stats
.ns_retries
++;
3860 ns
->num_rnnid_retries
++;
3861 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns
->port
),
3862 &ns
->timer
, bfa_fcs_lport_ns_timeout
, ns
,
3863 BFA_FCS_RETRY_TIMEOUT
);
3865 bfa_sm_set_state(ns
,
3866 bfa_fcs_lport_ns_sm_sending_rspn_id
);
3867 bfa_fcs_lport_ns_send_rspn_id(ns
, NULL
);
3871 case NSSM_EVENT_PORT_OFFLINE
:
3872 bfa_fcxp_discard(ns
->fcxp
);
3873 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
3877 bfa_sm_fault(ns
->port
->fcs
, event
);
3882 bfa_fcs_lport_ns_sm_rnn_id_retry(struct bfa_fcs_lport_ns_s
*ns
,
3883 enum vport_ns_event event
)
3885 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
3886 bfa_trc(ns
->port
->fcs
, event
);
3889 case NSSM_EVENT_TIMEOUT
:
3890 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_sending_rnn_id
);
3891 bfa_fcs_lport_ns_send_rnn_id(ns
, NULL
);
3894 case NSSM_EVENT_PORT_OFFLINE
:
3895 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
3896 bfa_timer_stop(&ns
->timer
);
3900 bfa_sm_fault(ns
->port
->fcs
, event
);
3905 bfa_fcs_lport_ns_sm_sending_rsnn_nn(struct bfa_fcs_lport_ns_s
*ns
,
3906 enum vport_ns_event event
)
3908 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
3909 bfa_trc(ns
->port
->fcs
, event
);
3912 case NSSM_EVENT_RSNN_NN_SENT
:
3913 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_rsnn_nn
);
3916 case NSSM_EVENT_PORT_OFFLINE
:
3917 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
3918 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns
->port
),
3923 bfa_sm_fault(ns
->port
->fcs
, event
);
3928 bfa_fcs_lport_ns_sm_rsnn_nn(struct bfa_fcs_lport_ns_s
*ns
,
3929 enum vport_ns_event event
)
3931 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
3932 bfa_trc(ns
->port
->fcs
, event
);
3935 case NSSM_EVENT_RSP_OK
:
3936 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_sending_rspn_id
);
3937 ns
->num_rsnn_nn_retries
= 0;
3938 bfa_fcs_lport_ns_send_rspn_id(ns
, NULL
);
3941 case NSSM_EVENT_RSP_ERROR
:
3942 if (ns
->num_rsnn_nn_retries
< BFA_FCS_MAX_NS_RETRIES
) {
3943 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_rsnn_nn_retry
);
3944 ns
->port
->stats
.ns_retries
++;
3945 ns
->num_rsnn_nn_retries
++;
3946 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns
->port
),
3947 &ns
->timer
, bfa_fcs_lport_ns_timeout
,
3948 ns
, BFA_FCS_RETRY_TIMEOUT
);
3950 bfa_sm_set_state(ns
,
3951 bfa_fcs_lport_ns_sm_sending_rspn_id
);
3952 bfa_fcs_lport_ns_send_rspn_id(ns
, NULL
);
3956 case NSSM_EVENT_PORT_OFFLINE
:
3957 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
3958 bfa_fcxp_discard(ns
->fcxp
);
3962 bfa_sm_fault(ns
->port
->fcs
, event
);
3967 bfa_fcs_lport_ns_sm_rsnn_nn_retry(struct bfa_fcs_lport_ns_s
*ns
,
3968 enum vport_ns_event event
)
3970 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
3971 bfa_trc(ns
->port
->fcs
, event
);
3974 case NSSM_EVENT_TIMEOUT
:
3975 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_sending_rsnn_nn
);
3976 bfa_fcs_lport_ns_send_rsnn_nn(ns
, NULL
);
3979 case NSSM_EVENT_PORT_OFFLINE
:
3980 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
3981 bfa_timer_stop(&ns
->timer
);
3985 bfa_sm_fault(ns
->port
->fcs
, event
);
3990 bfa_fcs_lport_ns_sm_sending_rspn_id(struct bfa_fcs_lport_ns_s
*ns
,
3991 enum vport_ns_event event
)
3993 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
3994 bfa_trc(ns
->port
->fcs
, event
);
3997 case NSSM_EVENT_RSPNID_SENT
:
3998 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_rspn_id
);
4001 case NSSM_EVENT_PORT_OFFLINE
:
4002 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
4003 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns
->port
),
4008 bfa_sm_fault(ns
->port
->fcs
, event
);
4013 bfa_fcs_lport_ns_sm_rspn_id(struct bfa_fcs_lport_ns_s
*ns
,
4014 enum vport_ns_event event
)
4016 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
4017 bfa_trc(ns
->port
->fcs
, event
);
4020 case NSSM_EVENT_RSP_ERROR
:
4022 * Start timer for a delayed retry
4024 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_rspn_id_retry
);
4025 ns
->port
->stats
.ns_retries
++;
4026 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns
->port
),
4027 &ns
->timer
, bfa_fcs_lport_ns_timeout
, ns
,
4028 BFA_FCS_RETRY_TIMEOUT
);
4031 case NSSM_EVENT_RSP_OK
:
4032 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_sending_rft_id
);
4033 bfa_fcs_lport_ns_send_rft_id(ns
, NULL
);
4036 case NSSM_EVENT_PORT_OFFLINE
:
4037 bfa_fcxp_discard(ns
->fcxp
);
4038 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
4042 bfa_sm_fault(ns
->port
->fcs
, event
);
4047 bfa_fcs_lport_ns_sm_rspn_id_retry(struct bfa_fcs_lport_ns_s
*ns
,
4048 enum vport_ns_event event
)
4050 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
4051 bfa_trc(ns
->port
->fcs
, event
);
4054 case NSSM_EVENT_TIMEOUT
:
4056 * Retry Timer Expired. Re-send
4058 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_sending_rspn_id
);
4059 bfa_fcs_lport_ns_send_rspn_id(ns
, NULL
);
4062 case NSSM_EVENT_PORT_OFFLINE
:
4063 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
4064 bfa_timer_stop(&ns
->timer
);
4068 bfa_sm_fault(ns
->port
->fcs
, event
);
4073 bfa_fcs_lport_ns_sm_sending_rft_id(struct bfa_fcs_lport_ns_s
*ns
,
4074 enum vport_ns_event event
)
4076 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
4077 bfa_trc(ns
->port
->fcs
, event
);
4080 case NSSM_EVENT_RFTID_SENT
:
4081 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_rft_id
);
4084 case NSSM_EVENT_PORT_OFFLINE
:
4085 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
4086 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns
->port
),
4091 bfa_sm_fault(ns
->port
->fcs
, event
);
4096 bfa_fcs_lport_ns_sm_rft_id(struct bfa_fcs_lport_ns_s
*ns
,
4097 enum vport_ns_event event
)
4099 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
4100 bfa_trc(ns
->port
->fcs
, event
);
4103 case NSSM_EVENT_RSP_OK
:
4104 /* Now move to register FC4 Features */
4105 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_sending_rff_id
);
4106 bfa_fcs_lport_ns_send_rff_id(ns
, NULL
);
4109 case NSSM_EVENT_RSP_ERROR
:
4111 * Start timer for a delayed retry
4113 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_rft_id_retry
);
4114 ns
->port
->stats
.ns_retries
++;
4115 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns
->port
),
4116 &ns
->timer
, bfa_fcs_lport_ns_timeout
, ns
,
4117 BFA_FCS_RETRY_TIMEOUT
);
4120 case NSSM_EVENT_PORT_OFFLINE
:
4121 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
4122 bfa_fcxp_discard(ns
->fcxp
);
4126 bfa_sm_fault(ns
->port
->fcs
, event
);
4131 bfa_fcs_lport_ns_sm_rft_id_retry(struct bfa_fcs_lport_ns_s
*ns
,
4132 enum vport_ns_event event
)
4134 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
4135 bfa_trc(ns
->port
->fcs
, event
);
4138 case NSSM_EVENT_TIMEOUT
:
4139 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_sending_rft_id
);
4140 bfa_fcs_lport_ns_send_rft_id(ns
, NULL
);
4143 case NSSM_EVENT_PORT_OFFLINE
:
4144 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
4145 bfa_timer_stop(&ns
->timer
);
4149 bfa_sm_fault(ns
->port
->fcs
, event
);
4154 bfa_fcs_lport_ns_sm_sending_rff_id(struct bfa_fcs_lport_ns_s
*ns
,
4155 enum vport_ns_event event
)
4157 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
4158 bfa_trc(ns
->port
->fcs
, event
);
4161 case NSSM_EVENT_RFFID_SENT
:
4162 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_rff_id
);
4165 case NSSM_EVENT_PORT_OFFLINE
:
4166 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
4167 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns
->port
),
4172 bfa_sm_fault(ns
->port
->fcs
, event
);
4177 bfa_fcs_lport_ns_sm_rff_id(struct bfa_fcs_lport_ns_s
*ns
,
4178 enum vport_ns_event event
)
4180 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
4181 bfa_trc(ns
->port
->fcs
, event
);
4184 case NSSM_EVENT_RSP_OK
:
4187 * If min cfg mode is enabled, we donot initiate rport
4188 * discovery with the fabric. Instead, we will retrieve the
4189 * boot targets from HAL/FW.
4191 if (__fcs_min_cfg(ns
->port
->fcs
)) {
4192 bfa_fcs_lport_ns_boot_target_disc(ns
->port
);
4193 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_online
);
4198 * If the port role is Initiator Mode issue NS query.
4199 * If it is Target Mode, skip this and go to online.
4201 if (BFA_FCS_VPORT_IS_INITIATOR_MODE(ns
->port
)) {
4202 bfa_sm_set_state(ns
,
4203 bfa_fcs_lport_ns_sm_sending_gid_ft
);
4204 bfa_fcs_lport_ns_send_gid_ft(ns
, NULL
);
4207 * kick off mgmt srvr state machine
4209 bfa_fcs_lport_ms_online(ns
->port
);
4212 case NSSM_EVENT_RSP_ERROR
:
4214 * Start timer for a delayed retry
4216 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_rff_id_retry
);
4217 ns
->port
->stats
.ns_retries
++;
4218 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns
->port
),
4219 &ns
->timer
, bfa_fcs_lport_ns_timeout
, ns
,
4220 BFA_FCS_RETRY_TIMEOUT
);
4223 case NSSM_EVENT_PORT_OFFLINE
:
4224 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
4225 bfa_fcxp_discard(ns
->fcxp
);
4229 bfa_sm_fault(ns
->port
->fcs
, event
);
4234 bfa_fcs_lport_ns_sm_rff_id_retry(struct bfa_fcs_lport_ns_s
*ns
,
4235 enum vport_ns_event event
)
4237 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
4238 bfa_trc(ns
->port
->fcs
, event
);
4241 case NSSM_EVENT_TIMEOUT
:
4242 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_sending_rff_id
);
4243 bfa_fcs_lport_ns_send_rff_id(ns
, NULL
);
4246 case NSSM_EVENT_PORT_OFFLINE
:
4247 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
4248 bfa_timer_stop(&ns
->timer
);
4252 bfa_sm_fault(ns
->port
->fcs
, event
);
4256 bfa_fcs_lport_ns_sm_sending_gid_ft(struct bfa_fcs_lport_ns_s
*ns
,
4257 enum vport_ns_event event
)
4259 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
4260 bfa_trc(ns
->port
->fcs
, event
);
4263 case NSSM_EVENT_GIDFT_SENT
:
4264 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_gid_ft
);
4267 case NSSM_EVENT_PORT_OFFLINE
:
4268 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
4269 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns
->port
),
4274 bfa_sm_fault(ns
->port
->fcs
, event
);
4279 bfa_fcs_lport_ns_sm_gid_ft(struct bfa_fcs_lport_ns_s
*ns
,
4280 enum vport_ns_event event
)
4282 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
4283 bfa_trc(ns
->port
->fcs
, event
);
4286 case NSSM_EVENT_RSP_OK
:
4287 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_online
);
4290 case NSSM_EVENT_RSP_ERROR
:
4292 * TBD: for certain reject codes, we don't need to retry
4295 * Start timer for a delayed retry
4297 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_gid_ft_retry
);
4298 ns
->port
->stats
.ns_retries
++;
4299 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns
->port
),
4300 &ns
->timer
, bfa_fcs_lport_ns_timeout
, ns
,
4301 BFA_FCS_RETRY_TIMEOUT
);
4304 case NSSM_EVENT_PORT_OFFLINE
:
4305 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
4306 bfa_fcxp_discard(ns
->fcxp
);
4309 case NSSM_EVENT_NS_QUERY
:
4313 bfa_sm_fault(ns
->port
->fcs
, event
);
4318 bfa_fcs_lport_ns_sm_gid_ft_retry(struct bfa_fcs_lport_ns_s
*ns
,
4319 enum vport_ns_event event
)
4321 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
4322 bfa_trc(ns
->port
->fcs
, event
);
4325 case NSSM_EVENT_TIMEOUT
:
4326 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_sending_gid_ft
);
4327 bfa_fcs_lport_ns_send_gid_ft(ns
, NULL
);
4330 case NSSM_EVENT_PORT_OFFLINE
:
4331 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
4332 bfa_timer_stop(&ns
->timer
);
4336 bfa_sm_fault(ns
->port
->fcs
, event
);
4341 bfa_fcs_lport_ns_sm_online(struct bfa_fcs_lport_ns_s
*ns
,
4342 enum vport_ns_event event
)
4344 bfa_trc(ns
->port
->fcs
, ns
->port
->port_cfg
.pwwn
);
4345 bfa_trc(ns
->port
->fcs
, event
);
4348 case NSSM_EVENT_PORT_OFFLINE
:
4349 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
4352 case NSSM_EVENT_NS_QUERY
:
4354 * If the port role is Initiator Mode issue NS query.
4355 * If it is Target Mode, skip this and go to online.
4357 if (BFA_FCS_VPORT_IS_INITIATOR_MODE(ns
->port
)) {
4358 bfa_sm_set_state(ns
,
4359 bfa_fcs_lport_ns_sm_sending_gid_ft
);
4360 bfa_fcs_lport_ns_send_gid_ft(ns
, NULL
);
4365 bfa_sm_fault(ns
->port
->fcs
, event
);
4372 * ns_pvt Nameserver local functions
4376 bfa_fcs_lport_ns_send_plogi(void *ns_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
4378 struct bfa_fcs_lport_ns_s
*ns
= ns_cbarg
;
4379 struct bfa_fcs_lport_s
*port
= ns
->port
;
4382 struct bfa_fcxp_s
*fcxp
;
4384 bfa_trc(port
->fcs
, port
->pid
);
4386 fcxp
= fcxp_alloced
? fcxp_alloced
:
4387 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
4389 port
->stats
.ns_plogi_alloc_wait
++;
4390 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &ns
->fcxp_wqe
,
4391 bfa_fcs_lport_ns_send_plogi
, ns
, BFA_TRUE
);
4396 len
= fc_plogi_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
4397 bfa_hton3b(FC_NAME_SERVER
),
4398 bfa_fcs_lport_get_fcid(port
), 0,
4399 port
->port_cfg
.pwwn
, port
->port_cfg
.nwwn
,
4400 bfa_fcport_get_maxfrsize(port
->fcs
->bfa
),
4401 bfa_fcport_get_rx_bbcredit(port
->fcs
->bfa
));
4403 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
4404 FC_CLASS_3
, len
, &fchs
,
4405 bfa_fcs_lport_ns_plogi_response
, (void *)ns
,
4406 FC_MAX_PDUSZ
, FC_ELS_TOV
);
4407 port
->stats
.ns_plogi_sent
++;
4409 bfa_sm_send_event(ns
, NSSM_EVENT_PLOGI_SENT
);
4413 bfa_fcs_lport_ns_plogi_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
,
4414 void *cbarg
, bfa_status_t req_status
, u32 rsp_len
,
4415 u32 resid_len
, struct fchs_s
*rsp_fchs
)
4417 struct bfa_fcs_lport_ns_s
*ns
= (struct bfa_fcs_lport_ns_s
*) cbarg
;
4418 struct bfa_fcs_lport_s
*port
= ns
->port
;
4419 /* struct fc_logi_s *plogi_resp; */
4420 struct fc_els_cmd_s
*els_cmd
;
4421 struct fc_ls_rjt_s
*ls_rjt
;
4423 bfa_trc(port
->fcs
, req_status
);
4424 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
4429 if (req_status
!= BFA_STATUS_OK
) {
4430 bfa_trc(port
->fcs
, req_status
);
4431 port
->stats
.ns_plogi_rsp_err
++;
4432 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4436 els_cmd
= (struct fc_els_cmd_s
*) BFA_FCXP_RSP_PLD(fcxp
);
4438 switch (els_cmd
->els_code
) {
4441 if (rsp_len
< sizeof(struct fc_logi_s
)) {
4442 bfa_trc(port
->fcs
, rsp_len
);
4443 port
->stats
.ns_plogi_acc_err
++;
4444 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4447 port
->stats
.ns_plogi_accepts
++;
4448 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_OK
);
4452 ls_rjt
= (struct fc_ls_rjt_s
*) BFA_FCXP_RSP_PLD(fcxp
);
4454 bfa_trc(port
->fcs
, ls_rjt
->reason_code
);
4455 bfa_trc(port
->fcs
, ls_rjt
->reason_code_expl
);
4457 port
->stats
.ns_rejects
++;
4459 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4463 port
->stats
.ns_plogi_unknown_rsp
++;
4464 bfa_trc(port
->fcs
, els_cmd
->els_code
);
4465 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4470 * Register node name for port_id
4473 bfa_fcs_lport_ns_send_rnn_id(void *ns_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
4475 struct bfa_fcs_lport_ns_s
*ns
= ns_cbarg
;
4476 struct bfa_fcs_lport_s
*port
= ns
->port
;
4479 struct bfa_fcxp_s
*fcxp
;
4481 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
4483 fcxp
= fcxp_alloced
? fcxp_alloced
:
4484 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
4486 port
->stats
.ns_rnnid_alloc_wait
++;
4487 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &ns
->fcxp_wqe
,
4488 bfa_fcs_lport_ns_send_rnn_id
, ns
, BFA_TRUE
);
4494 len
= fc_rnnid_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
4495 bfa_fcs_lport_get_fcid(port
),
4496 bfa_fcs_lport_get_fcid(port
),
4497 bfa_fcs_lport_get_nwwn(port
));
4499 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
4500 FC_CLASS_3
, len
, &fchs
,
4501 bfa_fcs_lport_ns_rnn_id_response
, (void *)ns
,
4502 FC_MAX_PDUSZ
, FC_FCCT_TOV
);
4504 port
->stats
.ns_rnnid_sent
++;
4505 bfa_sm_send_event(ns
, NSSM_EVENT_RNNID_SENT
);
4509 bfa_fcs_lport_ns_rnn_id_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
,
4510 void *cbarg
, bfa_status_t req_status
,
4511 u32 rsp_len
, u32 resid_len
,
4512 struct fchs_s
*rsp_fchs
)
4515 struct bfa_fcs_lport_ns_s
*ns
= (struct bfa_fcs_lport_ns_s
*) cbarg
;
4516 struct bfa_fcs_lport_s
*port
= ns
->port
;
4517 struct ct_hdr_s
*cthdr
= NULL
;
4519 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
4524 if (req_status
!= BFA_STATUS_OK
) {
4525 bfa_trc(port
->fcs
, req_status
);
4526 port
->stats
.ns_rnnid_rsp_err
++;
4527 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4531 cthdr
= (struct ct_hdr_s
*) BFA_FCXP_RSP_PLD(fcxp
);
4532 cthdr
->cmd_rsp_code
= be16_to_cpu(cthdr
->cmd_rsp_code
);
4534 if (cthdr
->cmd_rsp_code
== CT_RSP_ACCEPT
) {
4535 port
->stats
.ns_rnnid_accepts
++;
4536 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_OK
);
4540 port
->stats
.ns_rnnid_rejects
++;
4541 bfa_trc(port
->fcs
, cthdr
->reason_code
);
4542 bfa_trc(port
->fcs
, cthdr
->exp_code
);
4543 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4547 * Register the symbolic node name for a given node name.
4550 bfa_fcs_lport_ns_send_rsnn_nn(void *ns_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
4552 struct bfa_fcs_lport_ns_s
*ns
= ns_cbarg
;
4553 struct bfa_fcs_lport_s
*port
= ns
->port
;
4556 struct bfa_fcxp_s
*fcxp
;
4559 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
4561 fcxp
= fcxp_alloced
? fcxp_alloced
:
4562 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
4564 port
->stats
.ns_rsnn_nn_alloc_wait
++;
4565 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &ns
->fcxp_wqe
,
4566 bfa_fcs_lport_ns_send_rsnn_nn
, ns
, BFA_TRUE
);
4571 nsymbl
= (u8
*) &(bfa_fcs_lport_get_nsym_name(
4572 bfa_fcs_get_base_port(port
->fcs
)));
4574 len
= fc_rsnn_nn_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
4575 bfa_fcs_lport_get_fcid(port
),
4576 bfa_fcs_lport_get_nwwn(port
), nsymbl
);
4578 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
4579 FC_CLASS_3
, len
, &fchs
,
4580 bfa_fcs_lport_ns_rsnn_nn_response
, (void *)ns
,
4581 FC_MAX_PDUSZ
, FC_FCCT_TOV
);
4583 port
->stats
.ns_rsnn_nn_sent
++;
4585 bfa_sm_send_event(ns
, NSSM_EVENT_RSNN_NN_SENT
);
4589 bfa_fcs_lport_ns_rsnn_nn_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
,
4590 void *cbarg
, bfa_status_t req_status
,
4591 u32 rsp_len
, u32 resid_len
,
4592 struct fchs_s
*rsp_fchs
)
4594 struct bfa_fcs_lport_ns_s
*ns
= (struct bfa_fcs_lport_ns_s
*) cbarg
;
4595 struct bfa_fcs_lport_s
*port
= ns
->port
;
4596 struct ct_hdr_s
*cthdr
= NULL
;
4598 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
4603 if (req_status
!= BFA_STATUS_OK
) {
4604 bfa_trc(port
->fcs
, req_status
);
4605 port
->stats
.ns_rsnn_nn_rsp_err
++;
4606 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4610 cthdr
= (struct ct_hdr_s
*) BFA_FCXP_RSP_PLD(fcxp
);
4611 cthdr
->cmd_rsp_code
= be16_to_cpu(cthdr
->cmd_rsp_code
);
4613 if (cthdr
->cmd_rsp_code
== CT_RSP_ACCEPT
) {
4614 port
->stats
.ns_rsnn_nn_accepts
++;
4615 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_OK
);
4619 port
->stats
.ns_rsnn_nn_rejects
++;
4620 bfa_trc(port
->fcs
, cthdr
->reason_code
);
4621 bfa_trc(port
->fcs
, cthdr
->exp_code
);
4622 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4626 * Register the symbolic port name.
4629 bfa_fcs_lport_ns_send_rspn_id(void *ns_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
4631 struct bfa_fcs_lport_ns_s
*ns
= ns_cbarg
;
4632 struct bfa_fcs_lport_s
*port
= ns
->port
;
4635 struct bfa_fcxp_s
*fcxp
;
4637 u8
*psymbl
= &symbl
[0];
4639 memset(symbl
, 0, sizeof(symbl
));
4641 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
4643 fcxp
= fcxp_alloced
? fcxp_alloced
:
4644 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
4646 port
->stats
.ns_rspnid_alloc_wait
++;
4647 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &ns
->fcxp_wqe
,
4648 bfa_fcs_lport_ns_send_rspn_id
, ns
, BFA_TRUE
);
4654 * for V-Port, form a Port Symbolic Name
4658 * For Vports, we append the vport's port symbolic name
4659 * to that of the base port.
4663 (char *)&(bfa_fcs_lport_get_psym_name
4664 (bfa_fcs_get_base_port(port
->fcs
))),
4667 strlcat(symbl
, (char *)&(bfa_fcs_lport_get_psym_name(port
)),
4670 psymbl
= (u8
*) &(bfa_fcs_lport_get_psym_name(port
));
4673 len
= fc_rspnid_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
4674 bfa_fcs_lport_get_fcid(port
), 0, psymbl
);
4676 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
4677 FC_CLASS_3
, len
, &fchs
,
4678 bfa_fcs_lport_ns_rspn_id_response
, (void *)ns
,
4679 FC_MAX_PDUSZ
, FC_FCCT_TOV
);
4681 port
->stats
.ns_rspnid_sent
++;
4683 bfa_sm_send_event(ns
, NSSM_EVENT_RSPNID_SENT
);
4687 bfa_fcs_lport_ns_rspn_id_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
,
4688 void *cbarg
, bfa_status_t req_status
,
4689 u32 rsp_len
, u32 resid_len
,
4690 struct fchs_s
*rsp_fchs
)
4692 struct bfa_fcs_lport_ns_s
*ns
= (struct bfa_fcs_lport_ns_s
*) cbarg
;
4693 struct bfa_fcs_lport_s
*port
= ns
->port
;
4694 struct ct_hdr_s
*cthdr
= NULL
;
4696 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
4701 if (req_status
!= BFA_STATUS_OK
) {
4702 bfa_trc(port
->fcs
, req_status
);
4703 port
->stats
.ns_rspnid_rsp_err
++;
4704 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4708 cthdr
= (struct ct_hdr_s
*) BFA_FCXP_RSP_PLD(fcxp
);
4709 cthdr
->cmd_rsp_code
= be16_to_cpu(cthdr
->cmd_rsp_code
);
4711 if (cthdr
->cmd_rsp_code
== CT_RSP_ACCEPT
) {
4712 port
->stats
.ns_rspnid_accepts
++;
4713 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_OK
);
4717 port
->stats
.ns_rspnid_rejects
++;
4718 bfa_trc(port
->fcs
, cthdr
->reason_code
);
4719 bfa_trc(port
->fcs
, cthdr
->exp_code
);
4720 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4724 * Register FC4-Types
4727 bfa_fcs_lport_ns_send_rft_id(void *ns_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
4729 struct bfa_fcs_lport_ns_s
*ns
= ns_cbarg
;
4730 struct bfa_fcs_lport_s
*port
= ns
->port
;
4733 struct bfa_fcxp_s
*fcxp
;
4735 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
4737 fcxp
= fcxp_alloced
? fcxp_alloced
:
4738 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
4740 port
->stats
.ns_rftid_alloc_wait
++;
4741 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &ns
->fcxp_wqe
,
4742 bfa_fcs_lport_ns_send_rft_id
, ns
, BFA_TRUE
);
4747 len
= fc_rftid_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
4748 bfa_fcs_lport_get_fcid(port
), 0, port
->port_cfg
.roles
);
4750 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
4751 FC_CLASS_3
, len
, &fchs
,
4752 bfa_fcs_lport_ns_rft_id_response
, (void *)ns
,
4753 FC_MAX_PDUSZ
, FC_FCCT_TOV
);
4755 port
->stats
.ns_rftid_sent
++;
4756 bfa_sm_send_event(ns
, NSSM_EVENT_RFTID_SENT
);
4760 bfa_fcs_lport_ns_rft_id_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
,
4761 void *cbarg
, bfa_status_t req_status
,
4762 u32 rsp_len
, u32 resid_len
,
4763 struct fchs_s
*rsp_fchs
)
4765 struct bfa_fcs_lport_ns_s
*ns
= (struct bfa_fcs_lport_ns_s
*) cbarg
;
4766 struct bfa_fcs_lport_s
*port
= ns
->port
;
4767 struct ct_hdr_s
*cthdr
= NULL
;
4769 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
4774 if (req_status
!= BFA_STATUS_OK
) {
4775 bfa_trc(port
->fcs
, req_status
);
4776 port
->stats
.ns_rftid_rsp_err
++;
4777 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4781 cthdr
= (struct ct_hdr_s
*) BFA_FCXP_RSP_PLD(fcxp
);
4782 cthdr
->cmd_rsp_code
= be16_to_cpu(cthdr
->cmd_rsp_code
);
4784 if (cthdr
->cmd_rsp_code
== CT_RSP_ACCEPT
) {
4785 port
->stats
.ns_rftid_accepts
++;
4786 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_OK
);
4790 port
->stats
.ns_rftid_rejects
++;
4791 bfa_trc(port
->fcs
, cthdr
->reason_code
);
4792 bfa_trc(port
->fcs
, cthdr
->exp_code
);
4793 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4797 * Register FC4-Features : Should be done after RFT_ID
4800 bfa_fcs_lport_ns_send_rff_id(void *ns_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
4802 struct bfa_fcs_lport_ns_s
*ns
= ns_cbarg
;
4803 struct bfa_fcs_lport_s
*port
= ns
->port
;
4806 struct bfa_fcxp_s
*fcxp
;
4809 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
4811 fcxp
= fcxp_alloced
? fcxp_alloced
:
4812 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
4814 port
->stats
.ns_rffid_alloc_wait
++;
4815 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &ns
->fcxp_wqe
,
4816 bfa_fcs_lport_ns_send_rff_id
, ns
, BFA_TRUE
);
4821 if (BFA_FCS_VPORT_IS_INITIATOR_MODE(ns
->port
))
4822 fc4_ftrs
= FC_GS_FCP_FC4_FEATURE_INITIATOR
;
4824 len
= fc_rffid_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
4825 bfa_fcs_lport_get_fcid(port
), 0,
4826 FC_TYPE_FCP
, fc4_ftrs
);
4828 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
4829 FC_CLASS_3
, len
, &fchs
,
4830 bfa_fcs_lport_ns_rff_id_response
, (void *)ns
,
4831 FC_MAX_PDUSZ
, FC_FCCT_TOV
);
4833 port
->stats
.ns_rffid_sent
++;
4834 bfa_sm_send_event(ns
, NSSM_EVENT_RFFID_SENT
);
4838 bfa_fcs_lport_ns_rff_id_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
,
4839 void *cbarg
, bfa_status_t req_status
,
4840 u32 rsp_len
, u32 resid_len
,
4841 struct fchs_s
*rsp_fchs
)
4843 struct bfa_fcs_lport_ns_s
*ns
= (struct bfa_fcs_lport_ns_s
*) cbarg
;
4844 struct bfa_fcs_lport_s
*port
= ns
->port
;
4845 struct ct_hdr_s
*cthdr
= NULL
;
4847 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
4852 if (req_status
!= BFA_STATUS_OK
) {
4853 bfa_trc(port
->fcs
, req_status
);
4854 port
->stats
.ns_rffid_rsp_err
++;
4855 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4859 cthdr
= (struct ct_hdr_s
*) BFA_FCXP_RSP_PLD(fcxp
);
4860 cthdr
->cmd_rsp_code
= be16_to_cpu(cthdr
->cmd_rsp_code
);
4862 if (cthdr
->cmd_rsp_code
== CT_RSP_ACCEPT
) {
4863 port
->stats
.ns_rffid_accepts
++;
4864 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_OK
);
4868 port
->stats
.ns_rffid_rejects
++;
4869 bfa_trc(port
->fcs
, cthdr
->reason_code
);
4870 bfa_trc(port
->fcs
, cthdr
->exp_code
);
4872 if (cthdr
->reason_code
== CT_RSN_NOT_SUPP
) {
4873 /* if this command is not supported, we don't retry */
4874 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_OK
);
4876 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4879 * Query Fabric for FC4-Types Devices.
4881 * TBD : Need to use a local (FCS private) response buffer, since the response
4882 * can be larger than 2K.
4885 bfa_fcs_lport_ns_send_gid_ft(void *ns_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
4887 struct bfa_fcs_lport_ns_s
*ns
= ns_cbarg
;
4888 struct bfa_fcs_lport_s
*port
= ns
->port
;
4891 struct bfa_fcxp_s
*fcxp
;
4893 bfa_trc(port
->fcs
, port
->pid
);
4895 fcxp
= fcxp_alloced
? fcxp_alloced
:
4896 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
4898 port
->stats
.ns_gidft_alloc_wait
++;
4899 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &ns
->fcxp_wqe
,
4900 bfa_fcs_lport_ns_send_gid_ft
, ns
, BFA_TRUE
);
4906 * This query is only initiated for FCP initiator mode.
4908 len
= fc_gid_ft_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
4909 ns
->port
->pid
, FC_TYPE_FCP
);
4911 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
4912 FC_CLASS_3
, len
, &fchs
,
4913 bfa_fcs_lport_ns_gid_ft_response
, (void *)ns
,
4914 bfa_fcxp_get_maxrsp(port
->fcs
->bfa
), FC_FCCT_TOV
);
4916 port
->stats
.ns_gidft_sent
++;
4918 bfa_sm_send_event(ns
, NSSM_EVENT_GIDFT_SENT
);
4922 bfa_fcs_lport_ns_gid_ft_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
,
4923 void *cbarg
, bfa_status_t req_status
,
4924 u32 rsp_len
, u32 resid_len
,
4925 struct fchs_s
*rsp_fchs
)
4927 struct bfa_fcs_lport_ns_s
*ns
= (struct bfa_fcs_lport_ns_s
*) cbarg
;
4928 struct bfa_fcs_lport_s
*port
= ns
->port
;
4929 struct ct_hdr_s
*cthdr
= NULL
;
4932 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
4937 if (req_status
!= BFA_STATUS_OK
) {
4938 bfa_trc(port
->fcs
, req_status
);
4939 port
->stats
.ns_gidft_rsp_err
++;
4940 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4944 if (resid_len
!= 0) {
4946 * TBD : we will need to allocate a larger buffer & retry the
4949 bfa_trc(port
->fcs
, rsp_len
);
4950 bfa_trc(port
->fcs
, resid_len
);
4954 cthdr
= (struct ct_hdr_s
*) BFA_FCXP_RSP_PLD(fcxp
);
4955 cthdr
->cmd_rsp_code
= be16_to_cpu(cthdr
->cmd_rsp_code
);
4957 switch (cthdr
->cmd_rsp_code
) {
4961 port
->stats
.ns_gidft_accepts
++;
4962 n_pids
= (fc_get_ctresp_pyld_len(rsp_len
) / sizeof(u32
));
4963 bfa_trc(port
->fcs
, n_pids
);
4964 bfa_fcs_lport_ns_process_gidft_pids(port
,
4965 (u32
*) (cthdr
+ 1),
4967 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_OK
);
4973 * Check the reason code & explanation.
4974 * There may not have been any FC4 devices in the fabric
4976 port
->stats
.ns_gidft_rejects
++;
4977 bfa_trc(port
->fcs
, cthdr
->reason_code
);
4978 bfa_trc(port
->fcs
, cthdr
->exp_code
);
4980 if ((cthdr
->reason_code
== CT_RSN_UNABLE_TO_PERF
)
4981 && (cthdr
->exp_code
== CT_NS_EXP_FT_NOT_REG
)) {
4983 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_OK
);
4986 * for all other errors, retry
4988 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
4993 port
->stats
.ns_gidft_unknown_rsp
++;
4994 bfa_trc(port
->fcs
, cthdr
->cmd_rsp_code
);
4995 bfa_sm_send_event(ns
, NSSM_EVENT_RSP_ERROR
);
5000 * This routine will be called by bfa_timer on timer timeouts.
5002 * param[in] port - pointer to bfa_fcs_lport_t.
5007 * Special Considerations:
5012 bfa_fcs_lport_ns_timeout(void *arg
)
5014 struct bfa_fcs_lport_ns_s
*ns
= (struct bfa_fcs_lport_ns_s
*) arg
;
5016 ns
->port
->stats
.ns_timeouts
++;
5017 bfa_sm_send_event(ns
, NSSM_EVENT_TIMEOUT
);
5021 * Process the PID list in GID_FT response
5024 bfa_fcs_lport_ns_process_gidft_pids(struct bfa_fcs_lport_s
*port
, u32
*pid_buf
,
5027 struct fcgs_gidft_resp_s
*gidft_entry
;
5028 struct bfa_fcs_rport_s
*rport
;
5030 struct bfa_fcs_fabric_s
*fabric
= port
->fabric
;
5031 struct bfa_fcs_vport_s
*vport
;
5032 struct list_head
*qe
;
5035 for (ii
= 0; ii
< n_pids
; ii
++) {
5036 gidft_entry
= (struct fcgs_gidft_resp_s
*) &pid_buf
[ii
];
5038 if (gidft_entry
->pid
== port
->pid
)
5042 * Ignore PID if it is of base port
5043 * (Avoid vports discovering base port as remote port)
5045 if (gidft_entry
->pid
== fabric
->bport
.pid
)
5049 * Ignore PID if it is of vport created on the same base port
5050 * (Avoid vport discovering every other vport created on the
5051 * same port as remote port)
5053 list_for_each(qe
, &fabric
->vport_q
) {
5054 vport
= (struct bfa_fcs_vport_s
*) qe
;
5055 if (vport
->lport
.pid
== gidft_entry
->pid
)
5065 * Check if this rport already exists
5067 rport
= bfa_fcs_lport_get_rport_by_pid(port
, gidft_entry
->pid
);
5068 if (rport
== NULL
) {
5070 * this is a new device. create rport
5072 rport
= bfa_fcs_rport_create(port
, gidft_entry
->pid
);
5075 * this rport already exists
5077 bfa_fcs_rport_scn(rport
);
5080 bfa_trc(port
->fcs
, gidft_entry
->pid
);
5083 * if the last entry bit is set, bail out.
5085 if (gidft_entry
->last
)
5091 * fcs_ns_public FCS nameserver public interfaces
5095 * Functions called by port/fab.
5096 * These will send relevant Events to the ns state machine.
5099 bfa_fcs_lport_ns_init(struct bfa_fcs_lport_s
*port
)
5101 struct bfa_fcs_lport_ns_s
*ns
= BFA_FCS_GET_NS_FROM_PORT(port
);
5104 bfa_sm_set_state(ns
, bfa_fcs_lport_ns_sm_offline
);
5108 bfa_fcs_lport_ns_offline(struct bfa_fcs_lport_s
*port
)
5110 struct bfa_fcs_lport_ns_s
*ns
= BFA_FCS_GET_NS_FROM_PORT(port
);
5113 bfa_sm_send_event(ns
, NSSM_EVENT_PORT_OFFLINE
);
5117 bfa_fcs_lport_ns_online(struct bfa_fcs_lport_s
*port
)
5119 struct bfa_fcs_lport_ns_s
*ns
= BFA_FCS_GET_NS_FROM_PORT(port
);
5122 bfa_sm_send_event(ns
, NSSM_EVENT_PORT_ONLINE
);
5126 bfa_fcs_lport_ns_query(struct bfa_fcs_lport_s
*port
)
5128 struct bfa_fcs_lport_ns_s
*ns
= BFA_FCS_GET_NS_FROM_PORT(port
);
5130 bfa_trc(port
->fcs
, port
->pid
);
5131 if (bfa_sm_cmp_state(ns
, bfa_fcs_lport_ns_sm_online
))
5132 bfa_sm_send_event(ns
, NSSM_EVENT_NS_QUERY
);
5136 bfa_fcs_lport_ns_boot_target_disc(bfa_fcs_lport_t
*port
)
5139 struct bfa_fcs_rport_s
*rport
;
5141 wwn_t wwns
[BFA_PREBOOT_BOOTLUN_MAX
];
5144 bfa_iocfc_get_bootwwns(port
->fcs
->bfa
, &nwwns
, wwns
);
5146 for (ii
= 0 ; ii
< nwwns
; ++ii
) {
5147 rport
= bfa_fcs_rport_create_by_wwn(port
, wwns
[ii
]);
5153 bfa_fcs_lport_ns_util_send_rspn_id(void *cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
5155 struct bfa_fcs_lport_ns_s
*ns
= cbarg
;
5156 struct bfa_fcs_lport_s
*port
= ns
->port
;
5158 struct bfa_fcxp_s
*fcxp
;
5162 /* Avoid sending RSPN in the following states. */
5163 if (bfa_sm_cmp_state(ns
, bfa_fcs_lport_ns_sm_offline
) ||
5164 bfa_sm_cmp_state(ns
, bfa_fcs_lport_ns_sm_plogi_sending
) ||
5165 bfa_sm_cmp_state(ns
, bfa_fcs_lport_ns_sm_plogi
) ||
5166 bfa_sm_cmp_state(ns
, bfa_fcs_lport_ns_sm_plogi_retry
) ||
5167 bfa_sm_cmp_state(ns
, bfa_fcs_lport_ns_sm_rspn_id_retry
))
5170 memset(symbl
, 0, sizeof(symbl
));
5171 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
5173 fcxp
= fcxp_alloced
? fcxp_alloced
:
5174 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_FALSE
);
5176 port
->stats
.ns_rspnid_alloc_wait
++;
5177 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &ns
->fcxp_wqe
,
5178 bfa_fcs_lport_ns_util_send_rspn_id
, ns
, BFA_FALSE
);
5186 * For Vports, we append the vport's port symbolic name
5187 * to that of the base port.
5189 strlcpy(symbl
, (char *)&(bfa_fcs_lport_get_psym_name
5190 (bfa_fcs_get_base_port(port
->fcs
))),
5194 (char *)&(bfa_fcs_lport_get_psym_name(port
)),
5198 len
= fc_rspnid_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
5199 bfa_fcs_lport_get_fcid(port
), 0, symbl
);
5201 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
5202 FC_CLASS_3
, len
, &fchs
, NULL
, NULL
, FC_MAX_PDUSZ
, 0);
5204 port
->stats
.ns_rspnid_sent
++;
5211 #define FC_QOS_RSCN_EVENT 0x0c
5212 #define FC_FABRIC_NAME_RSCN_EVENT 0x0d
5215 * forward declarations
5217 static void bfa_fcs_lport_scn_send_scr(void *scn_cbarg
,
5218 struct bfa_fcxp_s
*fcxp_alloced
);
5219 static void bfa_fcs_lport_scn_scr_response(void *fcsarg
,
5220 struct bfa_fcxp_s
*fcxp
,
5222 bfa_status_t req_status
,
5225 struct fchs_s
*rsp_fchs
);
5226 static void bfa_fcs_lport_scn_send_ls_acc(struct bfa_fcs_lport_s
*port
,
5227 struct fchs_s
*rx_fchs
);
5228 static void bfa_fcs_lport_scn_timeout(void *arg
);
5231 * fcs_scm_sm FCS SCN state machine
5235 * VPort SCN State Machine events
5237 enum port_scn_event
{
5238 SCNSM_EVENT_PORT_ONLINE
= 1,
5239 SCNSM_EVENT_PORT_OFFLINE
= 2,
5240 SCNSM_EVENT_RSP_OK
= 3,
5241 SCNSM_EVENT_RSP_ERROR
= 4,
5242 SCNSM_EVENT_TIMEOUT
= 5,
5243 SCNSM_EVENT_SCR_SENT
= 6,
5246 static void bfa_fcs_lport_scn_sm_offline(struct bfa_fcs_lport_scn_s
*scn
,
5247 enum port_scn_event event
);
5248 static void bfa_fcs_lport_scn_sm_sending_scr(
5249 struct bfa_fcs_lport_scn_s
*scn
,
5250 enum port_scn_event event
);
5251 static void bfa_fcs_lport_scn_sm_scr(struct bfa_fcs_lport_scn_s
*scn
,
5252 enum port_scn_event event
);
5253 static void bfa_fcs_lport_scn_sm_scr_retry(struct bfa_fcs_lport_scn_s
*scn
,
5254 enum port_scn_event event
);
5255 static void bfa_fcs_lport_scn_sm_online(struct bfa_fcs_lport_scn_s
*scn
,
5256 enum port_scn_event event
);
5259 * Starting state - awaiting link up.
5262 bfa_fcs_lport_scn_sm_offline(struct bfa_fcs_lport_scn_s
*scn
,
5263 enum port_scn_event event
)
5266 case SCNSM_EVENT_PORT_ONLINE
:
5267 bfa_sm_set_state(scn
, bfa_fcs_lport_scn_sm_sending_scr
);
5268 bfa_fcs_lport_scn_send_scr(scn
, NULL
);
5271 case SCNSM_EVENT_PORT_OFFLINE
:
5275 bfa_sm_fault(scn
->port
->fcs
, event
);
5280 bfa_fcs_lport_scn_sm_sending_scr(struct bfa_fcs_lport_scn_s
*scn
,
5281 enum port_scn_event event
)
5284 case SCNSM_EVENT_SCR_SENT
:
5285 bfa_sm_set_state(scn
, bfa_fcs_lport_scn_sm_scr
);
5288 case SCNSM_EVENT_PORT_OFFLINE
:
5289 bfa_sm_set_state(scn
, bfa_fcs_lport_scn_sm_offline
);
5290 bfa_fcxp_walloc_cancel(scn
->port
->fcs
->bfa
, &scn
->fcxp_wqe
);
5294 bfa_sm_fault(scn
->port
->fcs
, event
);
5299 bfa_fcs_lport_scn_sm_scr(struct bfa_fcs_lport_scn_s
*scn
,
5300 enum port_scn_event event
)
5302 struct bfa_fcs_lport_s
*port
= scn
->port
;
5305 case SCNSM_EVENT_RSP_OK
:
5306 bfa_sm_set_state(scn
, bfa_fcs_lport_scn_sm_online
);
5309 case SCNSM_EVENT_RSP_ERROR
:
5310 bfa_sm_set_state(scn
, bfa_fcs_lport_scn_sm_scr_retry
);
5311 bfa_timer_start(port
->fcs
->bfa
, &scn
->timer
,
5312 bfa_fcs_lport_scn_timeout
, scn
,
5313 BFA_FCS_RETRY_TIMEOUT
);
5316 case SCNSM_EVENT_PORT_OFFLINE
:
5317 bfa_sm_set_state(scn
, bfa_fcs_lport_scn_sm_offline
);
5318 bfa_fcxp_discard(scn
->fcxp
);
5322 bfa_sm_fault(port
->fcs
, event
);
5327 bfa_fcs_lport_scn_sm_scr_retry(struct bfa_fcs_lport_scn_s
*scn
,
5328 enum port_scn_event event
)
5331 case SCNSM_EVENT_TIMEOUT
:
5332 bfa_sm_set_state(scn
, bfa_fcs_lport_scn_sm_sending_scr
);
5333 bfa_fcs_lport_scn_send_scr(scn
, NULL
);
5336 case SCNSM_EVENT_PORT_OFFLINE
:
5337 bfa_sm_set_state(scn
, bfa_fcs_lport_scn_sm_offline
);
5338 bfa_timer_stop(&scn
->timer
);
5342 bfa_sm_fault(scn
->port
->fcs
, event
);
5347 bfa_fcs_lport_scn_sm_online(struct bfa_fcs_lport_scn_s
*scn
,
5348 enum port_scn_event event
)
5351 case SCNSM_EVENT_PORT_OFFLINE
:
5352 bfa_sm_set_state(scn
, bfa_fcs_lport_scn_sm_offline
);
5356 bfa_sm_fault(scn
->port
->fcs
, event
);
5363 * fcs_scn_private FCS SCN private functions
5367 * This routine will be called to send a SCR command.
5370 bfa_fcs_lport_scn_send_scr(void *scn_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
5372 struct bfa_fcs_lport_scn_s
*scn
= scn_cbarg
;
5373 struct bfa_fcs_lport_s
*port
= scn
->port
;
5376 struct bfa_fcxp_s
*fcxp
;
5378 bfa_trc(port
->fcs
, port
->pid
);
5379 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
5381 fcxp
= fcxp_alloced
? fcxp_alloced
:
5382 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
5384 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &scn
->fcxp_wqe
,
5385 bfa_fcs_lport_scn_send_scr
, scn
, BFA_TRUE
);
5390 /* Handle VU registrations for Base port only */
5391 if ((!port
->vport
) && bfa_ioc_get_fcmode(&port
->fcs
->bfa
->ioc
)) {
5392 len
= fc_scr_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
5393 port
->fabric
->lps
->brcd_switch
,
5396 len
= fc_scr_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
5401 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
5402 FC_CLASS_3
, len
, &fchs
,
5403 bfa_fcs_lport_scn_scr_response
,
5404 (void *)scn
, FC_MAX_PDUSZ
, FC_ELS_TOV
);
5406 bfa_sm_send_event(scn
, SCNSM_EVENT_SCR_SENT
);
5410 bfa_fcs_lport_scn_scr_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
,
5411 void *cbarg
, bfa_status_t req_status
, u32 rsp_len
,
5412 u32 resid_len
, struct fchs_s
*rsp_fchs
)
5414 struct bfa_fcs_lport_scn_s
*scn
= (struct bfa_fcs_lport_scn_s
*) cbarg
;
5415 struct bfa_fcs_lport_s
*port
= scn
->port
;
5416 struct fc_els_cmd_s
*els_cmd
;
5417 struct fc_ls_rjt_s
*ls_rjt
;
5419 bfa_trc(port
->fcs
, port
->port_cfg
.pwwn
);
5424 if (req_status
!= BFA_STATUS_OK
) {
5425 bfa_trc(port
->fcs
, req_status
);
5426 bfa_sm_send_event(scn
, SCNSM_EVENT_RSP_ERROR
);
5430 els_cmd
= (struct fc_els_cmd_s
*) BFA_FCXP_RSP_PLD(fcxp
);
5432 switch (els_cmd
->els_code
) {
5435 bfa_sm_send_event(scn
, SCNSM_EVENT_RSP_OK
);
5440 ls_rjt
= (struct fc_ls_rjt_s
*) BFA_FCXP_RSP_PLD(fcxp
);
5442 bfa_trc(port
->fcs
, ls_rjt
->reason_code
);
5443 bfa_trc(port
->fcs
, ls_rjt
->reason_code_expl
);
5445 bfa_sm_send_event(scn
, SCNSM_EVENT_RSP_ERROR
);
5449 bfa_sm_send_event(scn
, SCNSM_EVENT_RSP_ERROR
);
5457 bfa_fcs_lport_scn_send_ls_acc(struct bfa_fcs_lport_s
*port
,
5458 struct fchs_s
*rx_fchs
)
5461 struct bfa_fcxp_s
*fcxp
;
5462 struct bfa_rport_s
*bfa_rport
= NULL
;
5465 bfa_trc(port
->fcs
, rx_fchs
->s_id
);
5467 fcxp
= bfa_fcs_fcxp_alloc(port
->fcs
, BFA_FALSE
);
5471 len
= fc_ls_acc_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
5472 rx_fchs
->s_id
, bfa_fcs_lport_get_fcid(port
),
5475 bfa_fcxp_send(fcxp
, bfa_rport
, port
->fabric
->vf_id
, port
->lp_tag
,
5476 BFA_FALSE
, FC_CLASS_3
, len
, &fchs
, NULL
, NULL
,
5481 * This routine will be called by bfa_timer on timer timeouts.
5483 * param[in] vport - pointer to bfa_fcs_lport_t.
5484 * param[out] vport_status - pointer to return vport status in
5489 * Special Considerations:
5494 bfa_fcs_lport_scn_timeout(void *arg
)
5496 struct bfa_fcs_lport_scn_s
*scn
= (struct bfa_fcs_lport_scn_s
*) arg
;
5498 bfa_sm_send_event(scn
, SCNSM_EVENT_TIMEOUT
);
5504 * fcs_scn_public FCS state change notification public interfaces
5508 * Functions called by port/fab
5511 bfa_fcs_lport_scn_init(struct bfa_fcs_lport_s
*port
)
5513 struct bfa_fcs_lport_scn_s
*scn
= BFA_FCS_GET_SCN_FROM_PORT(port
);
5516 bfa_sm_set_state(scn
, bfa_fcs_lport_scn_sm_offline
);
5520 bfa_fcs_lport_scn_offline(struct bfa_fcs_lport_s
*port
)
5522 struct bfa_fcs_lport_scn_s
*scn
= BFA_FCS_GET_SCN_FROM_PORT(port
);
5525 bfa_sm_send_event(scn
, SCNSM_EVENT_PORT_OFFLINE
);
5529 bfa_fcs_lport_fab_scn_online(struct bfa_fcs_lport_s
*port
)
5531 struct bfa_fcs_lport_scn_s
*scn
= BFA_FCS_GET_SCN_FROM_PORT(port
);
5534 bfa_sm_send_event(scn
, SCNSM_EVENT_PORT_ONLINE
);
5538 bfa_fcs_lport_scn_portid_rscn(struct bfa_fcs_lport_s
*port
, u32 rpid
)
5540 struct bfa_fcs_rport_s
*rport
;
5541 struct bfa_fcs_fabric_s
*fabric
= port
->fabric
;
5542 struct bfa_fcs_vport_s
*vport
;
5543 struct list_head
*qe
;
5545 bfa_trc(port
->fcs
, rpid
);
5548 * Ignore PID if it is of base port or of vports created on the
5549 * same base port. It is to avoid vports discovering base port or
5550 * other vports created on same base port as remote port
5552 if (rpid
== fabric
->bport
.pid
)
5555 list_for_each(qe
, &fabric
->vport_q
) {
5556 vport
= (struct bfa_fcs_vport_s
*) qe
;
5557 if (vport
->lport
.pid
== rpid
)
5561 * If this is an unknown device, then it just came online.
5562 * Otherwise let rport handle the RSCN event.
5564 rport
= bfa_fcs_lport_get_rport_by_pid(port
, rpid
);
5566 rport
= bfa_fcs_lport_get_rport_by_old_pid(port
, rpid
);
5568 if (rport
== NULL
) {
5570 * If min cfg mode is enabled, we donot need to
5571 * discover any new rports.
5573 if (!__fcs_min_cfg(port
->fcs
))
5574 rport
= bfa_fcs_rport_create(port
, rpid
);
5576 bfa_fcs_rport_scn(rport
);
5580 * rscn format based PID comparison
5582 #define __fc_pid_match(__c0, __c1, __fmt) \
5583 (((__fmt) == FC_RSCN_FORMAT_FABRIC) || \
5584 (((__fmt) == FC_RSCN_FORMAT_DOMAIN) && \
5585 ((__c0)[0] == (__c1)[0])) || \
5586 (((__fmt) == FC_RSCN_FORMAT_AREA) && \
5587 ((__c0)[0] == (__c1)[0]) && \
5588 ((__c0)[1] == (__c1)[1])))
5591 bfa_fcs_lport_scn_multiport_rscn(struct bfa_fcs_lport_s
*port
,
5592 enum fc_rscn_format format
,
5595 struct bfa_fcs_rport_s
*rport
;
5596 struct list_head
*qe
, *qe_next
;
5599 bfa_trc(port
->fcs
, format
);
5600 bfa_trc(port
->fcs
, rscn_pid
);
5602 c0
= (u8
*) &rscn_pid
;
5604 list_for_each_safe(qe
, qe_next
, &port
->rport_q
) {
5605 rport
= (struct bfa_fcs_rport_s
*) qe
;
5606 c1
= (u8
*) &rport
->pid
;
5607 if (__fc_pid_match(c0
, c1
, format
))
5608 bfa_fcs_rport_scn(rport
);
5614 bfa_fcs_lport_scn_process_rscn(struct bfa_fcs_lport_s
*port
,
5615 struct fchs_s
*fchs
, u32 len
)
5617 struct fc_rscn_pl_s
*rscn
= (struct fc_rscn_pl_s
*) (fchs
+ 1);
5620 bfa_boolean_t nsquery
= BFA_FALSE
, found
;
5624 (be16_to_cpu(rscn
->payldlen
) -
5625 sizeof(u32
)) / sizeof(rscn
->event
[0]);
5627 bfa_trc(port
->fcs
, num_entries
);
5629 port
->stats
.num_rscn
++;
5631 bfa_fcs_lport_scn_send_ls_acc(port
, fchs
);
5633 for (i
= 0; i
< num_entries
; i
++) {
5634 rscn_pid
= rscn
->event
[i
].portid
;
5636 bfa_trc(port
->fcs
, rscn
->event
[i
].format
);
5637 bfa_trc(port
->fcs
, rscn_pid
);
5639 /* check for duplicate entries in the list */
5641 for (j
= 0; j
< i
; j
++) {
5642 if (rscn
->event
[j
].portid
== rscn_pid
) {
5648 /* if found in down the list, pid has been already processed */
5650 bfa_trc(port
->fcs
, rscn_pid
);
5654 switch (rscn
->event
[i
].format
) {
5655 case FC_RSCN_FORMAT_PORTID
:
5656 if (rscn
->event
[i
].qualifier
== FC_QOS_RSCN_EVENT
) {
5658 * Ignore this event.
5659 * f/w would have processed it
5661 bfa_trc(port
->fcs
, rscn_pid
);
5663 port
->stats
.num_portid_rscn
++;
5664 bfa_fcs_lport_scn_portid_rscn(port
, rscn_pid
);
5668 case FC_RSCN_FORMAT_FABRIC
:
5669 if (rscn
->event
[i
].qualifier
==
5670 FC_FABRIC_NAME_RSCN_EVENT
) {
5671 bfa_fcs_lport_ms_fabric_rscn(port
);
5676 case FC_RSCN_FORMAT_AREA
:
5677 case FC_RSCN_FORMAT_DOMAIN
:
5679 bfa_fcs_lport_scn_multiport_rscn(port
,
5680 rscn
->event
[i
].format
,
5692 * If any of area, domain or fabric RSCN is received, do a fresh
5693 * discovery to find new devices.
5696 bfa_fcs_lport_ns_query(port
);
5703 * fcs_port_api BFA FCS port API
5705 struct bfa_fcs_lport_s
*
5706 bfa_fcs_get_base_port(struct bfa_fcs_s
*fcs
)
5708 return &fcs
->fabric
.bport
;
5712 bfa_fcs_lport_get_rport(struct bfa_fcs_lport_s
*port
, wwn_t wwn
, int index
,
5713 int nrports
, bfa_boolean_t bwwn
)
5715 struct list_head
*qh
, *qe
;
5716 struct bfa_fcs_rport_s
*rport
= NULL
;
5718 struct bfa_fcs_s
*fcs
;
5720 if (port
== NULL
|| nrports
== 0)
5724 bfa_trc(fcs
, (u32
) nrports
);
5727 qh
= &port
->rport_q
;
5728 qe
= bfa_q_first(qh
);
5730 while ((qe
!= qh
) && (i
< nrports
)) {
5731 rport
= (struct bfa_fcs_rport_s
*) qe
;
5732 if (bfa_ntoh3b(rport
->pid
) > 0xFFF000) {
5733 qe
= bfa_q_next(qe
);
5734 bfa_trc(fcs
, (u32
) rport
->pwwn
);
5735 bfa_trc(fcs
, rport
->pid
);
5741 if (!memcmp(&wwn
, &rport
->pwwn
, 8))
5749 qe
= bfa_q_next(qe
);
5760 bfa_fcs_lport_get_rport_quals(struct bfa_fcs_lport_s
*port
,
5761 struct bfa_rport_qualifier_s rports
[], int *nrports
)
5763 struct list_head
*qh
, *qe
;
5764 struct bfa_fcs_rport_s
*rport
= NULL
;
5766 struct bfa_fcs_s
*fcs
;
5768 if (port
== NULL
|| rports
== NULL
|| *nrports
== 0)
5772 bfa_trc(fcs
, (u32
) *nrports
);
5775 qh
= &port
->rport_q
;
5776 qe
= bfa_q_first(qh
);
5778 while ((qe
!= qh
) && (i
< *nrports
)) {
5779 rport
= (struct bfa_fcs_rport_s
*) qe
;
5780 if (bfa_ntoh3b(rport
->pid
) > 0xFFF000) {
5781 qe
= bfa_q_next(qe
);
5782 bfa_trc(fcs
, (u32
) rport
->pwwn
);
5783 bfa_trc(fcs
, rport
->pid
);
5788 if (!rport
->pwwn
&& !rport
->pid
) {
5789 qe
= bfa_q_next(qe
);
5793 rports
[i
].pwwn
= rport
->pwwn
;
5794 rports
[i
].pid
= rport
->pid
;
5797 qe
= bfa_q_next(qe
);
5805 * Iterate's through all the rport's in the given port to
5806 * determine the maximum operating speed.
5808 * !!!! To be used in TRL Functionality only !!!!
5811 bfa_fcs_lport_get_rport_max_speed(bfa_fcs_lport_t
*port
)
5813 struct list_head
*qh
, *qe
;
5814 struct bfa_fcs_rport_s
*rport
= NULL
;
5815 struct bfa_fcs_s
*fcs
;
5816 bfa_port_speed_t max_speed
= 0;
5817 struct bfa_port_attr_s port_attr
;
5818 bfa_port_speed_t port_speed
, rport_speed
;
5819 bfa_boolean_t trl_enabled
;
5825 trl_enabled
= bfa_fcport_is_ratelim(port
->fcs
->bfa
);
5827 /* Get Physical port's current speed */
5828 bfa_fcport_get_attr(port
->fcs
->bfa
, &port_attr
);
5829 port_speed
= port_attr
.speed
;
5830 bfa_trc(fcs
, port_speed
);
5832 qh
= &port
->rport_q
;
5833 qe
= bfa_q_first(qh
);
5836 rport
= (struct bfa_fcs_rport_s
*) qe
;
5837 if ((bfa_ntoh3b(rport
->pid
) > 0xFFF000) ||
5838 (bfa_fcs_rport_get_state(rport
) == BFA_RPORT_OFFLINE
) ||
5839 (rport
->scsi_function
!= BFA_RPORT_TARGET
)) {
5840 qe
= bfa_q_next(qe
);
5844 rport_speed
= rport
->rpf
.rpsc_speed
;
5845 if ((trl_enabled
) && (rport_speed
==
5846 BFA_PORT_SPEED_UNKNOWN
)) {
5847 /* Use default ratelim speed setting */
5849 bfa_fcport_get_ratelim_speed(port
->fcs
->bfa
);
5852 if (rport_speed
> max_speed
)
5853 max_speed
= rport_speed
;
5855 qe
= bfa_q_next(qe
);
5858 if (max_speed
> port_speed
)
5859 max_speed
= port_speed
;
5861 bfa_trc(fcs
, max_speed
);
5865 struct bfa_fcs_lport_s
*
5866 bfa_fcs_lookup_port(struct bfa_fcs_s
*fcs
, u16 vf_id
, wwn_t lpwwn
)
5868 struct bfa_fcs_vport_s
*vport
;
5871 WARN_ON(fcs
== NULL
);
5873 vf
= bfa_fcs_vf_lookup(fcs
, vf_id
);
5875 bfa_trc(fcs
, vf_id
);
5879 if (!lpwwn
|| (vf
->bport
.port_cfg
.pwwn
== lpwwn
))
5882 vport
= bfa_fcs_fabric_vport_lookup(vf
, lpwwn
);
5884 return &vport
->lport
;
5890 * API corresponding to NPIV_VPORT_GETINFO.
5893 bfa_fcs_lport_get_info(struct bfa_fcs_lport_s
*port
,
5894 struct bfa_lport_info_s
*port_info
)
5897 bfa_trc(port
->fcs
, port
->fabric
->fabric_name
);
5899 if (port
->vport
== NULL
) {
5901 * This is a Physical port
5903 port_info
->port_type
= BFA_LPORT_TYPE_PHYSICAL
;
5906 * @todo : need to fix the state & reason
5908 port_info
->port_state
= 0;
5909 port_info
->offline_reason
= 0;
5911 port_info
->port_wwn
= bfa_fcs_lport_get_pwwn(port
);
5912 port_info
->node_wwn
= bfa_fcs_lport_get_nwwn(port
);
5914 port_info
->max_vports_supp
=
5915 bfa_lps_get_max_vport(port
->fcs
->bfa
);
5916 port_info
->num_vports_inuse
=
5917 port
->fabric
->num_vports
;
5918 port_info
->max_rports_supp
= BFA_FCS_MAX_RPORTS_SUPP
;
5919 port_info
->num_rports_inuse
= port
->num_rports
;
5922 * This is a virtual port
5924 port_info
->port_type
= BFA_LPORT_TYPE_VIRTUAL
;
5927 * @todo : need to fix the state & reason
5929 port_info
->port_state
= 0;
5930 port_info
->offline_reason
= 0;
5932 port_info
->port_wwn
= bfa_fcs_lport_get_pwwn(port
);
5933 port_info
->node_wwn
= bfa_fcs_lport_get_nwwn(port
);
5938 bfa_fcs_lport_get_stats(struct bfa_fcs_lport_s
*fcs_port
,
5939 struct bfa_lport_stats_s
*port_stats
)
5941 *port_stats
= fcs_port
->stats
;
5945 bfa_fcs_lport_clear_stats(struct bfa_fcs_lport_s
*fcs_port
)
5947 memset(&fcs_port
->stats
, 0, sizeof(struct bfa_lport_stats_s
));
5951 * Let new loop map create missing rports
5954 bfa_fcs_lport_lip_scn_online(struct bfa_fcs_lport_s
*port
)
5956 bfa_fcs_lport_loop_online(port
);
5960 * FCS virtual port state machine
5963 #define __vport_fcs(__vp) ((__vp)->lport.fcs)
5964 #define __vport_pwwn(__vp) ((__vp)->lport.port_cfg.pwwn)
5965 #define __vport_nwwn(__vp) ((__vp)->lport.port_cfg.nwwn)
5966 #define __vport_bfa(__vp) ((__vp)->lport.fcs->bfa)
5967 #define __vport_fcid(__vp) ((__vp)->lport.pid)
5968 #define __vport_fabric(__vp) ((__vp)->lport.fabric)
5969 #define __vport_vfid(__vp) ((__vp)->lport.fabric->vf_id)
5971 #define BFA_FCS_VPORT_MAX_RETRIES 5
5973 * Forward declarations
5975 static void bfa_fcs_vport_do_fdisc(struct bfa_fcs_vport_s
*vport
);
5976 static void bfa_fcs_vport_timeout(void *vport_arg
);
5977 static void bfa_fcs_vport_do_logo(struct bfa_fcs_vport_s
*vport
);
5978 static void bfa_fcs_vport_free(struct bfa_fcs_vport_s
*vport
);
5981 * fcs_vport_sm FCS virtual port state machine
5985 * VPort State Machine events
5987 enum bfa_fcs_vport_event
{
5988 BFA_FCS_VPORT_SM_CREATE
= 1, /* vport create event */
5989 BFA_FCS_VPORT_SM_DELETE
= 2, /* vport delete event */
5990 BFA_FCS_VPORT_SM_START
= 3, /* vport start request */
5991 BFA_FCS_VPORT_SM_STOP
= 4, /* stop: unsupported */
5992 BFA_FCS_VPORT_SM_ONLINE
= 5, /* fabric online */
5993 BFA_FCS_VPORT_SM_OFFLINE
= 6, /* fabric offline event */
5994 BFA_FCS_VPORT_SM_FRMSENT
= 7, /* fdisc/logo sent events */
5995 BFA_FCS_VPORT_SM_RSP_OK
= 8, /* good response */
5996 BFA_FCS_VPORT_SM_RSP_ERROR
= 9, /* error/bad response */
5997 BFA_FCS_VPORT_SM_TIMEOUT
= 10, /* delay timer event */
5998 BFA_FCS_VPORT_SM_DELCOMP
= 11, /* lport delete completion */
5999 BFA_FCS_VPORT_SM_RSP_DUP_WWN
= 12, /* Dup wnn error*/
6000 BFA_FCS_VPORT_SM_RSP_FAILED
= 13, /* non-retryable failure */
6001 BFA_FCS_VPORT_SM_STOPCOMP
= 14, /* vport delete completion */
6002 BFA_FCS_VPORT_SM_FABRIC_MAX
= 15, /* max vports on fabric */
6005 static void bfa_fcs_vport_sm_uninit(struct bfa_fcs_vport_s
*vport
,
6006 enum bfa_fcs_vport_event event
);
6007 static void bfa_fcs_vport_sm_created(struct bfa_fcs_vport_s
*vport
,
6008 enum bfa_fcs_vport_event event
);
6009 static void bfa_fcs_vport_sm_offline(struct bfa_fcs_vport_s
*vport
,
6010 enum bfa_fcs_vport_event event
);
6011 static void bfa_fcs_vport_sm_fdisc(struct bfa_fcs_vport_s
*vport
,
6012 enum bfa_fcs_vport_event event
);
6013 static void bfa_fcs_vport_sm_fdisc_retry(struct bfa_fcs_vport_s
*vport
,
6014 enum bfa_fcs_vport_event event
);
6015 static void bfa_fcs_vport_sm_fdisc_rsp_wait(struct bfa_fcs_vport_s
*vport
,
6016 enum bfa_fcs_vport_event event
);
6017 static void bfa_fcs_vport_sm_online(struct bfa_fcs_vport_s
*vport
,
6018 enum bfa_fcs_vport_event event
);
6019 static void bfa_fcs_vport_sm_deleting(struct bfa_fcs_vport_s
*vport
,
6020 enum bfa_fcs_vport_event event
);
6021 static void bfa_fcs_vport_sm_cleanup(struct bfa_fcs_vport_s
*vport
,
6022 enum bfa_fcs_vport_event event
);
6023 static void bfa_fcs_vport_sm_logo(struct bfa_fcs_vport_s
*vport
,
6024 enum bfa_fcs_vport_event event
);
6025 static void bfa_fcs_vport_sm_error(struct bfa_fcs_vport_s
*vport
,
6026 enum bfa_fcs_vport_event event
);
6027 static void bfa_fcs_vport_sm_stopping(struct bfa_fcs_vport_s
*vport
,
6028 enum bfa_fcs_vport_event event
);
6029 static void bfa_fcs_vport_sm_logo_for_stop(struct bfa_fcs_vport_s
*vport
,
6030 enum bfa_fcs_vport_event event
);
6032 static struct bfa_sm_table_s vport_sm_table
[] = {
6033 {BFA_SM(bfa_fcs_vport_sm_uninit
), BFA_FCS_VPORT_UNINIT
},
6034 {BFA_SM(bfa_fcs_vport_sm_created
), BFA_FCS_VPORT_CREATED
},
6035 {BFA_SM(bfa_fcs_vport_sm_offline
), BFA_FCS_VPORT_OFFLINE
},
6036 {BFA_SM(bfa_fcs_vport_sm_fdisc
), BFA_FCS_VPORT_FDISC
},
6037 {BFA_SM(bfa_fcs_vport_sm_fdisc_retry
), BFA_FCS_VPORT_FDISC_RETRY
},
6038 {BFA_SM(bfa_fcs_vport_sm_fdisc_rsp_wait
), BFA_FCS_VPORT_FDISC_RSP_WAIT
},
6039 {BFA_SM(bfa_fcs_vport_sm_online
), BFA_FCS_VPORT_ONLINE
},
6040 {BFA_SM(bfa_fcs_vport_sm_deleting
), BFA_FCS_VPORT_DELETING
},
6041 {BFA_SM(bfa_fcs_vport_sm_cleanup
), BFA_FCS_VPORT_CLEANUP
},
6042 {BFA_SM(bfa_fcs_vport_sm_logo
), BFA_FCS_VPORT_LOGO
},
6043 {BFA_SM(bfa_fcs_vport_sm_error
), BFA_FCS_VPORT_ERROR
}
6050 bfa_fcs_vport_sm_uninit(struct bfa_fcs_vport_s
*vport
,
6051 enum bfa_fcs_vport_event event
)
6053 bfa_trc(__vport_fcs(vport
), __vport_pwwn(vport
));
6054 bfa_trc(__vport_fcs(vport
), event
);
6057 case BFA_FCS_VPORT_SM_CREATE
:
6058 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_created
);
6059 bfa_fcs_fabric_addvport(__vport_fabric(vport
), vport
);
6063 bfa_sm_fault(__vport_fcs(vport
), event
);
6068 * Created state - a start event is required to start up the state machine.
6071 bfa_fcs_vport_sm_created(struct bfa_fcs_vport_s
*vport
,
6072 enum bfa_fcs_vport_event event
)
6074 bfa_trc(__vport_fcs(vport
), __vport_pwwn(vport
));
6075 bfa_trc(__vport_fcs(vport
), event
);
6078 case BFA_FCS_VPORT_SM_START
:
6079 if (bfa_sm_cmp_state(__vport_fabric(vport
),
6080 bfa_fcs_fabric_sm_online
)
6081 && bfa_fcs_fabric_npiv_capable(__vport_fabric(vport
))) {
6082 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_fdisc
);
6083 bfa_fcs_vport_do_fdisc(vport
);
6086 * Fabric is offline or not NPIV capable, stay in
6089 vport
->vport_stats
.fab_no_npiv
++;
6090 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_offline
);
6094 case BFA_FCS_VPORT_SM_DELETE
:
6095 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_cleanup
);
6096 bfa_fcs_lport_delete(&vport
->lport
);
6099 case BFA_FCS_VPORT_SM_ONLINE
:
6100 case BFA_FCS_VPORT_SM_OFFLINE
:
6102 * Ignore ONLINE/OFFLINE events from fabric
6103 * till vport is started.
6108 bfa_sm_fault(__vport_fcs(vport
), event
);
6113 * Offline state - awaiting ONLINE event from fabric SM.
6116 bfa_fcs_vport_sm_offline(struct bfa_fcs_vport_s
*vport
,
6117 enum bfa_fcs_vport_event event
)
6119 bfa_trc(__vport_fcs(vport
), __vport_pwwn(vport
));
6120 bfa_trc(__vport_fcs(vport
), event
);
6123 case BFA_FCS_VPORT_SM_DELETE
:
6124 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_cleanup
);
6125 bfa_fcs_lport_delete(&vport
->lport
);
6128 case BFA_FCS_VPORT_SM_ONLINE
:
6129 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_fdisc
);
6130 vport
->fdisc_retries
= 0;
6131 bfa_fcs_vport_do_fdisc(vport
);
6134 case BFA_FCS_VPORT_SM_STOP
:
6135 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_cleanup
);
6136 bfa_sm_send_event(&vport
->lport
, BFA_FCS_PORT_SM_STOP
);
6139 case BFA_FCS_VPORT_SM_OFFLINE
:
6141 * This can happen if the vport couldn't be initialzied
6142 * due the fact that the npiv was not enabled on the switch.
6143 * In that case we will put the vport in offline state.
6144 * However, the link can go down and cause the this event to
6145 * be sent when we are already offline. Ignore it.
6150 bfa_sm_fault(__vport_fcs(vport
), event
);
6156 * FDISC is sent and awaiting reply from fabric.
6159 bfa_fcs_vport_sm_fdisc(struct bfa_fcs_vport_s
*vport
,
6160 enum bfa_fcs_vport_event event
)
6162 bfa_trc(__vport_fcs(vport
), __vport_pwwn(vport
));
6163 bfa_trc(__vport_fcs(vport
), event
);
6166 case BFA_FCS_VPORT_SM_DELETE
:
6167 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_fdisc_rsp_wait
);
6170 case BFA_FCS_VPORT_SM_OFFLINE
:
6171 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_offline
);
6172 bfa_sm_send_event(vport
->lps
, BFA_LPS_SM_OFFLINE
);
6175 case BFA_FCS_VPORT_SM_RSP_OK
:
6176 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_online
);
6177 bfa_fcs_lport_online(&vport
->lport
);
6180 case BFA_FCS_VPORT_SM_RSP_ERROR
:
6181 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_fdisc_retry
);
6182 bfa_timer_start(__vport_bfa(vport
), &vport
->timer
,
6183 bfa_fcs_vport_timeout
, vport
,
6184 BFA_FCS_RETRY_TIMEOUT
);
6187 case BFA_FCS_VPORT_SM_RSP_FAILED
:
6188 case BFA_FCS_VPORT_SM_FABRIC_MAX
:
6189 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_offline
);
6192 case BFA_FCS_VPORT_SM_RSP_DUP_WWN
:
6193 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_error
);
6197 bfa_sm_fault(__vport_fcs(vport
), event
);
6202 * FDISC attempt failed - a timer is active to retry FDISC.
6205 bfa_fcs_vport_sm_fdisc_retry(struct bfa_fcs_vport_s
*vport
,
6206 enum bfa_fcs_vport_event event
)
6208 bfa_trc(__vport_fcs(vport
), __vport_pwwn(vport
));
6209 bfa_trc(__vport_fcs(vport
), event
);
6212 case BFA_FCS_VPORT_SM_DELETE
:
6213 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_cleanup
);
6214 bfa_timer_stop(&vport
->timer
);
6215 bfa_fcs_lport_delete(&vport
->lport
);
6218 case BFA_FCS_VPORT_SM_OFFLINE
:
6219 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_offline
);
6220 bfa_timer_stop(&vport
->timer
);
6223 case BFA_FCS_VPORT_SM_TIMEOUT
:
6224 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_fdisc
);
6225 vport
->vport_stats
.fdisc_retries
++;
6226 vport
->fdisc_retries
++;
6227 bfa_fcs_vport_do_fdisc(vport
);
6231 bfa_sm_fault(__vport_fcs(vport
), event
);
6236 * FDISC is in progress and we got a vport delete request -
6237 * this is a wait state while we wait for fdisc response and
6238 * we will transition to the appropriate state - on rsp status.
6241 bfa_fcs_vport_sm_fdisc_rsp_wait(struct bfa_fcs_vport_s
*vport
,
6242 enum bfa_fcs_vport_event event
)
6244 bfa_trc(__vport_fcs(vport
), __vport_pwwn(vport
));
6245 bfa_trc(__vport_fcs(vport
), event
);
6248 case BFA_FCS_VPORT_SM_RSP_OK
:
6249 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_deleting
);
6250 bfa_fcs_lport_delete(&vport
->lport
);
6253 case BFA_FCS_VPORT_SM_DELETE
:
6256 case BFA_FCS_VPORT_SM_OFFLINE
:
6257 case BFA_FCS_VPORT_SM_RSP_ERROR
:
6258 case BFA_FCS_VPORT_SM_RSP_FAILED
:
6259 case BFA_FCS_VPORT_SM_FABRIC_MAX
:
6260 case BFA_FCS_VPORT_SM_RSP_DUP_WWN
:
6261 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_cleanup
);
6262 bfa_sm_send_event(vport
->lps
, BFA_LPS_SM_OFFLINE
);
6263 bfa_fcs_lport_delete(&vport
->lport
);
6267 bfa_sm_fault(__vport_fcs(vport
), event
);
6272 * Vport is online (FDISC is complete).
6275 bfa_fcs_vport_sm_online(struct bfa_fcs_vport_s
*vport
,
6276 enum bfa_fcs_vport_event event
)
6278 bfa_trc(__vport_fcs(vport
), __vport_pwwn(vport
));
6279 bfa_trc(__vport_fcs(vport
), event
);
6282 case BFA_FCS_VPORT_SM_DELETE
:
6283 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_deleting
);
6284 bfa_fcs_lport_delete(&vport
->lport
);
6287 case BFA_FCS_VPORT_SM_STOP
:
6288 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_stopping
);
6289 bfa_sm_send_event(&vport
->lport
, BFA_FCS_PORT_SM_STOP
);
6292 case BFA_FCS_VPORT_SM_OFFLINE
:
6293 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_offline
);
6294 bfa_sm_send_event(vport
->lps
, BFA_LPS_SM_OFFLINE
);
6295 bfa_fcs_lport_offline(&vport
->lport
);
6299 bfa_sm_fault(__vport_fcs(vport
), event
);
6304 * Vport is being stopped - awaiting lport stop completion to send
6308 bfa_fcs_vport_sm_stopping(struct bfa_fcs_vport_s
*vport
,
6309 enum bfa_fcs_vport_event event
)
6311 bfa_trc(__vport_fcs(vport
), __vport_pwwn(vport
));
6312 bfa_trc(__vport_fcs(vport
), event
);
6315 case BFA_FCS_VPORT_SM_STOPCOMP
:
6316 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_logo_for_stop
);
6317 bfa_fcs_vport_do_logo(vport
);
6320 case BFA_FCS_VPORT_SM_OFFLINE
:
6321 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_cleanup
);
6325 bfa_sm_fault(__vport_fcs(vport
), event
);
6330 * Vport is being deleted - awaiting lport delete completion to send
6334 bfa_fcs_vport_sm_deleting(struct bfa_fcs_vport_s
*vport
,
6335 enum bfa_fcs_vport_event event
)
6337 bfa_trc(__vport_fcs(vport
), __vport_pwwn(vport
));
6338 bfa_trc(__vport_fcs(vport
), event
);
6341 case BFA_FCS_VPORT_SM_DELETE
:
6344 case BFA_FCS_VPORT_SM_DELCOMP
:
6345 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_logo
);
6346 bfa_fcs_vport_do_logo(vport
);
6349 case BFA_FCS_VPORT_SM_OFFLINE
:
6350 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_cleanup
);
6354 bfa_sm_fault(__vport_fcs(vport
), event
);
6360 * This state will be set when the Vport Creation fails due
6361 * to errors like Dup WWN. In this state only operation allowed
6362 * is a Vport Delete.
6365 bfa_fcs_vport_sm_error(struct bfa_fcs_vport_s
*vport
,
6366 enum bfa_fcs_vport_event event
)
6368 bfa_trc(__vport_fcs(vport
), __vport_pwwn(vport
));
6369 bfa_trc(__vport_fcs(vport
), event
);
6372 case BFA_FCS_VPORT_SM_DELETE
:
6373 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_cleanup
);
6374 bfa_fcs_lport_delete(&vport
->lport
);
6378 bfa_trc(__vport_fcs(vport
), event
);
6383 * Lport cleanup is in progress since vport is being deleted. Fabric is
6384 * offline, so no LOGO is needed to complete vport deletion.
6387 bfa_fcs_vport_sm_cleanup(struct bfa_fcs_vport_s
*vport
,
6388 enum bfa_fcs_vport_event event
)
6390 bfa_trc(__vport_fcs(vport
), __vport_pwwn(vport
));
6391 bfa_trc(__vport_fcs(vport
), event
);
6394 case BFA_FCS_VPORT_SM_DELCOMP
:
6395 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_uninit
);
6396 bfa_fcs_vport_free(vport
);
6399 case BFA_FCS_VPORT_SM_STOPCOMP
:
6400 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_created
);
6403 case BFA_FCS_VPORT_SM_DELETE
:
6407 bfa_sm_fault(__vport_fcs(vport
), event
);
6412 * LOGO is sent to fabric. Vport stop is in progress. Lport stop cleanup
6416 bfa_fcs_vport_sm_logo_for_stop(struct bfa_fcs_vport_s
*vport
,
6417 enum bfa_fcs_vport_event event
)
6419 bfa_trc(__vport_fcs(vport
), __vport_pwwn(vport
));
6420 bfa_trc(__vport_fcs(vport
), event
);
6423 case BFA_FCS_VPORT_SM_OFFLINE
:
6424 bfa_sm_send_event(vport
->lps
, BFA_LPS_SM_OFFLINE
);
6427 case BFA_FCS_VPORT_SM_RSP_OK
:
6428 case BFA_FCS_VPORT_SM_RSP_ERROR
:
6429 bfa_sm_set_state(vport
, bfa_fcs_vport_sm_created
);
6433 bfa_sm_fault(__vport_fcs(vport
), event
);
6438 * LOGO is sent to fabric. Vport delete is in progress. Lport delete cleanup
6442 bfa_fcs_vport_sm_logo(struct bfa_fcs_vport_s
*vport
,
6443 enum bfa_fcs_vport_event event
)
6445 bfa_trc(__vport_fcs(vport
), __vport_pwwn(vport
));
6446 bfa_trc(__vport_fcs(vport
), event
);
6449 case BFA_FCS_VPORT_SM_OFFLINE
:
6450 bfa_sm_send_event(vport
->lps
, BFA_LPS_SM_OFFLINE
);
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
);