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 * fcpim.c - FCP initiator mode i-t nexus state machine
24 #include "fcs_fcpim.h"
25 #include "fcs_rport.h"
26 #include "fcs_lport.h"
27 #include "fcs_trcmod.h"
30 #include <fcs/bfa_fcs_fcpim.h>
31 #include <fcb/bfa_fcb_fcpim.h>
32 #include <aen/bfa_aen_itnim.h>
34 BFA_TRC_FILE(FCS
, FCPIM
);
37 * forward declarations
39 static void bfa_fcs_itnim_timeout(void *arg
);
40 static void bfa_fcs_itnim_free(struct bfa_fcs_itnim_s
*itnim
);
41 static void bfa_fcs_itnim_send_prli(void *itnim_cbarg
,
42 struct bfa_fcxp_s
*fcxp_alloced
);
43 static void bfa_fcs_itnim_prli_response(void *fcsarg
,
44 struct bfa_fcxp_s
*fcxp
,
46 bfa_status_t req_status
,
49 struct fchs_s
*rsp_fchs
);
50 static void bfa_fcs_itnim_aen_post(struct bfa_fcs_itnim_s
*itnim
,
51 enum bfa_itnim_aen_event event
);
54 * fcs_itnim_sm FCS itnim state machine events
57 enum bfa_fcs_itnim_event
{
58 BFA_FCS_ITNIM_SM_ONLINE
= 1, /* rport online event */
59 BFA_FCS_ITNIM_SM_OFFLINE
= 2, /* rport offline */
60 BFA_FCS_ITNIM_SM_FRMSENT
= 3, /* prli frame is sent */
61 BFA_FCS_ITNIM_SM_RSP_OK
= 4, /* good response */
62 BFA_FCS_ITNIM_SM_RSP_ERROR
= 5, /* error response */
63 BFA_FCS_ITNIM_SM_TIMEOUT
= 6, /* delay timeout */
64 BFA_FCS_ITNIM_SM_HCB_OFFLINE
= 7, /* BFA online callback */
65 BFA_FCS_ITNIM_SM_HCB_ONLINE
= 8, /* BFA offline callback */
66 BFA_FCS_ITNIM_SM_INITIATOR
= 9, /* rport is initiator */
67 BFA_FCS_ITNIM_SM_DELETE
= 10, /* delete event from rport */
68 BFA_FCS_ITNIM_SM_PRLO
= 11, /* delete event from rport */
71 static void bfa_fcs_itnim_sm_offline(struct bfa_fcs_itnim_s
*itnim
,
72 enum bfa_fcs_itnim_event event
);
73 static void bfa_fcs_itnim_sm_prli_send(struct bfa_fcs_itnim_s
*itnim
,
74 enum bfa_fcs_itnim_event event
);
75 static void bfa_fcs_itnim_sm_prli(struct bfa_fcs_itnim_s
*itnim
,
76 enum bfa_fcs_itnim_event event
);
77 static void bfa_fcs_itnim_sm_prli_retry(struct bfa_fcs_itnim_s
*itnim
,
78 enum bfa_fcs_itnim_event event
);
79 static void bfa_fcs_itnim_sm_hcb_online(struct bfa_fcs_itnim_s
*itnim
,
80 enum bfa_fcs_itnim_event event
);
81 static void bfa_fcs_itnim_sm_online(struct bfa_fcs_itnim_s
*itnim
,
82 enum bfa_fcs_itnim_event event
);
83 static void bfa_fcs_itnim_sm_hcb_offline(struct bfa_fcs_itnim_s
*itnim
,
84 enum bfa_fcs_itnim_event event
);
85 static void bfa_fcs_itnim_sm_initiator(struct bfa_fcs_itnim_s
*itnim
,
86 enum bfa_fcs_itnim_event event
);
88 static struct bfa_sm_table_s itnim_sm_table
[] = {
89 {BFA_SM(bfa_fcs_itnim_sm_offline
), BFA_ITNIM_OFFLINE
},
90 {BFA_SM(bfa_fcs_itnim_sm_prli_send
), BFA_ITNIM_PRLI_SEND
},
91 {BFA_SM(bfa_fcs_itnim_sm_prli
), BFA_ITNIM_PRLI_SENT
},
92 {BFA_SM(bfa_fcs_itnim_sm_prli_retry
), BFA_ITNIM_PRLI_RETRY
},
93 {BFA_SM(bfa_fcs_itnim_sm_hcb_online
), BFA_ITNIM_HCB_ONLINE
},
94 {BFA_SM(bfa_fcs_itnim_sm_online
), BFA_ITNIM_ONLINE
},
95 {BFA_SM(bfa_fcs_itnim_sm_hcb_offline
), BFA_ITNIM_HCB_OFFLINE
},
96 {BFA_SM(bfa_fcs_itnim_sm_initiator
), BFA_ITNIM_INITIATIOR
},
100 * fcs_itnim_sm FCS itnim state machine
104 bfa_fcs_itnim_sm_offline(struct bfa_fcs_itnim_s
*itnim
,
105 enum bfa_fcs_itnim_event event
)
107 bfa_trc(itnim
->fcs
, itnim
->rport
->pwwn
);
108 bfa_trc(itnim
->fcs
, event
);
111 case BFA_FCS_ITNIM_SM_ONLINE
:
112 bfa_sm_set_state(itnim
, bfa_fcs_itnim_sm_prli_send
);
113 bfa_fcs_itnim_send_prli(itnim
, NULL
);
116 case BFA_FCS_ITNIM_SM_OFFLINE
:
117 bfa_fcs_rport_itnim_ack(itnim
->rport
);
120 case BFA_FCS_ITNIM_SM_INITIATOR
:
121 bfa_sm_set_state(itnim
, bfa_fcs_itnim_sm_initiator
);
124 case BFA_FCS_ITNIM_SM_DELETE
:
125 bfa_fcs_itnim_free(itnim
);
135 bfa_fcs_itnim_sm_prli_send(struct bfa_fcs_itnim_s
*itnim
,
136 enum bfa_fcs_itnim_event event
)
138 bfa_trc(itnim
->fcs
, itnim
->rport
->pwwn
);
139 bfa_trc(itnim
->fcs
, event
);
142 case BFA_FCS_ITNIM_SM_FRMSENT
:
143 bfa_sm_set_state(itnim
, bfa_fcs_itnim_sm_prli
);
146 case BFA_FCS_ITNIM_SM_INITIATOR
:
147 bfa_sm_set_state(itnim
, bfa_fcs_itnim_sm_initiator
);
148 bfa_fcxp_walloc_cancel(itnim
->fcs
->bfa
, &itnim
->fcxp_wqe
);
151 case BFA_FCS_ITNIM_SM_OFFLINE
:
152 bfa_sm_set_state(itnim
, bfa_fcs_itnim_sm_offline
);
153 bfa_fcxp_walloc_cancel(itnim
->fcs
->bfa
, &itnim
->fcxp_wqe
);
154 bfa_fcs_rport_itnim_ack(itnim
->rport
);
157 case BFA_FCS_ITNIM_SM_DELETE
:
158 bfa_sm_set_state(itnim
, bfa_fcs_itnim_sm_offline
);
159 bfa_fcxp_walloc_cancel(itnim
->fcs
->bfa
, &itnim
->fcxp_wqe
);
160 bfa_fcs_itnim_free(itnim
);
169 bfa_fcs_itnim_sm_prli(struct bfa_fcs_itnim_s
*itnim
,
170 enum bfa_fcs_itnim_event event
)
172 bfa_trc(itnim
->fcs
, itnim
->rport
->pwwn
);
173 bfa_trc(itnim
->fcs
, event
);
176 case BFA_FCS_ITNIM_SM_RSP_OK
:
177 bfa_sm_set_state(itnim
, bfa_fcs_itnim_sm_hcb_online
);
178 bfa_itnim_online(itnim
->bfa_itnim
, itnim
->seq_rec
);
181 case BFA_FCS_ITNIM_SM_RSP_ERROR
:
182 bfa_sm_set_state(itnim
, bfa_fcs_itnim_sm_prli_retry
);
183 bfa_timer_start(itnim
->fcs
->bfa
, &itnim
->timer
,
184 bfa_fcs_itnim_timeout
, itnim
,
185 BFA_FCS_RETRY_TIMEOUT
);
188 case BFA_FCS_ITNIM_SM_OFFLINE
:
189 bfa_sm_set_state(itnim
, bfa_fcs_itnim_sm_offline
);
190 bfa_fcxp_discard(itnim
->fcxp
);
191 bfa_fcs_rport_itnim_ack(itnim
->rport
);
194 case BFA_FCS_ITNIM_SM_INITIATOR
:
195 bfa_sm_set_state(itnim
, bfa_fcs_itnim_sm_initiator
);
197 * dont discard fcxp. accept will reach same state
201 case BFA_FCS_ITNIM_SM_DELETE
:
202 bfa_sm_set_state(itnim
, bfa_fcs_itnim_sm_offline
);
203 bfa_fcxp_discard(itnim
->fcxp
);
204 bfa_fcs_itnim_free(itnim
);
213 bfa_fcs_itnim_sm_prli_retry(struct bfa_fcs_itnim_s
*itnim
,
214 enum bfa_fcs_itnim_event event
)
216 bfa_trc(itnim
->fcs
, itnim
->rport
->pwwn
);
217 bfa_trc(itnim
->fcs
, event
);
220 case BFA_FCS_ITNIM_SM_TIMEOUT
:
221 bfa_sm_set_state(itnim
, bfa_fcs_itnim_sm_prli_send
);
222 bfa_fcs_itnim_send_prli(itnim
, NULL
);
225 case BFA_FCS_ITNIM_SM_OFFLINE
:
226 bfa_sm_set_state(itnim
, bfa_fcs_itnim_sm_offline
);
227 bfa_timer_stop(&itnim
->timer
);
228 bfa_fcs_rport_itnim_ack(itnim
->rport
);
231 case BFA_FCS_ITNIM_SM_INITIATOR
:
232 bfa_sm_set_state(itnim
, bfa_fcs_itnim_sm_initiator
);
233 bfa_timer_stop(&itnim
->timer
);
236 case BFA_FCS_ITNIM_SM_DELETE
:
237 bfa_sm_set_state(itnim
, bfa_fcs_itnim_sm_offline
);
238 bfa_timer_stop(&itnim
->timer
);
239 bfa_fcs_itnim_free(itnim
);
248 bfa_fcs_itnim_sm_hcb_online(struct bfa_fcs_itnim_s
*itnim
,
249 enum bfa_fcs_itnim_event event
)
251 bfa_trc(itnim
->fcs
, itnim
->rport
->pwwn
);
252 bfa_trc(itnim
->fcs
, event
);
255 case BFA_FCS_ITNIM_SM_HCB_ONLINE
:
256 bfa_sm_set_state(itnim
, bfa_fcs_itnim_sm_online
);
257 bfa_fcb_itnim_online(itnim
->itnim_drv
);
258 bfa_fcs_itnim_aen_post(itnim
, BFA_ITNIM_AEN_ONLINE
);
261 case BFA_FCS_ITNIM_SM_OFFLINE
:
262 bfa_sm_set_state(itnim
, bfa_fcs_itnim_sm_offline
);
263 bfa_itnim_offline(itnim
->bfa_itnim
);
264 bfa_fcs_rport_itnim_ack(itnim
->rport
);
267 case BFA_FCS_ITNIM_SM_DELETE
:
268 bfa_sm_set_state(itnim
, bfa_fcs_itnim_sm_offline
);
269 bfa_fcs_itnim_free(itnim
);
278 bfa_fcs_itnim_sm_online(struct bfa_fcs_itnim_s
*itnim
,
279 enum bfa_fcs_itnim_event event
)
281 bfa_trc(itnim
->fcs
, itnim
->rport
->pwwn
);
282 bfa_trc(itnim
->fcs
, event
);
285 case BFA_FCS_ITNIM_SM_OFFLINE
:
286 bfa_sm_set_state(itnim
, bfa_fcs_itnim_sm_hcb_offline
);
287 bfa_fcb_itnim_offline(itnim
->itnim_drv
);
288 bfa_itnim_offline(itnim
->bfa_itnim
);
289 if (bfa_fcs_port_is_online(itnim
->rport
->port
) == BFA_TRUE
)
290 bfa_fcs_itnim_aen_post(itnim
, BFA_ITNIM_AEN_DISCONNECT
);
292 bfa_fcs_itnim_aen_post(itnim
, BFA_ITNIM_AEN_OFFLINE
);
295 case BFA_FCS_ITNIM_SM_DELETE
:
296 bfa_sm_set_state(itnim
, bfa_fcs_itnim_sm_offline
);
297 bfa_fcs_itnim_free(itnim
);
306 bfa_fcs_itnim_sm_hcb_offline(struct bfa_fcs_itnim_s
*itnim
,
307 enum bfa_fcs_itnim_event event
)
309 bfa_trc(itnim
->fcs
, itnim
->rport
->pwwn
);
310 bfa_trc(itnim
->fcs
, event
);
313 case BFA_FCS_ITNIM_SM_HCB_OFFLINE
:
314 bfa_sm_set_state(itnim
, bfa_fcs_itnim_sm_offline
);
315 bfa_fcs_rport_itnim_ack(itnim
->rport
);
318 case BFA_FCS_ITNIM_SM_DELETE
:
319 bfa_sm_set_state(itnim
, bfa_fcs_itnim_sm_offline
);
320 bfa_fcs_itnim_free(itnim
);
329 * This state is set when a discovered rport is also in intiator mode.
330 * This ITN is marked as no_op and is not active and will not be truned into
334 bfa_fcs_itnim_sm_initiator(struct bfa_fcs_itnim_s
*itnim
,
335 enum bfa_fcs_itnim_event event
)
337 bfa_trc(itnim
->fcs
, itnim
->rport
->pwwn
);
338 bfa_trc(itnim
->fcs
, event
);
341 case BFA_FCS_ITNIM_SM_OFFLINE
:
342 bfa_sm_set_state(itnim
, bfa_fcs_itnim_sm_offline
);
343 bfa_fcs_rport_itnim_ack(itnim
->rport
);
346 case BFA_FCS_ITNIM_SM_RSP_ERROR
:
347 case BFA_FCS_ITNIM_SM_ONLINE
:
348 case BFA_FCS_ITNIM_SM_INITIATOR
:
351 case BFA_FCS_ITNIM_SM_DELETE
:
352 bfa_sm_set_state(itnim
, bfa_fcs_itnim_sm_offline
);
353 bfa_fcs_itnim_free(itnim
);
364 * itnim_private FCS ITNIM private interfaces
368 bfa_fcs_itnim_aen_post(struct bfa_fcs_itnim_s
*itnim
,
369 enum bfa_itnim_aen_event event
)
371 struct bfa_fcs_rport_s
*rport
= itnim
->rport
;
372 union bfa_aen_data_u aen_data
;
373 struct bfa_log_mod_s
*logmod
= rport
->fcs
->logm
;
374 wwn_t lpwwn
= bfa_fcs_port_get_pwwn(rport
->port
);
375 wwn_t rpwwn
= rport
->pwwn
;
376 char lpwwn_ptr
[BFA_STRING_32
];
377 char rpwwn_ptr
[BFA_STRING_32
];
380 * Don't post events for well known addresses
382 if (BFA_FCS_PID_IS_WKA(rport
->pid
))
385 wwn2str(lpwwn_ptr
, lpwwn
);
386 wwn2str(rpwwn_ptr
, rpwwn
);
389 case BFA_ITNIM_AEN_ONLINE
:
390 bfa_log(logmod
, BFA_AEN_ITNIM_ONLINE
, rpwwn_ptr
, lpwwn_ptr
);
392 case BFA_ITNIM_AEN_OFFLINE
:
393 bfa_log(logmod
, BFA_AEN_ITNIM_OFFLINE
, rpwwn_ptr
, lpwwn_ptr
);
395 case BFA_ITNIM_AEN_DISCONNECT
:
396 bfa_log(logmod
, BFA_AEN_ITNIM_DISCONNECT
, rpwwn_ptr
, lpwwn_ptr
);
402 aen_data
.itnim
.vf_id
= rport
->port
->fabric
->vf_id
;
403 aen_data
.itnim
.ppwwn
=
404 bfa_fcs_port_get_pwwn(bfa_fcs_get_base_port(itnim
->fcs
));
405 aen_data
.itnim
.lpwwn
= lpwwn
;
406 aen_data
.itnim
.rpwwn
= rpwwn
;
410 bfa_fcs_itnim_send_prli(void *itnim_cbarg
, struct bfa_fcxp_s
*fcxp_alloced
)
412 struct bfa_fcs_itnim_s
*itnim
= itnim_cbarg
;
413 struct bfa_fcs_rport_s
*rport
= itnim
->rport
;
414 struct bfa_fcs_port_s
*port
= rport
->port
;
416 struct bfa_fcxp_s
*fcxp
;
419 bfa_trc(itnim
->fcs
, itnim
->rport
->pwwn
);
421 fcxp
= fcxp_alloced
? fcxp_alloced
: bfa_fcs_fcxp_alloc(port
->fcs
);
423 itnim
->stats
.fcxp_alloc_wait
++;
424 bfa_fcxp_alloc_wait(port
->fcs
->bfa
, &itnim
->fcxp_wqe
,
425 bfa_fcs_itnim_send_prli
, itnim
);
430 len
= fc_prli_build(&fchs
, bfa_fcxp_get_reqbuf(fcxp
), itnim
->rport
->pid
,
431 bfa_fcs_port_get_fcid(port
), 0);
433 bfa_fcxp_send(fcxp
, rport
->bfa_rport
, port
->fabric
->vf_id
, port
->lp_tag
,
434 BFA_FALSE
, FC_CLASS_3
, len
, &fchs
,
435 bfa_fcs_itnim_prli_response
, (void *)itnim
, FC_MAX_PDUSZ
,
438 itnim
->stats
.prli_sent
++;
439 bfa_sm_send_event(itnim
, BFA_FCS_ITNIM_SM_FRMSENT
);
443 bfa_fcs_itnim_prli_response(void *fcsarg
, struct bfa_fcxp_s
*fcxp
, void *cbarg
,
444 bfa_status_t req_status
, u32 rsp_len
,
445 u32 resid_len
, struct fchs_s
*rsp_fchs
)
447 struct bfa_fcs_itnim_s
*itnim
= (struct bfa_fcs_itnim_s
*)cbarg
;
448 struct fc_els_cmd_s
*els_cmd
;
449 struct fc_prli_s
*prli_resp
;
450 struct fc_ls_rjt_s
*ls_rjt
;
451 struct fc_prli_params_s
*sparams
;
453 bfa_trc(itnim
->fcs
, req_status
);
458 if (req_status
!= BFA_STATUS_OK
) {
459 itnim
->stats
.prli_rsp_err
++;
460 bfa_sm_send_event(itnim
, BFA_FCS_ITNIM_SM_RSP_ERROR
);
464 els_cmd
= (struct fc_els_cmd_s
*) BFA_FCXP_RSP_PLD(fcxp
);
466 if (els_cmd
->els_code
== FC_ELS_ACC
) {
467 prli_resp
= (struct fc_prli_s
*) els_cmd
;
469 if (fc_prli_rsp_parse(prli_resp
, rsp_len
) != FC_PARSE_OK
) {
470 bfa_trc(itnim
->fcs
, rsp_len
);
472 * Check if this r-port is also in Initiator mode.
473 * If so, we need to set this ITN as a no-op.
475 if (prli_resp
->parampage
.servparams
.initiator
) {
476 bfa_trc(itnim
->fcs
, prli_resp
->parampage
.type
);
477 itnim
->rport
->scsi_function
=
479 itnim
->stats
.prli_rsp_acc
++;
480 bfa_sm_send_event(itnim
,
481 BFA_FCS_ITNIM_SM_INITIATOR
);
485 itnim
->stats
.prli_rsp_parse_err
++;
488 itnim
->rport
->scsi_function
= BFA_RPORT_TARGET
;
490 sparams
= &prli_resp
->parampage
.servparams
;
491 itnim
->seq_rec
= sparams
->retry
;
492 itnim
->rec_support
= sparams
->rec_support
;
493 itnim
->task_retry_id
= sparams
->task_retry_id
;
494 itnim
->conf_comp
= sparams
->confirm
;
496 itnim
->stats
.prli_rsp_acc
++;
497 bfa_sm_send_event(itnim
, BFA_FCS_ITNIM_SM_RSP_OK
);
499 ls_rjt
= (struct fc_ls_rjt_s
*) BFA_FCXP_RSP_PLD(fcxp
);
501 bfa_trc(itnim
->fcs
, ls_rjt
->reason_code
);
502 bfa_trc(itnim
->fcs
, ls_rjt
->reason_code_expl
);
504 itnim
->stats
.prli_rsp_rjt
++;
505 bfa_sm_send_event(itnim
, BFA_FCS_ITNIM_SM_RSP_ERROR
);
510 bfa_fcs_itnim_timeout(void *arg
)
512 struct bfa_fcs_itnim_s
*itnim
= (struct bfa_fcs_itnim_s
*)arg
;
514 itnim
->stats
.timeout
++;
515 bfa_sm_send_event(itnim
, BFA_FCS_ITNIM_SM_TIMEOUT
);
519 bfa_fcs_itnim_free(struct bfa_fcs_itnim_s
*itnim
)
521 bfa_itnim_delete(itnim
->bfa_itnim
);
522 bfa_fcb_itnim_free(itnim
->fcs
->bfad
, itnim
->itnim_drv
);
528 * itnim_public FCS ITNIM public interfaces
532 * Called by rport when a new rport is created.
534 * @param[in] rport - remote port.
536 struct bfa_fcs_itnim_s
*
537 bfa_fcs_itnim_create(struct bfa_fcs_rport_s
*rport
)
539 struct bfa_fcs_port_s
*port
= rport
->port
;
540 struct bfa_fcs_itnim_s
*itnim
;
541 struct bfad_itnim_s
*itnim_drv
;
542 struct bfa_itnim_s
*bfa_itnim
;
545 * call bfad to allocate the itnim
547 bfa_fcb_itnim_alloc(port
->fcs
->bfad
, &itnim
, &itnim_drv
);
549 bfa_trc(port
->fcs
, rport
->pwwn
);
556 itnim
->rport
= rport
;
557 itnim
->fcs
= rport
->fcs
;
558 itnim
->itnim_drv
= itnim_drv
;
561 * call BFA to create the itnim
563 bfa_itnim
= bfa_itnim_create(port
->fcs
->bfa
, rport
->bfa_rport
, itnim
);
565 if (bfa_itnim
== NULL
) {
566 bfa_trc(port
->fcs
, rport
->pwwn
);
567 bfa_fcb_itnim_free(port
->fcs
->bfad
, itnim_drv
);
572 itnim
->bfa_itnim
= bfa_itnim
;
573 itnim
->seq_rec
= BFA_FALSE
;
574 itnim
->rec_support
= BFA_FALSE
;
575 itnim
->conf_comp
= BFA_FALSE
;
576 itnim
->task_retry_id
= BFA_FALSE
;
581 bfa_sm_set_state(itnim
, bfa_fcs_itnim_sm_offline
);
587 * Called by rport to delete the instance of FCPIM.
589 * @param[in] rport - remote port.
592 bfa_fcs_itnim_delete(struct bfa_fcs_itnim_s
*itnim
)
594 bfa_trc(itnim
->fcs
, itnim
->rport
->pid
);
595 bfa_sm_send_event(itnim
, BFA_FCS_ITNIM_SM_DELETE
);
599 * Notification from rport that PLOGI is complete to initiate FC-4 session.
602 bfa_fcs_itnim_rport_online(struct bfa_fcs_itnim_s
*itnim
)
604 itnim
->stats
.onlines
++;
606 if (!BFA_FCS_PID_IS_WKA(itnim
->rport
->pid
)) {
607 bfa_sm_send_event(itnim
, BFA_FCS_ITNIM_SM_ONLINE
);
610 * For well known addresses, we set the itnim to initiator
613 itnim
->stats
.initiator
++;
614 bfa_sm_send_event(itnim
, BFA_FCS_ITNIM_SM_INITIATOR
);
619 * Called by rport to handle a remote device offline.
622 bfa_fcs_itnim_rport_offline(struct bfa_fcs_itnim_s
*itnim
)
624 itnim
->stats
.offlines
++;
625 bfa_sm_send_event(itnim
, BFA_FCS_ITNIM_SM_OFFLINE
);
629 * Called by rport when remote port is known to be an initiator from
633 bfa_fcs_itnim_is_initiator(struct bfa_fcs_itnim_s
*itnim
)
635 bfa_trc(itnim
->fcs
, itnim
->rport
->pid
);
636 itnim
->stats
.initiator
++;
637 bfa_sm_send_event(itnim
, BFA_FCS_ITNIM_SM_INITIATOR
);
641 * Called by rport to check if the itnim is online.
644 bfa_fcs_itnim_get_online_state(struct bfa_fcs_itnim_s
*itnim
)
646 bfa_trc(itnim
->fcs
, itnim
->rport
->pid
);
647 switch (bfa_sm_to_state(itnim_sm_table
, itnim
->sm
)) {
648 case BFA_ITNIM_ONLINE
:
649 case BFA_ITNIM_INITIATIOR
:
650 return BFA_STATUS_OK
;
653 return BFA_STATUS_NO_FCPIM_NEXUS
;
659 * BFA completion callback for bfa_itnim_online().
662 bfa_cb_itnim_online(void *cbarg
)
664 struct bfa_fcs_itnim_s
*itnim
= (struct bfa_fcs_itnim_s
*)cbarg
;
666 bfa_trc(itnim
->fcs
, itnim
->rport
->pwwn
);
667 bfa_sm_send_event(itnim
, BFA_FCS_ITNIM_SM_HCB_ONLINE
);
671 * BFA completion callback for bfa_itnim_offline().
674 bfa_cb_itnim_offline(void *cb_arg
)
676 struct bfa_fcs_itnim_s
*itnim
= (struct bfa_fcs_itnim_s
*)cb_arg
;
678 bfa_trc(itnim
->fcs
, itnim
->rport
->pwwn
);
679 bfa_sm_send_event(itnim
, BFA_FCS_ITNIM_SM_HCB_OFFLINE
);
683 * Mark the beginning of PATH TOV handling. IO completion callbacks
687 bfa_cb_itnim_tov_begin(void *cb_arg
)
689 struct bfa_fcs_itnim_s
*itnim
= (struct bfa_fcs_itnim_s
*)cb_arg
;
691 bfa_trc(itnim
->fcs
, itnim
->rport
->pwwn
);
692 bfa_fcb_itnim_tov_begin(itnim
->itnim_drv
);
696 * Mark the end of PATH TOV handling. All pending IOs are already cleaned up.
699 bfa_cb_itnim_tov(void *cb_arg
)
701 struct bfa_fcs_itnim_s
*itnim
= (struct bfa_fcs_itnim_s
*)cb_arg
;
703 bfa_trc(itnim
->fcs
, itnim
->rport
->pwwn
);
704 bfa_fcb_itnim_tov(itnim
->itnim_drv
);
708 * BFA notification to FCS/driver for second level error recovery.
710 * Atleast one I/O request has timedout and target is unresponsive to
711 * repeated abort requests. Second level error recovery should be initiated
712 * by starting implicit logout and recovery procedures.
715 bfa_cb_itnim_sler(void *cb_arg
)
717 struct bfa_fcs_itnim_s
*itnim
= (struct bfa_fcs_itnim_s
*)cb_arg
;
720 bfa_trc(itnim
->fcs
, itnim
->rport
->pwwn
);
721 bfa_fcs_rport_logo_imp(itnim
->rport
);
724 struct bfa_fcs_itnim_s
*
725 bfa_fcs_itnim_lookup(struct bfa_fcs_port_s
*port
, wwn_t rpwwn
)
727 struct bfa_fcs_rport_s
*rport
;
728 rport
= bfa_fcs_rport_lookup(port
, rpwwn
);
733 bfa_assert(rport
->itnim
!= NULL
);
738 bfa_fcs_itnim_attr_get(struct bfa_fcs_port_s
*port
, wwn_t rpwwn
,
739 struct bfa_itnim_attr_s
*attr
)
741 struct bfa_fcs_itnim_s
*itnim
= NULL
;
743 itnim
= bfa_fcs_itnim_lookup(port
, rpwwn
);
746 return BFA_STATUS_NO_FCPIM_NEXUS
;
748 attr
->state
= bfa_sm_to_state(itnim_sm_table
, itnim
->sm
);
749 attr
->retry
= itnim
->seq_rec
;
750 attr
->rec_support
= itnim
->rec_support
;
751 attr
->conf_comp
= itnim
->conf_comp
;
752 attr
->task_retry_id
= itnim
->task_retry_id
;
754 return BFA_STATUS_OK
;
758 bfa_fcs_itnim_stats_get(struct bfa_fcs_port_s
*port
, wwn_t rpwwn
,
759 struct bfa_itnim_stats_s
*stats
)
761 struct bfa_fcs_itnim_s
*itnim
= NULL
;
763 bfa_assert(port
!= NULL
);
765 itnim
= bfa_fcs_itnim_lookup(port
, rpwwn
);
768 return BFA_STATUS_NO_FCPIM_NEXUS
;
770 bfa_os_memcpy(stats
, &itnim
->stats
, sizeof(struct bfa_itnim_stats_s
));
772 return BFA_STATUS_OK
;
776 bfa_fcs_itnim_stats_clear(struct bfa_fcs_port_s
*port
, wwn_t rpwwn
)
778 struct bfa_fcs_itnim_s
*itnim
= NULL
;
780 bfa_assert(port
!= NULL
);
782 itnim
= bfa_fcs_itnim_lookup(port
, rpwwn
);
785 return BFA_STATUS_NO_FCPIM_NEXUS
;
787 bfa_os_memset(&itnim
->stats
, 0, sizeof(struct bfa_itnim_stats_s
));
788 return BFA_STATUS_OK
;
792 bfa_fcs_fcpim_uf_recv(struct bfa_fcs_itnim_s
*itnim
, struct fchs_s
*fchs
,
795 struct fc_els_cmd_s
*els_cmd
;
797 bfa_trc(itnim
->fcs
, fchs
->type
);
799 if (fchs
->type
!= FC_TYPE_ELS
)
802 els_cmd
= (struct fc_els_cmd_s
*) (fchs
+ 1);
804 bfa_trc(itnim
->fcs
, els_cmd
->els_code
);
806 switch (els_cmd
->els_code
) {
808 /* bfa_sm_send_event(itnim, BFA_FCS_ITNIM_SM_PRLO); */
817 bfa_fcs_itnim_pause(struct bfa_fcs_itnim_s
*itnim
)
822 bfa_fcs_itnim_resume(struct bfa_fcs_itnim_s
*itnim
)
827 * Module initialization
830 bfa_fcs_fcpim_modinit(struct bfa_fcs_s
*fcs
)
838 bfa_fcs_fcpim_modexit(struct bfa_fcs_s
*fcs
)
840 bfa_fcs_modexit_comp(fcs
);