2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
6 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License (GPL) Version 2 as
10 * published by the Free Software Foundation
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
19 * rport.c Remote port implementation.
22 #include <linux/slab.h>
26 #include "fcs_vport.h"
27 #include "fcs_lport.h"
28 #include "fcs_rport.h"
29 #include "fcs_fcpim.h"
30 #include "fcs_fcptm.h"
31 #include "fcs_trcmod.h"
34 #include <fcb/bfa_fcb_rport.h>
35 #include <aen/bfa_aen_rport.h>
37 BFA_TRC_FILE(FCS
, RPORT
);
39 #define BFA_FCS_RPORT_MAX_RETRIES (5)
42 static u32 bfa_fcs_rport_del_timeout
=
43 BFA_FCS_RPORT_DEF_DEL_TIMEOUT
* 1000;
46 * forward declarations
48 static struct bfa_fcs_rport_s
*bfa_fcs_rport_alloc(struct bfa_fcs_port_s
*port
,
49 wwn_t pwwn
, u32 rpid
);
50 static void bfa_fcs_rport_free(struct bfa_fcs_rport_s
*rport
);
51 static void bfa_fcs_rport_hal_online(struct bfa_fcs_rport_s
*rport
);
52 static void bfa_fcs_rport_online_action(struct bfa_fcs_rport_s
*rport
);
53 static void bfa_fcs_rport_offline_action(struct bfa_fcs_rport_s
*rport
);
54 static void bfa_fcs_rport_update(struct bfa_fcs_rport_s
*rport
,
55 struct fc_logi_s
*plogi
);
56 static void bfa_fcs_rport_fc4_pause(struct bfa_fcs_rport_s
*rport
);
57 static void bfa_fcs_rport_fc4_resume(struct bfa_fcs_rport_s
*rport
);
58 static void bfa_fcs_rport_timeout(void *arg
);
59 static void bfa_fcs_rport_send_plogi(void *rport_cbarg
,
60 struct bfa_fcxp_s
*fcxp_alloced
);
61 static void bfa_fcs_rport_send_plogiacc(void *rport_cbarg
,
62 struct bfa_fcxp_s
*fcxp_alloced
);
63 static void bfa_fcs_rport_plogi_response(void *fcsarg
,
64 struct bfa_fcxp_s
*fcxp
,
66 bfa_status_t req_status
,
69 struct fchs_s
*rsp_fchs
);
70 static void bfa_fcs_rport_send_adisc(void *rport_cbarg
,
71 struct bfa_fcxp_s
*fcxp_alloced
);
72 static void bfa_fcs_rport_adisc_response(void *fcsarg
,
73 struct bfa_fcxp_s
*fcxp
,
75 bfa_status_t req_status
,
78 struct fchs_s
*rsp_fchs
);
79 static void bfa_fcs_rport_send_gidpn(void *rport_cbarg
,
80 struct bfa_fcxp_s
*fcxp_alloced
);
81 static void bfa_fcs_rport_gidpn_response(void *fcsarg
,
82 struct bfa_fcxp_s
*fcxp
,
84 bfa_status_t req_status
,
87 struct fchs_s
*rsp_fchs
);
88 static void bfa_fcs_rport_send_logo(void *rport_cbarg
,
89 struct bfa_fcxp_s
*fcxp_alloced
);
90 static void bfa_fcs_rport_send_logo_acc(void *rport_cbarg
);
91 static void bfa_fcs_rport_process_prli(struct bfa_fcs_rport_s
*rport
,
92 struct fchs_s
*rx_fchs
, u16 len
);
93 static void bfa_fcs_rport_send_ls_rjt(struct bfa_fcs_rport_s
*rport
,
94 struct fchs_s
*rx_fchs
, u8 reason_code
,
96 static void bfa_fcs_rport_process_adisc(struct bfa_fcs_rport_s
*rport
,
97 struct fchs_s
*rx_fchs
, u16 len
);
99 * fcs_rport_sm FCS rport state machine events
103 RPSM_EVENT_PLOGI_SEND
= 1, /* new rport; start with PLOGI */
104 RPSM_EVENT_PLOGI_RCVD
= 2, /* Inbound PLOGI from remote port */
105 RPSM_EVENT_PLOGI_COMP
= 3, /* PLOGI completed to rport */
106 RPSM_EVENT_LOGO_RCVD
= 4, /* LOGO from remote device */
107 RPSM_EVENT_LOGO_IMP
= 5, /* implicit logo for SLER */
108 RPSM_EVENT_FCXP_SENT
= 6, /* Frame from has been sent */
109 RPSM_EVENT_DELETE
= 7, /* RPORT delete request */
110 RPSM_EVENT_SCN
= 8, /* state change notification */
111 RPSM_EVENT_ACCEPTED
= 9,/* Good response from remote device */
112 RPSM_EVENT_FAILED
= 10, /* Request to rport failed. */
113 RPSM_EVENT_TIMEOUT
= 11, /* Rport SM timeout event */
114 RPSM_EVENT_HCB_ONLINE
= 12, /* BFA rport online callback */
115 RPSM_EVENT_HCB_OFFLINE
= 13, /* BFA rport offline callback */
116 RPSM_EVENT_FC4_OFFLINE
= 14, /* FC-4 offline complete */
117 RPSM_EVENT_ADDRESS_CHANGE
= 15, /* Rport's PID has changed */
118 RPSM_EVENT_ADDRESS_DISC
= 16 /* Need to Discover rport's PID */
121 static void bfa_fcs_rport_sm_uninit(struct bfa_fcs_rport_s
*rport
,
122 enum rport_event event
);
123 static void bfa_fcs_rport_sm_plogi_sending(struct bfa_fcs_rport_s
*rport
,
124 enum rport_event event
);
125 static void bfa_fcs_rport_sm_plogiacc_sending(struct bfa_fcs_rport_s
*rport
,
126 enum rport_event event
);
127 static void bfa_fcs_rport_sm_plogi_retry(struct bfa_fcs_rport_s
*rport
,
128 enum rport_event event
);
129 static void bfa_fcs_rport_sm_plogi(struct bfa_fcs_rport_s
*rport
,
130 enum rport_event event
);
131 static void bfa_fcs_rport_sm_hal_online(struct bfa_fcs_rport_s
*rport
,
132 enum rport_event event
);
133 static void bfa_fcs_rport_sm_online(struct bfa_fcs_rport_s
*rport
,
134 enum rport_event event
);
135 static void bfa_fcs_rport_sm_nsquery_sending(struct bfa_fcs_rport_s
*rport
,
136 enum rport_event event
);
137 static void bfa_fcs_rport_sm_nsquery(struct bfa_fcs_rport_s
*rport
,
138 enum rport_event event
);
139 static void bfa_fcs_rport_sm_adisc_sending(struct bfa_fcs_rport_s
*rport
,
140 enum rport_event event
);
141 static void bfa_fcs_rport_sm_adisc(struct bfa_fcs_rport_s
*rport
,
142 enum rport_event event
);
143 static void bfa_fcs_rport_sm_fc4_logorcv(struct bfa_fcs_rport_s
*rport
,
144 enum rport_event event
);
145 static void bfa_fcs_rport_sm_fc4_logosend(struct bfa_fcs_rport_s
*rport
,
146 enum rport_event event
);
147 static void bfa_fcs_rport_sm_fc4_offline(struct bfa_fcs_rport_s
*rport
,
148 enum rport_event event
);
149 static void bfa_fcs_rport_sm_hcb_offline(struct bfa_fcs_rport_s
*rport
,
150 enum rport_event event
);
151 static void bfa_fcs_rport_sm_hcb_logorcv(struct bfa_fcs_rport_s
*rport
,
152 enum rport_event event
);
153 static void bfa_fcs_rport_sm_hcb_logosend(struct bfa_fcs_rport_s
*rport
,
154 enum rport_event event
);
155 static void bfa_fcs_rport_sm_logo_sending(struct bfa_fcs_rport_s
*rport
,
156 enum rport_event event
);
157 static void bfa_fcs_rport_sm_offline(struct bfa_fcs_rport_s
*rport
,
158 enum rport_event event
);
159 static void bfa_fcs_rport_sm_nsdisc_sending(struct bfa_fcs_rport_s
*rport
,
160 enum rport_event event
);
161 static void bfa_fcs_rport_sm_nsdisc_retry(struct bfa_fcs_rport_s
*rport
,
162 enum rport_event event
);
163 static void bfa_fcs_rport_sm_nsdisc_sent(struct bfa_fcs_rport_s
*rport
,
164 enum rport_event event
);
165 static void bfa_fcs_rport_sm_nsdisc_sent(struct bfa_fcs_rport_s
*rport
,
166 enum rport_event event
);
168 static struct bfa_sm_table_s rport_sm_table
[] = {
169 {BFA_SM(bfa_fcs_rport_sm_uninit
), BFA_RPORT_UNINIT
},
170 {BFA_SM(bfa_fcs_rport_sm_plogi_sending
), BFA_RPORT_PLOGI
},
171 {BFA_SM(bfa_fcs_rport_sm_plogiacc_sending
), BFA_RPORT_ONLINE
},
172 {BFA_SM(bfa_fcs_rport_sm_plogi_retry
), BFA_RPORT_PLOGI_RETRY
},
173 {BFA_SM(bfa_fcs_rport_sm_plogi
), BFA_RPORT_PLOGI
},
174 {BFA_SM(bfa_fcs_rport_sm_hal_online
), BFA_RPORT_ONLINE
},
175 {BFA_SM(bfa_fcs_rport_sm_online
), BFA_RPORT_ONLINE
},
176 {BFA_SM(bfa_fcs_rport_sm_nsquery_sending
), BFA_RPORT_NSQUERY
},
177 {BFA_SM(bfa_fcs_rport_sm_nsquery
), BFA_RPORT_NSQUERY
},
178 {BFA_SM(bfa_fcs_rport_sm_adisc_sending
), BFA_RPORT_ADISC
},
179 {BFA_SM(bfa_fcs_rport_sm_adisc
), BFA_RPORT_ADISC
},
180 {BFA_SM(bfa_fcs_rport_sm_fc4_logorcv
), BFA_RPORT_LOGORCV
},
181 {BFA_SM(bfa_fcs_rport_sm_fc4_logosend
), BFA_RPORT_LOGO
},
182 {BFA_SM(bfa_fcs_rport_sm_fc4_offline
), BFA_RPORT_OFFLINE
},
183 {BFA_SM(bfa_fcs_rport_sm_hcb_offline
), BFA_RPORT_OFFLINE
},
184 {BFA_SM(bfa_fcs_rport_sm_hcb_logorcv
), BFA_RPORT_LOGORCV
},
185 {BFA_SM(bfa_fcs_rport_sm_hcb_logosend
), BFA_RPORT_LOGO
},
186 {BFA_SM(bfa_fcs_rport_sm_logo_sending
), BFA_RPORT_LOGO
},
187 {BFA_SM(bfa_fcs_rport_sm_offline
), BFA_RPORT_OFFLINE
},
188 {BFA_SM(bfa_fcs_rport_sm_nsdisc_sending
), BFA_RPORT_NSDISC
},
189 {BFA_SM(bfa_fcs_rport_sm_nsdisc_retry
), BFA_RPORT_NSDISC
},
190 {BFA_SM(bfa_fcs_rport_sm_nsdisc_sent
), BFA_RPORT_NSDISC
},
197 bfa_fcs_rport_sm_uninit(struct bfa_fcs_rport_s
*rport
, enum rport_event event
)
199 bfa_trc(rport
->fcs
, rport
->pwwn
);
200 bfa_trc(rport
->fcs
, rport
->pid
);
201 bfa_trc(rport
->fcs
, event
);
204 case RPSM_EVENT_PLOGI_SEND
:
205 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogi_sending
);
206 rport
->plogi_retries
= 0;
207 bfa_fcs_rport_send_plogi(rport
, NULL
);
210 case RPSM_EVENT_PLOGI_RCVD
:
211 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogiacc_sending
);
212 bfa_fcs_rport_send_plogiacc(rport
, NULL
);
215 case RPSM_EVENT_PLOGI_COMP
:
216 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_hal_online
);
217 bfa_fcs_rport_hal_online(rport
);
220 case RPSM_EVENT_ADDRESS_CHANGE
:
221 case RPSM_EVENT_ADDRESS_DISC
:
222 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_nsdisc_sending
);
223 rport
->ns_retries
= 0;
224 bfa_fcs_rport_send_gidpn(rport
, NULL
);
228 bfa_sm_fault(rport
->fcs
, event
);
233 * PLOGI is being sent.
236 bfa_fcs_rport_sm_plogi_sending(struct bfa_fcs_rport_s
*rport
,
237 enum rport_event event
)
239 bfa_trc(rport
->fcs
, rport
->pwwn
);
240 bfa_trc(rport
->fcs
, rport
->pid
);
241 bfa_trc(rport
->fcs
, event
);
244 case RPSM_EVENT_FCXP_SENT
:
245 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogi
);
248 case RPSM_EVENT_DELETE
:
249 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_uninit
);
250 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
251 bfa_fcs_rport_free(rport
);
254 case RPSM_EVENT_PLOGI_RCVD
:
255 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogiacc_sending
);
256 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
257 bfa_fcs_rport_send_plogiacc(rport
, NULL
);
260 case RPSM_EVENT_ADDRESS_CHANGE
:
261 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
262 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_nsdisc_sending
);
263 rport
->ns_retries
= 0;
264 bfa_fcs_rport_send_gidpn(rport
, NULL
);
267 case RPSM_EVENT_LOGO_IMP
:
269 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
270 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
271 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
272 bfa_fcs_rport_timeout
, rport
,
273 bfa_fcs_rport_del_timeout
);
280 bfa_sm_fault(rport
->fcs
, event
);
285 * PLOGI is being sent.
288 bfa_fcs_rport_sm_plogiacc_sending(struct bfa_fcs_rport_s
*rport
,
289 enum rport_event event
)
291 bfa_trc(rport
->fcs
, rport
->pwwn
);
292 bfa_trc(rport
->fcs
, rport
->pid
);
293 bfa_trc(rport
->fcs
, event
);
296 case RPSM_EVENT_FCXP_SENT
:
297 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_hal_online
);
298 bfa_fcs_rport_hal_online(rport
);
301 case RPSM_EVENT_DELETE
:
302 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_uninit
);
303 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
304 bfa_fcs_rport_free(rport
);
309 * Ignore, SCN is possibly online notification.
313 case RPSM_EVENT_ADDRESS_CHANGE
:
314 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
315 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_nsdisc_sending
);
316 rport
->ns_retries
= 0;
317 bfa_fcs_rport_send_gidpn(rport
, NULL
);
320 case RPSM_EVENT_LOGO_IMP
:
322 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
323 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
324 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
325 bfa_fcs_rport_timeout
, rport
,
326 bfa_fcs_rport_del_timeout
);
329 case RPSM_EVENT_HCB_OFFLINE
:
331 * Ignore BFA callback, on a PLOGI receive we call bfa offline.
336 bfa_sm_fault(rport
->fcs
, event
);
344 bfa_fcs_rport_sm_plogi_retry(struct bfa_fcs_rport_s
*rport
,
345 enum rport_event event
)
347 bfa_trc(rport
->fcs
, rport
->pwwn
);
348 bfa_trc(rport
->fcs
, rport
->pid
);
349 bfa_trc(rport
->fcs
, event
);
353 bfa_timer_stop(&rport
->timer
);
358 case RPSM_EVENT_TIMEOUT
:
359 rport
->plogi_retries
++;
360 if (rport
->plogi_retries
< BFA_FCS_RPORT_MAX_RETRIES
) {
361 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogi_sending
);
362 bfa_fcs_rport_send_plogi(rport
, NULL
);
365 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
366 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
367 bfa_fcs_rport_timeout
, rport
,
368 bfa_fcs_rport_del_timeout
);
372 case RPSM_EVENT_DELETE
:
373 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_uninit
);
374 bfa_timer_stop(&rport
->timer
);
375 bfa_fcs_rport_free(rport
);
378 case RPSM_EVENT_LOGO_RCVD
:
381 case RPSM_EVENT_PLOGI_RCVD
:
382 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogiacc_sending
);
383 bfa_timer_stop(&rport
->timer
);
384 bfa_fcs_rport_send_plogiacc(rport
, NULL
);
387 case RPSM_EVENT_ADDRESS_CHANGE
:
388 bfa_timer_stop(&rport
->timer
);
389 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_nsdisc_sending
);
390 rport
->ns_retries
= 0;
391 bfa_fcs_rport_send_gidpn(rport
, NULL
);
394 case RPSM_EVENT_LOGO_IMP
:
396 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
397 bfa_timer_stop(&rport
->timer
);
398 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
399 bfa_fcs_rport_timeout
, rport
,
400 bfa_fcs_rport_del_timeout
);
403 case RPSM_EVENT_PLOGI_COMP
:
404 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_hal_online
);
405 bfa_timer_stop(&rport
->timer
);
406 bfa_fcs_rport_hal_online(rport
);
410 bfa_sm_fault(rport
->fcs
, event
);
418 bfa_fcs_rport_sm_plogi(struct bfa_fcs_rport_s
*rport
, enum rport_event event
)
420 bfa_trc(rport
->fcs
, rport
->pwwn
);
421 bfa_trc(rport
->fcs
, rport
->pid
);
422 bfa_trc(rport
->fcs
, event
);
425 case RPSM_EVENT_ACCEPTED
:
426 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_hal_online
);
427 rport
->plogi_retries
= 0;
428 bfa_fcs_rport_hal_online(rport
);
431 case RPSM_EVENT_LOGO_RCVD
:
432 bfa_fcs_rport_send_logo_acc(rport
);
433 bfa_fcxp_discard(rport
->fcxp
);
437 case RPSM_EVENT_FAILED
:
438 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogi_retry
);
439 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
440 bfa_fcs_rport_timeout
, rport
,
441 BFA_FCS_RETRY_TIMEOUT
);
444 case RPSM_EVENT_LOGO_IMP
:
446 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
447 bfa_fcxp_discard(rport
->fcxp
);
448 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
449 bfa_fcs_rport_timeout
, rport
,
450 bfa_fcs_rport_del_timeout
);
453 case RPSM_EVENT_ADDRESS_CHANGE
:
454 bfa_fcxp_discard(rport
->fcxp
);
455 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_nsdisc_sending
);
456 rport
->ns_retries
= 0;
457 bfa_fcs_rport_send_gidpn(rport
, NULL
);
460 case RPSM_EVENT_PLOGI_RCVD
:
461 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogiacc_sending
);
462 bfa_fcxp_discard(rport
->fcxp
);
463 bfa_fcs_rport_send_plogiacc(rport
, NULL
);
468 * Ignore SCN - wait for PLOGI response.
472 case RPSM_EVENT_DELETE
:
473 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_uninit
);
474 bfa_fcxp_discard(rport
->fcxp
);
475 bfa_fcs_rport_free(rport
);
478 case RPSM_EVENT_PLOGI_COMP
:
479 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_hal_online
);
480 bfa_fcxp_discard(rport
->fcxp
);
481 bfa_fcs_rport_hal_online(rport
);
485 bfa_sm_fault(rport
->fcs
, event
);
490 * PLOGI is complete. Awaiting BFA rport online callback. FC-4s
494 bfa_fcs_rport_sm_hal_online(struct bfa_fcs_rport_s
*rport
,
495 enum rport_event event
)
497 bfa_trc(rport
->fcs
, rport
->pwwn
);
498 bfa_trc(rport
->fcs
, rport
->pid
);
499 bfa_trc(rport
->fcs
, event
);
502 case RPSM_EVENT_HCB_ONLINE
:
503 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_online
);
504 bfa_fcs_rport_online_action(rport
);
507 case RPSM_EVENT_LOGO_RCVD
:
508 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_hcb_logorcv
);
509 bfa_rport_offline(rport
->bfa_rport
);
512 case RPSM_EVENT_LOGO_IMP
:
513 case RPSM_EVENT_ADDRESS_CHANGE
:
514 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_hcb_offline
);
515 bfa_rport_offline(rport
->bfa_rport
);
518 case RPSM_EVENT_PLOGI_RCVD
:
519 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogiacc_sending
);
520 bfa_rport_offline(rport
->bfa_rport
);
521 bfa_fcs_rport_send_plogiacc(rport
, NULL
);
524 case RPSM_EVENT_DELETE
:
525 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_hcb_logosend
);
526 bfa_rport_offline(rport
->bfa_rport
);
532 * Ignore SCN - PLOGI just completed, FC-4 login should detect
538 bfa_sm_fault(rport
->fcs
, event
);
543 * Rport is ONLINE. FC-4s active.
546 bfa_fcs_rport_sm_online(struct bfa_fcs_rport_s
*rport
, enum rport_event event
)
548 bfa_trc(rport
->fcs
, rport
->pwwn
);
549 bfa_trc(rport
->fcs
, rport
->pid
);
550 bfa_trc(rport
->fcs
, event
);
555 * Pause FC-4 activity till rport is authenticated.
556 * In switched fabrics, check presence of device in nameserver
559 bfa_fcs_rport_fc4_pause(rport
);
561 if (bfa_fcs_fabric_is_switched(rport
->port
->fabric
)) {
562 bfa_sm_set_state(rport
,
563 bfa_fcs_rport_sm_nsquery_sending
);
564 rport
->ns_retries
= 0;
565 bfa_fcs_rport_send_gidpn(rport
, NULL
);
567 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_adisc_sending
);
568 bfa_fcs_rport_send_adisc(rport
, NULL
);
572 case RPSM_EVENT_PLOGI_RCVD
:
573 case RPSM_EVENT_LOGO_IMP
:
574 case RPSM_EVENT_ADDRESS_CHANGE
:
575 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_offline
);
576 bfa_fcs_rport_offline_action(rport
);
579 case RPSM_EVENT_DELETE
:
580 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_logosend
);
581 bfa_fcs_rport_offline_action(rport
);
584 case RPSM_EVENT_LOGO_RCVD
:
585 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_logorcv
);
586 bfa_fcs_rport_offline_action(rport
);
589 case RPSM_EVENT_PLOGI_COMP
:
593 bfa_sm_fault(rport
->fcs
, event
);
598 * An SCN event is received in ONLINE state. NS query is being sent
599 * prior to ADISC authentication with rport. FC-4s are paused.
602 bfa_fcs_rport_sm_nsquery_sending(struct bfa_fcs_rport_s
*rport
,
603 enum rport_event event
)
605 bfa_trc(rport
->fcs
, rport
->pwwn
);
606 bfa_trc(rport
->fcs
, rport
->pid
);
607 bfa_trc(rport
->fcs
, event
);
610 case RPSM_EVENT_FCXP_SENT
:
611 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_nsquery
);
614 case RPSM_EVENT_DELETE
:
615 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_logosend
);
616 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
617 bfa_fcs_rport_offline_action(rport
);
622 * ignore SCN, wait for response to query itself
626 case RPSM_EVENT_LOGO_RCVD
:
627 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_logorcv
);
628 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
629 bfa_fcs_rport_offline_action(rport
);
632 case RPSM_EVENT_LOGO_IMP
:
634 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
635 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
636 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
637 bfa_fcs_rport_timeout
, rport
,
638 bfa_fcs_rport_del_timeout
);
641 case RPSM_EVENT_PLOGI_RCVD
:
642 case RPSM_EVENT_ADDRESS_CHANGE
:
643 case RPSM_EVENT_PLOGI_COMP
:
644 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_offline
);
645 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
646 bfa_fcs_rport_offline_action(rport
);
650 bfa_sm_fault(rport
->fcs
, event
);
655 * An SCN event is received in ONLINE state. NS query is sent to rport.
659 bfa_fcs_rport_sm_nsquery(struct bfa_fcs_rport_s
*rport
, enum rport_event event
)
661 bfa_trc(rport
->fcs
, rport
->pwwn
);
662 bfa_trc(rport
->fcs
, rport
->pid
);
663 bfa_trc(rport
->fcs
, event
);
666 case RPSM_EVENT_ACCEPTED
:
667 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_adisc_sending
);
668 bfa_fcs_rport_send_adisc(rport
, NULL
);
671 case RPSM_EVENT_FAILED
:
673 if (rport
->ns_retries
< BFA_FCS_RPORT_MAX_RETRIES
) {
674 bfa_sm_set_state(rport
,
675 bfa_fcs_rport_sm_nsquery_sending
);
676 bfa_fcs_rport_send_gidpn(rport
, NULL
);
678 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_offline
);
679 bfa_fcs_rport_offline_action(rport
);
683 case RPSM_EVENT_DELETE
:
684 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_logosend
);
685 bfa_fcxp_discard(rport
->fcxp
);
686 bfa_fcs_rport_offline_action(rport
);
692 case RPSM_EVENT_LOGO_RCVD
:
693 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_logorcv
);
694 bfa_fcxp_discard(rport
->fcxp
);
695 bfa_fcs_rport_offline_action(rport
);
698 case RPSM_EVENT_PLOGI_COMP
:
699 case RPSM_EVENT_ADDRESS_CHANGE
:
700 case RPSM_EVENT_PLOGI_RCVD
:
701 case RPSM_EVENT_LOGO_IMP
:
702 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_offline
);
703 bfa_fcxp_discard(rport
->fcxp
);
704 bfa_fcs_rport_offline_action(rport
);
708 bfa_sm_fault(rport
->fcs
, event
);
713 * An SCN event is received in ONLINE state. ADISC is being sent for
714 * authenticating with rport. FC-4s are paused.
717 bfa_fcs_rport_sm_adisc_sending(struct bfa_fcs_rport_s
*rport
,
718 enum rport_event event
)
720 bfa_trc(rport
->fcs
, rport
->pwwn
);
721 bfa_trc(rport
->fcs
, rport
->pid
);
722 bfa_trc(rport
->fcs
, event
);
725 case RPSM_EVENT_FCXP_SENT
:
726 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_adisc
);
729 case RPSM_EVENT_DELETE
:
730 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_logosend
);
731 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
732 bfa_fcs_rport_offline_action(rport
);
735 case RPSM_EVENT_LOGO_IMP
:
736 case RPSM_EVENT_ADDRESS_CHANGE
:
737 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_offline
);
738 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
739 bfa_fcs_rport_offline_action(rport
);
742 case RPSM_EVENT_LOGO_RCVD
:
743 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_logorcv
);
744 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
745 bfa_fcs_rport_offline_action(rport
);
751 case RPSM_EVENT_PLOGI_RCVD
:
752 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_offline
);
753 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
754 bfa_fcs_rport_offline_action(rport
);
758 bfa_sm_fault(rport
->fcs
, event
);
763 * An SCN event is received in ONLINE state. ADISC is to rport.
767 bfa_fcs_rport_sm_adisc(struct bfa_fcs_rport_s
*rport
, enum rport_event event
)
769 bfa_trc(rport
->fcs
, rport
->pwwn
);
770 bfa_trc(rport
->fcs
, rport
->pid
);
771 bfa_trc(rport
->fcs
, event
);
774 case RPSM_EVENT_ACCEPTED
:
775 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_online
);
776 bfa_fcs_rport_fc4_resume(rport
);
779 case RPSM_EVENT_PLOGI_RCVD
:
781 * Too complex to cleanup FC-4 & rport and then acc to PLOGI.
782 * At least go offline when a PLOGI is received.
784 bfa_fcxp_discard(rport
->fcxp
);
786 * !!! fall through !!!
789 case RPSM_EVENT_FAILED
:
790 case RPSM_EVENT_ADDRESS_CHANGE
:
791 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_offline
);
792 bfa_fcs_rport_offline_action(rport
);
795 case RPSM_EVENT_DELETE
:
796 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_logosend
);
797 bfa_fcxp_discard(rport
->fcxp
);
798 bfa_fcs_rport_offline_action(rport
);
803 * already processing RSCN
807 case RPSM_EVENT_LOGO_IMP
:
808 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_offline
);
809 bfa_fcxp_discard(rport
->fcxp
);
810 bfa_fcs_rport_offline_action(rport
);
813 case RPSM_EVENT_LOGO_RCVD
:
814 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_logorcv
);
815 bfa_fcxp_discard(rport
->fcxp
);
816 bfa_fcs_rport_offline_action(rport
);
820 bfa_sm_fault(rport
->fcs
, event
);
825 * Rport has sent LOGO. Awaiting FC-4 offline completion callback.
828 bfa_fcs_rport_sm_fc4_logorcv(struct bfa_fcs_rport_s
*rport
,
829 enum rport_event event
)
831 bfa_trc(rport
->fcs
, rport
->pwwn
);
832 bfa_trc(rport
->fcs
, rport
->pid
);
833 bfa_trc(rport
->fcs
, event
);
836 case RPSM_EVENT_FC4_OFFLINE
:
837 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_hcb_logorcv
);
838 bfa_rport_offline(rport
->bfa_rport
);
841 case RPSM_EVENT_DELETE
:
842 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_logosend
);
845 case RPSM_EVENT_LOGO_RCVD
:
846 case RPSM_EVENT_ADDRESS_CHANGE
:
850 bfa_sm_fault(rport
->fcs
, event
);
855 * LOGO needs to be sent to rport. Awaiting FC-4 offline completion
859 bfa_fcs_rport_sm_fc4_logosend(struct bfa_fcs_rport_s
*rport
,
860 enum rport_event event
)
862 bfa_trc(rport
->fcs
, rport
->pwwn
);
863 bfa_trc(rport
->fcs
, rport
->pid
);
864 bfa_trc(rport
->fcs
, event
);
867 case RPSM_EVENT_FC4_OFFLINE
:
868 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_hcb_logosend
);
869 bfa_rport_offline(rport
->bfa_rport
);
873 bfa_sm_fault(rport
->fcs
, event
);
878 * Rport is going offline. Awaiting FC-4 offline completion callback.
881 bfa_fcs_rport_sm_fc4_offline(struct bfa_fcs_rport_s
*rport
,
882 enum rport_event event
)
884 bfa_trc(rport
->fcs
, rport
->pwwn
);
885 bfa_trc(rport
->fcs
, rport
->pid
);
886 bfa_trc(rport
->fcs
, event
);
889 case RPSM_EVENT_FC4_OFFLINE
:
890 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_hcb_offline
);
891 bfa_rport_offline(rport
->bfa_rport
);
895 case RPSM_EVENT_LOGO_IMP
:
896 case RPSM_EVENT_LOGO_RCVD
:
897 case RPSM_EVENT_ADDRESS_CHANGE
:
899 * rport is already going offline.
900 * SCN - ignore and wait till transitioning to offline state
904 case RPSM_EVENT_DELETE
:
905 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_fc4_logosend
);
909 bfa_sm_fault(rport
->fcs
, event
);
914 * Rport is offline. FC-4s are offline. Awaiting BFA rport offline
918 bfa_fcs_rport_sm_hcb_offline(struct bfa_fcs_rport_s
*rport
,
919 enum rport_event event
)
921 bfa_trc(rport
->fcs
, rport
->pwwn
);
922 bfa_trc(rport
->fcs
, rport
->pid
);
923 bfa_trc(rport
->fcs
, event
);
926 case RPSM_EVENT_HCB_OFFLINE
:
927 case RPSM_EVENT_ADDRESS_CHANGE
:
928 if (bfa_fcs_port_is_online(rport
->port
)) {
929 if (bfa_fcs_fabric_is_switched(rport
->port
->fabric
)) {
930 bfa_sm_set_state(rport
,
931 bfa_fcs_rport_sm_nsdisc_sending
);
932 rport
->ns_retries
= 0;
933 bfa_fcs_rport_send_gidpn(rport
, NULL
);
935 bfa_sm_set_state(rport
,
936 bfa_fcs_rport_sm_plogi_sending
);
937 rport
->plogi_retries
= 0;
938 bfa_fcs_rport_send_plogi(rport
, NULL
);
942 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
943 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
944 bfa_fcs_rport_timeout
, rport
,
945 bfa_fcs_rport_del_timeout
);
949 case RPSM_EVENT_DELETE
:
950 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_uninit
);
951 bfa_fcs_rport_free(rport
);
955 case RPSM_EVENT_LOGO_RCVD
:
957 * Ignore, already offline.
962 bfa_sm_fault(rport
->fcs
, event
);
967 * Rport is offline. FC-4s are offline. Awaiting BFA rport offline
968 * callback to send LOGO accept.
971 bfa_fcs_rport_sm_hcb_logorcv(struct bfa_fcs_rport_s
*rport
,
972 enum rport_event event
)
974 bfa_trc(rport
->fcs
, rport
->pwwn
);
975 bfa_trc(rport
->fcs
, rport
->pid
);
976 bfa_trc(rport
->fcs
, event
);
979 case RPSM_EVENT_HCB_OFFLINE
:
980 case RPSM_EVENT_ADDRESS_CHANGE
:
982 bfa_fcs_rport_send_logo_acc(rport
);
984 * If the lport is online and if the rport is not a well known
985 * address port, we try to re-discover the r-port.
987 if (bfa_fcs_port_is_online(rport
->port
)
988 && (!BFA_FCS_PID_IS_WKA(rport
->pid
))) {
989 bfa_sm_set_state(rport
,
990 bfa_fcs_rport_sm_nsdisc_sending
);
991 rport
->ns_retries
= 0;
992 bfa_fcs_rport_send_gidpn(rport
, NULL
);
995 * if it is not a well known address, reset the pid to
998 if (!BFA_FCS_PID_IS_WKA(rport
->pid
))
1000 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
1001 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
1002 bfa_fcs_rport_timeout
, rport
,
1003 bfa_fcs_rport_del_timeout
);
1007 case RPSM_EVENT_DELETE
:
1008 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_hcb_logosend
);
1011 case RPSM_EVENT_LOGO_IMP
:
1012 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_hcb_offline
);
1015 case RPSM_EVENT_LOGO_RCVD
:
1017 * Ignore - already processing a LOGO.
1022 bfa_sm_fault(rport
->fcs
, event
);
1027 * Rport is being deleted. FC-4s are offline. Awaiting BFA rport offline
1028 * callback to send LOGO.
1031 bfa_fcs_rport_sm_hcb_logosend(struct bfa_fcs_rport_s
*rport
,
1032 enum rport_event event
)
1034 bfa_trc(rport
->fcs
, rport
->pwwn
);
1035 bfa_trc(rport
->fcs
, rport
->pid
);
1036 bfa_trc(rport
->fcs
, event
);
1039 case RPSM_EVENT_HCB_OFFLINE
:
1040 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_logo_sending
);
1041 bfa_fcs_rport_send_logo(rport
, NULL
);
1044 case RPSM_EVENT_LOGO_RCVD
:
1045 case RPSM_EVENT_ADDRESS_CHANGE
:
1049 bfa_sm_fault(rport
->fcs
, event
);
1054 * Rport is being deleted. FC-4s are offline. LOGO is being sent.
1057 bfa_fcs_rport_sm_logo_sending(struct bfa_fcs_rport_s
*rport
,
1058 enum rport_event event
)
1060 bfa_trc(rport
->fcs
, rport
->pwwn
);
1061 bfa_trc(rport
->fcs
, rport
->pid
);
1062 bfa_trc(rport
->fcs
, event
);
1065 case RPSM_EVENT_FCXP_SENT
:
1067 * Once LOGO is sent, we donot wait for the response
1069 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_uninit
);
1070 bfa_fcs_rport_free(rport
);
1073 case RPSM_EVENT_SCN
:
1074 case RPSM_EVENT_ADDRESS_CHANGE
:
1077 case RPSM_EVENT_LOGO_RCVD
:
1078 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_uninit
);
1079 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
1080 bfa_fcs_rport_free(rport
);
1084 bfa_sm_fault(rport
->fcs
, event
);
1089 * Rport is offline. FC-4s are offline. BFA rport is offline.
1090 * Timer active to delete stale rport.
1093 bfa_fcs_rport_sm_offline(struct bfa_fcs_rport_s
*rport
, enum rport_event event
)
1095 bfa_trc(rport
->fcs
, rport
->pwwn
);
1096 bfa_trc(rport
->fcs
, rport
->pid
);
1097 bfa_trc(rport
->fcs
, event
);
1100 case RPSM_EVENT_TIMEOUT
:
1101 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_uninit
);
1102 bfa_fcs_rport_free(rport
);
1105 case RPSM_EVENT_SCN
:
1106 case RPSM_EVENT_ADDRESS_CHANGE
:
1107 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_nsdisc_sending
);
1108 bfa_timer_stop(&rport
->timer
);
1109 rport
->ns_retries
= 0;
1110 bfa_fcs_rport_send_gidpn(rport
, NULL
);
1113 case RPSM_EVENT_DELETE
:
1114 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_uninit
);
1115 bfa_timer_stop(&rport
->timer
);
1116 bfa_fcs_rport_free(rport
);
1119 case RPSM_EVENT_PLOGI_RCVD
:
1120 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogiacc_sending
);
1121 bfa_timer_stop(&rport
->timer
);
1122 bfa_fcs_rport_send_plogiacc(rport
, NULL
);
1125 case RPSM_EVENT_LOGO_RCVD
:
1126 case RPSM_EVENT_LOGO_IMP
:
1129 case RPSM_EVENT_PLOGI_COMP
:
1130 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_hal_online
);
1131 bfa_timer_stop(&rport
->timer
);
1132 bfa_fcs_rport_hal_online(rport
);
1135 case RPSM_EVENT_PLOGI_SEND
:
1136 bfa_timer_stop(&rport
->timer
);
1137 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogi_sending
);
1138 rport
->plogi_retries
= 0;
1139 bfa_fcs_rport_send_plogi(rport
, NULL
);
1143 bfa_sm_fault(rport
->fcs
, event
);
1148 * Rport address has changed. Nameserver discovery request is being sent.
1151 bfa_fcs_rport_sm_nsdisc_sending(struct bfa_fcs_rport_s
*rport
,
1152 enum rport_event event
)
1154 bfa_trc(rport
->fcs
, rport
->pwwn
);
1155 bfa_trc(rport
->fcs
, rport
->pid
);
1156 bfa_trc(rport
->fcs
, event
);
1159 case RPSM_EVENT_FCXP_SENT
:
1160 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_nsdisc_sent
);
1163 case RPSM_EVENT_DELETE
:
1164 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_uninit
);
1165 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
1166 bfa_fcs_rport_free(rport
);
1169 case RPSM_EVENT_PLOGI_RCVD
:
1170 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogiacc_sending
);
1171 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
1172 bfa_fcs_rport_send_plogiacc(rport
, NULL
);
1175 case RPSM_EVENT_SCN
:
1176 case RPSM_EVENT_LOGO_RCVD
:
1177 case RPSM_EVENT_PLOGI_SEND
:
1180 case RPSM_EVENT_ADDRESS_CHANGE
:
1181 rport
->ns_retries
= 0; /* reset the retry count */
1184 case RPSM_EVENT_LOGO_IMP
:
1185 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
1186 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
1187 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
1188 bfa_fcs_rport_timeout
, rport
,
1189 bfa_fcs_rport_del_timeout
);
1192 case RPSM_EVENT_PLOGI_COMP
:
1193 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_hal_online
);
1194 bfa_fcxp_walloc_cancel(rport
->fcs
->bfa
, &rport
->fcxp_wqe
);
1195 bfa_fcs_rport_hal_online(rport
);
1199 bfa_sm_fault(rport
->fcs
, event
);
1204 * Nameserver discovery failed. Waiting for timeout to retry.
1207 bfa_fcs_rport_sm_nsdisc_retry(struct bfa_fcs_rport_s
*rport
,
1208 enum rport_event event
)
1210 bfa_trc(rport
->fcs
, rport
->pwwn
);
1211 bfa_trc(rport
->fcs
, rport
->pid
);
1212 bfa_trc(rport
->fcs
, event
);
1215 case RPSM_EVENT_TIMEOUT
:
1216 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_nsdisc_sending
);
1217 bfa_fcs_rport_send_gidpn(rport
, NULL
);
1220 case RPSM_EVENT_SCN
:
1221 case RPSM_EVENT_ADDRESS_CHANGE
:
1222 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_nsdisc_sending
);
1223 bfa_timer_stop(&rport
->timer
);
1224 rport
->ns_retries
= 0;
1225 bfa_fcs_rport_send_gidpn(rport
, NULL
);
1228 case RPSM_EVENT_DELETE
:
1229 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_uninit
);
1230 bfa_timer_stop(&rport
->timer
);
1231 bfa_fcs_rport_free(rport
);
1234 case RPSM_EVENT_PLOGI_RCVD
:
1235 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogiacc_sending
);
1236 bfa_timer_stop(&rport
->timer
);
1237 bfa_fcs_rport_send_plogiacc(rport
, NULL
);
1240 case RPSM_EVENT_LOGO_IMP
:
1242 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
1243 bfa_timer_stop(&rport
->timer
);
1244 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
1245 bfa_fcs_rport_timeout
, rport
,
1246 bfa_fcs_rport_del_timeout
);
1249 case RPSM_EVENT_LOGO_RCVD
:
1250 bfa_fcs_rport_send_logo_acc(rport
);
1253 case RPSM_EVENT_PLOGI_COMP
:
1254 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_hal_online
);
1255 bfa_timer_stop(&rport
->timer
);
1256 bfa_fcs_rport_hal_online(rport
);
1260 bfa_sm_fault(rport
->fcs
, event
);
1265 * Rport address has changed. Nameserver discovery request is sent.
1268 bfa_fcs_rport_sm_nsdisc_sent(struct bfa_fcs_rport_s
*rport
,
1269 enum rport_event event
)
1271 bfa_trc(rport
->fcs
, rport
->pwwn
);
1272 bfa_trc(rport
->fcs
, rport
->pid
);
1273 bfa_trc(rport
->fcs
, event
);
1276 case RPSM_EVENT_ACCEPTED
:
1277 case RPSM_EVENT_ADDRESS_CHANGE
:
1279 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogi_sending
);
1280 bfa_fcs_rport_send_plogi(rport
, NULL
);
1282 bfa_sm_set_state(rport
,
1283 bfa_fcs_rport_sm_nsdisc_sending
);
1284 rport
->ns_retries
= 0;
1285 bfa_fcs_rport_send_gidpn(rport
, NULL
);
1289 case RPSM_EVENT_FAILED
:
1290 rport
->ns_retries
++;
1291 if (rport
->ns_retries
< BFA_FCS_RPORT_MAX_RETRIES
) {
1292 bfa_sm_set_state(rport
,
1293 bfa_fcs_rport_sm_nsdisc_sending
);
1294 bfa_fcs_rport_send_gidpn(rport
, NULL
);
1297 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
1298 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
1299 bfa_fcs_rport_timeout
, rport
,
1300 bfa_fcs_rport_del_timeout
);
1304 case RPSM_EVENT_DELETE
:
1305 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_uninit
);
1306 bfa_fcxp_discard(rport
->fcxp
);
1307 bfa_fcs_rport_free(rport
);
1310 case RPSM_EVENT_PLOGI_RCVD
:
1311 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_plogiacc_sending
);
1312 bfa_fcxp_discard(rport
->fcxp
);
1313 bfa_fcs_rport_send_plogiacc(rport
, NULL
);
1316 case RPSM_EVENT_LOGO_IMP
:
1318 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_offline
);
1319 bfa_fcxp_discard(rport
->fcxp
);
1320 bfa_timer_start(rport
->fcs
->bfa
, &rport
->timer
,
1321 bfa_fcs_rport_timeout
, rport
,
1322 bfa_fcs_rport_del_timeout
);
1325 case RPSM_EVENT_SCN
:
1327 * ignore, wait for NS query response
1331 case RPSM_EVENT_LOGO_RCVD
:
1333 * Not logged-in yet. Accept LOGO.
1335 bfa_fcs_rport_send_logo_acc(rport
);
1338 case RPSM_EVENT_PLOGI_COMP
:
1339 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_hal_online
);
1340 bfa_fcxp_discard(rport
->fcxp
);
1341 bfa_fcs_rport_hal_online(rport
);
1345 bfa_sm_fault(rport
->fcs
, event
);
1352 * fcs_rport_private FCS RPORT provate functions
1356 bfa_fcs_rport_send_plogi(void *rport_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
1358 struct bfa_fcs_rport_s
*rport
= rport_cbarg
;
1359 struct bfa_fcs_port_s
*port
= rport
->port
;
1362 struct bfa_fcxp_s
*fcxp
;
1364 bfa_trc(rport
->fcs
, rport
->pwwn
);
1366 fcxp
= fcxp_alloced
? fcxp_alloced
: bfa_fcs_fcxp_alloc(port
->fcs
);
1368 bfa_fcxp_alloc_wait(port
->fcs
->bfa
, &rport
->fcxp_wqe
,
1369 bfa_fcs_rport_send_plogi
, rport
);
1374 len
= fc_plogi_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
), rport
->pid
,
1375 bfa_fcs_port_get_fcid(port
), 0,
1376 port
->port_cfg
.pwwn
, port
->port_cfg
.nwwn
,
1377 bfa_fcport_get_maxfrsize(port
->fcs
->bfa
));
1379 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
1380 FC_CLASS_3
, len
, &fchs
, bfa_fcs_rport_plogi_response
,
1381 (void *)rport
, FC_MAX_PDUSZ
, FC_RA_TOV
);
1383 rport
->stats
.plogis
++;
1384 bfa_sm_send_event(rport
, RPSM_EVENT_FCXP_SENT
);
1388 bfa_fcs_rport_plogi_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
, void *cbarg
,
1389 bfa_status_t req_status
, u32 rsp_len
,
1390 u32 resid_len
, struct fchs_s
*rsp_fchs
)
1392 struct bfa_fcs_rport_s
*rport
= (struct bfa_fcs_rport_s
*)cbarg
;
1393 struct fc_logi_s
*plogi_rsp
;
1394 struct fc_ls_rjt_s
*ls_rjt
;
1395 struct bfa_fcs_rport_s
*twin
;
1396 struct list_head
*qe
;
1398 bfa_trc(rport
->fcs
, rport
->pwwn
);
1403 if (req_status
!= BFA_STATUS_OK
) {
1404 bfa_trc(rport
->fcs
, req_status
);
1405 rport
->stats
.plogi_failed
++;
1406 bfa_sm_send_event(rport
, RPSM_EVENT_FAILED
);
1410 plogi_rsp
= (struct fc_logi_s
*) BFA_FCXP_RSP_PLD(fcxp
);
1413 * Check for failure first.
1415 if (plogi_rsp
->els_cmd
.els_code
!= FC_ELS_ACC
) {
1416 ls_rjt
= (struct fc_ls_rjt_s
*) BFA_FCXP_RSP_PLD(fcxp
);
1418 bfa_trc(rport
->fcs
, ls_rjt
->reason_code
);
1419 bfa_trc(rport
->fcs
, ls_rjt
->reason_code_expl
);
1421 rport
->stats
.plogi_rejects
++;
1422 bfa_sm_send_event(rport
, RPSM_EVENT_FAILED
);
1427 * PLOGI is complete. Make sure this device is not one of the known
1428 * device with a new FC port address.
1430 list_for_each(qe
, &rport
->port
->rport_q
) {
1431 twin
= (struct bfa_fcs_rport_s
*)qe
;
1434 if (!rport
->pwwn
&& (plogi_rsp
->port_name
== twin
->pwwn
)) {
1435 bfa_trc(rport
->fcs
, twin
->pid
);
1436 bfa_trc(rport
->fcs
, rport
->pid
);
1439 * Update plogi stats in twin
1441 twin
->stats
.plogis
+= rport
->stats
.plogis
;
1442 twin
->stats
.plogi_rejects
+= rport
->stats
.plogi_rejects
;
1443 twin
->stats
.plogi_timeouts
+=
1444 rport
->stats
.plogi_timeouts
;
1445 twin
->stats
.plogi_failed
+= rport
->stats
.plogi_failed
;
1446 twin
->stats
.plogi_rcvd
+= rport
->stats
.plogi_rcvd
;
1447 twin
->stats
.plogi_accs
++;
1449 bfa_fcs_rport_delete(rport
);
1451 bfa_fcs_rport_update(twin
, plogi_rsp
);
1452 twin
->pid
= rsp_fchs
->s_id
;
1453 bfa_sm_send_event(twin
, RPSM_EVENT_PLOGI_COMP
);
1459 * Normal login path -- no evil twins.
1461 rport
->stats
.plogi_accs
++;
1462 bfa_fcs_rport_update(rport
, plogi_rsp
);
1463 bfa_sm_send_event(rport
, RPSM_EVENT_ACCEPTED
);
1467 bfa_fcs_rport_send_plogiacc(void *rport_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
1469 struct bfa_fcs_rport_s
*rport
= rport_cbarg
;
1470 struct bfa_fcs_port_s
*port
= rport
->port
;
1473 struct bfa_fcxp_s
*fcxp
;
1475 bfa_trc(rport
->fcs
, rport
->pwwn
);
1476 bfa_trc(rport
->fcs
, rport
->reply_oxid
);
1478 fcxp
= fcxp_alloced
? fcxp_alloced
: bfa_fcs_fcxp_alloc(port
->fcs
);
1480 bfa_fcxp_alloc_wait(port
->fcs
->bfa
, &rport
->fcxp_wqe
,
1481 bfa_fcs_rport_send_plogiacc
, rport
);
1486 len
= fc_plogi_acc_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
), rport
->pid
,
1487 bfa_fcs_port_get_fcid(port
), rport
->reply_oxid
,
1488 port
->port_cfg
.pwwn
, port
->port_cfg
.nwwn
,
1489 bfa_fcport_get_maxfrsize(port
->fcs
->bfa
));
1491 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
1492 FC_CLASS_3
, len
, &fchs
, NULL
, NULL
, FC_MAX_PDUSZ
, 0);
1494 bfa_sm_send_event(rport
, RPSM_EVENT_FCXP_SENT
);
1498 bfa_fcs_rport_send_adisc(void *rport_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
1500 struct bfa_fcs_rport_s
*rport
= rport_cbarg
;
1501 struct bfa_fcs_port_s
*port
= rport
->port
;
1504 struct bfa_fcxp_s
*fcxp
;
1506 bfa_trc(rport
->fcs
, rport
->pwwn
);
1508 fcxp
= fcxp_alloced
? fcxp_alloced
: bfa_fcs_fcxp_alloc(port
->fcs
);
1510 bfa_fcxp_alloc_wait(port
->fcs
->bfa
, &rport
->fcxp_wqe
,
1511 bfa_fcs_rport_send_adisc
, rport
);
1516 len
= fc_adisc_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
), rport
->pid
,
1517 bfa_fcs_port_get_fcid(port
), 0,
1518 port
->port_cfg
.pwwn
, port
->port_cfg
.nwwn
);
1520 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
1521 FC_CLASS_3
, len
, &fchs
, bfa_fcs_rport_adisc_response
,
1522 rport
, FC_MAX_PDUSZ
, FC_RA_TOV
);
1524 rport
->stats
.adisc_sent
++;
1525 bfa_sm_send_event(rport
, RPSM_EVENT_FCXP_SENT
);
1529 bfa_fcs_rport_adisc_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
, void *cbarg
,
1530 bfa_status_t req_status
, u32 rsp_len
,
1531 u32 resid_len
, struct fchs_s
*rsp_fchs
)
1533 struct bfa_fcs_rport_s
*rport
= (struct bfa_fcs_rport_s
*)cbarg
;
1534 void *pld
= bfa_fcxp_get_rspbuf(fcxp
);
1535 struct fc_ls_rjt_s
*ls_rjt
;
1537 if (req_status
!= BFA_STATUS_OK
) {
1538 bfa_trc(rport
->fcs
, req_status
);
1539 rport
->stats
.adisc_failed
++;
1540 bfa_sm_send_event(rport
, RPSM_EVENT_FAILED
);
1544 if (fc_adisc_rsp_parse((struct fc_adisc_s
*)pld
, rsp_len
, rport
->pwwn
,
1545 rport
->nwwn
) == FC_PARSE_OK
) {
1546 rport
->stats
.adisc_accs
++;
1547 bfa_sm_send_event(rport
, RPSM_EVENT_ACCEPTED
);
1551 rport
->stats
.adisc_rejects
++;
1553 bfa_trc(rport
->fcs
, ls_rjt
->els_cmd
.els_code
);
1554 bfa_trc(rport
->fcs
, ls_rjt
->reason_code
);
1555 bfa_trc(rport
->fcs
, ls_rjt
->reason_code_expl
);
1556 bfa_sm_send_event(rport
, RPSM_EVENT_FAILED
);
1560 bfa_fcs_rport_send_gidpn(void *rport_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
1562 struct bfa_fcs_rport_s
*rport
= rport_cbarg
;
1563 struct bfa_fcs_port_s
*port
= rport
->port
;
1565 struct bfa_fcxp_s
*fcxp
;
1568 bfa_trc(rport
->fcs
, rport
->pid
);
1570 fcxp
= fcxp_alloced
? fcxp_alloced
: bfa_fcs_fcxp_alloc(port
->fcs
);
1572 bfa_fcxp_alloc_wait(port
->fcs
->bfa
, &rport
->fcxp_wqe
,
1573 bfa_fcs_rport_send_gidpn
, rport
);
1578 len
= fc_gidpn_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
1579 bfa_fcs_port_get_fcid(port
), 0, rport
->pwwn
);
1581 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
1582 FC_CLASS_3
, len
, &fchs
, bfa_fcs_rport_gidpn_response
,
1583 (void *)rport
, FC_MAX_PDUSZ
, FC_RA_TOV
);
1585 bfa_sm_send_event(rport
, RPSM_EVENT_FCXP_SENT
);
1589 bfa_fcs_rport_gidpn_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
, void *cbarg
,
1590 bfa_status_t req_status
, u32 rsp_len
,
1591 u32 resid_len
, struct fchs_s
*rsp_fchs
)
1593 struct bfa_fcs_rport_s
*rport
= (struct bfa_fcs_rport_s
*)cbarg
;
1594 struct bfa_fcs_rport_s
*twin
;
1595 struct list_head
*qe
;
1596 struct ct_hdr_s
*cthdr
;
1597 struct fcgs_gidpn_resp_s
*gidpn_rsp
;
1599 bfa_trc(rport
->fcs
, rport
->pwwn
);
1601 cthdr
= (struct ct_hdr_s
*) BFA_FCXP_RSP_PLD(fcxp
);
1602 cthdr
->cmd_rsp_code
= bfa_os_ntohs(cthdr
->cmd_rsp_code
);
1604 if (cthdr
->cmd_rsp_code
== CT_RSP_ACCEPT
) {
1606 * Check if the pid is the same as before.
1608 gidpn_rsp
= (struct fcgs_gidpn_resp_s
*) (cthdr
+ 1);
1610 if (gidpn_rsp
->dap
== rport
->pid
) {
1614 bfa_sm_send_event(rport
, RPSM_EVENT_ACCEPTED
);
1617 * Device's PID has changed. We need to cleanup and
1618 * re-login. If there is another device with the the
1619 * newly discovered pid, send an scn notice so that its
1620 * new pid can be discovered.
1622 list_for_each(qe
, &rport
->port
->rport_q
) {
1623 twin
= (struct bfa_fcs_rport_s
*)qe
;
1626 if (gidpn_rsp
->dap
== twin
->pid
) {
1627 bfa_trc(rport
->fcs
, twin
->pid
);
1628 bfa_trc(rport
->fcs
, rport
->pid
);
1631 bfa_sm_send_event(twin
,
1632 RPSM_EVENT_ADDRESS_CHANGE
);
1635 rport
->pid
= gidpn_rsp
->dap
;
1636 bfa_sm_send_event(rport
, RPSM_EVENT_ADDRESS_CHANGE
);
1644 switch (cthdr
->reason_code
) {
1645 case CT_RSN_LOGICAL_BUSY
:
1649 bfa_sm_send_event(rport
, RPSM_EVENT_TIMEOUT
);
1652 case CT_RSN_UNABLE_TO_PERF
:
1654 * device doesn't exist : Start timer to cleanup this later.
1656 bfa_sm_send_event(rport
, RPSM_EVENT_FAILED
);
1660 bfa_sm_send_event(rport
, RPSM_EVENT_FAILED
);
1666 * Called to send a logout to the rport.
1669 bfa_fcs_rport_send_logo(void *rport_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
1671 struct bfa_fcs_rport_s
*rport
= rport_cbarg
;
1672 struct bfa_fcs_port_s
*port
;
1674 struct bfa_fcxp_s
*fcxp
;
1677 bfa_trc(rport
->fcs
, rport
->pid
);
1681 fcxp
= fcxp_alloced
? fcxp_alloced
: bfa_fcs_fcxp_alloc(port
->fcs
);
1683 bfa_fcxp_alloc_wait(port
->fcs
->bfa
, &rport
->fcxp_wqe
,
1684 bfa_fcs_rport_send_logo
, rport
);
1689 len
= fc_logo_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
), rport
->pid
,
1690 bfa_fcs_port_get_fcid(port
), 0,
1691 bfa_fcs_port_get_pwwn(port
));
1693 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
1694 FC_CLASS_3
, len
, &fchs
, NULL
, rport
, FC_MAX_PDUSZ
,
1697 rport
->stats
.logos
++;
1698 bfa_fcxp_discard(rport
->fcxp
);
1699 bfa_sm_send_event(rport
, RPSM_EVENT_FCXP_SENT
);
1703 * Send ACC for a LOGO received.
1706 bfa_fcs_rport_send_logo_acc(void *rport_cbarg
)
1708 struct bfa_fcs_rport_s
*rport
= rport_cbarg
;
1709 struct bfa_fcs_port_s
*port
;
1711 struct bfa_fcxp_s
*fcxp
;
1714 bfa_trc(rport
->fcs
, rport
->pid
);
1718 fcxp
= bfa_fcs_fcxp_alloc(port
->fcs
);
1722 rport
->stats
.logo_rcvd
++;
1723 len
= fc_logo_acc_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
), rport
->pid
,
1724 bfa_fcs_port_get_fcid(port
), rport
->reply_oxid
);
1726 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
1727 FC_CLASS_3
, len
, &fchs
, NULL
, NULL
, FC_MAX_PDUSZ
, 0);
1731 * This routine will be called by bfa_timer on timer timeouts.
1733 * param[in] rport - pointer to bfa_fcs_port_ns_t.
1734 * param[out] rport_status - pointer to return vport status in
1739 * Special Considerations:
1744 bfa_fcs_rport_timeout(void *arg
)
1746 struct bfa_fcs_rport_s
*rport
= (struct bfa_fcs_rport_s
*)arg
;
1748 rport
->stats
.plogi_timeouts
++;
1749 bfa_sm_send_event(rport
, RPSM_EVENT_TIMEOUT
);
1753 bfa_fcs_rport_process_prli(struct bfa_fcs_rport_s
*rport
,
1754 struct fchs_s
*rx_fchs
, u16 len
)
1756 struct bfa_fcxp_s
*fcxp
;
1758 struct bfa_fcs_port_s
*port
= rport
->port
;
1759 struct fc_prli_s
*prli
;
1761 bfa_trc(port
->fcs
, rx_fchs
->s_id
);
1762 bfa_trc(port
->fcs
, rx_fchs
->d_id
);
1764 rport
->stats
.prli_rcvd
++;
1766 if (BFA_FCS_VPORT_IS_TARGET_MODE(port
)) {
1768 * Target Mode : Let the fcptm handle it
1770 bfa_fcs_tin_rx_prli(rport
->tin
, rx_fchs
, len
);
1775 * We are either in Initiator or ipfc Mode
1777 prli
= (struct fc_prli_s
*) (rx_fchs
+ 1);
1779 if (prli
->parampage
.servparams
.initiator
) {
1780 bfa_trc(rport
->fcs
, prli
->parampage
.type
);
1781 rport
->scsi_function
= BFA_RPORT_INITIATOR
;
1782 bfa_fcs_itnim_is_initiator(rport
->itnim
);
1785 * @todo: PRLI from a target ?
1787 bfa_trc(port
->fcs
, rx_fchs
->s_id
);
1788 rport
->scsi_function
= BFA_RPORT_TARGET
;
1791 fcxp
= bfa_fcs_fcxp_alloc(port
->fcs
);
1795 len
= fc_prli_acc_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
), rx_fchs
->s_id
,
1796 bfa_fcs_port_get_fcid(port
), rx_fchs
->ox_id
,
1797 port
->port_cfg
.roles
);
1799 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
1800 FC_CLASS_3
, len
, &fchs
, NULL
, NULL
, FC_MAX_PDUSZ
, 0);
1804 bfa_fcs_rport_process_rpsc(struct bfa_fcs_rport_s
*rport
,
1805 struct fchs_s
*rx_fchs
, u16 len
)
1807 struct bfa_fcxp_s
*fcxp
;
1809 struct bfa_fcs_port_s
*port
= rport
->port
;
1810 struct fc_rpsc_speed_info_s speeds
;
1811 struct bfa_pport_attr_s pport_attr
;
1813 bfa_trc(port
->fcs
, rx_fchs
->s_id
);
1814 bfa_trc(port
->fcs
, rx_fchs
->d_id
);
1816 rport
->stats
.rpsc_rcvd
++;
1817 speeds
.port_speed_cap
=
1818 RPSC_SPEED_CAP_1G
| RPSC_SPEED_CAP_2G
| RPSC_SPEED_CAP_4G
|
1822 * get curent speed from pport attributes from BFA
1824 bfa_fcport_get_attr(port
->fcs
->bfa
, &pport_attr
);
1826 speeds
.port_op_speed
= fc_bfa_speed_to_rpsc_operspeed(pport_attr
.speed
);
1828 fcxp
= bfa_fcs_fcxp_alloc(port
->fcs
);
1832 len
= fc_rpsc_acc_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
), rx_fchs
->s_id
,
1833 bfa_fcs_port_get_fcid(port
), rx_fchs
->ox_id
,
1836 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
1837 FC_CLASS_3
, len
, &fchs
, NULL
, NULL
, FC_MAX_PDUSZ
, 0);
1841 bfa_fcs_rport_process_adisc(struct bfa_fcs_rport_s
*rport
,
1842 struct fchs_s
*rx_fchs
, u16 len
)
1844 struct bfa_fcxp_s
*fcxp
;
1846 struct bfa_fcs_port_s
*port
= rport
->port
;
1847 struct fc_adisc_s
*adisc
;
1849 bfa_trc(port
->fcs
, rx_fchs
->s_id
);
1850 bfa_trc(port
->fcs
, rx_fchs
->d_id
);
1852 rport
->stats
.adisc_rcvd
++;
1854 if (BFA_FCS_VPORT_IS_TARGET_MODE(port
)) {
1856 * @todo : Target Mode handling
1858 bfa_trc(port
->fcs
, rx_fchs
->d_id
);
1863 adisc
= (struct fc_adisc_s
*) (rx_fchs
+ 1);
1866 * Accept if the itnim for this rport is online. Else reject the ADISC
1868 if (bfa_fcs_itnim_get_online_state(rport
->itnim
) == BFA_STATUS_OK
) {
1870 fcxp
= bfa_fcs_fcxp_alloc(port
->fcs
);
1874 len
= fc_adisc_acc_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
),
1876 bfa_fcs_port_get_fcid(port
),
1877 rx_fchs
->ox_id
, port
->port_cfg
.pwwn
,
1878 port
->port_cfg
.nwwn
);
1880 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
,
1881 BFA_FALSE
, FC_CLASS_3
, len
, &fchs
, NULL
, NULL
,
1884 rport
->stats
.adisc_rejected
++;
1885 bfa_fcs_rport_send_ls_rjt(rport
, rx_fchs
,
1886 FC_LS_RJT_RSN_UNABLE_TO_PERF_CMD
,
1887 FC_LS_RJT_EXP_LOGIN_REQUIRED
);
1893 bfa_fcs_rport_hal_online(struct bfa_fcs_rport_s
*rport
)
1895 struct bfa_fcs_port_s
*port
= rport
->port
;
1896 struct bfa_rport_info_s rport_info
;
1898 rport_info
.pid
= rport
->pid
;
1899 rport_info
.local_pid
= port
->pid
;
1900 rport_info
.lp_tag
= port
->lp_tag
;
1901 rport_info
.vf_id
= port
->fabric
->vf_id
;
1902 rport_info
.vf_en
= port
->fabric
->is_vf
;
1903 rport_info
.fc_class
= rport
->fc_cos
;
1904 rport_info
.cisc
= rport
->cisc
;
1905 rport_info
.max_frmsz
= rport
->maxfrsize
;
1906 bfa_rport_online(rport
->bfa_rport
, &rport_info
);
1910 bfa_fcs_rport_fc4_pause(struct bfa_fcs_rport_s
*rport
)
1912 if (bfa_fcs_port_is_initiator(rport
->port
))
1913 bfa_fcs_itnim_pause(rport
->itnim
);
1915 if (bfa_fcs_port_is_target(rport
->port
))
1916 bfa_fcs_tin_pause(rport
->tin
);
1920 bfa_fcs_rport_fc4_resume(struct bfa_fcs_rport_s
*rport
)
1922 if (bfa_fcs_port_is_initiator(rport
->port
))
1923 bfa_fcs_itnim_resume(rport
->itnim
);
1925 if (bfa_fcs_port_is_target(rport
->port
))
1926 bfa_fcs_tin_resume(rport
->tin
);
1929 static struct bfa_fcs_rport_s
*
1930 bfa_fcs_rport_alloc(struct bfa_fcs_port_s
*port
, wwn_t pwwn
, u32 rpid
)
1932 struct bfa_fcs_s
*fcs
= port
->fcs
;
1933 struct bfa_fcs_rport_s
*rport
;
1934 struct bfad_rport_s
*rport_drv
;
1939 if (bfa_fcb_rport_alloc(fcs
->bfad
, &rport
, &rport_drv
)
1950 rport
->rp_drv
= rport_drv
;
1955 * allocate BFA rport
1957 rport
->bfa_rport
= bfa_rport_create(port
->fcs
->bfa
, rport
);
1958 if (!rport
->bfa_rport
) {
1967 bfa_assert(bfa_fcs_port_is_initiator(port
) ^
1968 bfa_fcs_port_is_target(port
));
1970 if (bfa_fcs_port_is_initiator(port
)) {
1971 rport
->itnim
= bfa_fcs_itnim_create(rport
);
1972 if (!rport
->itnim
) {
1974 bfa_rport_delete(rport
->bfa_rport
);
1980 if (bfa_fcs_port_is_target(port
)) {
1981 rport
->tin
= bfa_fcs_tin_create(rport
);
1984 bfa_rport_delete(rport
->bfa_rport
);
1990 bfa_fcs_port_add_rport(port
, rport
);
1992 bfa_sm_set_state(rport
, bfa_fcs_rport_sm_uninit
);
1995 * Initialize the Rport Features(RPF) Sub Module
1997 if (!BFA_FCS_PID_IS_WKA(rport
->pid
))
1998 bfa_fcs_rpf_init(rport
);
2005 bfa_fcs_rport_free(struct bfa_fcs_rport_s
*rport
)
2007 struct bfa_fcs_port_s
*port
= rport
->port
;
2011 * - delete BFA rport
2012 * - remove from queue of rports
2014 if (bfa_fcs_port_is_initiator(port
))
2015 bfa_fcs_itnim_delete(rport
->itnim
);
2017 if (bfa_fcs_port_is_target(port
))
2018 bfa_fcs_tin_delete(rport
->tin
);
2020 bfa_rport_delete(rport
->bfa_rport
);
2021 bfa_fcs_port_del_rport(port
, rport
);
2022 kfree(rport
->rp_drv
);
2026 bfa_fcs_rport_aen_post(struct bfa_fcs_rport_s
*rport
,
2027 enum bfa_rport_aen_event event
,
2028 struct bfa_rport_aen_data_s
*data
)
2030 union bfa_aen_data_u aen_data
;
2031 struct bfa_log_mod_s
*logmod
= rport
->fcs
->logm
;
2032 wwn_t lpwwn
= bfa_fcs_port_get_pwwn(rport
->port
);
2033 wwn_t rpwwn
= rport
->pwwn
;
2034 char lpwwn_ptr
[BFA_STRING_32
];
2035 char rpwwn_ptr
[BFA_STRING_32
];
2036 char *prio_str
[] = { "unknown", "high", "medium", "low" };
2038 wwn2str(lpwwn_ptr
, lpwwn
);
2039 wwn2str(rpwwn_ptr
, rpwwn
);
2042 case BFA_RPORT_AEN_ONLINE
:
2043 case BFA_RPORT_AEN_OFFLINE
:
2044 case BFA_RPORT_AEN_DISCONNECT
:
2045 bfa_log(logmod
, BFA_LOG_CREATE_ID(BFA_AEN_CAT_RPORT
, event
),
2046 rpwwn_ptr
, lpwwn_ptr
);
2048 case BFA_RPORT_AEN_QOS_PRIO
:
2049 aen_data
.rport
.priv
.qos
= data
->priv
.qos
;
2050 bfa_log(logmod
, BFA_AEN_RPORT_QOS_PRIO
,
2051 prio_str
[aen_data
.rport
.priv
.qos
.qos_priority
],
2052 rpwwn_ptr
, lpwwn_ptr
);
2054 case BFA_RPORT_AEN_QOS_FLOWID
:
2055 aen_data
.rport
.priv
.qos
= data
->priv
.qos
;
2056 bfa_log(logmod
, BFA_AEN_RPORT_QOS_FLOWID
,
2057 aen_data
.rport
.priv
.qos
.qos_flow_id
, rpwwn_ptr
,
2064 aen_data
.rport
.vf_id
= rport
->port
->fabric
->vf_id
;
2065 aen_data
.rport
.ppwwn
=
2066 bfa_fcs_port_get_pwwn(bfa_fcs_get_base_port(rport
->fcs
));
2067 aen_data
.rport
.lpwwn
= lpwwn
;
2068 aen_data
.rport
.rpwwn
= rpwwn
;
2072 bfa_fcs_rport_online_action(struct bfa_fcs_rport_s
*rport
)
2074 struct bfa_fcs_port_s
*port
= rport
->port
;
2076 rport
->stats
.onlines
++;
2078 if (bfa_fcs_port_is_initiator(port
)) {
2079 bfa_fcs_itnim_rport_online(rport
->itnim
);
2080 if (!BFA_FCS_PID_IS_WKA(rport
->pid
))
2081 bfa_fcs_rpf_rport_online(rport
);
2084 if (bfa_fcs_port_is_target(port
))
2085 bfa_fcs_tin_rport_online(rport
->tin
);
2088 * Don't post events for well known addresses
2090 if (!BFA_FCS_PID_IS_WKA(rport
->pid
))
2091 bfa_fcs_rport_aen_post(rport
, BFA_RPORT_AEN_ONLINE
, NULL
);
2095 bfa_fcs_rport_offline_action(struct bfa_fcs_rport_s
*rport
)
2097 struct bfa_fcs_port_s
*port
= rport
->port
;
2099 rport
->stats
.offlines
++;
2102 * Don't post events for well known addresses
2104 if (!BFA_FCS_PID_IS_WKA(rport
->pid
)) {
2105 if (bfa_fcs_port_is_online(rport
->port
) == BFA_TRUE
) {
2106 bfa_fcs_rport_aen_post(rport
, BFA_RPORT_AEN_DISCONNECT
,
2109 bfa_fcs_rport_aen_post(rport
, BFA_RPORT_AEN_OFFLINE
,
2114 if (bfa_fcs_port_is_initiator(port
)) {
2115 bfa_fcs_itnim_rport_offline(rport
->itnim
);
2116 if (!BFA_FCS_PID_IS_WKA(rport
->pid
))
2117 bfa_fcs_rpf_rport_offline(rport
);
2120 if (bfa_fcs_port_is_target(port
))
2121 bfa_fcs_tin_rport_offline(rport
->tin
);
2125 * Update rport parameters from PLOGI or PLOGI accept.
2128 bfa_fcs_rport_update(struct bfa_fcs_rport_s
*rport
, struct fc_logi_s
*plogi
)
2130 struct bfa_fcs_port_s
*port
= rport
->port
;
2136 rport
->pwwn
= plogi
->port_name
;
2137 rport
->nwwn
= plogi
->node_name
;
2140 * - class of service
2143 if (plogi
->class3
.class_valid
)
2144 rport
->fc_cos
= FC_CLASS_3
;
2146 if (plogi
->class2
.class_valid
)
2147 rport
->fc_cos
|= FC_CLASS_2
;
2151 * - MAX receive frame size
2153 rport
->cisc
= plogi
->csp
.cisc
;
2154 rport
->maxfrsize
= bfa_os_ntohs(plogi
->class3
.rxsz
);
2156 bfa_trc(port
->fcs
, bfa_os_ntohs(plogi
->csp
.bbcred
));
2157 bfa_trc(port
->fcs
, port
->fabric
->bb_credit
);
2159 * Direct Attach P2P mode :
2160 * This is to handle a bug (233476) in IBM targets in Direct Attach
2161 * Mode. Basically, in FLOGI Accept the target would have erroneously
2162 * set the BB Credit to the value used in the FLOGI sent by the HBA.
2163 * It uses the correct value (its own BB credit) in PLOGI.
2165 if ((!bfa_fcs_fabric_is_switched(port
->fabric
))
2166 && (bfa_os_ntohs(plogi
->csp
.bbcred
) < port
->fabric
->bb_credit
)) {
2168 bfa_trc(port
->fcs
, bfa_os_ntohs(plogi
->csp
.bbcred
));
2169 bfa_trc(port
->fcs
, port
->fabric
->bb_credit
);
2171 port
->fabric
->bb_credit
= bfa_os_ntohs(plogi
->csp
.bbcred
);
2172 bfa_fcport_set_tx_bbcredit(port
->fcs
->bfa
,
2173 port
->fabric
->bb_credit
);
2179 * Called to handle LOGO received from an existing remote port.
2182 bfa_fcs_rport_process_logo(struct bfa_fcs_rport_s
*rport
, struct fchs_s
*fchs
)
2184 rport
->reply_oxid
= fchs
->ox_id
;
2185 bfa_trc(rport
->fcs
, rport
->reply_oxid
);
2187 rport
->stats
.logo_rcvd
++;
2188 bfa_sm_send_event(rport
, RPSM_EVENT_LOGO_RCVD
);
2194 * fcs_rport_public FCS rport public interfaces
2198 * Called by bport/vport to create a remote port instance for a discovered
2201 * @param[in] port - base port or vport
2202 * @param[in] rpid - remote port ID
2206 struct bfa_fcs_rport_s
*
2207 bfa_fcs_rport_create(struct bfa_fcs_port_s
*port
, u32 rpid
)
2209 struct bfa_fcs_rport_s
*rport
;
2211 bfa_trc(port
->fcs
, rpid
);
2212 rport
= bfa_fcs_rport_alloc(port
, WWN_NULL
, rpid
);
2216 bfa_sm_send_event(rport
, RPSM_EVENT_PLOGI_SEND
);
2221 * Called to create a rport for which only the wwn is known.
2223 * @param[in] port - base port
2224 * @param[in] rpwwn - remote port wwn
2228 struct bfa_fcs_rport_s
*
2229 bfa_fcs_rport_create_by_wwn(struct bfa_fcs_port_s
*port
, wwn_t rpwwn
)
2231 struct bfa_fcs_rport_s
*rport
;
2233 bfa_trc(port
->fcs
, rpwwn
);
2234 rport
= bfa_fcs_rport_alloc(port
, rpwwn
, 0);
2238 bfa_sm_send_event(rport
, RPSM_EVENT_ADDRESS_DISC
);
2243 * Called by bport in private loop topology to indicate that a
2244 * rport has been discovered and plogi has been completed.
2246 * @param[in] port - base port or vport
2247 * @param[in] rpid - remote port ID
2250 bfa_fcs_rport_start(struct bfa_fcs_port_s
*port
, struct fchs_s
*fchs
,
2251 struct fc_logi_s
*plogi
)
2253 struct bfa_fcs_rport_s
*rport
;
2255 rport
= bfa_fcs_rport_alloc(port
, WWN_NULL
, fchs
->s_id
);
2259 bfa_fcs_rport_update(rport
, plogi
);
2261 bfa_sm_send_event(rport
, RPSM_EVENT_PLOGI_COMP
);
2265 * Called by bport/vport to handle PLOGI received from a new remote port.
2266 * If an existing rport does a plogi, it will be handled separately.
2269 bfa_fcs_rport_plogi_create(struct bfa_fcs_port_s
*port
, struct fchs_s
*fchs
,
2270 struct fc_logi_s
*plogi
)
2272 struct bfa_fcs_rport_s
*rport
;
2274 rport
= bfa_fcs_rport_alloc(port
, plogi
->port_name
, fchs
->s_id
);
2278 bfa_fcs_rport_update(rport
, plogi
);
2280 rport
->reply_oxid
= fchs
->ox_id
;
2281 bfa_trc(rport
->fcs
, rport
->reply_oxid
);
2283 rport
->stats
.plogi_rcvd
++;
2284 bfa_sm_send_event(rport
, RPSM_EVENT_PLOGI_RCVD
);
2288 wwn_compare(wwn_t wwn1
, wwn_t wwn2
)
2290 u8
*b1
= (u8
*) &wwn1
;
2291 u8
*b2
= (u8
*) &wwn2
;
2294 for (i
= 0; i
< sizeof(wwn_t
); i
++) {
2304 * Called by bport/vport to handle PLOGI received from an existing
2308 bfa_fcs_rport_plogi(struct bfa_fcs_rport_s
*rport
, struct fchs_s
*rx_fchs
,
2309 struct fc_logi_s
*plogi
)
2312 * @todo Handle P2P and initiator-initiator.
2315 bfa_fcs_rport_update(rport
, plogi
);
2317 rport
->reply_oxid
= rx_fchs
->ox_id
;
2318 bfa_trc(rport
->fcs
, rport
->reply_oxid
);
2321 * In Switched fabric topology,
2322 * PLOGI to each other. If our pwwn is smaller, ignore it,
2323 * if it is not a well known address.
2324 * If the link topology is N2N,
2325 * this Plogi should be accepted.
2327 if ((wwn_compare(rport
->port
->port_cfg
.pwwn
, rport
->pwwn
) == -1)
2328 && (bfa_fcs_fabric_is_switched(rport
->port
->fabric
))
2329 && (!BFA_FCS_PID_IS_WKA(rport
->pid
))) {
2330 bfa_trc(rport
->fcs
, rport
->pid
);
2334 rport
->stats
.plogi_rcvd
++;
2335 bfa_sm_send_event(rport
, RPSM_EVENT_PLOGI_RCVD
);
2339 * Called by bport/vport to delete a remote port instance.
2341 * Rport delete is called under the following conditions:
2342 * - vport is deleted
2344 * - explicit request from OS to delete rport (vmware)
2347 bfa_fcs_rport_delete(struct bfa_fcs_rport_s
*rport
)
2349 bfa_sm_send_event(rport
, RPSM_EVENT_DELETE
);
2353 * Called by bport/vport to when a target goes offline.
2357 bfa_fcs_rport_offline(struct bfa_fcs_rport_s
*rport
)
2359 bfa_sm_send_event(rport
, RPSM_EVENT_LOGO_IMP
);
2363 * Called by bport in n2n when a target (attached port) becomes online.
2367 bfa_fcs_rport_online(struct bfa_fcs_rport_s
*rport
)
2369 bfa_sm_send_event(rport
, RPSM_EVENT_PLOGI_SEND
);
2373 * Called by bport/vport to notify SCN for the remote port
2376 bfa_fcs_rport_scn(struct bfa_fcs_rport_s
*rport
)
2379 rport
->stats
.rscns
++;
2380 bfa_sm_send_event(rport
, RPSM_EVENT_SCN
);
2384 * Called by fcpim to notify that the ITN cleanup is done.
2387 bfa_fcs_rport_itnim_ack(struct bfa_fcs_rport_s
*rport
)
2389 bfa_sm_send_event(rport
, RPSM_EVENT_FC4_OFFLINE
);
2393 * Called by fcptm to notify that the ITN cleanup is done.
2396 bfa_fcs_rport_tin_ack(struct bfa_fcs_rport_s
*rport
)
2398 bfa_sm_send_event(rport
, RPSM_EVENT_FC4_OFFLINE
);
2402 * This routine BFA callback for bfa_rport_online() call.
2404 * param[in] cb_arg - rport struct.
2409 * Special Considerations:
2414 bfa_cb_rport_online(void *cbarg
)
2417 struct bfa_fcs_rport_s
*rport
= (struct bfa_fcs_rport_s
*)cbarg
;
2419 bfa_trc(rport
->fcs
, rport
->pwwn
);
2420 bfa_sm_send_event(rport
, RPSM_EVENT_HCB_ONLINE
);
2424 * This routine BFA callback for bfa_rport_offline() call.
2431 * Special Considerations:
2436 bfa_cb_rport_offline(void *cbarg
)
2438 struct bfa_fcs_rport_s
*rport
= (struct bfa_fcs_rport_s
*)cbarg
;
2440 bfa_trc(rport
->fcs
, rport
->pwwn
);
2441 bfa_sm_send_event(rport
, RPSM_EVENT_HCB_OFFLINE
);
2445 * This routine is a static BFA callback when there is a QoS flow_id
2446 * change notification
2448 * @param[in] rport -
2452 * Special Considerations:
2457 bfa_cb_rport_qos_scn_flowid(void *cbarg
,
2458 struct bfa_rport_qos_attr_s old_qos_attr
,
2459 struct bfa_rport_qos_attr_s new_qos_attr
)
2461 struct bfa_fcs_rport_s
*rport
= (struct bfa_fcs_rport_s
*)cbarg
;
2462 struct bfa_rport_aen_data_s aen_data
;
2464 bfa_trc(rport
->fcs
, rport
->pwwn
);
2465 aen_data
.priv
.qos
= new_qos_attr
;
2466 bfa_fcs_rport_aen_post(rport
, BFA_RPORT_AEN_QOS_FLOWID
, &aen_data
);
2470 * This routine is a static BFA callback when there is a QoS priority
2471 * change notification
2473 * @param[in] rport -
2477 * Special Considerations:
2482 bfa_cb_rport_qos_scn_prio(void *cbarg
, struct bfa_rport_qos_attr_s old_qos_attr
,
2483 struct bfa_rport_qos_attr_s new_qos_attr
)
2485 struct bfa_fcs_rport_s
*rport
= (struct bfa_fcs_rport_s
*)cbarg
;
2486 struct bfa_rport_aen_data_s aen_data
;
2488 bfa_trc(rport
->fcs
, rport
->pwwn
);
2489 aen_data
.priv
.qos
= new_qos_attr
;
2490 bfa_fcs_rport_aen_post(rport
, BFA_RPORT_AEN_QOS_PRIO
, &aen_data
);
2494 * Called to process any unsolicted frames from this remote port
2497 bfa_fcs_rport_logo_imp(struct bfa_fcs_rport_s
*rport
)
2499 bfa_sm_send_event(rport
, RPSM_EVENT_LOGO_IMP
);
2503 * Called to process any unsolicted frames from this remote port
2506 bfa_fcs_rport_uf_recv(struct bfa_fcs_rport_s
*rport
, struct fchs_s
*fchs
,
2509 struct bfa_fcs_port_s
*port
= rport
->port
;
2510 struct fc_els_cmd_s
*els_cmd
;
2512 bfa_trc(rport
->fcs
, fchs
->s_id
);
2513 bfa_trc(rport
->fcs
, fchs
->d_id
);
2514 bfa_trc(rport
->fcs
, fchs
->type
);
2516 if (fchs
->type
!= FC_TYPE_ELS
)
2519 els_cmd
= (struct fc_els_cmd_s
*) (fchs
+ 1);
2521 bfa_trc(rport
->fcs
, els_cmd
->els_code
);
2523 switch (els_cmd
->els_code
) {
2525 bfa_fcs_rport_process_logo(rport
, fchs
);
2529 bfa_fcs_rport_process_adisc(rport
, fchs
, len
);
2533 if (bfa_fcs_port_is_initiator(port
))
2534 bfa_fcs_fcpim_uf_recv(rport
->itnim
, fchs
, len
);
2536 if (bfa_fcs_port_is_target(port
))
2537 bfa_fcs_fcptm_uf_recv(rport
->tin
, fchs
, len
);
2541 bfa_fcs_rport_process_prli(rport
, fchs
, len
);
2545 bfa_fcs_rport_process_rpsc(rport
, fchs
, len
);
2549 bfa_fcs_rport_send_ls_rjt(rport
, fchs
,
2550 FC_LS_RJT_RSN_CMD_NOT_SUPP
,
2551 FC_LS_RJT_EXP_NO_ADDL_INFO
);
2560 bfa_fcs_rport_send_ls_rjt(struct bfa_fcs_rport_s
*rport
, struct fchs_s
*rx_fchs
,
2561 u8 reason_code
, u8 reason_code_expl
)
2563 struct bfa_fcs_port_s
*port
= rport
->port
;
2565 struct bfa_fcxp_s
*fcxp
;
2568 bfa_trc(rport
->fcs
, rx_fchs
->s_id
);
2570 fcxp
= bfa_fcs_fcxp_alloc(rport
->fcs
);
2574 len
= fc_ls_rjt_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
), rx_fchs
->s_id
,
2575 bfa_fcs_port_get_fcid(port
), rx_fchs
->ox_id
,
2576 reason_code
, reason_code_expl
);
2578 bfa_fcxp_send(fcxp
, NULL
, port
->fabric
->vf_id
, port
->lp_tag
, BFA_FALSE
,
2579 FC_CLASS_3
, len
, &fchs
, NULL
, NULL
, FC_MAX_PDUSZ
, 0);
2583 * Return state of rport.
2586 bfa_fcs_rport_get_state(struct bfa_fcs_rport_s
*rport
)
2588 return bfa_sm_to_state(rport_sm_table
, rport
->sm
);
2592 * Called by the Driver to set rport delete/ageout timeout
2594 * param[in] rport timeout value in seconds.
2599 bfa_fcs_rport_set_del_timeout(u8 rport_tmo
)
2602 * convert to Millisecs
2605 bfa_fcs_rport_del_timeout
= rport_tmo
* 1000;