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.
12 * rport.c Remote port implementation.
18 #include "bfa_fcbuild.h"
20 BFA_TRC_FILE(FCS
, RPORT
);
23 bfa_fcs_rport_del_timeout
= BFA_FCS_RPORT_DEF_DEL_TIMEOUT
* 1000;
26 * bfa_fcs_rport_max_logins is max count of bfa_fcs_rports
27 * whereas DEF_CFG_NUM_RPORTS is max count of bfa_rports
29 static u32 bfa_fcs_rport_max_logins
= BFA_FCS_MAX_RPORT_LOGINS
;
32 * forward declarations
34 static struct bfa_fcs_rport_s
*bfa_fcs_rport_alloc(
35 struct bfa_fcs_lport_s
*port
, wwn_t pwwn
, u32 rpid
);
36 static void bfa_fcs_rport_free(struct bfa_fcs_rport_s
*rport
);
37 static void bfa_fcs_rport_hal_online(struct bfa_fcs_rport_s
*rport
);
38 static void bfa_fcs_rport_fcs_online_action(struct bfa_fcs_rport_s
*rport
);
39 static void bfa_fcs_rport_hal_online_action(struct bfa_fcs_rport_s
*rport
);
40 static void bfa_fcs_rport_fcs_offline_action(struct bfa_fcs_rport_s
*rport
);
41 static void bfa_fcs_rport_hal_offline_action(struct bfa_fcs_rport_s
*rport
);
42 static void bfa_fcs_rport_update(struct bfa_fcs_rport_s
*rport
,
43 struct fc_logi_s
*plogi
);
44 static void bfa_fcs_rport_timeout(void *arg
);
45 static void bfa_fcs_rport_send_plogi(void *rport_cbarg
,
46 struct bfa_fcxp_s
*fcxp_alloced
);
47 static void bfa_fcs_rport_send_plogiacc(void *rport_cbarg
,
48 struct bfa_fcxp_s
*fcxp_alloced
);
49 static void bfa_fcs_rport_plogi_response(void *fcsarg
,
50 struct bfa_fcxp_s
*fcxp
, void *cbarg
,
51 bfa_status_t req_status
, u32 rsp_len
,
52 u32 resid_len
, struct fchs_s
*rsp_fchs
);
53 static void bfa_fcs_rport_send_adisc(void *rport_cbarg
,
54 struct bfa_fcxp_s
*fcxp_alloced
);
55 static void bfa_fcs_rport_adisc_response(void *fcsarg
,
56 struct bfa_fcxp_s
*fcxp
, void *cbarg
,
57 bfa_status_t req_status
, u32 rsp_len
,
58 u32 resid_len
, struct fchs_s
*rsp_fchs
);
59 static void bfa_fcs_rport_send_nsdisc(void *rport_cbarg
,
60 struct bfa_fcxp_s
*fcxp_alloced
);
61 static void bfa_fcs_rport_gidpn_response(void *fcsarg
,
62 struct bfa_fcxp_s
*fcxp
, void *cbarg
,
63 bfa_status_t req_status
, u32 rsp_len
,
64 u32 resid_len
, struct fchs_s
*rsp_fchs
);
65 static void bfa_fcs_rport_gpnid_response(void *fcsarg
,
66 struct bfa_fcxp_s
*fcxp
, void *cbarg
,
67 bfa_status_t req_status
, u32 rsp_len
,
68 u32 resid_len
, struct fchs_s
*rsp_fchs
);
69 static void bfa_fcs_rport_send_logo(void *rport_cbarg
,
70 struct bfa_fcxp_s
*fcxp_alloced
);
71 static void bfa_fcs_rport_send_logo_acc(void *rport_cbarg
);
72 static void bfa_fcs_rport_process_prli(struct bfa_fcs_rport_s
*rport
,
73 struct fchs_s
*rx_fchs
, u16 len
);
74 static void bfa_fcs_rport_send_ls_rjt(struct bfa_fcs_rport_s
*rport
,
75 struct fchs_s
*rx_fchs
, u8 reason_code
,
77 static void bfa_fcs_rport_process_adisc(struct bfa_fcs_rport_s
*rport
,
78 struct fchs_s
*rx_fchs
, u16 len
);
79 static void bfa_fcs_rport_send_prlo_acc(struct bfa_fcs_rport_s
*rport
);
80 static void bfa_fcs_rport_hal_offline(struct bfa_fcs_rport_s
*rport
);
82 static void bfa_fcs_rport_sm_uninit(struct bfa_fcs_rport_s
*rport
,
83 enum rport_event event
);
84 static void bfa_fcs_rport_sm_plogi_sending(struct bfa_fcs_rport_s
*rport
,
85 enum rport_event event
);
86 static void bfa_fcs_rport_sm_plogiacc_sending(struct bfa_fcs_rport_s
*rport
,
87 enum rport_event event
);
88 static void bfa_fcs_rport_sm_plogi_retry(struct bfa_fcs_rport_s
*rport
,
89 enum rport_event event
);
90 static void bfa_fcs_rport_sm_plogi(struct bfa_fcs_rport_s
*rport
,
91 enum rport_event event
);
92 static void bfa_fcs_rport_sm_fc4_fcs_online(struct bfa_fcs_rport_s
*rport
,
93 enum rport_event event
);
94 static void bfa_fcs_rport_sm_hal_online(struct bfa_fcs_rport_s
*rport
,
95 enum rport_event event
);
96 static void bfa_fcs_rport_sm_online(struct bfa_fcs_rport_s
*rport
,
97 enum rport_event event
);
98 static void bfa_fcs_rport_sm_nsquery_sending(struct bfa_fcs_rport_s
*rport
,
99 enum rport_event event
);
100 static void bfa_fcs_rport_sm_nsquery(struct bfa_fcs_rport_s
*rport
,
101 enum rport_event event
);
102 static void bfa_fcs_rport_sm_adisc_online_sending(
103 struct bfa_fcs_rport_s
*rport
, enum rport_event event
);
104 static void bfa_fcs_rport_sm_adisc_online(struct bfa_fcs_rport_s
*rport
,
105 enum rport_event event
);
106 static void bfa_fcs_rport_sm_adisc_offline_sending(struct bfa_fcs_rport_s
107 *rport
, enum rport_event event
);
108 static void bfa_fcs_rport_sm_adisc_offline(struct bfa_fcs_rport_s
*rport
,
109 enum rport_event event
);
110 static void bfa_fcs_rport_sm_fc4_logorcv(struct bfa_fcs_rport_s
*rport
,
111 enum rport_event event
);
112 static void bfa_fcs_rport_sm_fc4_logosend(struct bfa_fcs_rport_s
*rport
,
113 enum rport_event event
);
114 static void bfa_fcs_rport_sm_fc4_offline(struct bfa_fcs_rport_s
*rport
,
115 enum rport_event event
);
116 static void bfa_fcs_rport_sm_hcb_offline(struct bfa_fcs_rport_s
*rport
,
117 enum rport_event event
);
118 static void bfa_fcs_rport_sm_hcb_logorcv(struct bfa_fcs_rport_s
*rport
,
119 enum rport_event event
);
120 static void bfa_fcs_rport_sm_hcb_logosend(struct bfa_fcs_rport_s
*rport
,
121 enum rport_event event
);
122 static void bfa_fcs_rport_sm_logo_sending(struct bfa_fcs_rport_s
*rport
,
123 enum rport_event event
);
124 static void bfa_fcs_rport_sm_offline(struct bfa_fcs_rport_s
*rport
,
125 enum rport_event event
);
126 static void bfa_fcs_rport_sm_nsdisc_sending(struct bfa_fcs_rport_s
*rport
,
127 enum rport_event event
);
128 static void bfa_fcs_rport_sm_nsdisc_retry(struct bfa_fcs_rport_s
*rport
,
129 enum rport_event event
);
130 static void bfa_fcs_rport_sm_nsdisc_sent(struct bfa_fcs_rport_s
*rport
,
131 enum rport_event event
);
132 static void bfa_fcs_rport_sm_nsdisc_sent(struct bfa_fcs_rport_s
*rport
,
133 enum rport_event event
);
134 static void bfa_fcs_rport_sm_fc4_off_delete(struct bfa_fcs_rport_s
*rport
,
135 enum rport_event event
);
136 static void bfa_fcs_rport_sm_delete_pending(struct bfa_fcs_rport_s
*rport
,
137 enum rport_event event
);
139 static struct bfa_sm_table_s rport_sm_table
[] = {
140 {BFA_SM(bfa_fcs_rport_sm_uninit
), BFA_RPORT_UNINIT
},
141 {BFA_SM(bfa_fcs_rport_sm_plogi_sending
), BFA_RPORT_PLOGI
},
142 {BFA_SM(bfa_fcs_rport_sm_plogiacc_sending
), BFA_RPORT_ONLINE
},
143 {BFA_SM(bfa_fcs_rport_sm_plogi_retry
), BFA_RPORT_PLOGI_RETRY
},
144 {BFA_SM(bfa_fcs_rport_sm_plogi
), BFA_RPORT_PLOGI
},
145 {BFA_SM(bfa_fcs_rport_sm_fc4_fcs_online
), BFA_RPORT_ONLINE
},
146 {BFA_SM(bfa_fcs_rport_sm_hal_online
), BFA_RPORT_ONLINE
},
147 {BFA_SM(bfa_fcs_rport_sm_online
), BFA_RPORT_ONLINE
},
148 {BFA_SM(bfa_fcs_rport_sm_nsquery_sending
), BFA_RPORT_NSQUERY
},
149 {BFA_SM(bfa_fcs_rport_sm_nsquery
), BFA_RPORT_NSQUERY
},
150 {BFA_SM(bfa_fcs_rport_sm_adisc_online_sending
), BFA_RPORT_ADISC
},
151 {BFA_SM(bfa_fcs_rport_sm_adisc_online
), BFA_RPORT_ADISC
},
152 {BFA_SM(bfa_fcs_rport_sm_adisc_offline_sending
), BFA_RPORT_ADISC
},
153 {BFA_SM(bfa_fcs_rport_sm_adisc_offline
), BFA_RPORT_ADISC
},
154 {BFA_SM(bfa_fcs_rport_sm_fc4_logorcv
), BFA_RPORT_LOGORCV
},
155 {BFA_SM(bfa_fcs_rport_sm_fc4_logosend
), BFA_RPORT_LOGO
},
156 {BFA_SM(bfa_fcs_rport_sm_fc4_offline
), BFA_RPORT_OFFLINE
},
157 {BFA_SM(bfa_fcs_rport_sm_hcb_offline
), BFA_RPORT_OFFLINE
},
158 {BFA_SM(bfa_fcs_rport_sm_hcb_logorcv
), BFA_RPORT_LOGORCV
},
159 {BFA_SM(bfa_fcs_rport_sm_hcb_logosend
), BFA_RPORT_LOGO
},
160 {BFA_SM(bfa_fcs_rport_sm_logo_sending
), BFA_RPORT_LOGO
},
161 {BFA_SM(bfa_fcs_rport_sm_offline
), BFA_RPORT_OFFLINE
},
162 {BFA_SM(bfa_fcs_rport_sm_nsdisc_sending
), BFA_RPORT_NSDISC
},
163 {BFA_SM(bfa_fcs_rport_sm_nsdisc_retry
), BFA_RPORT_NSDISC
},
164 {BFA_SM(bfa_fcs_rport_sm_nsdisc_sent
), BFA_RPORT_NSDISC
},
171 bfa_fcs_rport_sm_uninit(struct bfa_fcs_rport_s
*rport
, enum rport_event event
)
173 bfa_trc(rport
->fcs
, rport
->pwwn
);
174 bfa_trc(rport
->fcs
, rport
->pid
);
175 bfa_trc(rport
->fcs
, event
);
178 case RPSM_EVENT_PLOGI_SEND
:
179 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogi_sending
);
180 rport
->plogi_retries
= 0;
181 bfa_fcs_rport_send_plogi(rport
, NULL
);
184 case RPSM_EVENT_PLOGI_RCVD
:
185 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogiacc_sending
);
186 bfa_fcs_rport_send_plogiacc(rport
, NULL
);
189 case RPSM_EVENT_PLOGI_COMP
:
190 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_hal_online
);
191 bfa_fcs_rport_hal_online(rport
);
194 case RPSM_EVENT_ADDRESS_CHANGE
:
195 case RPSM_EVENT_ADDRESS_DISC
:
196 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_nsdisc_sending
);
197 rport
->ns_retries
= 0;
198 bfa_fcs_rport_send_nsdisc(rport
, NULL
);
201 bfa_sm_fault(rport
->fcs
, event
);
206 * PLOGI is being sent.
209 bfa_fcs_rport_sm_plogi_sending(struct bfa_fcs_rport_s
*rport
,
210 enum rport_event event
)
212 bfa_trc(rport
->fcs
, rport
->pwwn
);
213 bfa_trc(rport
->fcs
, rport
->pid
);
214 bfa_trc(rport
->fcs
, event
);
217 case RPSM_EVENT_FCXP_SENT
:
218 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogi
);
221 case RPSM_EVENT_DELETE
:
222 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_uninit
);
223 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
224 bfa_fcs_rport_free(rport
);
227 case RPSM_EVENT_PLOGI_RCVD
:
228 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogiacc_sending
);
229 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
230 bfa_fcs_rport_send_plogiacc(rport
, NULL
);
233 case RPSM_EVENT_SCN_OFFLINE
:
234 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
235 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
236 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
237 bfa_fcs_rport_timeout
, rport
,
238 bfa_fcs_rport_del_timeout
);
240 case RPSM_EVENT_ADDRESS_CHANGE
:
241 case RPSM_EVENT_FAB_SCN
:
243 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
244 WARN_ON(!(bfa_fcport_get_topology(rport
->port
->fcs
->bfa
) !=
245 BFA_PORT_TOPOLOGY_LOOP
));
246 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_nsdisc_sending
);
247 rport
->ns_retries
= 0;
248 bfa_fcs_rport_send_nsdisc(rport
, NULL
);
251 case RPSM_EVENT_LOGO_IMP
:
253 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
254 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
255 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
256 bfa_fcs_rport_timeout
, rport
,
257 bfa_fcs_rport_del_timeout
);
262 bfa_sm_fault(rport
->fcs
, event
);
267 * PLOGI is being sent.
270 bfa_fcs_rport_sm_plogiacc_sending(struct bfa_fcs_rport_s
*rport
,
271 enum rport_event event
)
273 bfa_trc(rport
->fcs
, rport
->pwwn
);
274 bfa_trc(rport
->fcs
, rport
->pid
);
275 bfa_trc(rport
->fcs
, event
);
278 case RPSM_EVENT_FCXP_SENT
:
279 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_fcs_online
);
280 bfa_fcs_rport_fcs_online_action(rport
);
283 case RPSM_EVENT_DELETE
:
284 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_uninit
);
285 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
286 bfa_fcs_rport_free(rport
);
289 case RPSM_EVENT_PLOGI_RCVD
:
290 case RPSM_EVENT_PLOGI_COMP
:
291 case RPSM_EVENT_FAB_SCN
:
293 * Ignore, SCN is possibly online notification.
297 case RPSM_EVENT_SCN_OFFLINE
:
298 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
299 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
300 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
301 bfa_fcs_rport_timeout
, rport
,
302 bfa_fcs_rport_del_timeout
);
305 case RPSM_EVENT_ADDRESS_CHANGE
:
306 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
307 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_nsdisc_sending
);
308 rport
->ns_retries
= 0;
309 bfa_fcs_rport_send_nsdisc(rport
, NULL
);
312 case RPSM_EVENT_LOGO_IMP
:
314 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
315 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
316 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
317 bfa_fcs_rport_timeout
, rport
,
318 bfa_fcs_rport_del_timeout
);
321 case RPSM_EVENT_HCB_OFFLINE
:
323 * Ignore BFA callback, on a PLOGI receive we call bfa offline.
328 bfa_sm_fault(rport
->fcs
, event
);
336 bfa_fcs_rport_sm_plogi_retry(struct bfa_fcs_rport_s
*rport
,
337 enum rport_event event
)
339 bfa_trc(rport
->fcs
, rport
->pwwn
);
340 bfa_trc(rport
->fcs
, rport
->pid
);
341 bfa_trc(rport
->fcs
, event
);
344 case RPSM_EVENT_TIMEOUT
:
345 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogi_sending
);
346 bfa_fcs_rport_send_plogi(rport
, NULL
);
349 case RPSM_EVENT_DELETE
:
350 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_uninit
);
351 bfa_timer_stop(&rport
->timer
);
352 bfa_fcs_rport_free(rport
);
355 case RPSM_EVENT_PRLO_RCVD
:
356 case RPSM_EVENT_LOGO_RCVD
:
359 case RPSM_EVENT_PLOGI_RCVD
:
360 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogiacc_sending
);
361 bfa_timer_stop(&rport
->timer
);
362 bfa_fcs_rport_send_plogiacc(rport
, NULL
);
365 case RPSM_EVENT_SCN_OFFLINE
:
366 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
367 bfa_timer_stop(&rport
->timer
);
368 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
369 bfa_fcs_rport_timeout
, rport
,
370 bfa_fcs_rport_del_timeout
);
373 case RPSM_EVENT_ADDRESS_CHANGE
:
374 case RPSM_EVENT_FAB_SCN
:
375 bfa_timer_stop(&rport
->timer
);
376 WARN_ON(!(bfa_fcport_get_topology(rport
->port
->fcs
->bfa
) !=
377 BFA_PORT_TOPOLOGY_LOOP
));
378 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_nsdisc_sending
);
379 rport
->ns_retries
= 0;
380 bfa_fcs_rport_send_nsdisc(rport
, NULL
);
383 case RPSM_EVENT_LOGO_IMP
:
385 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
386 bfa_timer_stop(&rport
->timer
);
387 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
388 bfa_fcs_rport_timeout
, rport
,
389 bfa_fcs_rport_del_timeout
);
392 case RPSM_EVENT_PLOGI_COMP
:
393 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_fcs_online
);
394 bfa_timer_stop(&rport
->timer
);
395 bfa_fcs_rport_fcs_online_action(rport
);
399 bfa_sm_fault(rport
->fcs
, event
);
407 bfa_fcs_rport_sm_plogi(struct bfa_fcs_rport_s
*rport
, enum rport_event event
)
409 bfa_trc(rport
->fcs
, rport
->pwwn
);
410 bfa_trc(rport
->fcs
, rport
->pid
);
411 bfa_trc(rport
->fcs
, event
);
414 case RPSM_EVENT_ACCEPTED
:
415 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_fcs_online
);
416 rport
->plogi_retries
= 0;
417 bfa_fcs_rport_fcs_online_action(rport
);
420 case RPSM_EVENT_LOGO_RCVD
:
421 bfa_fcs_rport_send_logo_acc(rport
);
423 case RPSM_EVENT_PRLO_RCVD
:
424 if (rport
->prlo
== BFA_TRUE
)
425 bfa_fcs_rport_send_prlo_acc(rport
);
427 bfa_fcxp_discard(rport
->fcxp
);
429 case RPSM_EVENT_FAILED
:
430 if (rport
->plogi_retries
< BFA_FCS_RPORT_MAX_RETRIES
) {
431 rport
->plogi_retries
++;
432 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogi_retry
);
433 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
434 bfa_fcs_rport_timeout
, rport
,
435 BFA_FCS_RETRY_TIMEOUT
);
437 bfa_stats(rport
->port
, rport_del_max_plogi_retry
);
438 rport
->old_pid
= rport
->pid
;
440 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
441 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
442 bfa_fcs_rport_timeout
, rport
,
443 bfa_fcs_rport_del_timeout
);
447 case RPSM_EVENT_SCN_ONLINE
:
450 case RPSM_EVENT_SCN_OFFLINE
:
451 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
452 bfa_fcxp_discard(rport
->fcxp
);
453 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
454 bfa_fcs_rport_timeout
, rport
,
455 bfa_fcs_rport_del_timeout
);
458 case RPSM_EVENT_PLOGI_RETRY
:
459 rport
->plogi_retries
= 0;
460 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogi_retry
);
461 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
462 bfa_fcs_rport_timeout
, rport
,
466 case RPSM_EVENT_LOGO_IMP
:
468 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
469 bfa_fcxp_discard(rport
->fcxp
);
470 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
471 bfa_fcs_rport_timeout
, rport
,
472 bfa_fcs_rport_del_timeout
);
475 case RPSM_EVENT_ADDRESS_CHANGE
:
476 case RPSM_EVENT_FAB_SCN
:
477 bfa_fcxp_discard(rport
->fcxp
);
478 WARN_ON(!(bfa_fcport_get_topology(rport
->port
->fcs
->bfa
) !=
479 BFA_PORT_TOPOLOGY_LOOP
));
480 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_nsdisc_sending
);
481 rport
->ns_retries
= 0;
482 bfa_fcs_rport_send_nsdisc(rport
, NULL
);
485 case RPSM_EVENT_PLOGI_RCVD
:
486 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogiacc_sending
);
487 bfa_fcxp_discard(rport
->fcxp
);
488 bfa_fcs_rport_send_plogiacc(rport
, NULL
);
491 case RPSM_EVENT_DELETE
:
492 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_uninit
);
493 bfa_fcxp_discard(rport
->fcxp
);
494 bfa_fcs_rport_free(rport
);
497 case RPSM_EVENT_PLOGI_COMP
:
498 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_fcs_online
);
499 bfa_fcxp_discard(rport
->fcxp
);
500 bfa_fcs_rport_fcs_online_action(rport
);
504 bfa_sm_fault(rport
->fcs
, event
);
509 * PLOGI is done. Await bfa_fcs_itnim to ascertain the scsi function
512 bfa_fcs_rport_sm_fc4_fcs_online(struct bfa_fcs_rport_s
*rport
,
513 enum rport_event event
)
515 bfa_trc(rport
->fcs
, rport
->pwwn
);
516 bfa_trc(rport
->fcs
, rport
->pid
);
517 bfa_trc(rport
->fcs
, event
);
520 case RPSM_EVENT_FC4_FCS_ONLINE
:
521 if (rport
->scsi_function
== BFA_RPORT_INITIATOR
) {
522 if (!BFA_FCS_PID_IS_WKA(rport
->pid
))
523 bfa_fcs_rpf_rport_online(rport
);
524 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_online
);
528 if (!rport
->bfa_rport
)
530 bfa_rport_create(rport
->fcs
->bfa
, rport
);
532 if (rport
->bfa_rport
) {
533 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_hal_online
);
534 bfa_fcs_rport_hal_online(rport
);
536 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_logosend
);
537 bfa_fcs_rport_fcs_offline_action(rport
);
541 case RPSM_EVENT_PLOGI_RCVD
:
542 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_offline
);
543 rport
->plogi_pending
= BFA_TRUE
;
544 bfa_fcs_rport_fcs_offline_action(rport
);
547 case RPSM_EVENT_PLOGI_COMP
:
548 case RPSM_EVENT_LOGO_IMP
:
549 case RPSM_EVENT_ADDRESS_CHANGE
:
550 case RPSM_EVENT_FAB_SCN
:
551 case RPSM_EVENT_SCN_OFFLINE
:
552 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_offline
);
553 bfa_fcs_rport_fcs_offline_action(rport
);
556 case RPSM_EVENT_LOGO_RCVD
:
557 case RPSM_EVENT_PRLO_RCVD
:
558 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_logorcv
);
559 bfa_fcs_rport_fcs_offline_action(rport
);
562 case RPSM_EVENT_DELETE
:
563 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_logosend
);
564 bfa_fcs_rport_fcs_offline_action(rport
);
568 bfa_sm_fault(rport
->fcs
, event
);
574 * PLOGI is complete. Awaiting BFA rport online callback. FC-4s
578 bfa_fcs_rport_sm_hal_online(struct bfa_fcs_rport_s
*rport
,
579 enum rport_event event
)
581 bfa_trc(rport
->fcs
, rport
->pwwn
);
582 bfa_trc(rport
->fcs
, rport
->pid
);
583 bfa_trc(rport
->fcs
, event
);
586 case RPSM_EVENT_HCB_ONLINE
:
587 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_online
);
588 bfa_fcs_rport_hal_online_action(rport
);
591 case RPSM_EVENT_PLOGI_COMP
:
594 case RPSM_EVENT_PRLO_RCVD
:
595 case RPSM_EVENT_LOGO_RCVD
:
596 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_logorcv
);
597 bfa_fcs_rport_fcs_offline_action(rport
);
600 case RPSM_EVENT_FAB_SCN
:
601 case RPSM_EVENT_LOGO_IMP
:
602 case RPSM_EVENT_ADDRESS_CHANGE
:
603 case RPSM_EVENT_SCN_OFFLINE
:
604 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_offline
);
605 bfa_fcs_rport_fcs_offline_action(rport
);
608 case RPSM_EVENT_PLOGI_RCVD
:
609 rport
->plogi_pending
= BFA_TRUE
;
610 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_offline
);
611 bfa_fcs_rport_fcs_offline_action(rport
);
614 case RPSM_EVENT_DELETE
:
615 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_logosend
);
616 bfa_fcs_rport_fcs_offline_action(rport
);
620 bfa_sm_fault(rport
->fcs
, event
);
625 * Rport is ONLINE. FC-4s active.
628 bfa_fcs_rport_sm_online(struct bfa_fcs_rport_s
*rport
, enum rport_event event
)
630 bfa_trc(rport
->fcs
, rport
->pwwn
);
631 bfa_trc(rport
->fcs
, rport
->pid
);
632 bfa_trc(rport
->fcs
, event
);
635 case RPSM_EVENT_FAB_SCN
:
636 if (bfa_fcs_fabric_is_switched(rport
->port
->fabric
)) {
637 bfa_sm_set_state(rport
,
638 bfa_fcs_rport_sm_nsquery_sending
);
639 rport
->ns_retries
= 0;
640 bfa_fcs_rport_send_nsdisc(rport
, NULL
);
642 bfa_sm_set_state(rport
,
643 bfa_fcs_rport_sm_adisc_online_sending
);
644 bfa_fcs_rport_send_adisc(rport
, NULL
);
648 case RPSM_EVENT_PLOGI_RCVD
:
649 case RPSM_EVENT_LOGO_IMP
:
650 case RPSM_EVENT_ADDRESS_CHANGE
:
651 case RPSM_EVENT_SCN_OFFLINE
:
652 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_offline
);
653 bfa_fcs_rport_hal_offline_action(rport
);
656 case RPSM_EVENT_DELETE
:
657 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_logosend
);
658 bfa_fcs_rport_hal_offline_action(rport
);
661 case RPSM_EVENT_LOGO_RCVD
:
662 case RPSM_EVENT_PRLO_RCVD
:
663 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_logorcv
);
664 bfa_fcs_rport_hal_offline_action(rport
);
667 case RPSM_EVENT_SCN_ONLINE
:
668 case RPSM_EVENT_PLOGI_COMP
:
672 bfa_sm_fault(rport
->fcs
, event
);
677 * An SCN event is received in ONLINE state. NS query is being sent
678 * prior to ADISC authentication with rport. FC-4s are paused.
681 bfa_fcs_rport_sm_nsquery_sending(struct bfa_fcs_rport_s
*rport
,
682 enum rport_event event
)
684 bfa_trc(rport
->fcs
, rport
->pwwn
);
685 bfa_trc(rport
->fcs
, rport
->pid
);
686 bfa_trc(rport
->fcs
, event
);
689 case RPSM_EVENT_FCXP_SENT
:
690 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_nsquery
);
693 case RPSM_EVENT_DELETE
:
694 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_logosend
);
695 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
696 bfa_fcs_rport_hal_offline_action(rport
);
699 case RPSM_EVENT_FAB_SCN
:
701 * ignore SCN, wait for response to query itself
705 case RPSM_EVENT_LOGO_RCVD
:
706 case RPSM_EVENT_PRLO_RCVD
:
707 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_logorcv
);
708 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
709 bfa_fcs_rport_hal_offline_action(rport
);
712 case RPSM_EVENT_LOGO_IMP
:
713 case RPSM_EVENT_PLOGI_RCVD
:
714 case RPSM_EVENT_ADDRESS_CHANGE
:
715 case RPSM_EVENT_PLOGI_COMP
:
716 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_offline
);
717 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
718 bfa_fcs_rport_hal_offline_action(rport
);
722 bfa_sm_fault(rport
->fcs
, event
);
727 * An SCN event is received in ONLINE state. NS query is sent to rport.
731 bfa_fcs_rport_sm_nsquery(struct bfa_fcs_rport_s
*rport
, enum rport_event event
)
733 bfa_trc(rport
->fcs
, rport
->pwwn
);
734 bfa_trc(rport
->fcs
, rport
->pid
);
735 bfa_trc(rport
->fcs
, event
);
738 case RPSM_EVENT_ACCEPTED
:
739 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_adisc_online_sending
);
740 bfa_fcs_rport_send_adisc(rport
, NULL
);
743 case RPSM_EVENT_FAILED
:
745 if (rport
->ns_retries
< BFA_FCS_RPORT_MAX_RETRIES
) {
746 bfa_sm_set_state(rport
,
747 bfa_fcs_rport_sm_nsquery_sending
);
748 bfa_fcs_rport_send_nsdisc(rport
, NULL
);
750 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_offline
);
751 bfa_fcs_rport_hal_offline_action(rport
);
755 case RPSM_EVENT_DELETE
:
756 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_logosend
);
757 bfa_fcxp_discard(rport
->fcxp
);
758 bfa_fcs_rport_hal_offline_action(rport
);
761 case RPSM_EVENT_FAB_SCN
:
764 case RPSM_EVENT_LOGO_RCVD
:
765 case RPSM_EVENT_PRLO_RCVD
:
766 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_logorcv
);
767 bfa_fcxp_discard(rport
->fcxp
);
768 bfa_fcs_rport_hal_offline_action(rport
);
771 case RPSM_EVENT_PLOGI_COMP
:
772 case RPSM_EVENT_ADDRESS_CHANGE
:
773 case RPSM_EVENT_PLOGI_RCVD
:
774 case RPSM_EVENT_LOGO_IMP
:
775 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_offline
);
776 bfa_fcxp_discard(rport
->fcxp
);
777 bfa_fcs_rport_hal_offline_action(rport
);
781 bfa_sm_fault(rport
->fcs
, event
);
786 * An SCN event is received in ONLINE state. ADISC is being sent for
787 * authenticating with rport. FC-4s are paused.
790 bfa_fcs_rport_sm_adisc_online_sending(struct bfa_fcs_rport_s
*rport
,
791 enum rport_event event
)
793 bfa_trc(rport
->fcs
, rport
->pwwn
);
794 bfa_trc(rport
->fcs
, rport
->pid
);
795 bfa_trc(rport
->fcs
, event
);
798 case RPSM_EVENT_FCXP_SENT
:
799 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_adisc_online
);
802 case RPSM_EVENT_DELETE
:
803 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_logosend
);
804 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
805 bfa_fcs_rport_hal_offline_action(rport
);
808 case RPSM_EVENT_LOGO_IMP
:
809 case RPSM_EVENT_ADDRESS_CHANGE
:
810 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_offline
);
811 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
812 bfa_fcs_rport_hal_offline_action(rport
);
815 case RPSM_EVENT_LOGO_RCVD
:
816 case RPSM_EVENT_PRLO_RCVD
:
817 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_logorcv
);
818 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
819 bfa_fcs_rport_hal_offline_action(rport
);
822 case RPSM_EVENT_FAB_SCN
:
825 case RPSM_EVENT_PLOGI_RCVD
:
826 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_offline
);
827 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
828 bfa_fcs_rport_hal_offline_action(rport
);
832 bfa_sm_fault(rport
->fcs
, event
);
837 * An SCN event is received in ONLINE state. ADISC is to rport.
841 bfa_fcs_rport_sm_adisc_online(struct bfa_fcs_rport_s
*rport
,
842 enum rport_event event
)
844 bfa_trc(rport
->fcs
, rport
->pwwn
);
845 bfa_trc(rport
->fcs
, rport
->pid
);
846 bfa_trc(rport
->fcs
, event
);
849 case RPSM_EVENT_ACCEPTED
:
850 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_online
);
853 case RPSM_EVENT_PLOGI_RCVD
:
855 * Too complex to cleanup FC-4 & rport and then acc to PLOGI.
856 * At least go offline when a PLOGI is received.
858 bfa_fcxp_discard(rport
->fcxp
);
861 case RPSM_EVENT_FAILED
:
862 case RPSM_EVENT_ADDRESS_CHANGE
:
863 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_offline
);
864 bfa_fcs_rport_hal_offline_action(rport
);
867 case RPSM_EVENT_DELETE
:
868 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_logosend
);
869 bfa_fcxp_discard(rport
->fcxp
);
870 bfa_fcs_rport_hal_offline_action(rport
);
873 case RPSM_EVENT_FAB_SCN
:
875 * already processing RSCN
879 case RPSM_EVENT_LOGO_IMP
:
880 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_offline
);
881 bfa_fcxp_discard(rport
->fcxp
);
882 bfa_fcs_rport_hal_offline_action(rport
);
885 case RPSM_EVENT_LOGO_RCVD
:
886 case RPSM_EVENT_PRLO_RCVD
:
887 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_logorcv
);
888 bfa_fcxp_discard(rport
->fcxp
);
889 bfa_fcs_rport_hal_offline_action(rport
);
893 bfa_sm_fault(rport
->fcs
, event
);
898 * ADISC is being sent for authenticating with rport
899 * Already did offline actions.
902 bfa_fcs_rport_sm_adisc_offline_sending(struct bfa_fcs_rport_s
*rport
,
903 enum rport_event event
)
905 bfa_trc(rport
->fcs
, rport
->pwwn
);
906 bfa_trc(rport
->fcs
, rport
->pid
);
907 bfa_trc(rport
->fcs
, event
);
910 case RPSM_EVENT_FCXP_SENT
:
911 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_adisc_offline
);
914 case RPSM_EVENT_DELETE
:
915 case RPSM_EVENT_SCN_OFFLINE
:
916 case RPSM_EVENT_LOGO_IMP
:
917 case RPSM_EVENT_LOGO_RCVD
:
918 case RPSM_EVENT_PRLO_RCVD
:
919 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
920 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
,
922 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
923 bfa_fcs_rport_timeout
, rport
,
924 bfa_fcs_rport_del_timeout
);
927 case RPSM_EVENT_PLOGI_RCVD
:
928 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogiacc_sending
);
929 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
930 bfa_fcs_rport_send_plogiacc(rport
, NULL
);
934 bfa_sm_fault(rport
->fcs
, event
);
940 * Already did offline actions
943 bfa_fcs_rport_sm_adisc_offline(struct bfa_fcs_rport_s
*rport
,
944 enum rport_event event
)
946 bfa_trc(rport
->fcs
, rport
->pwwn
);
947 bfa_trc(rport
->fcs
, rport
->pid
);
948 bfa_trc(rport
->fcs
, event
);
951 case RPSM_EVENT_ACCEPTED
:
952 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_hal_online
);
953 bfa_fcs_rport_hal_online(rport
);
956 case RPSM_EVENT_PLOGI_RCVD
:
957 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogiacc_sending
);
958 bfa_fcxp_discard(rport
->fcxp
);
959 bfa_fcs_rport_send_plogiacc(rport
, NULL
);
962 case RPSM_EVENT_FAILED
:
963 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
964 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
965 bfa_fcs_rport_timeout
, rport
,
966 bfa_fcs_rport_del_timeout
);
969 case RPSM_EVENT_DELETE
:
970 case RPSM_EVENT_SCN_OFFLINE
:
971 case RPSM_EVENT_LOGO_IMP
:
972 case RPSM_EVENT_LOGO_RCVD
:
973 case RPSM_EVENT_PRLO_RCVD
:
974 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
975 bfa_fcxp_discard(rport
->fcxp
);
976 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
977 bfa_fcs_rport_timeout
, rport
,
978 bfa_fcs_rport_del_timeout
);
982 bfa_sm_fault(rport
->fcs
, event
);
987 * Rport has sent LOGO. Awaiting FC-4 offline completion callback.
990 bfa_fcs_rport_sm_fc4_logorcv(struct bfa_fcs_rport_s
*rport
,
991 enum rport_event event
)
993 bfa_trc(rport
->fcs
, rport
->pwwn
);
994 bfa_trc(rport
->fcs
, rport
->pid
);
995 bfa_trc(rport
->fcs
, event
);
998 case RPSM_EVENT_FC4_OFFLINE
:
999 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_hcb_logorcv
);
1000 bfa_fcs_rport_hal_offline(rport
);
1003 case RPSM_EVENT_DELETE
:
1004 if (rport
->pid
&& (rport
->prlo
== BFA_TRUE
))
1005 bfa_fcs_rport_send_prlo_acc(rport
);
1006 if (rport
->pid
&& (rport
->prlo
== BFA_FALSE
))
1007 bfa_fcs_rport_send_logo_acc(rport
);
1009 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_off_delete
);
1012 case RPSM_EVENT_SCN_ONLINE
:
1013 case RPSM_EVENT_SCN_OFFLINE
:
1014 case RPSM_EVENT_HCB_ONLINE
:
1015 case RPSM_EVENT_LOGO_RCVD
:
1016 case RPSM_EVENT_PRLO_RCVD
:
1017 case RPSM_EVENT_ADDRESS_CHANGE
:
1021 bfa_sm_fault(rport
->fcs
, event
);
1026 * LOGO needs to be sent to rport. Awaiting FC-4 offline completion
1030 bfa_fcs_rport_sm_fc4_logosend(struct bfa_fcs_rport_s
*rport
,
1031 enum rport_event event
)
1033 bfa_trc(rport
->fcs
, rport
->pwwn
);
1034 bfa_trc(rport
->fcs
, rport
->pid
);
1035 bfa_trc(rport
->fcs
, event
);
1038 case RPSM_EVENT_FC4_OFFLINE
:
1039 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_hcb_logosend
);
1040 bfa_fcs_rport_hal_offline(rport
);
1043 case RPSM_EVENT_LOGO_RCVD
:
1044 bfa_fcs_rport_send_logo_acc(rport
);
1046 case RPSM_EVENT_PRLO_RCVD
:
1047 if (rport
->prlo
== BFA_TRUE
)
1048 bfa_fcs_rport_send_prlo_acc(rport
);
1049 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_off_delete
);
1052 case RPSM_EVENT_HCB_ONLINE
:
1053 case RPSM_EVENT_DELETE
:
1054 /* Rport is being deleted */
1058 bfa_sm_fault(rport
->fcs
, event
);
1063 * Rport is going offline. Awaiting FC-4 offline completion callback.
1066 bfa_fcs_rport_sm_fc4_offline(struct bfa_fcs_rport_s
*rport
,
1067 enum rport_event event
)
1069 bfa_trc(rport
->fcs
, rport
->pwwn
);
1070 bfa_trc(rport
->fcs
, rport
->pid
);
1071 bfa_trc(rport
->fcs
, event
);
1074 case RPSM_EVENT_FC4_OFFLINE
:
1075 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_hcb_offline
);
1076 bfa_fcs_rport_hal_offline(rport
);
1079 case RPSM_EVENT_SCN_ONLINE
:
1081 case RPSM_EVENT_LOGO_RCVD
:
1083 * Rport is going offline. Just ack the logo
1085 bfa_fcs_rport_send_logo_acc(rport
);
1088 case RPSM_EVENT_PRLO_RCVD
:
1089 bfa_fcs_rport_send_prlo_acc(rport
);
1092 case RPSM_EVENT_SCN_OFFLINE
:
1093 case RPSM_EVENT_HCB_ONLINE
:
1094 case RPSM_EVENT_FAB_SCN
:
1095 case RPSM_EVENT_LOGO_IMP
:
1096 case RPSM_EVENT_ADDRESS_CHANGE
:
1098 * rport is already going offline.
1099 * SCN - ignore and wait till transitioning to offline state
1103 case RPSM_EVENT_DELETE
:
1104 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_logosend
);
1108 bfa_sm_fault(rport
->fcs
, event
);
1113 * Rport is offline. FC-4s are offline. Awaiting BFA rport offline
1117 bfa_fcs_rport_sm_hcb_offline(struct bfa_fcs_rport_s
*rport
,
1118 enum rport_event event
)
1120 bfa_trc(rport
->fcs
, rport
->pwwn
);
1121 bfa_trc(rport
->fcs
, rport
->pid
);
1122 bfa_trc(rport
->fcs
, event
);
1125 case RPSM_EVENT_HCB_OFFLINE
:
1126 if (bfa_fcs_lport_is_online(rport
->port
) &&
1127 (rport
->plogi_pending
)) {
1128 rport
->plogi_pending
= BFA_FALSE
;
1129 bfa_sm_set_state(rport
,
1130 bfa_fcs_rport_sm_plogiacc_sending
);
1131 bfa_fcs_rport_send_plogiacc(rport
, NULL
);
1136 case RPSM_EVENT_ADDRESS_CHANGE
:
1137 if (!bfa_fcs_lport_is_online(rport
->port
)) {
1139 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
1140 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
1141 bfa_fcs_rport_timeout
, rport
,
1142 bfa_fcs_rport_del_timeout
);
1145 if (bfa_fcs_fabric_is_switched(rport
->port
->fabric
)) {
1146 bfa_sm_set_state(rport
,
1147 bfa_fcs_rport_sm_nsdisc_sending
);
1148 rport
->ns_retries
= 0;
1149 bfa_fcs_rport_send_nsdisc(rport
, NULL
);
1150 } else if (bfa_fcport_get_topology(rport
->port
->fcs
->bfa
) ==
1151 BFA_PORT_TOPOLOGY_LOOP
) {
1152 if (rport
->scn_online
) {
1153 bfa_sm_set_state(rport
,
1154 bfa_fcs_rport_sm_adisc_offline_sending
);
1155 bfa_fcs_rport_send_adisc(rport
, NULL
);
1157 bfa_sm_set_state(rport
,
1158 bfa_fcs_rport_sm_offline
);
1159 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
1160 bfa_fcs_rport_timeout
, rport
,
1161 bfa_fcs_rport_del_timeout
);
1164 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogi_sending
);
1165 rport
->plogi_retries
= 0;
1166 bfa_fcs_rport_send_plogi(rport
, NULL
);
1170 case RPSM_EVENT_DELETE
:
1171 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_uninit
);
1172 bfa_fcs_rport_free(rport
);
1175 case RPSM_EVENT_SCN_ONLINE
:
1176 case RPSM_EVENT_SCN_OFFLINE
:
1177 case RPSM_EVENT_FAB_SCN
:
1178 case RPSM_EVENT_LOGO_RCVD
:
1179 case RPSM_EVENT_PRLO_RCVD
:
1180 case RPSM_EVENT_PLOGI_RCVD
:
1181 case RPSM_EVENT_LOGO_IMP
:
1183 * Ignore, already offline.
1188 bfa_sm_fault(rport
->fcs
, event
);
1193 * Rport is offline. FC-4s are offline. Awaiting BFA rport offline
1194 * callback to send LOGO accept.
1197 bfa_fcs_rport_sm_hcb_logorcv(struct bfa_fcs_rport_s
*rport
,
1198 enum rport_event event
)
1200 bfa_trc(rport
->fcs
, rport
->pwwn
);
1201 bfa_trc(rport
->fcs
, rport
->pid
);
1202 bfa_trc(rport
->fcs
, event
);
1205 case RPSM_EVENT_HCB_OFFLINE
:
1206 case RPSM_EVENT_ADDRESS_CHANGE
:
1207 if (rport
->pid
&& (rport
->prlo
== BFA_TRUE
))
1208 bfa_fcs_rport_send_prlo_acc(rport
);
1209 if (rport
->pid
&& (rport
->prlo
== BFA_FALSE
))
1210 bfa_fcs_rport_send_logo_acc(rport
);
1212 * If the lport is online and if the rport is not a well
1213 * known address port,
1214 * we try to re-discover the r-port.
1216 if (bfa_fcs_lport_is_online(rport
->port
) &&
1217 (!BFA_FCS_PID_IS_WKA(rport
->pid
))) {
1218 if (bfa_fcs_fabric_is_switched(rport
->port
->fabric
)) {
1219 bfa_sm_set_state(rport
,
1220 bfa_fcs_rport_sm_nsdisc_sending
);
1221 rport
->ns_retries
= 0;
1222 bfa_fcs_rport_send_nsdisc(rport
, NULL
);
1224 /* For N2N Direct Attach, try to re-login */
1225 bfa_sm_set_state(rport
,
1226 bfa_fcs_rport_sm_plogi_sending
);
1227 rport
->plogi_retries
= 0;
1228 bfa_fcs_rport_send_plogi(rport
, NULL
);
1232 * if it is not a well known address, reset the
1235 if (!BFA_FCS_PID_IS_WKA(rport
->pid
))
1237 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
1238 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
1239 bfa_fcs_rport_timeout
, rport
,
1240 bfa_fcs_rport_del_timeout
);
1244 case RPSM_EVENT_DELETE
:
1245 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_delete_pending
);
1246 if (rport
->pid
&& (rport
->prlo
== BFA_TRUE
))
1247 bfa_fcs_rport_send_prlo_acc(rport
);
1248 if (rport
->pid
&& (rport
->prlo
== BFA_FALSE
))
1249 bfa_fcs_rport_send_logo_acc(rport
);
1252 case RPSM_EVENT_LOGO_IMP
:
1253 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_hcb_offline
);
1256 case RPSM_EVENT_SCN_ONLINE
:
1257 case RPSM_EVENT_SCN_OFFLINE
:
1258 case RPSM_EVENT_LOGO_RCVD
:
1259 case RPSM_EVENT_PRLO_RCVD
:
1261 * Ignore - already processing a LOGO.
1266 bfa_sm_fault(rport
->fcs
, event
);
1271 * Rport is being deleted. FC-4s are offline.
1272 * Awaiting BFA rport offline
1273 * callback to send LOGO.
1276 bfa_fcs_rport_sm_hcb_logosend(struct bfa_fcs_rport_s
*rport
,
1277 enum rport_event event
)
1279 bfa_trc(rport
->fcs
, rport
->pwwn
);
1280 bfa_trc(rport
->fcs
, rport
->pid
);
1281 bfa_trc(rport
->fcs
, event
);
1284 case RPSM_EVENT_HCB_OFFLINE
:
1285 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_logo_sending
);
1286 bfa_fcs_rport_send_logo(rport
, NULL
);
1289 case RPSM_EVENT_LOGO_RCVD
:
1290 bfa_fcs_rport_send_logo_acc(rport
);
1292 case RPSM_EVENT_PRLO_RCVD
:
1293 if (rport
->prlo
== BFA_TRUE
)
1294 bfa_fcs_rport_send_prlo_acc(rport
);
1296 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_delete_pending
);
1299 case RPSM_EVENT_SCN_ONLINE
:
1300 case RPSM_EVENT_SCN_OFFLINE
:
1301 case RPSM_EVENT_ADDRESS_CHANGE
:
1305 bfa_sm_fault(rport
->fcs
, event
);
1310 * Rport is being deleted. FC-4s are offline. LOGO is being sent.
1313 bfa_fcs_rport_sm_logo_sending(struct bfa_fcs_rport_s
*rport
,
1314 enum rport_event event
)
1316 bfa_trc(rport
->fcs
, rport
->pwwn
);
1317 bfa_trc(rport
->fcs
, rport
->pid
);
1318 bfa_trc(rport
->fcs
, event
);
1321 case RPSM_EVENT_FCXP_SENT
:
1322 /* Once LOGO is sent, we donot wait for the response */
1323 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_uninit
);
1324 bfa_fcs_rport_free(rport
);
1327 case RPSM_EVENT_SCN_ONLINE
:
1328 case RPSM_EVENT_SCN_OFFLINE
:
1329 case RPSM_EVENT_FAB_SCN
:
1330 case RPSM_EVENT_ADDRESS_CHANGE
:
1333 case RPSM_EVENT_LOGO_RCVD
:
1334 bfa_fcs_rport_send_logo_acc(rport
);
1336 case RPSM_EVENT_PRLO_RCVD
:
1337 if (rport
->prlo
== BFA_TRUE
)
1338 bfa_fcs_rport_send_prlo_acc(rport
);
1340 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_uninit
);
1341 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
1342 bfa_fcs_rport_free(rport
);
1346 bfa_sm_fault(rport
->fcs
, event
);
1351 * Rport is offline. FC-4s are offline. BFA rport is offline.
1352 * Timer active to delete stale rport.
1355 bfa_fcs_rport_sm_offline(struct bfa_fcs_rport_s
*rport
, enum rport_event event
)
1357 bfa_trc(rport
->fcs
, rport
->pwwn
);
1358 bfa_trc(rport
->fcs
, rport
->pid
);
1359 bfa_trc(rport
->fcs
, event
);
1362 case RPSM_EVENT_TIMEOUT
:
1363 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_uninit
);
1364 bfa_fcs_rport_free(rport
);
1367 case RPSM_EVENT_FAB_SCN
:
1368 case RPSM_EVENT_ADDRESS_CHANGE
:
1369 bfa_timer_stop(&rport
->timer
);
1370 WARN_ON(!(bfa_fcport_get_topology(rport
->port
->fcs
->bfa
) !=
1371 BFA_PORT_TOPOLOGY_LOOP
));
1372 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_nsdisc_sending
);
1373 rport
->ns_retries
= 0;
1374 bfa_fcs_rport_send_nsdisc(rport
, NULL
);
1377 case RPSM_EVENT_DELETE
:
1378 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_uninit
);
1379 bfa_timer_stop(&rport
->timer
);
1380 bfa_fcs_rport_free(rport
);
1383 case RPSM_EVENT_PLOGI_RCVD
:
1384 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogiacc_sending
);
1385 bfa_timer_stop(&rport
->timer
);
1386 bfa_fcs_rport_send_plogiacc(rport
, NULL
);
1389 case RPSM_EVENT_LOGO_RCVD
:
1390 case RPSM_EVENT_PRLO_RCVD
:
1391 case RPSM_EVENT_LOGO_IMP
:
1392 case RPSM_EVENT_SCN_OFFLINE
:
1395 case RPSM_EVENT_PLOGI_COMP
:
1396 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_fcs_online
);
1397 bfa_timer_stop(&rport
->timer
);
1398 bfa_fcs_rport_fcs_online_action(rport
);
1401 case RPSM_EVENT_SCN_ONLINE
:
1402 bfa_timer_stop(&rport
->timer
);
1403 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogi_sending
);
1404 bfa_fcs_rport_send_plogi(rport
, NULL
);
1407 case RPSM_EVENT_PLOGI_SEND
:
1408 bfa_timer_stop(&rport
->timer
);
1409 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogi_sending
);
1410 rport
->plogi_retries
= 0;
1411 bfa_fcs_rport_send_plogi(rport
, NULL
);
1415 bfa_sm_fault(rport
->fcs
, event
);
1420 * Rport address has changed. Nameserver discovery request is being sent.
1423 bfa_fcs_rport_sm_nsdisc_sending(struct bfa_fcs_rport_s
*rport
,
1424 enum rport_event event
)
1426 bfa_trc(rport
->fcs
, rport
->pwwn
);
1427 bfa_trc(rport
->fcs
, rport
->pid
);
1428 bfa_trc(rport
->fcs
, event
);
1431 case RPSM_EVENT_FCXP_SENT
:
1432 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_nsdisc_sent
);
1435 case RPSM_EVENT_DELETE
:
1436 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_uninit
);
1437 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
1438 bfa_fcs_rport_free(rport
);
1441 case RPSM_EVENT_PLOGI_RCVD
:
1442 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogiacc_sending
);
1443 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
1444 bfa_fcs_rport_send_plogiacc(rport
, NULL
);
1447 case RPSM_EVENT_FAB_SCN
:
1448 case RPSM_EVENT_LOGO_RCVD
:
1449 case RPSM_EVENT_PRLO_RCVD
:
1450 case RPSM_EVENT_PLOGI_SEND
:
1453 case RPSM_EVENT_ADDRESS_CHANGE
:
1454 rport
->ns_retries
= 0; /* reset the retry count */
1457 case RPSM_EVENT_LOGO_IMP
:
1458 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
1459 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
1460 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
1461 bfa_fcs_rport_timeout
, rport
,
1462 bfa_fcs_rport_del_timeout
);
1465 case RPSM_EVENT_PLOGI_COMP
:
1466 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_fcs_online
);
1467 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
1468 bfa_fcs_rport_fcs_online_action(rport
);
1472 bfa_sm_fault(rport
->fcs
, event
);
1477 * Nameserver discovery failed. Waiting for timeout to retry.
1480 bfa_fcs_rport_sm_nsdisc_retry(struct bfa_fcs_rport_s
*rport
,
1481 enum rport_event event
)
1483 bfa_trc(rport
->fcs
, rport
->pwwn
);
1484 bfa_trc(rport
->fcs
, rport
->pid
);
1485 bfa_trc(rport
->fcs
, event
);
1488 case RPSM_EVENT_TIMEOUT
:
1489 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_nsdisc_sending
);
1490 bfa_fcs_rport_send_nsdisc(rport
, NULL
);
1493 case RPSM_EVENT_FAB_SCN
:
1494 case RPSM_EVENT_ADDRESS_CHANGE
:
1495 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_nsdisc_sending
);
1496 bfa_timer_stop(&rport
->timer
);
1497 rport
->ns_retries
= 0;
1498 bfa_fcs_rport_send_nsdisc(rport
, NULL
);
1501 case RPSM_EVENT_DELETE
:
1502 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_uninit
);
1503 bfa_timer_stop(&rport
->timer
);
1504 bfa_fcs_rport_free(rport
);
1507 case RPSM_EVENT_PLOGI_RCVD
:
1508 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogiacc_sending
);
1509 bfa_timer_stop(&rport
->timer
);
1510 bfa_fcs_rport_send_plogiacc(rport
, NULL
);
1513 case RPSM_EVENT_LOGO_IMP
:
1515 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
1516 bfa_timer_stop(&rport
->timer
);
1517 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
1518 bfa_fcs_rport_timeout
, rport
,
1519 bfa_fcs_rport_del_timeout
);
1522 case RPSM_EVENT_LOGO_RCVD
:
1523 bfa_fcs_rport_send_logo_acc(rport
);
1525 case RPSM_EVENT_PRLO_RCVD
:
1526 bfa_fcs_rport_send_prlo_acc(rport
);
1529 case RPSM_EVENT_PLOGI_COMP
:
1530 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_fcs_online
);
1531 bfa_timer_stop(&rport
->timer
);
1532 bfa_fcs_rport_fcs_online_action(rport
);
1536 bfa_sm_fault(rport
->fcs
, event
);
1541 * Rport address has changed. Nameserver discovery request is sent.
1544 bfa_fcs_rport_sm_nsdisc_sent(struct bfa_fcs_rport_s
*rport
,
1545 enum rport_event event
)
1547 bfa_trc(rport
->fcs
, rport
->pwwn
);
1548 bfa_trc(rport
->fcs
, rport
->pid
);
1549 bfa_trc(rport
->fcs
, event
);
1552 case RPSM_EVENT_ACCEPTED
:
1553 case RPSM_EVENT_ADDRESS_CHANGE
:
1555 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogi_sending
);
1556 bfa_fcs_rport_send_plogi(rport
, NULL
);
1558 bfa_sm_set_state(rport
,
1559 bfa_fcs_rport_sm_nsdisc_sending
);
1560 rport
->ns_retries
= 0;
1561 bfa_fcs_rport_send_nsdisc(rport
, NULL
);
1565 case RPSM_EVENT_FAILED
:
1566 rport
->ns_retries
++;
1567 if (rport
->ns_retries
< BFA_FCS_RPORT_MAX_RETRIES
) {
1568 bfa_sm_set_state(rport
,
1569 bfa_fcs_rport_sm_nsdisc_sending
);
1570 bfa_fcs_rport_send_nsdisc(rport
, NULL
);
1572 rport
->old_pid
= rport
->pid
;
1574 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
1575 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
1576 bfa_fcs_rport_timeout
, rport
,
1577 bfa_fcs_rport_del_timeout
);
1581 case RPSM_EVENT_DELETE
:
1582 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_uninit
);
1583 bfa_fcxp_discard(rport
->fcxp
);
1584 bfa_fcs_rport_free(rport
);
1587 case RPSM_EVENT_PLOGI_RCVD
:
1588 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogiacc_sending
);
1589 bfa_fcxp_discard(rport
->fcxp
);
1590 bfa_fcs_rport_send_plogiacc(rport
, NULL
);
1593 case RPSM_EVENT_LOGO_IMP
:
1595 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
1596 bfa_fcxp_discard(rport
->fcxp
);
1597 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
1598 bfa_fcs_rport_timeout
, rport
,
1599 bfa_fcs_rport_del_timeout
);
1603 case RPSM_EVENT_PRLO_RCVD
:
1604 bfa_fcs_rport_send_prlo_acc(rport
);
1606 case RPSM_EVENT_FAB_SCN
:
1608 * ignore, wait for NS query response
1612 case RPSM_EVENT_LOGO_RCVD
:
1614 * Not logged-in yet. Accept LOGO.
1616 bfa_fcs_rport_send_logo_acc(rport
);
1619 case RPSM_EVENT_PLOGI_COMP
:
1620 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_fcs_online
);
1621 bfa_fcxp_discard(rport
->fcxp
);
1622 bfa_fcs_rport_fcs_online_action(rport
);
1626 bfa_sm_fault(rport
->fcs
, event
);
1631 * Rport needs to be deleted
1632 * waiting for ITNIM clean up to finish
1635 bfa_fcs_rport_sm_fc4_off_delete(struct bfa_fcs_rport_s
*rport
,
1636 enum rport_event event
)
1638 bfa_trc(rport
->fcs
, rport
->pwwn
);
1639 bfa_trc(rport
->fcs
, rport
->pid
);
1640 bfa_trc(rport
->fcs
, event
);
1643 case RPSM_EVENT_FC4_OFFLINE
:
1644 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_delete_pending
);
1645 bfa_fcs_rport_hal_offline(rport
);
1648 case RPSM_EVENT_DELETE
:
1649 case RPSM_EVENT_PLOGI_RCVD
:
1650 /* Ignore these events */
1654 bfa_sm_fault(rport
->fcs
, event
);
1660 * RPort needs to be deleted
1661 * waiting for BFA/FW to finish current processing
1664 bfa_fcs_rport_sm_delete_pending(struct bfa_fcs_rport_s
*rport
,
1665 enum rport_event event
)
1667 bfa_trc(rport
->fcs
, rport
->pwwn
);
1668 bfa_trc(rport
->fcs
, rport
->pid
);
1669 bfa_trc(rport
->fcs
, event
);
1672 case RPSM_EVENT_HCB_OFFLINE
:
1673 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_uninit
);
1674 bfa_fcs_rport_free(rport
);
1677 case RPSM_EVENT_DELETE
:
1678 case RPSM_EVENT_LOGO_IMP
:
1679 case RPSM_EVENT_PLOGI_RCVD
:
1680 /* Ignore these events */
1684 bfa_sm_fault(rport
->fcs
, event
);
1689 * fcs_rport_private FCS RPORT provate functions
1693 bfa_fcs_rport_send_plogi(void *rport_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
1695 struct bfa_fcs_rport_s
*rport
= rport_cbarg
;
1696 struct bfa_fcs_lport_s
*port
= rport
->port
;
1699 struct bfa_fcxp_s
*fcxp
;
1701 bfa_trc(rport
->fcs
, rport
->pwwn
);
1703 fcxp
= fcxp_alloced
? fcxp_alloced
:
1704 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
1706 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &rport
->fcxp_wqe
,
1707 bfa_fcs_rport_send_plogi
, rport
, BFA_TRUE
);
1712 len
= fc_plogi_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
), rport
->pid
,
1713 bfa_fcs_lport_get_fcid(port
), 0,
1714 port
->port_cfg
.pwwn
, port
->port_cfg
.nwwn
,
1715 bfa_fcport_get_maxfrsize(port
->fcs
->bfa
),
1716 bfa_fcport_get_rx_bbcredit(port
->fcs
->bfa
));
1718 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
1719 FC_CLASS_3
, len
, &fchs
, bfa_fcs_rport_plogi_response
,
1720 (void *)rport
, FC_MAX_PDUSZ
, FC_ELS_TOV
);
1722 rport
->stats
.plogis
++;
1723 bfa_sm_send_event(rport
, RPSM_EVENT_FCXP_SENT
);
1727 bfa_fcs_rport_plogi_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
, void *cbarg
,
1728 bfa_status_t req_status
, u32 rsp_len
,
1729 u32 resid_len
, struct fchs_s
*rsp_fchs
)
1731 struct bfa_fcs_rport_s
*rport
= (struct bfa_fcs_rport_s
*) cbarg
;
1732 struct fc_logi_s
*plogi_rsp
;
1733 struct fc_ls_rjt_s
*ls_rjt
;
1734 struct bfa_fcs_rport_s
*twin
;
1735 struct list_head
*qe
;
1737 bfa_trc(rport
->fcs
, rport
->pwwn
);
1742 if (req_status
!= BFA_STATUS_OK
) {
1743 bfa_trc(rport
->fcs
, req_status
);
1744 rport
->stats
.plogi_failed
++;
1745 bfa_sm_send_event(rport
, RPSM_EVENT_FAILED
);
1749 plogi_rsp
= (struct fc_logi_s
*) BFA_FCXP_RSP_PLD(fcxp
);
1752 * Check for failure first.
1754 if (plogi_rsp
->els_cmd
.els_code
!= FC_ELS_ACC
) {
1755 ls_rjt
= (struct fc_ls_rjt_s
*) BFA_FCXP_RSP_PLD(fcxp
);
1757 bfa_trc(rport
->fcs
, ls_rjt
->reason_code
);
1758 bfa_trc(rport
->fcs
, ls_rjt
->reason_code_expl
);
1760 if ((ls_rjt
->reason_code
== FC_LS_RJT_RSN_UNABLE_TO_PERF_CMD
) &&
1761 (ls_rjt
->reason_code_expl
== FC_LS_RJT_EXP_INSUFF_RES
)) {
1762 rport
->stats
.rjt_insuff_res
++;
1763 bfa_sm_send_event(rport
, RPSM_EVENT_PLOGI_RETRY
);
1767 rport
->stats
.plogi_rejects
++;
1768 bfa_sm_send_event(rport
, RPSM_EVENT_FAILED
);
1773 * PLOGI is complete. Make sure this device is not one of the known
1774 * device with a new FC port address.
1776 list_for_each(qe
, &rport
->port
->rport_q
) {
1777 twin
= (struct bfa_fcs_rport_s
*) qe
;
1780 if (!rport
->pwwn
&& (plogi_rsp
->port_name
== twin
->pwwn
)) {
1781 bfa_trc(rport
->fcs
, twin
->pid
);
1782 bfa_trc(rport
->fcs
, rport
->pid
);
1784 /* Update plogi stats in twin */
1785 twin
->stats
.plogis
+= rport
->stats
.plogis
;
1786 twin
->stats
.plogi_rejects
+=
1787 rport
->stats
.plogi_rejects
;
1788 twin
->stats
.plogi_timeouts
+=
1789 rport
->stats
.plogi_timeouts
;
1790 twin
->stats
.plogi_failed
+=
1791 rport
->stats
.plogi_failed
;
1792 twin
->stats
.plogi_rcvd
+= rport
->stats
.plogi_rcvd
;
1793 twin
->stats
.plogi_accs
++;
1795 bfa_sm_send_event(rport
, RPSM_EVENT_DELETE
);
1797 bfa_fcs_rport_update(twin
, plogi_rsp
);
1798 twin
->pid
= rsp_fchs
->s_id
;
1799 bfa_sm_send_event(twin
, RPSM_EVENT_PLOGI_COMP
);
1805 * Normal login path -- no evil twins.
1807 rport
->stats
.plogi_accs
++;
1808 bfa_fcs_rport_update(rport
, plogi_rsp
);
1809 bfa_sm_send_event(rport
, RPSM_EVENT_ACCEPTED
);
1813 bfa_fcs_rport_send_plogiacc(void *rport_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
1815 struct bfa_fcs_rport_s
*rport
= rport_cbarg
;
1816 struct bfa_fcs_lport_s
*port
= rport
->port
;
1819 struct bfa_fcxp_s
*fcxp
;
1821 bfa_trc(rport
->fcs
, rport
->pwwn
);
1822 bfa_trc(rport
->fcs
, rport
->reply_oxid
);
1824 fcxp
= fcxp_alloced
? fcxp_alloced
:
1825 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_FALSE
);
1827 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &rport
->fcxp_wqe
,
1828 bfa_fcs_rport_send_plogiacc
, rport
, BFA_FALSE
);
1833 len
= fc_plogi_acc_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
1834 rport
->pid
, bfa_fcs_lport_get_fcid(port
),
1835 rport
->reply_oxid
, port
->port_cfg
.pwwn
,
1836 port
->port_cfg
.nwwn
,
1837 bfa_fcport_get_maxfrsize(port
->fcs
->bfa
),
1838 bfa_fcport_get_rx_bbcredit(port
->fcs
->bfa
));
1840 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
1841 FC_CLASS_3
, len
, &fchs
, NULL
, NULL
, FC_MAX_PDUSZ
, 0);
1843 bfa_sm_send_event(rport
, RPSM_EVENT_FCXP_SENT
);
1847 bfa_fcs_rport_send_adisc(void *rport_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
1849 struct bfa_fcs_rport_s
*rport
= rport_cbarg
;
1850 struct bfa_fcs_lport_s
*port
= rport
->port
;
1853 struct bfa_fcxp_s
*fcxp
;
1855 bfa_trc(rport
->fcs
, rport
->pwwn
);
1857 fcxp
= fcxp_alloced
? fcxp_alloced
:
1858 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
1860 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &rport
->fcxp_wqe
,
1861 bfa_fcs_rport_send_adisc
, rport
, BFA_TRUE
);
1866 len
= fc_adisc_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
), rport
->pid
,
1867 bfa_fcs_lport_get_fcid(port
), 0,
1868 port
->port_cfg
.pwwn
, port
->port_cfg
.nwwn
);
1870 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
1871 FC_CLASS_3
, len
, &fchs
, bfa_fcs_rport_adisc_response
,
1872 rport
, FC_MAX_PDUSZ
, FC_ELS_TOV
);
1874 rport
->stats
.adisc_sent
++;
1875 bfa_sm_send_event(rport
, RPSM_EVENT_FCXP_SENT
);
1879 bfa_fcs_rport_adisc_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
, void *cbarg
,
1880 bfa_status_t req_status
, u32 rsp_len
,
1881 u32 resid_len
, struct fchs_s
*rsp_fchs
)
1883 struct bfa_fcs_rport_s
*rport
= (struct bfa_fcs_rport_s
*) cbarg
;
1884 void *pld
= bfa_fcxp_get_rspbuf(fcxp
);
1885 struct fc_ls_rjt_s
*ls_rjt
;
1887 if (req_status
!= BFA_STATUS_OK
) {
1888 bfa_trc(rport
->fcs
, req_status
);
1889 rport
->stats
.adisc_failed
++;
1890 bfa_sm_send_event(rport
, RPSM_EVENT_FAILED
);
1894 if (fc_adisc_rsp_parse((struct fc_adisc_s
*)pld
, rsp_len
, rport
->pwwn
,
1895 rport
->nwwn
) == FC_PARSE_OK
) {
1896 rport
->stats
.adisc_accs
++;
1897 bfa_sm_send_event(rport
, RPSM_EVENT_ACCEPTED
);
1901 rport
->stats
.adisc_rejects
++;
1903 bfa_trc(rport
->fcs
, ls_rjt
->els_cmd
.els_code
);
1904 bfa_trc(rport
->fcs
, ls_rjt
->reason_code
);
1905 bfa_trc(rport
->fcs
, ls_rjt
->reason_code_expl
);
1906 bfa_sm_send_event(rport
, RPSM_EVENT_FAILED
);
1910 bfa_fcs_rport_send_nsdisc(void *rport_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
1912 struct bfa_fcs_rport_s
*rport
= rport_cbarg
;
1913 struct bfa_fcs_lport_s
*port
= rport
->port
;
1915 struct bfa_fcxp_s
*fcxp
;
1917 bfa_cb_fcxp_send_t cbfn
;
1919 bfa_trc(rport
->fcs
, rport
->pid
);
1921 fcxp
= fcxp_alloced
? fcxp_alloced
:
1922 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
1924 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &rport
->fcxp_wqe
,
1925 bfa_fcs_rport_send_nsdisc
, rport
, BFA_TRUE
);
1931 len
= fc_gidpn_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
1932 bfa_fcs_lport_get_fcid(port
), 0, rport
->pwwn
);
1933 cbfn
= bfa_fcs_rport_gidpn_response
;
1935 len
= fc_gpnid_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
1936 bfa_fcs_lport_get_fcid(port
), 0, rport
->pid
);
1937 cbfn
= bfa_fcs_rport_gpnid_response
;
1940 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
1941 FC_CLASS_3
, len
, &fchs
, cbfn
,
1942 (void *)rport
, FC_MAX_PDUSZ
, FC_FCCT_TOV
);
1944 bfa_sm_send_event(rport
, RPSM_EVENT_FCXP_SENT
);
1948 bfa_fcs_rport_gidpn_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
, void *cbarg
,
1949 bfa_status_t req_status
, u32 rsp_len
,
1950 u32 resid_len
, struct fchs_s
*rsp_fchs
)
1952 struct bfa_fcs_rport_s
*rport
= (struct bfa_fcs_rport_s
*) cbarg
;
1953 struct ct_hdr_s
*cthdr
;
1954 struct fcgs_gidpn_resp_s
*gidpn_rsp
;
1955 struct bfa_fcs_rport_s
*twin
;
1956 struct list_head
*qe
;
1958 bfa_trc(rport
->fcs
, rport
->pwwn
);
1960 cthdr
= (struct ct_hdr_s
*) BFA_FCXP_RSP_PLD(fcxp
);
1961 cthdr
->cmd_rsp_code
= be16_to_cpu(cthdr
->cmd_rsp_code
);
1963 if (cthdr
->cmd_rsp_code
== CT_RSP_ACCEPT
) {
1964 /* Check if the pid is the same as before. */
1965 gidpn_rsp
= (struct fcgs_gidpn_resp_s
*) (cthdr
+ 1);
1967 if (gidpn_rsp
->dap
== rport
->pid
) {
1968 /* Device is online */
1969 bfa_sm_send_event(rport
, RPSM_EVENT_ACCEPTED
);
1972 * Device's PID has changed. We need to cleanup
1973 * and re-login. If there is another device with
1974 * the the newly discovered pid, send an scn notice
1975 * so that its new pid can be discovered.
1977 list_for_each(qe
, &rport
->port
->rport_q
) {
1978 twin
= (struct bfa_fcs_rport_s
*) qe
;
1981 if (gidpn_rsp
->dap
== twin
->pid
) {
1982 bfa_trc(rport
->fcs
, twin
->pid
);
1983 bfa_trc(rport
->fcs
, rport
->pid
);
1986 bfa_sm_send_event(twin
,
1987 RPSM_EVENT_ADDRESS_CHANGE
);
1990 rport
->pid
= gidpn_rsp
->dap
;
1991 bfa_sm_send_event(rport
, RPSM_EVENT_ADDRESS_CHANGE
);
1999 switch (cthdr
->reason_code
) {
2000 case CT_RSN_LOGICAL_BUSY
:
2004 bfa_sm_send_event(rport
, RPSM_EVENT_TIMEOUT
);
2007 case CT_RSN_UNABLE_TO_PERF
:
2009 * device doesn't exist : Start timer to cleanup this later.
2011 bfa_sm_send_event(rport
, RPSM_EVENT_FAILED
);
2015 bfa_sm_send_event(rport
, RPSM_EVENT_FAILED
);
2021 bfa_fcs_rport_gpnid_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
, void *cbarg
,
2022 bfa_status_t req_status
, u32 rsp_len
,
2023 u32 resid_len
, struct fchs_s
*rsp_fchs
)
2025 struct bfa_fcs_rport_s
*rport
= (struct bfa_fcs_rport_s
*) cbarg
;
2026 struct ct_hdr_s
*cthdr
;
2028 bfa_trc(rport
->fcs
, rport
->pwwn
);
2030 cthdr
= (struct ct_hdr_s
*) BFA_FCXP_RSP_PLD(fcxp
);
2031 cthdr
->cmd_rsp_code
= be16_to_cpu(cthdr
->cmd_rsp_code
);
2033 if (cthdr
->cmd_rsp_code
== CT_RSP_ACCEPT
) {
2034 bfa_sm_send_event(rport
, RPSM_EVENT_ACCEPTED
);
2041 switch (cthdr
->reason_code
) {
2042 case CT_RSN_LOGICAL_BUSY
:
2046 bfa_sm_send_event(rport
, RPSM_EVENT_TIMEOUT
);
2049 case CT_RSN_UNABLE_TO_PERF
:
2051 * device doesn't exist : Start timer to cleanup this later.
2053 bfa_sm_send_event(rport
, RPSM_EVENT_FAILED
);
2057 bfa_sm_send_event(rport
, RPSM_EVENT_FAILED
);
2063 * Called to send a logout to the rport.
2066 bfa_fcs_rport_send_logo(void *rport_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
2068 struct bfa_fcs_rport_s
*rport
= rport_cbarg
;
2069 struct bfa_fcs_lport_s
*port
;
2071 struct bfa_fcxp_s
*fcxp
;
2074 bfa_trc(rport
->fcs
, rport
->pid
);
2078 fcxp
= fcxp_alloced
? fcxp_alloced
:
2079 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_FALSE
);
2081 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &rport
->fcxp_wqe
,
2082 bfa_fcs_rport_send_logo
, rport
, BFA_FALSE
);
2087 len
= fc_logo_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
), rport
->pid
,
2088 bfa_fcs_lport_get_fcid(port
), 0,
2089 bfa_fcs_lport_get_pwwn(port
));
2091 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
2092 FC_CLASS_3
, len
, &fchs
, NULL
,
2093 rport
, FC_MAX_PDUSZ
, FC_ELS_TOV
);
2095 rport
->stats
.logos
++;
2096 bfa_fcxp_discard(rport
->fcxp
);
2097 bfa_sm_send_event(rport
, RPSM_EVENT_FCXP_SENT
);
2101 * Send ACC for a LOGO received.
2104 bfa_fcs_rport_send_logo_acc(void *rport_cbarg
)
2106 struct bfa_fcs_rport_s
*rport
= rport_cbarg
;
2107 struct bfa_fcs_lport_s
*port
;
2109 struct bfa_fcxp_s
*fcxp
;
2112 bfa_trc(rport
->fcs
, rport
->pid
);
2116 fcxp
= bfa_fcs_fcxp_alloc(port
->fcs
, BFA_FALSE
);
2120 rport
->stats
.logo_rcvd
++;
2121 len
= fc_logo_acc_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
2122 rport
->pid
, bfa_fcs_lport_get_fcid(port
),
2125 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
2126 FC_CLASS_3
, len
, &fchs
, NULL
, NULL
, FC_MAX_PDUSZ
, 0);
2131 * This routine will be called by bfa_timer on timer timeouts.
2133 * param[in] rport - pointer to bfa_fcs_lport_ns_t.
2134 * param[out] rport_status - pointer to return vport status in
2139 * Special Considerations:
2144 bfa_fcs_rport_timeout(void *arg
)
2146 struct bfa_fcs_rport_s
*rport
= (struct bfa_fcs_rport_s
*) arg
;
2148 rport
->stats
.plogi_timeouts
++;
2149 bfa_stats(rport
->port
, rport_plogi_timeouts
);
2150 bfa_sm_send_event(rport
, RPSM_EVENT_TIMEOUT
);
2154 bfa_fcs_rport_process_prli(struct bfa_fcs_rport_s
*rport
,
2155 struct fchs_s
*rx_fchs
, u16 len
)
2157 struct bfa_fcxp_s
*fcxp
;
2159 struct bfa_fcs_lport_s
*port
= rport
->port
;
2160 struct fc_prli_s
*prli
;
2162 bfa_trc(port
->fcs
, rx_fchs
->s_id
);
2163 bfa_trc(port
->fcs
, rx_fchs
->d_id
);
2165 rport
->stats
.prli_rcvd
++;
2168 * We are in Initiator Mode
2170 prli
= (struct fc_prli_s
*) (rx_fchs
+ 1);
2172 if (prli
->parampage
.servparams
.target
) {
2174 * PRLI from a target ?
2176 * PRLI sent by us will be used to transition the IT nexus,
2177 * once the response is received from the target.
2179 bfa_trc(port
->fcs
, rx_fchs
->s_id
);
2180 rport
->scsi_function
= BFA_RPORT_TARGET
;
2182 bfa_trc(rport
->fcs
, prli
->parampage
.type
);
2183 rport
->scsi_function
= BFA_RPORT_INITIATOR
;
2184 bfa_fcs_itnim_is_initiator(rport
->itnim
);
2187 fcxp
= bfa_fcs_fcxp_alloc(port
->fcs
, BFA_FALSE
);
2191 len
= fc_prli_acc_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
2192 rx_fchs
->s_id
, bfa_fcs_lport_get_fcid(port
),
2193 rx_fchs
->ox_id
, port
->port_cfg
.roles
);
2195 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
2196 FC_CLASS_3
, len
, &fchs
, NULL
, NULL
, FC_MAX_PDUSZ
, 0);
2200 bfa_fcs_rport_process_rpsc(struct bfa_fcs_rport_s
*rport
,
2201 struct fchs_s
*rx_fchs
, u16 len
)
2203 struct bfa_fcxp_s
*fcxp
;
2205 struct bfa_fcs_lport_s
*port
= rport
->port
;
2206 struct fc_rpsc_speed_info_s speeds
;
2207 struct bfa_port_attr_s pport_attr
;
2209 bfa_trc(port
->fcs
, rx_fchs
->s_id
);
2210 bfa_trc(port
->fcs
, rx_fchs
->d_id
);
2212 rport
->stats
.rpsc_rcvd
++;
2213 speeds
.port_speed_cap
=
2214 RPSC_SPEED_CAP_1G
| RPSC_SPEED_CAP_2G
| RPSC_SPEED_CAP_4G
|
2218 * get curent speed from pport attributes from BFA
2220 bfa_fcport_get_attr(port
->fcs
->bfa
, &pport_attr
);
2222 speeds
.port_op_speed
= fc_bfa_speed_to_rpsc_operspeed(pport_attr
.speed
);
2224 fcxp
= bfa_fcs_fcxp_alloc(port
->fcs
, BFA_FALSE
);
2228 len
= fc_rpsc_acc_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
2229 rx_fchs
->s_id
, bfa_fcs_lport_get_fcid(port
),
2230 rx_fchs
->ox_id
, &speeds
);
2232 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
2233 FC_CLASS_3
, len
, &fchs
, NULL
, NULL
, FC_MAX_PDUSZ
, 0);
2237 bfa_fcs_rport_process_adisc(struct bfa_fcs_rport_s
*rport
,
2238 struct fchs_s
*rx_fchs
, u16 len
)
2240 struct bfa_fcxp_s
*fcxp
;
2242 struct bfa_fcs_lport_s
*port
= rport
->port
;
2243 struct fc_adisc_s
*adisc
;
2245 bfa_trc(port
->fcs
, rx_fchs
->s_id
);
2246 bfa_trc(port
->fcs
, rx_fchs
->d_id
);
2248 rport
->stats
.adisc_rcvd
++;
2250 adisc
= (struct fc_adisc_s
*) (rx_fchs
+ 1);
2253 * Accept if the itnim for this rport is online.
2254 * Else reject the ADISC.
2256 if (bfa_fcs_itnim_get_online_state(rport
->itnim
) == BFA_STATUS_OK
) {
2258 fcxp
= bfa_fcs_fcxp_alloc(port
->fcs
, BFA_FALSE
);
2262 len
= fc_adisc_acc_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
2263 rx_fchs
->s_id
, bfa_fcs_lport_get_fcid(port
),
2264 rx_fchs
->ox_id
, port
->port_cfg
.pwwn
,
2265 port
->port_cfg
.nwwn
);
2267 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
,
2268 BFA_FALSE
, FC_CLASS_3
, len
, &fchs
, NULL
, NULL
,
2271 rport
->stats
.adisc_rejected
++;
2272 bfa_fcs_rport_send_ls_rjt(rport
, rx_fchs
,
2273 FC_LS_RJT_RSN_UNABLE_TO_PERF_CMD
,
2274 FC_LS_RJT_EXP_LOGIN_REQUIRED
);
2279 bfa_fcs_rport_hal_online(struct bfa_fcs_rport_s
*rport
)
2281 struct bfa_fcs_lport_s
*port
= rport
->port
;
2282 struct bfa_rport_info_s rport_info
;
2284 rport_info
.pid
= rport
->pid
;
2285 rport_info
.local_pid
= port
->pid
;
2286 rport_info
.lp_tag
= port
->lp_tag
;
2287 rport_info
.vf_id
= port
->fabric
->vf_id
;
2288 rport_info
.vf_en
= port
->fabric
->is_vf
;
2289 rport_info
.fc_class
= rport
->fc_cos
;
2290 rport_info
.cisc
= rport
->cisc
;
2291 rport_info
.max_frmsz
= rport
->maxfrsize
;
2292 bfa_rport_online(rport
->bfa_rport
, &rport_info
);
2296 bfa_fcs_rport_hal_offline(struct bfa_fcs_rport_s
*rport
)
2298 if (rport
->bfa_rport
)
2299 bfa_sm_send_event(rport
->bfa_rport
, BFA_RPORT_SM_OFFLINE
);
2301 bfa_cb_rport_offline(rport
);
2304 static struct bfa_fcs_rport_s
*
2305 bfa_fcs_rport_alloc(struct bfa_fcs_lport_s
*port
, wwn_t pwwn
, u32 rpid
)
2307 struct bfa_fcs_s
*fcs
= port
->fcs
;
2308 struct bfa_fcs_rport_s
*rport
;
2309 struct bfad_rport_s
*rport_drv
;
2314 if (fcs
->num_rport_logins
>= bfa_fcs_rport_max_logins
) {
2319 if (bfa_fcb_rport_alloc(fcs
->bfad
, &rport
, &rport_drv
)
2330 rport
->rp_drv
= rport_drv
;
2335 rport
->bfa_rport
= NULL
;
2340 WARN_ON(!bfa_fcs_lport_is_initiator(port
));
2342 if (bfa_fcs_lport_is_initiator(port
)) {
2343 rport
->itnim
= bfa_fcs_itnim_create(rport
);
2344 if (!rport
->itnim
) {
2351 bfa_fcs_lport_add_rport(port
, rport
);
2352 fcs
->num_rport_logins
++;
2354 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_uninit
);
2356 /* Initialize the Rport Features(RPF) Sub Module */
2357 if (!BFA_FCS_PID_IS_WKA(rport
->pid
))
2358 bfa_fcs_rpf_init(rport
);
2365 bfa_fcs_rport_free(struct bfa_fcs_rport_s
*rport
)
2367 struct bfa_fcs_lport_s
*port
= rport
->port
;
2368 struct bfa_fcs_s
*fcs
= port
->fcs
;
2372 * - delete BFA rport
2373 * - remove from queue of rports
2375 rport
->plogi_pending
= BFA_FALSE
;
2377 if (bfa_fcs_lport_is_initiator(port
)) {
2378 bfa_fcs_itnim_delete(rport
->itnim
);
2379 if (rport
->pid
!= 0 && !BFA_FCS_PID_IS_WKA(rport
->pid
))
2380 bfa_fcs_rpf_rport_offline(rport
);
2383 if (rport
->bfa_rport
) {
2384 bfa_sm_send_event(rport
->bfa_rport
, BFA_RPORT_SM_DELETE
);
2385 rport
->bfa_rport
= NULL
;
2388 bfa_fcs_lport_del_rport(port
, rport
);
2389 fcs
->num_rport_logins
--;
2390 kfree(rport
->rp_drv
);
2394 bfa_fcs_rport_aen_post(struct bfa_fcs_rport_s
*rport
,
2395 enum bfa_rport_aen_event event
,
2396 struct bfa_rport_aen_data_s
*data
)
2398 struct bfa_fcs_lport_s
*port
= rport
->port
;
2399 struct bfad_s
*bfad
= (struct bfad_s
*)port
->fcs
->bfad
;
2400 struct bfa_aen_entry_s
*aen_entry
;
2402 bfad_get_aen_entry(bfad
, aen_entry
);
2406 if (event
== BFA_RPORT_AEN_QOS_PRIO
)
2407 aen_entry
->aen_data
.rport
.priv
.qos
= data
->priv
.qos
;
2408 else if (event
== BFA_RPORT_AEN_QOS_FLOWID
)
2409 aen_entry
->aen_data
.rport
.priv
.qos
= data
->priv
.qos
;
2411 aen_entry
->aen_data
.rport
.vf_id
= rport
->port
->fabric
->vf_id
;
2412 aen_entry
->aen_data
.rport
.ppwwn
= bfa_fcs_lport_get_pwwn(
2413 bfa_fcs_get_base_port(rport
->fcs
));
2414 aen_entry
->aen_data
.rport
.lpwwn
= bfa_fcs_lport_get_pwwn(rport
->port
);
2415 aen_entry
->aen_data
.rport
.rpwwn
= rport
->pwwn
;
2417 /* Send the AEN notification */
2418 bfad_im_post_vendor_event(aen_entry
, bfad
, ++rport
->fcs
->fcs_aen_seq
,
2419 BFA_AEN_CAT_RPORT
, event
);
2423 bfa_fcs_rport_fcs_online_action(struct bfa_fcs_rport_s
*rport
)
2425 if ((!rport
->pid
) || (!rport
->pwwn
)) {
2426 bfa_trc(rport
->fcs
, rport
->pid
);
2427 bfa_sm_fault(rport
->fcs
, rport
->pid
);
2430 bfa_sm_send_event(rport
->itnim
, BFA_FCS_ITNIM_SM_FCS_ONLINE
);
2434 bfa_fcs_rport_hal_online_action(struct bfa_fcs_rport_s
*rport
)
2436 struct bfa_fcs_lport_s
*port
= rport
->port
;
2437 struct bfad_s
*bfad
= (struct bfad_s
*)port
->fcs
->bfad
;
2438 char lpwwn_buf
[BFA_STRING_32
];
2439 char rpwwn_buf
[BFA_STRING_32
];
2441 rport
->stats
.onlines
++;
2443 if ((!rport
->pid
) || (!rport
->pwwn
)) {
2444 bfa_trc(rport
->fcs
, rport
->pid
);
2445 bfa_sm_fault(rport
->fcs
, rport
->pid
);
2448 if (bfa_fcs_lport_is_initiator(port
)) {
2449 bfa_fcs_itnim_brp_online(rport
->itnim
);
2450 if (!BFA_FCS_PID_IS_WKA(rport
->pid
))
2451 bfa_fcs_rpf_rport_online(rport
);
2454 wwn2str(lpwwn_buf
, bfa_fcs_lport_get_pwwn(port
));
2455 wwn2str(rpwwn_buf
, rport
->pwwn
);
2456 if (!BFA_FCS_PID_IS_WKA(rport
->pid
)) {
2457 BFA_LOG(KERN_INFO
, bfad
, bfa_log_level
,
2458 "Remote port (WWN = %s) online for logical port (WWN = %s)\n",
2459 rpwwn_buf
, lpwwn_buf
);
2460 bfa_fcs_rport_aen_post(rport
, BFA_RPORT_AEN_ONLINE
, NULL
);
2465 bfa_fcs_rport_fcs_offline_action(struct bfa_fcs_rport_s
*rport
)
2467 if (!BFA_FCS_PID_IS_WKA(rport
->pid
))
2468 bfa_fcs_rpf_rport_offline(rport
);
2470 bfa_fcs_itnim_rport_offline(rport
->itnim
);
2474 bfa_fcs_rport_hal_offline_action(struct bfa_fcs_rport_s
*rport
)
2476 struct bfa_fcs_lport_s
*port
= rport
->port
;
2477 struct bfad_s
*bfad
= (struct bfad_s
*)port
->fcs
->bfad
;
2478 char lpwwn_buf
[BFA_STRING_32
];
2479 char rpwwn_buf
[BFA_STRING_32
];
2481 if (!rport
->bfa_rport
) {
2482 bfa_fcs_rport_fcs_offline_action(rport
);
2486 rport
->stats
.offlines
++;
2488 wwn2str(lpwwn_buf
, bfa_fcs_lport_get_pwwn(port
));
2489 wwn2str(rpwwn_buf
, rport
->pwwn
);
2490 if (!BFA_FCS_PID_IS_WKA(rport
->pid
)) {
2491 if (bfa_fcs_lport_is_online(rport
->port
) == BFA_TRUE
) {
2492 BFA_LOG(KERN_ERR
, bfad
, bfa_log_level
,
2493 "Remote port (WWN = %s) connectivity lost for "
2494 "logical port (WWN = %s)\n",
2495 rpwwn_buf
, lpwwn_buf
);
2496 bfa_fcs_rport_aen_post(rport
,
2497 BFA_RPORT_AEN_DISCONNECT
, NULL
);
2499 BFA_LOG(KERN_INFO
, bfad
, bfa_log_level
,
2500 "Remote port (WWN = %s) offlined by "
2501 "logical port (WWN = %s)\n",
2502 rpwwn_buf
, lpwwn_buf
);
2503 bfa_fcs_rport_aen_post(rport
,
2504 BFA_RPORT_AEN_OFFLINE
, NULL
);
2508 if (bfa_fcs_lport_is_initiator(port
)) {
2509 bfa_fcs_itnim_rport_offline(rport
->itnim
);
2510 if (!BFA_FCS_PID_IS_WKA(rport
->pid
))
2511 bfa_fcs_rpf_rport_offline(rport
);
2516 * Update rport parameters from PLOGI or PLOGI accept.
2519 bfa_fcs_rport_update(struct bfa_fcs_rport_s
*rport
, struct fc_logi_s
*plogi
)
2521 bfa_fcs_lport_t
*port
= rport
->port
;
2527 rport
->pwwn
= plogi
->port_name
;
2528 rport
->nwwn
= plogi
->node_name
;
2531 * - class of service
2534 if (plogi
->class3
.class_valid
)
2535 rport
->fc_cos
= FC_CLASS_3
;
2537 if (plogi
->class2
.class_valid
)
2538 rport
->fc_cos
|= FC_CLASS_2
;
2542 * - MAX receive frame size
2544 rport
->cisc
= plogi
->csp
.cisc
;
2545 if (be16_to_cpu(plogi
->class3
.rxsz
) < be16_to_cpu(plogi
->csp
.rxsz
))
2546 rport
->maxfrsize
= be16_to_cpu(plogi
->class3
.rxsz
);
2548 rport
->maxfrsize
= be16_to_cpu(plogi
->csp
.rxsz
);
2550 bfa_trc(port
->fcs
, be16_to_cpu(plogi
->csp
.bbcred
));
2551 bfa_trc(port
->fcs
, port
->fabric
->bb_credit
);
2553 * Direct Attach P2P mode :
2554 * This is to handle a bug (233476) in IBM targets in Direct Attach
2555 * Mode. Basically, in FLOGI Accept the target would have
2556 * erroneously set the BB Credit to the value used in the FLOGI
2557 * sent by the HBA. It uses the correct value (its own BB credit)
2560 if ((!bfa_fcs_fabric_is_switched(port
->fabric
)) &&
2561 (be16_to_cpu(plogi
->csp
.bbcred
) < port
->fabric
->bb_credit
)) {
2563 bfa_trc(port
->fcs
, be16_to_cpu(plogi
->csp
.bbcred
));
2564 bfa_trc(port
->fcs
, port
->fabric
->bb_credit
);
2566 port
->fabric
->bb_credit
= be16_to_cpu(plogi
->csp
.bbcred
);
2567 bfa_fcport_set_tx_bbcredit(port
->fcs
->bfa
,
2568 port
->fabric
->bb_credit
);
2574 * Called to handle LOGO received from an existing remote port.
2577 bfa_fcs_rport_process_logo(struct bfa_fcs_rport_s
*rport
, struct fchs_s
*fchs
)
2579 rport
->reply_oxid
= fchs
->ox_id
;
2580 bfa_trc(rport
->fcs
, rport
->reply_oxid
);
2582 rport
->prlo
= BFA_FALSE
;
2583 rport
->stats
.logo_rcvd
++;
2584 bfa_sm_send_event(rport
, RPSM_EVENT_LOGO_RCVD
);
2590 * fcs_rport_public FCS rport public interfaces
2594 * Called by bport/vport to create a remote port instance for a discovered
2597 * @param[in] port - base port or vport
2598 * @param[in] rpid - remote port ID
2602 struct bfa_fcs_rport_s
*
2603 bfa_fcs_rport_create(struct bfa_fcs_lport_s
*port
, u32 rpid
)
2605 struct bfa_fcs_rport_s
*rport
;
2607 bfa_trc(port
->fcs
, rpid
);
2608 rport
= bfa_fcs_rport_alloc(port
, WWN_NULL
, rpid
);
2612 bfa_sm_send_event(rport
, RPSM_EVENT_PLOGI_SEND
);
2617 * Called to create a rport for which only the wwn is known.
2619 * @param[in] port - base port
2620 * @param[in] rpwwn - remote port wwn
2624 struct bfa_fcs_rport_s
*
2625 bfa_fcs_rport_create_by_wwn(struct bfa_fcs_lport_s
*port
, wwn_t rpwwn
)
2627 struct bfa_fcs_rport_s
*rport
;
2628 bfa_trc(port
->fcs
, rpwwn
);
2629 rport
= bfa_fcs_rport_alloc(port
, rpwwn
, 0);
2633 bfa_sm_send_event(rport
, RPSM_EVENT_ADDRESS_DISC
);
2637 * Called by bport in private loop topology to indicate that a
2638 * rport has been discovered and plogi has been completed.
2640 * @param[in] port - base port or vport
2641 * @param[in] rpid - remote port ID
2644 bfa_fcs_rport_start(struct bfa_fcs_lport_s
*port
, struct fchs_s
*fchs
,
2645 struct fc_logi_s
*plogi
)
2647 struct bfa_fcs_rport_s
*rport
;
2649 rport
= bfa_fcs_rport_alloc(port
, WWN_NULL
, fchs
->s_id
);
2653 bfa_fcs_rport_update(rport
, plogi
);
2655 bfa_sm_send_event(rport
, RPSM_EVENT_PLOGI_COMP
);
2659 * Called by bport/vport to handle PLOGI received from a new remote port.
2660 * If an existing rport does a plogi, it will be handled separately.
2663 bfa_fcs_rport_plogi_create(struct bfa_fcs_lport_s
*port
, struct fchs_s
*fchs
,
2664 struct fc_logi_s
*plogi
)
2666 struct bfa_fcs_rport_s
*rport
;
2668 rport
= bfa_fcs_rport_alloc(port
, plogi
->port_name
, fchs
->s_id
);
2672 bfa_fcs_rport_update(rport
, plogi
);
2674 rport
->reply_oxid
= fchs
->ox_id
;
2675 bfa_trc(rport
->fcs
, rport
->reply_oxid
);
2677 rport
->stats
.plogi_rcvd
++;
2678 bfa_sm_send_event(rport
, RPSM_EVENT_PLOGI_RCVD
);
2682 * Called by bport/vport to handle PLOGI received from an existing
2686 bfa_fcs_rport_plogi(struct bfa_fcs_rport_s
*rport
, struct fchs_s
*rx_fchs
,
2687 struct fc_logi_s
*plogi
)
2690 * @todo Handle P2P and initiator-initiator.
2693 bfa_fcs_rport_update(rport
, plogi
);
2695 rport
->reply_oxid
= rx_fchs
->ox_id
;
2696 bfa_trc(rport
->fcs
, rport
->reply_oxid
);
2698 rport
->pid
= rx_fchs
->s_id
;
2699 bfa_trc(rport
->fcs
, rport
->pid
);
2701 rport
->stats
.plogi_rcvd
++;
2702 bfa_sm_send_event(rport
, RPSM_EVENT_PLOGI_RCVD
);
2707 * Called by bport/vport to notify SCN for the remote port
2710 bfa_fcs_rport_scn(struct bfa_fcs_rport_s
*rport
)
2712 rport
->stats
.rscns
++;
2713 bfa_sm_send_event(rport
, RPSM_EVENT_FAB_SCN
);
2718 * This routine BFA callback for bfa_rport_online() call.
2720 * param[in] cb_arg - rport struct.
2725 * Special Considerations:
2730 bfa_cb_rport_online(void *cbarg
)
2733 struct bfa_fcs_rport_s
*rport
= (struct bfa_fcs_rport_s
*) cbarg
;
2735 bfa_trc(rport
->fcs
, rport
->pwwn
);
2736 bfa_sm_send_event(rport
, RPSM_EVENT_HCB_ONLINE
);
2741 * This routine BFA callback for bfa_rport_offline() call.
2748 * Special Considerations:
2753 bfa_cb_rport_offline(void *cbarg
)
2755 struct bfa_fcs_rport_s
*rport
= (struct bfa_fcs_rport_s
*) cbarg
;
2757 bfa_trc(rport
->fcs
, rport
->pwwn
);
2758 bfa_sm_send_event(rport
, RPSM_EVENT_HCB_OFFLINE
);
2763 * This routine is a static BFA callback when there is a QoS flow_id
2764 * change notification
2771 * Special Considerations:
2776 bfa_cb_rport_qos_scn_flowid(void *cbarg
,
2777 struct bfa_rport_qos_attr_s old_qos_attr
,
2778 struct bfa_rport_qos_attr_s new_qos_attr
)
2780 struct bfa_fcs_rport_s
*rport
= (struct bfa_fcs_rport_s
*) cbarg
;
2781 struct bfa_rport_aen_data_s aen_data
;
2783 bfa_trc(rport
->fcs
, rport
->pwwn
);
2784 aen_data
.priv
.qos
= new_qos_attr
;
2785 bfa_fcs_rport_aen_post(rport
, BFA_RPORT_AEN_QOS_FLOWID
, &aen_data
);
2789 bfa_cb_rport_scn_online(struct bfa_s
*bfa
)
2791 struct bfa_fcs_s
*fcs
= &((struct bfad_s
*)bfa
->bfad
)->bfa_fcs
;
2792 struct bfa_fcs_lport_s
*port
= bfa_fcs_get_base_port(fcs
);
2793 struct bfa_fcs_rport_s
*rp
;
2794 struct list_head
*qe
;
2796 list_for_each(qe
, &port
->rport_q
) {
2797 rp
= (struct bfa_fcs_rport_s
*) qe
;
2798 bfa_sm_send_event(rp
, RPSM_EVENT_SCN_ONLINE
);
2799 rp
->scn_online
= BFA_TRUE
;
2802 if (bfa_fcs_lport_is_online(port
))
2803 bfa_fcs_lport_lip_scn_online(port
);
2807 bfa_cb_rport_scn_no_dev(void *rport
)
2809 struct bfa_fcs_rport_s
*rp
= rport
;
2811 bfa_sm_send_event(rp
, RPSM_EVENT_SCN_OFFLINE
);
2812 rp
->scn_online
= BFA_FALSE
;
2816 bfa_cb_rport_scn_offline(struct bfa_s
*bfa
)
2818 struct bfa_fcs_s
*fcs
= &((struct bfad_s
*)bfa
->bfad
)->bfa_fcs
;
2819 struct bfa_fcs_lport_s
*port
= bfa_fcs_get_base_port(fcs
);
2820 struct bfa_fcs_rport_s
*rp
;
2821 struct list_head
*qe
;
2823 list_for_each(qe
, &port
->rport_q
) {
2824 rp
= (struct bfa_fcs_rport_s
*) qe
;
2825 bfa_sm_send_event(rp
, RPSM_EVENT_SCN_OFFLINE
);
2826 rp
->scn_online
= BFA_FALSE
;
2832 * This routine is a static BFA callback when there is a QoS priority
2833 * change notification
2840 * Special Considerations:
2845 bfa_cb_rport_qos_scn_prio(void *cbarg
,
2846 struct bfa_rport_qos_attr_s old_qos_attr
,
2847 struct bfa_rport_qos_attr_s new_qos_attr
)
2849 struct bfa_fcs_rport_s
*rport
= (struct bfa_fcs_rport_s
*) cbarg
;
2850 struct bfa_rport_aen_data_s aen_data
;
2852 bfa_trc(rport
->fcs
, rport
->pwwn
);
2853 aen_data
.priv
.qos
= new_qos_attr
;
2854 bfa_fcs_rport_aen_post(rport
, BFA_RPORT_AEN_QOS_PRIO
, &aen_data
);
2858 * Called to process any unsolicted frames from this remote port
2861 bfa_fcs_rport_uf_recv(struct bfa_fcs_rport_s
*rport
,
2862 struct fchs_s
*fchs
, u16 len
)
2864 struct bfa_fcs_lport_s
*port
= rport
->port
;
2865 struct fc_els_cmd_s
*els_cmd
;
2867 bfa_trc(rport
->fcs
, fchs
->s_id
);
2868 bfa_trc(rport
->fcs
, fchs
->d_id
);
2869 bfa_trc(rport
->fcs
, fchs
->type
);
2871 if (fchs
->type
!= FC_TYPE_ELS
)
2874 els_cmd
= (struct fc_els_cmd_s
*) (fchs
+ 1);
2876 bfa_trc(rport
->fcs
, els_cmd
->els_code
);
2878 switch (els_cmd
->els_code
) {
2880 bfa_stats(port
, plogi_rcvd
);
2881 bfa_fcs_rport_process_logo(rport
, fchs
);
2885 bfa_stats(port
, adisc_rcvd
);
2886 bfa_fcs_rport_process_adisc(rport
, fchs
, len
);
2890 bfa_stats(port
, prlo_rcvd
);
2891 if (bfa_fcs_lport_is_initiator(port
))
2892 bfa_fcs_fcpim_uf_recv(rport
->itnim
, fchs
, len
);
2896 bfa_stats(port
, prli_rcvd
);
2897 bfa_fcs_rport_process_prli(rport
, fchs
, len
);
2901 bfa_stats(port
, rpsc_rcvd
);
2902 bfa_fcs_rport_process_rpsc(rport
, fchs
, len
);
2906 bfa_stats(port
, un_handled_els_rcvd
);
2907 bfa_fcs_rport_send_ls_rjt(rport
, fchs
,
2908 FC_LS_RJT_RSN_CMD_NOT_SUPP
,
2909 FC_LS_RJT_EXP_NO_ADDL_INFO
);
2914 /* send best case acc to prlo */
2916 bfa_fcs_rport_send_prlo_acc(struct bfa_fcs_rport_s
*rport
)
2918 struct bfa_fcs_lport_s
*port
= rport
->port
;
2920 struct bfa_fcxp_s
*fcxp
;
2923 bfa_trc(rport
->fcs
, rport
->pid
);
2925 fcxp
= bfa_fcs_fcxp_alloc(port
->fcs
, BFA_FALSE
);
2928 len
= fc_prlo_acc_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
2929 rport
->pid
, bfa_fcs_lport_get_fcid(port
),
2930 rport
->reply_oxid
, 0);
2932 bfa_fcxp_send(fcxp
, rport
->bfa_rport
, port
->fabric
->vf_id
,
2933 port
->lp_tag
, BFA_FALSE
, FC_CLASS_3
, len
, &fchs
,
2934 NULL
, NULL
, FC_MAX_PDUSZ
, 0);
2941 bfa_fcs_rport_send_ls_rjt(struct bfa_fcs_rport_s
*rport
, struct fchs_s
*rx_fchs
,
2942 u8 reason_code
, u8 reason_code_expl
)
2944 struct bfa_fcs_lport_s
*port
= rport
->port
;
2946 struct bfa_fcxp_s
*fcxp
;
2949 bfa_trc(rport
->fcs
, rx_fchs
->s_id
);
2951 fcxp
= bfa_fcs_fcxp_alloc(rport
->fcs
, BFA_FALSE
);
2955 len
= fc_ls_rjt_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
2956 rx_fchs
->s_id
, bfa_fcs_lport_get_fcid(port
),
2957 rx_fchs
->ox_id
, reason_code
, reason_code_expl
);
2959 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
,
2960 BFA_FALSE
, FC_CLASS_3
, len
, &fchs
, NULL
, NULL
,
2965 * Return state of rport.
2968 bfa_fcs_rport_get_state(struct bfa_fcs_rport_s
*rport
)
2970 return bfa_sm_to_state(rport_sm_table
, rport
->sm
);
2976 * Called by the Driver to set rport delete/ageout timeout
2978 * param[in] rport timeout value in seconds.
2983 bfa_fcs_rport_set_del_timeout(u8 rport_tmo
)
2985 /* convert to Millisecs */
2987 bfa_fcs_rport_del_timeout
= rport_tmo
* 1000;
2990 bfa_fcs_rport_prlo(struct bfa_fcs_rport_s
*rport
, __be16 ox_id
)
2992 bfa_trc(rport
->fcs
, rport
->pid
);
2994 rport
->prlo
= BFA_TRUE
;
2995 rport
->reply_oxid
= ox_id
;
2996 bfa_sm_send_event(rport
, RPSM_EVENT_PRLO_RCVD
);
3000 * Called by BFAD to set the max limit on number of bfa_fcs_rport allocation
3001 * which limits number of concurrent logins to remote ports
3004 bfa_fcs_rport_set_max_logins(u32 max_logins
)
3007 bfa_fcs_rport_max_logins
= max_logins
;
3011 bfa_fcs_rport_get_attr(struct bfa_fcs_rport_s
*rport
,
3012 struct bfa_rport_attr_s
*rport_attr
)
3014 struct bfa_rport_qos_attr_s qos_attr
;
3015 struct bfa_fcs_lport_s
*port
= rport
->port
;
3016 bfa_port_speed_t rport_speed
= rport
->rpf
.rpsc_speed
;
3017 struct bfa_port_attr_s port_attr
;
3019 bfa_fcport_get_attr(rport
->fcs
->bfa
, &port_attr
);
3021 memset(rport_attr
, 0, sizeof(struct bfa_rport_attr_s
));
3022 memset(&qos_attr
, 0, sizeof(struct bfa_rport_qos_attr_s
));
3024 rport_attr
->pid
= rport
->pid
;
3025 rport_attr
->pwwn
= rport
->pwwn
;
3026 rport_attr
->nwwn
= rport
->nwwn
;
3027 rport_attr
->cos_supported
= rport
->fc_cos
;
3028 rport_attr
->df_sz
= rport
->maxfrsize
;
3029 rport_attr
->state
= bfa_fcs_rport_get_state(rport
);
3030 rport_attr
->fc_cos
= rport
->fc_cos
;
3031 rport_attr
->cisc
= rport
->cisc
;
3032 rport_attr
->scsi_function
= rport
->scsi_function
;
3033 rport_attr
->curr_speed
= rport
->rpf
.rpsc_speed
;
3034 rport_attr
->assigned_speed
= rport
->rpf
.assigned_speed
;
3036 if (rport
->bfa_rport
) {
3037 qos_attr
.qos_priority
= rport
->bfa_rport
->qos_attr
.qos_priority
;
3038 qos_attr
.qos_flow_id
=
3039 cpu_to_be32(rport
->bfa_rport
->qos_attr
.qos_flow_id
);
3041 rport_attr
->qos_attr
= qos_attr
;
3043 rport_attr
->trl_enforced
= BFA_FALSE
;
3044 if (bfa_fcport_is_ratelim(port
->fcs
->bfa
) &&
3045 (rport
->scsi_function
== BFA_RPORT_TARGET
)) {
3046 if (rport_speed
== BFA_PORT_SPEED_UNKNOWN
)
3048 bfa_fcport_get_ratelim_speed(rport
->fcs
->bfa
);
3050 if ((bfa_fcs_lport_get_rport_max_speed(port
) !=
3051 BFA_PORT_SPEED_UNKNOWN
) && (rport_speed
< port_attr
.speed
))
3052 rport_attr
->trl_enforced
= BFA_TRUE
;
3057 * Remote port implementation.
3061 * fcs_rport_api FCS rport API.
3064 struct bfa_fcs_rport_s
*
3065 bfa_fcs_rport_lookup(struct bfa_fcs_lport_s
*port
, wwn_t rpwwn
)
3067 struct bfa_fcs_rport_s
*rport
;
3069 rport
= bfa_fcs_lport_get_rport_by_pwwn(port
, rpwwn
);
3070 if (rport
== NULL
) {
3072 * TBD Error handling
3079 struct bfa_fcs_rport_s
*
3080 bfa_fcs_rport_lookup_by_nwwn(struct bfa_fcs_lport_s
*port
, wwn_t rnwwn
)
3082 struct bfa_fcs_rport_s
*rport
;
3084 rport
= bfa_fcs_lport_get_rport_by_nwwn(port
, rnwwn
);
3085 if (rport
== NULL
) {
3087 * TBD Error handling
3095 * Remote port features (RPF) implementation.
3098 #define BFA_FCS_RPF_RETRIES (3)
3099 #define BFA_FCS_RPF_RETRY_TIMEOUT (1000) /* 1 sec (In millisecs) */
3101 static void bfa_fcs_rpf_send_rpsc2(void *rport_cbarg
,
3102 struct bfa_fcxp_s
*fcxp_alloced
);
3103 static void bfa_fcs_rpf_rpsc2_response(void *fcsarg
,
3104 struct bfa_fcxp_s
*fcxp
,
3106 bfa_status_t req_status
,
3109 struct fchs_s
*rsp_fchs
);
3111 static void bfa_fcs_rpf_timeout(void *arg
);
3114 * fcs_rport_ftrs_sm FCS rport state machine events
3118 RPFSM_EVENT_RPORT_OFFLINE
= 1, /* Rport offline */
3119 RPFSM_EVENT_RPORT_ONLINE
= 2, /* Rport online */
3120 RPFSM_EVENT_FCXP_SENT
= 3, /* Frame from has been sent */
3121 RPFSM_EVENT_TIMEOUT
= 4, /* Rport SM timeout event */
3122 RPFSM_EVENT_RPSC_COMP
= 5,
3123 RPFSM_EVENT_RPSC_FAIL
= 6,
3124 RPFSM_EVENT_RPSC_ERROR
= 7,
3127 static void bfa_fcs_rpf_sm_uninit(struct bfa_fcs_rpf_s
*rpf
,
3128 enum rpf_event event
);
3129 static void bfa_fcs_rpf_sm_rpsc_sending(struct bfa_fcs_rpf_s
*rpf
,
3130 enum rpf_event event
);
3131 static void bfa_fcs_rpf_sm_rpsc(struct bfa_fcs_rpf_s
*rpf
,
3132 enum rpf_event event
);
3133 static void bfa_fcs_rpf_sm_rpsc_retry(struct bfa_fcs_rpf_s
*rpf
,
3134 enum rpf_event event
);
3135 static void bfa_fcs_rpf_sm_offline(struct bfa_fcs_rpf_s
*rpf
,
3136 enum rpf_event event
);
3137 static void bfa_fcs_rpf_sm_online(struct bfa_fcs_rpf_s
*rpf
,
3138 enum rpf_event event
);
3141 bfa_fcs_rpf_sm_uninit(struct bfa_fcs_rpf_s
*rpf
, enum rpf_event event
)
3143 struct bfa_fcs_rport_s
*rport
= rpf
->rport
;
3144 struct bfa_fcs_fabric_s
*fabric
= &rport
->fcs
->fabric
;
3146 bfa_trc(rport
->fcs
, rport
->pwwn
);
3147 bfa_trc(rport
->fcs
, rport
->pid
);
3148 bfa_trc(rport
->fcs
, event
);
3151 case RPFSM_EVENT_RPORT_ONLINE
:
3152 /* Send RPSC2 to a Brocade fabric only. */
3153 if ((!BFA_FCS_PID_IS_WKA(rport
->pid
)) &&
3154 ((rport
->port
->fabric
->lps
->brcd_switch
) ||
3155 (bfa_fcs_fabric_get_switch_oui(fabric
) ==
3156 BFA_FCS_BRCD_SWITCH_OUI
))) {
3157 bfa_sm_set_state(rpf
, bfa_fcs_rpf_sm_rpsc_sending
);
3158 rpf
->rpsc_retries
= 0;
3159 bfa_fcs_rpf_send_rpsc2(rpf
, NULL
);
3163 case RPFSM_EVENT_RPORT_OFFLINE
:
3167 bfa_sm_fault(rport
->fcs
, event
);
3172 bfa_fcs_rpf_sm_rpsc_sending(struct bfa_fcs_rpf_s
*rpf
, enum rpf_event event
)
3174 struct bfa_fcs_rport_s
*rport
= rpf
->rport
;
3176 bfa_trc(rport
->fcs
, event
);
3179 case RPFSM_EVENT_FCXP_SENT
:
3180 bfa_sm_set_state(rpf
, bfa_fcs_rpf_sm_rpsc
);
3183 case RPFSM_EVENT_RPORT_OFFLINE
:
3184 bfa_sm_set_state(rpf
, bfa_fcs_rpf_sm_offline
);
3185 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rpf
->fcxp_wqe
);
3186 rpf
->rpsc_retries
= 0;
3190 bfa_sm_fault(rport
->fcs
, event
);
3195 bfa_fcs_rpf_sm_rpsc(struct bfa_fcs_rpf_s
*rpf
, enum rpf_event event
)
3197 struct bfa_fcs_rport_s
*rport
= rpf
->rport
;
3199 bfa_trc(rport
->fcs
, rport
->pid
);
3200 bfa_trc(rport
->fcs
, event
);
3203 case RPFSM_EVENT_RPSC_COMP
:
3204 bfa_sm_set_state(rpf
, bfa_fcs_rpf_sm_online
);
3205 /* Update speed info in f/w via BFA */
3206 if (rpf
->rpsc_speed
!= BFA_PORT_SPEED_UNKNOWN
)
3207 bfa_rport_speed(rport
->bfa_rport
, rpf
->rpsc_speed
);
3208 else if (rpf
->assigned_speed
!= BFA_PORT_SPEED_UNKNOWN
)
3209 bfa_rport_speed(rport
->bfa_rport
, rpf
->assigned_speed
);
3212 case RPFSM_EVENT_RPSC_FAIL
:
3213 /* RPSC not supported by rport */
3214 bfa_sm_set_state(rpf
, bfa_fcs_rpf_sm_online
);
3217 case RPFSM_EVENT_RPSC_ERROR
:
3218 /* need to retry...delayed a bit. */
3219 if (rpf
->rpsc_retries
++ < BFA_FCS_RPF_RETRIES
) {
3220 bfa_timer_start(rport
->fcs
->bfa
, &rpf
->timer
,
3221 bfa_fcs_rpf_timeout
, rpf
,
3222 BFA_FCS_RPF_RETRY_TIMEOUT
);
3223 bfa_sm_set_state(rpf
, bfa_fcs_rpf_sm_rpsc_retry
);
3225 bfa_sm_set_state(rpf
, bfa_fcs_rpf_sm_online
);
3229 case RPFSM_EVENT_RPORT_OFFLINE
:
3230 bfa_sm_set_state(rpf
, bfa_fcs_rpf_sm_offline
);
3231 bfa_fcxp_discard(rpf
->fcxp
);
3232 rpf
->rpsc_retries
= 0;
3236 bfa_sm_fault(rport
->fcs
, event
);
3241 bfa_fcs_rpf_sm_rpsc_retry(struct bfa_fcs_rpf_s
*rpf
, enum rpf_event event
)
3243 struct bfa_fcs_rport_s
*rport
= rpf
->rport
;
3245 bfa_trc(rport
->fcs
, rport
->pid
);
3246 bfa_trc(rport
->fcs
, event
);
3249 case RPFSM_EVENT_TIMEOUT
:
3250 /* re-send the RPSC */
3251 bfa_sm_set_state(rpf
, bfa_fcs_rpf_sm_rpsc_sending
);
3252 bfa_fcs_rpf_send_rpsc2(rpf
, NULL
);
3255 case RPFSM_EVENT_RPORT_OFFLINE
:
3256 bfa_timer_stop(&rpf
->timer
);
3257 bfa_sm_set_state(rpf
, bfa_fcs_rpf_sm_offline
);
3258 rpf
->rpsc_retries
= 0;
3262 bfa_sm_fault(rport
->fcs
, event
);
3267 bfa_fcs_rpf_sm_online(struct bfa_fcs_rpf_s
*rpf
, enum rpf_event event
)
3269 struct bfa_fcs_rport_s
*rport
= rpf
->rport
;
3271 bfa_trc(rport
->fcs
, rport
->pwwn
);
3272 bfa_trc(rport
->fcs
, rport
->pid
);
3273 bfa_trc(rport
->fcs
, event
);
3276 case RPFSM_EVENT_RPORT_OFFLINE
:
3277 bfa_sm_set_state(rpf
, bfa_fcs_rpf_sm_offline
);
3278 rpf
->rpsc_retries
= 0;
3282 bfa_sm_fault(rport
->fcs
, event
);
3287 bfa_fcs_rpf_sm_offline(struct bfa_fcs_rpf_s
*rpf
, enum rpf_event event
)
3289 struct bfa_fcs_rport_s
*rport
= rpf
->rport
;
3291 bfa_trc(rport
->fcs
, rport
->pwwn
);
3292 bfa_trc(rport
->fcs
, rport
->pid
);
3293 bfa_trc(rport
->fcs
, event
);
3296 case RPFSM_EVENT_RPORT_ONLINE
:
3297 bfa_sm_set_state(rpf
, bfa_fcs_rpf_sm_rpsc_sending
);
3298 bfa_fcs_rpf_send_rpsc2(rpf
, NULL
);
3301 case RPFSM_EVENT_RPORT_OFFLINE
:
3305 bfa_sm_fault(rport
->fcs
, event
);
3309 * Called when Rport is created.
3312 bfa_fcs_rpf_init(struct bfa_fcs_rport_s
*rport
)
3314 struct bfa_fcs_rpf_s
*rpf
= &rport
->rpf
;
3316 bfa_trc(rport
->fcs
, rport
->pid
);
3319 bfa_sm_set_state(rpf
, bfa_fcs_rpf_sm_uninit
);
3323 * Called when Rport becomes online
3326 bfa_fcs_rpf_rport_online(struct bfa_fcs_rport_s
*rport
)
3328 bfa_trc(rport
->fcs
, rport
->pid
);
3330 if (__fcs_min_cfg(rport
->port
->fcs
))
3333 if (bfa_fcs_fabric_is_switched(rport
->port
->fabric
))
3334 bfa_sm_send_event(&rport
->rpf
, RPFSM_EVENT_RPORT_ONLINE
);
3338 * Called when Rport becomes offline
3341 bfa_fcs_rpf_rport_offline(struct bfa_fcs_rport_s
*rport
)
3343 bfa_trc(rport
->fcs
, rport
->pid
);
3345 if (__fcs_min_cfg(rport
->port
->fcs
))
3348 rport
->rpf
.rpsc_speed
= 0;
3349 bfa_sm_send_event(&rport
->rpf
, RPFSM_EVENT_RPORT_OFFLINE
);
3353 bfa_fcs_rpf_timeout(void *arg
)
3355 struct bfa_fcs_rpf_s
*rpf
= (struct bfa_fcs_rpf_s
*) arg
;
3356 struct bfa_fcs_rport_s
*rport
= rpf
->rport
;
3358 bfa_trc(rport
->fcs
, rport
->pid
);
3359 bfa_sm_send_event(rpf
, RPFSM_EVENT_TIMEOUT
);
3363 bfa_fcs_rpf_send_rpsc2(void *rpf_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
3365 struct bfa_fcs_rpf_s
*rpf
= (struct bfa_fcs_rpf_s
*)rpf_cbarg
;
3366 struct bfa_fcs_rport_s
*rport
= rpf
->rport
;
3367 struct bfa_fcs_lport_s
*port
= rport
->port
;
3370 struct bfa_fcxp_s
*fcxp
;
3372 bfa_trc(rport
->fcs
, rport
->pwwn
);
3374 fcxp
= fcxp_alloced
? fcxp_alloced
:
3375 bfa_fcs_fcxp_alloc(port
->fcs
, BFA_TRUE
);
3377 bfa_fcs_fcxp_alloc_wait(port
->fcs
->bfa
, &rpf
->fcxp_wqe
,
3378 bfa_fcs_rpf_send_rpsc2
, rpf
, BFA_TRUE
);
3383 len
= fc_rpsc2_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
), rport
->pid
,
3384 bfa_fcs_lport_get_fcid(port
), &rport
->pid
, 1);
3386 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
3387 FC_CLASS_3
, len
, &fchs
, bfa_fcs_rpf_rpsc2_response
,
3388 rpf
, FC_MAX_PDUSZ
, FC_ELS_TOV
);
3389 rport
->stats
.rpsc_sent
++;
3390 bfa_sm_send_event(rpf
, RPFSM_EVENT_FCXP_SENT
);
3395 bfa_fcs_rpf_rpsc2_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
, void *cbarg
,
3396 bfa_status_t req_status
, u32 rsp_len
,
3397 u32 resid_len
, struct fchs_s
*rsp_fchs
)
3399 struct bfa_fcs_rpf_s
*rpf
= (struct bfa_fcs_rpf_s
*) cbarg
;
3400 struct bfa_fcs_rport_s
*rport
= rpf
->rport
;
3401 struct fc_ls_rjt_s
*ls_rjt
;
3402 struct fc_rpsc2_acc_s
*rpsc2_acc
;
3405 bfa_trc(rport
->fcs
, req_status
);
3407 if (req_status
!= BFA_STATUS_OK
) {
3408 bfa_trc(rport
->fcs
, req_status
);
3409 if (req_status
== BFA_STATUS_ETIMER
)
3410 rport
->stats
.rpsc_failed
++;
3411 bfa_sm_send_event(rpf
, RPFSM_EVENT_RPSC_ERROR
);
3415 rpsc2_acc
= (struct fc_rpsc2_acc_s
*) BFA_FCXP_RSP_PLD(fcxp
);
3416 if (rpsc2_acc
->els_cmd
== FC_ELS_ACC
) {
3417 rport
->stats
.rpsc_accs
++;
3418 num_ents
= be16_to_cpu(rpsc2_acc
->num_pids
);
3419 bfa_trc(rport
->fcs
, num_ents
);
3421 WARN_ON(be32_to_cpu(rpsc2_acc
->port_info
[0].pid
) !=
3422 bfa_ntoh3b(rport
->pid
));
3424 be32_to_cpu(rpsc2_acc
->port_info
[0].pid
));
3426 be16_to_cpu(rpsc2_acc
->port_info
[0].speed
));
3428 be16_to_cpu(rpsc2_acc
->port_info
[0].index
));
3430 rpsc2_acc
->port_info
[0].type
);
3432 if (rpsc2_acc
->port_info
[0].speed
== 0) {
3433 bfa_sm_send_event(rpf
, RPFSM_EVENT_RPSC_ERROR
);
3437 rpf
->rpsc_speed
= fc_rpsc_operspeed_to_bfa_speed(
3438 be16_to_cpu(rpsc2_acc
->port_info
[0].speed
));
3440 bfa_sm_send_event(rpf
, RPFSM_EVENT_RPSC_COMP
);
3443 ls_rjt
= (struct fc_ls_rjt_s
*) BFA_FCXP_RSP_PLD(fcxp
);
3444 bfa_trc(rport
->fcs
, ls_rjt
->reason_code
);
3445 bfa_trc(rport
->fcs
, ls_rjt
->reason_code_expl
);
3446 rport
->stats
.rpsc_rejects
++;
3447 if (ls_rjt
->reason_code
== FC_LS_RJT_RSN_CMD_NOT_SUPP
)
3448 bfa_sm_send_event(rpf
, RPFSM_EVENT_RPSC_FAIL
);
3450 bfa_sm_send_event(rpf
, RPFSM_EVENT_RPSC_ERROR
);