Lines Matching refs:rdata

119 	struct fc_rport_priv *rdata = NULL, *tmp_rdata;  in fc_rport_lookup()  local
125 rdata = tmp_rdata; in fc_rport_lookup()
129 return rdata; in fc_rport_lookup()
142 struct fc_rport_priv *rdata; in fc_rport_create() local
146 rdata = fc_rport_lookup(lport, port_id); in fc_rport_create()
147 if (rdata) in fc_rport_create()
148 return rdata; in fc_rport_create()
150 rdata = kzalloc(sizeof(*rdata) + lport->rport_priv_size, GFP_KERNEL); in fc_rport_create()
151 if (!rdata) in fc_rport_create()
154 rdata->ids.node_name = -1; in fc_rport_create()
155 rdata->ids.port_name = -1; in fc_rport_create()
156 rdata->ids.port_id = port_id; in fc_rport_create()
157 rdata->ids.roles = FC_RPORT_ROLE_UNKNOWN; in fc_rport_create()
159 kref_init(&rdata->kref); in fc_rport_create()
160 mutex_init(&rdata->rp_mutex); in fc_rport_create()
161 rdata->local_port = lport; in fc_rport_create()
162 rdata->rp_state = RPORT_ST_INIT; in fc_rport_create()
163 rdata->event = RPORT_EV_NONE; in fc_rport_create()
164 rdata->flags = FC_RP_FLAGS_REC_SUPPORTED; in fc_rport_create()
165 rdata->e_d_tov = lport->e_d_tov; in fc_rport_create()
166 rdata->r_a_tov = lport->r_a_tov; in fc_rport_create()
167 rdata->maxframe_size = FC_MIN_MAX_PAYLOAD; in fc_rport_create()
168 INIT_DELAYED_WORK(&rdata->retry_work, fc_rport_timeout); in fc_rport_create()
169 INIT_WORK(&rdata->event_work, fc_rport_work); in fc_rport_create()
171 rdata->lld_event_callback = lport->tt.rport_event_callback; in fc_rport_create()
172 list_add_rcu(&rdata->peers, &lport->disc.rports); in fc_rport_create()
174 return rdata; in fc_rport_create()
184 struct fc_rport_priv *rdata; in fc_rport_destroy() local
186 rdata = container_of(kref, struct fc_rport_priv, kref); in fc_rport_destroy()
187 WARN_ON(!list_empty(&rdata->peers)); in fc_rport_destroy()
188 kfree_rcu(rdata, rcu); in fc_rport_destroy()
196 static const char *fc_rport_state(struct fc_rport_priv *rdata) in fc_rport_state() argument
200 cp = fc_rport_state_names[rdata->rp_state]; in fc_rport_state()
250 static void fc_rport_state_enter(struct fc_rport_priv *rdata, in fc_rport_state_enter() argument
253 lockdep_assert_held(&rdata->rp_mutex); in fc_rport_state_enter()
255 if (rdata->rp_state != new) in fc_rport_state_enter()
256 rdata->retries = 0; in fc_rport_state_enter()
257 rdata->rp_state = new; in fc_rport_state_enter()
269 struct fc_rport_priv *rdata = in fc_rport_work() local
273 struct fc_lport *lport = rdata->local_port; in fc_rport_work()
280 mutex_lock(&rdata->rp_mutex); in fc_rport_work()
281 event = rdata->event; in fc_rport_work()
282 rport_ops = rdata->ops; in fc_rport_work()
283 rport = rdata->rport; in fc_rport_work()
285 FC_RPORT_DBG(rdata, "work event %u\n", event); in fc_rport_work()
289 ids = rdata->ids; in fc_rport_work()
290 rdata->event = RPORT_EV_NONE; in fc_rport_work()
291 rdata->major_retries = 0; in fc_rport_work()
292 kref_get(&rdata->kref); in fc_rport_work()
293 mutex_unlock(&rdata->rp_mutex); in fc_rport_work()
296 FC_RPORT_DBG(rdata, "No rport!\n"); in fc_rport_work()
300 FC_RPORT_DBG(rdata, "Failed to add the rport\n"); in fc_rport_work()
301 fc_rport_logoff(rdata); in fc_rport_work()
302 kref_put(&rdata->kref, fc_rport_destroy); in fc_rport_work()
305 mutex_lock(&rdata->rp_mutex); in fc_rport_work()
306 if (rdata->rport) in fc_rport_work()
307 FC_RPORT_DBG(rdata, "rport already allocated\n"); in fc_rport_work()
308 rdata->rport = rport; in fc_rport_work()
309 rport->maxframe_size = rdata->maxframe_size; in fc_rport_work()
310 rport->supported_classes = rdata->supported_classes; in fc_rport_work()
314 rpriv->rp_state = rdata->rp_state; in fc_rport_work()
315 rpriv->flags = rdata->flags; in fc_rport_work()
316 rpriv->e_d_tov = rdata->e_d_tov; in fc_rport_work()
317 rpriv->r_a_tov = rdata->r_a_tov; in fc_rport_work()
318 mutex_unlock(&rdata->rp_mutex); in fc_rport_work()
321 FC_RPORT_DBG(rdata, "callback ev %d\n", event); in fc_rport_work()
322 rport_ops->event_callback(lport, rdata, event); in fc_rport_work()
324 if (rdata->lld_event_callback) { in fc_rport_work()
325 FC_RPORT_DBG(rdata, "lld callback ev %d\n", event); in fc_rport_work()
326 rdata->lld_event_callback(lport, rdata, event); in fc_rport_work()
328 kref_put(&rdata->kref, fc_rport_destroy); in fc_rport_work()
334 if (rdata->prli_count) { in fc_rport_work()
339 prov->prlo(rdata); in fc_rport_work()
343 port_id = rdata->ids.port_id; in fc_rport_work()
344 mutex_unlock(&rdata->rp_mutex); in fc_rport_work()
347 FC_RPORT_DBG(rdata, "callback ev %d\n", event); in fc_rport_work()
348 rport_ops->event_callback(lport, rdata, event); in fc_rport_work()
350 if (rdata->lld_event_callback) { in fc_rport_work()
351 FC_RPORT_DBG(rdata, "lld callback ev %d\n", event); in fc_rport_work()
352 rdata->lld_event_callback(lport, rdata, event); in fc_rport_work()
354 if (cancel_delayed_work_sync(&rdata->retry_work)) in fc_rport_work()
355 kref_put(&rdata->kref, fc_rport_destroy); in fc_rport_work()
366 mutex_lock(&rdata->rp_mutex); in fc_rport_work()
367 rdata->rport = NULL; in fc_rport_work()
368 mutex_unlock(&rdata->rp_mutex); in fc_rport_work()
372 mutex_lock(&rdata->rp_mutex); in fc_rport_work()
373 if (rdata->rp_state == RPORT_ST_DELETE) { in fc_rport_work()
375 rdata->event = RPORT_EV_NONE; in fc_rport_work()
376 mutex_unlock(&rdata->rp_mutex); in fc_rport_work()
377 kref_put(&rdata->kref, fc_rport_destroy); in fc_rport_work()
378 } else if ((rdata->flags & FC_RP_STARTED) && in fc_rport_work()
379 rdata->major_retries < in fc_rport_work()
381 rdata->major_retries++; in fc_rport_work()
382 rdata->event = RPORT_EV_NONE; in fc_rport_work()
383 FC_RPORT_DBG(rdata, "work restart\n"); in fc_rport_work()
384 fc_rport_enter_flogi(rdata); in fc_rport_work()
385 mutex_unlock(&rdata->rp_mutex); in fc_rport_work()
387 mutex_unlock(&rdata->rp_mutex); in fc_rport_work()
388 FC_RPORT_DBG(rdata, "work delete\n"); in fc_rport_work()
390 list_del_rcu(&rdata->peers); in fc_rport_work()
392 kref_put(&rdata->kref, fc_rport_destroy); in fc_rport_work()
398 rdata->event = RPORT_EV_NONE; in fc_rport_work()
399 if (rdata->rp_state == RPORT_ST_READY) { in fc_rport_work()
400 FC_RPORT_DBG(rdata, "work reopen\n"); in fc_rport_work()
401 fc_rport_enter_ready(rdata); in fc_rport_work()
403 mutex_unlock(&rdata->rp_mutex); in fc_rport_work()
408 mutex_unlock(&rdata->rp_mutex); in fc_rport_work()
411 kref_put(&rdata->kref, fc_rport_destroy); in fc_rport_work()
434 int fc_rport_login(struct fc_rport_priv *rdata) in fc_rport_login() argument
436 mutex_lock(&rdata->rp_mutex); in fc_rport_login()
438 if (rdata->flags & FC_RP_STARTED) { in fc_rport_login()
439 FC_RPORT_DBG(rdata, "port already started\n"); in fc_rport_login()
440 mutex_unlock(&rdata->rp_mutex); in fc_rport_login()
444 rdata->flags |= FC_RP_STARTED; in fc_rport_login()
445 switch (rdata->rp_state) { in fc_rport_login()
447 FC_RPORT_DBG(rdata, "ADISC port\n"); in fc_rport_login()
448 fc_rport_enter_adisc(rdata); in fc_rport_login()
451 FC_RPORT_DBG(rdata, "Restart deleted port\n"); in fc_rport_login()
454 FC_RPORT_DBG(rdata, "Login to port\n"); in fc_rport_login()
455 fc_rport_enter_flogi(rdata); in fc_rport_login()
458 FC_RPORT_DBG(rdata, "Login in progress, state %s\n", in fc_rport_login()
459 fc_rport_state(rdata)); in fc_rport_login()
462 mutex_unlock(&rdata->rp_mutex); in fc_rport_login()
482 static void fc_rport_enter_delete(struct fc_rport_priv *rdata, in fc_rport_enter_delete() argument
485 lockdep_assert_held(&rdata->rp_mutex); in fc_rport_enter_delete()
487 if (rdata->rp_state == RPORT_ST_DELETE) in fc_rport_enter_delete()
490 FC_RPORT_DBG(rdata, "Delete port\n"); in fc_rport_enter_delete()
492 fc_rport_state_enter(rdata, RPORT_ST_DELETE); in fc_rport_enter_delete()
494 kref_get(&rdata->kref); in fc_rport_enter_delete()
495 if (rdata->event == RPORT_EV_NONE && in fc_rport_enter_delete()
496 !queue_work(rport_event_queue, &rdata->event_work)) in fc_rport_enter_delete()
497 kref_put(&rdata->kref, fc_rport_destroy); in fc_rport_enter_delete()
499 rdata->event = event; in fc_rport_enter_delete()
510 int fc_rport_logoff(struct fc_rport_priv *rdata) in fc_rport_logoff() argument
512 struct fc_lport *lport = rdata->local_port; in fc_rport_logoff()
513 u32 port_id = rdata->ids.port_id; in fc_rport_logoff()
515 mutex_lock(&rdata->rp_mutex); in fc_rport_logoff()
517 FC_RPORT_DBG(rdata, "Remove port\n"); in fc_rport_logoff()
519 rdata->flags &= ~FC_RP_STARTED; in fc_rport_logoff()
520 if (rdata->rp_state == RPORT_ST_DELETE) { in fc_rport_logoff()
521 FC_RPORT_DBG(rdata, "Port in Delete state, not removing\n"); in fc_rport_logoff()
533 fc_rport_enter_logo(rdata); in fc_rport_logoff()
539 fc_rport_enter_delete(rdata, RPORT_EV_STOP); in fc_rport_logoff()
541 mutex_unlock(&rdata->rp_mutex); in fc_rport_logoff()
552 static void fc_rport_enter_ready(struct fc_rport_priv *rdata) in fc_rport_enter_ready() argument
554 lockdep_assert_held(&rdata->rp_mutex); in fc_rport_enter_ready()
556 fc_rport_state_enter(rdata, RPORT_ST_READY); in fc_rport_enter_ready()
558 FC_RPORT_DBG(rdata, "Port is Ready\n"); in fc_rport_enter_ready()
560 kref_get(&rdata->kref); in fc_rport_enter_ready()
561 if (rdata->event == RPORT_EV_NONE && in fc_rport_enter_ready()
562 !queue_work(rport_event_queue, &rdata->event_work)) in fc_rport_enter_ready()
563 kref_put(&rdata->kref, fc_rport_destroy); in fc_rport_enter_ready()
565 rdata->event = RPORT_EV_READY; in fc_rport_enter_ready()
580 struct fc_rport_priv *rdata = in fc_rport_timeout() local
583 mutex_lock(&rdata->rp_mutex); in fc_rport_timeout()
584 FC_RPORT_DBG(rdata, "Port timeout, state %s\n", fc_rport_state(rdata)); in fc_rport_timeout()
586 switch (rdata->rp_state) { in fc_rport_timeout()
588 fc_rport_enter_flogi(rdata); in fc_rport_timeout()
591 fc_rport_enter_plogi(rdata); in fc_rport_timeout()
594 fc_rport_enter_prli(rdata); in fc_rport_timeout()
597 fc_rport_enter_rtv(rdata); in fc_rport_timeout()
600 fc_rport_enter_adisc(rdata); in fc_rport_timeout()
609 mutex_unlock(&rdata->rp_mutex); in fc_rport_timeout()
610 kref_put(&rdata->kref, fc_rport_destroy); in fc_rport_timeout()
620 static void fc_rport_error(struct fc_rport_priv *rdata, int err) in fc_rport_error() argument
622 struct fc_lport *lport = rdata->local_port; in fc_rport_error()
624 lockdep_assert_held(&rdata->rp_mutex); in fc_rport_error()
626 FC_RPORT_DBG(rdata, "Error %d in state %s, retries %d\n", in fc_rport_error()
627 -err, fc_rport_state(rdata), rdata->retries); in fc_rport_error()
629 switch (rdata->rp_state) { in fc_rport_error()
631 rdata->flags &= ~FC_RP_STARTED; in fc_rport_error()
632 fc_rport_enter_delete(rdata, RPORT_EV_FAILED); in fc_rport_error()
636 rdata->flags &= ~FC_RP_STARTED; in fc_rport_error()
637 fc_rport_enter_delete(rdata, RPORT_EV_FAILED); in fc_rport_error()
639 fc_rport_enter_logo(rdata); in fc_rport_error()
642 fc_rport_enter_ready(rdata); in fc_rport_error()
646 fc_rport_enter_logo(rdata); in fc_rport_error()
666 static void fc_rport_error_retry(struct fc_rport_priv *rdata, int err) in fc_rport_error_retry() argument
668 unsigned long delay = msecs_to_jiffies(rdata->e_d_tov); in fc_rport_error_retry()
670 lockdep_assert_held(&rdata->rp_mutex); in fc_rport_error_retry()
676 if (rdata->retries < rdata->local_port->max_rport_retry_count) { in fc_rport_error_retry()
677 FC_RPORT_DBG(rdata, "Error %d in state %s, retrying\n", in fc_rport_error_retry()
678 err, fc_rport_state(rdata)); in fc_rport_error_retry()
679 rdata->retries++; in fc_rport_error_retry()
683 kref_get(&rdata->kref); in fc_rport_error_retry()
684 if (!schedule_delayed_work(&rdata->retry_work, delay)) in fc_rport_error_retry()
685 kref_put(&rdata->kref, fc_rport_destroy); in fc_rport_error_retry()
690 fc_rport_error(rdata, err); in fc_rport_error_retry()
703 static int fc_rport_login_complete(struct fc_rport_priv *rdata, in fc_rport_login_complete() argument
706 struct fc_lport *lport = rdata->local_port; in fc_rport_login_complete()
719 FC_RPORT_DBG(rdata, "Fabric bit set in FLOGI\n"); in fc_rport_login_complete()
730 if (e_d_tov > rdata->e_d_tov) in fc_rport_login_complete()
731 rdata->e_d_tov = e_d_tov; in fc_rport_login_complete()
733 rdata->maxframe_size = fc_plogi_get_maxframe(flogi, lport->mfs); in fc_rport_login_complete()
746 struct fc_rport_priv *rdata = rp_arg; in fc_rport_flogi_resp() local
747 struct fc_lport *lport = rdata->local_port; in fc_rport_flogi_resp()
753 FC_RPORT_DBG(rdata, "Received a FLOGI %s\n", in fc_rport_flogi_resp()
759 mutex_lock(&rdata->rp_mutex); in fc_rport_flogi_resp()
761 if (rdata->rp_state != RPORT_ST_FLOGI) { in fc_rport_flogi_resp()
762 FC_RPORT_DBG(rdata, "Received a FLOGI response, but in state " in fc_rport_flogi_resp()
763 "%s\n", fc_rport_state(rdata)); in fc_rport_flogi_resp()
770 fc_rport_error(rdata, PTR_ERR(fp)); in fc_rport_flogi_resp()
778 FC_RPORT_DBG(rdata, "FLOGI ELS rejected, reason %x expl %x\n", in fc_rport_flogi_resp()
783 FC_RPORT_DBG(rdata, "FLOGI ELS invalid opcode %x\n", opcode); in fc_rport_flogi_resp()
787 if (fc_rport_login_complete(rdata, fp)) { in fc_rport_flogi_resp()
788 FC_RPORT_DBG(rdata, "FLOGI failed, no login\n"); in fc_rport_flogi_resp()
799 if (r_a_tov > rdata->r_a_tov) in fc_rport_flogi_resp()
800 rdata->r_a_tov = r_a_tov; in fc_rport_flogi_resp()
802 if (rdata->ids.port_name < lport->wwpn) in fc_rport_flogi_resp()
803 fc_rport_enter_plogi(rdata); in fc_rport_flogi_resp()
805 fc_rport_state_enter(rdata, RPORT_ST_PLOGI_WAIT); in fc_rport_flogi_resp()
809 mutex_unlock(&rdata->rp_mutex); in fc_rport_flogi_resp()
811 kref_put(&rdata->kref, fc_rport_destroy); in fc_rport_flogi_resp()
814 FC_RPORT_DBG(rdata, "Bad FLOGI response\n"); in fc_rport_flogi_resp()
815 fc_rport_error_retry(rdata, err); in fc_rport_flogi_resp()
825 static void fc_rport_enter_flogi(struct fc_rport_priv *rdata) in fc_rport_enter_flogi() argument
827 struct fc_lport *lport = rdata->local_port; in fc_rport_enter_flogi()
830 lockdep_assert_held(&rdata->rp_mutex); in fc_rport_enter_flogi()
833 return fc_rport_enter_plogi(rdata); in fc_rport_enter_flogi()
835 FC_RPORT_DBG(rdata, "Entered FLOGI state from %s state\n", in fc_rport_enter_flogi()
836 fc_rport_state(rdata)); in fc_rport_enter_flogi()
838 fc_rport_state_enter(rdata, RPORT_ST_FLOGI); in fc_rport_enter_flogi()
842 return fc_rport_error_retry(rdata, -FC_EX_ALLOC_ERR); in fc_rport_enter_flogi()
844 kref_get(&rdata->kref); in fc_rport_enter_flogi()
845 if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, ELS_FLOGI, in fc_rport_enter_flogi()
846 fc_rport_flogi_resp, rdata, in fc_rport_enter_flogi()
848 fc_rport_error_retry(rdata, -FC_EX_XMIT_ERR); in fc_rport_enter_flogi()
849 kref_put(&rdata->kref, fc_rport_destroy); in fc_rport_enter_flogi()
865 struct fc_rport_priv *rdata; in fc_rport_recv_flogi_req() local
888 rdata = fc_rport_lookup(lport, sid); in fc_rport_recv_flogi_req()
889 if (!rdata) { in fc_rport_recv_flogi_req()
894 mutex_lock(&rdata->rp_mutex); in fc_rport_recv_flogi_req()
896 FC_RPORT_DBG(rdata, "Received FLOGI in %s state\n", in fc_rport_recv_flogi_req()
897 fc_rport_state(rdata)); in fc_rport_recv_flogi_req()
899 switch (rdata->rp_state) { in fc_rport_recv_flogi_req()
915 mutex_unlock(&rdata->rp_mutex); in fc_rport_recv_flogi_req()
931 fc_rport_enter_delete(rdata, RPORT_EV_LOGO); in fc_rport_recv_flogi_req()
932 mutex_unlock(&rdata->rp_mutex); in fc_rport_recv_flogi_req()
937 if (fc_rport_login_complete(rdata, fp)) { in fc_rport_recv_flogi_req()
938 mutex_unlock(&rdata->rp_mutex); in fc_rport_recv_flogi_req()
960 if (rdata->rp_state != RPORT_ST_FLOGI) { in fc_rport_recv_flogi_req()
961 if (rdata->ids.port_name < lport->wwpn) in fc_rport_recv_flogi_req()
962 fc_rport_enter_plogi(rdata); in fc_rport_recv_flogi_req()
964 fc_rport_state_enter(rdata, RPORT_ST_PLOGI_WAIT); in fc_rport_recv_flogi_req()
967 mutex_unlock(&rdata->rp_mutex); in fc_rport_recv_flogi_req()
968 kref_put(&rdata->kref, fc_rport_destroy); in fc_rport_recv_flogi_req()
973 kref_put(&rdata->kref, fc_rport_destroy); in fc_rport_recv_flogi_req()
992 struct fc_rport_priv *rdata = rdata_arg; in fc_rport_plogi_resp() local
993 struct fc_lport *lport = rdata->local_port; in fc_rport_plogi_resp()
999 FC_RPORT_DBG(rdata, "Received a PLOGI %s\n", fc_els_resp_type(fp)); in fc_rport_plogi_resp()
1004 mutex_lock(&rdata->rp_mutex); in fc_rport_plogi_resp()
1006 if (rdata->rp_state != RPORT_ST_PLOGI) { in fc_rport_plogi_resp()
1007 FC_RPORT_DBG(rdata, "Received a PLOGI response, but in state " in fc_rport_plogi_resp()
1008 "%s\n", fc_rport_state(rdata)); in fc_rport_plogi_resp()
1015 fc_rport_error_retry(rdata, PTR_ERR(fp)); in fc_rport_plogi_resp()
1022 rdata->ids.port_name = get_unaligned_be64(&plp->fl_wwpn); in fc_rport_plogi_resp()
1023 rdata->ids.node_name = get_unaligned_be64(&plp->fl_wwnn); in fc_rport_plogi_resp()
1026 rdata->sp_features = ntohs(plp->fl_csp.sp_features); in fc_rport_plogi_resp()
1029 fc_rport_login_complete(rdata, fp); in fc_rport_plogi_resp()
1034 rdata->max_seq = csp_seq; in fc_rport_plogi_resp()
1035 rdata->maxframe_size = fc_plogi_get_maxframe(plp, lport->mfs); in fc_rport_plogi_resp()
1036 fc_rport_enter_prli(rdata); in fc_rport_plogi_resp()
1041 FC_RPORT_DBG(rdata, "PLOGI ELS rejected, reason %x expl %x\n", in fc_rport_plogi_resp()
1043 fc_rport_error_retry(rdata, -FC_EX_ELS_RJT); in fc_rport_plogi_resp()
1048 mutex_unlock(&rdata->rp_mutex); in fc_rport_plogi_resp()
1050 kref_put(&rdata->kref, fc_rport_destroy); in fc_rport_plogi_resp()
1054 fc_rport_compatible_roles(struct fc_lport *lport, struct fc_rport_priv *rdata) in fc_rport_compatible_roles() argument
1056 if (rdata->ids.roles == FC_PORT_ROLE_UNKNOWN) in fc_rport_compatible_roles()
1058 if ((rdata->ids.roles & FC_PORT_ROLE_FCP_TARGET) && in fc_rport_compatible_roles()
1061 if ((rdata->ids.roles & FC_PORT_ROLE_FCP_INITIATOR) && in fc_rport_compatible_roles()
1073 static void fc_rport_enter_plogi(struct fc_rport_priv *rdata) in fc_rport_enter_plogi() argument
1075 struct fc_lport *lport = rdata->local_port; in fc_rport_enter_plogi()
1078 lockdep_assert_held(&rdata->rp_mutex); in fc_rport_enter_plogi()
1080 if (!fc_rport_compatible_roles(lport, rdata)) { in fc_rport_enter_plogi()
1081 FC_RPORT_DBG(rdata, "PLOGI suppressed for incompatible role\n"); in fc_rport_enter_plogi()
1082 fc_rport_state_enter(rdata, RPORT_ST_PLOGI_WAIT); in fc_rport_enter_plogi()
1086 FC_RPORT_DBG(rdata, "Port entered PLOGI state from %s state\n", in fc_rport_enter_plogi()
1087 fc_rport_state(rdata)); in fc_rport_enter_plogi()
1089 fc_rport_state_enter(rdata, RPORT_ST_PLOGI); in fc_rport_enter_plogi()
1091 rdata->maxframe_size = FC_MIN_MAX_PAYLOAD; in fc_rport_enter_plogi()
1094 FC_RPORT_DBG(rdata, "%s frame alloc failed\n", __func__); in fc_rport_enter_plogi()
1095 fc_rport_error_retry(rdata, -FC_EX_ALLOC_ERR); in fc_rport_enter_plogi()
1098 rdata->e_d_tov = lport->e_d_tov; in fc_rport_enter_plogi()
1100 kref_get(&rdata->kref); in fc_rport_enter_plogi()
1101 if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, ELS_PLOGI, in fc_rport_enter_plogi()
1102 fc_rport_plogi_resp, rdata, in fc_rport_enter_plogi()
1104 fc_rport_error_retry(rdata, -FC_EX_XMIT_ERR); in fc_rport_enter_plogi()
1105 kref_put(&rdata->kref, fc_rport_destroy); in fc_rport_enter_plogi()
1122 struct fc_rport_priv *rdata = rdata_arg; in fc_rport_prli_resp() local
1135 FC_RPORT_DBG(rdata, "Received a PRLI %s\n", fc_els_resp_type(fp)); in fc_rport_prli_resp()
1140 mutex_lock(&rdata->rp_mutex); in fc_rport_prli_resp()
1142 if (rdata->rp_state != RPORT_ST_PRLI) { in fc_rport_prli_resp()
1143 FC_RPORT_DBG(rdata, "Received a PRLI response, but in state " in fc_rport_prli_resp()
1144 "%s\n", fc_rport_state(rdata)); in fc_rport_prli_resp()
1151 fc_rport_error_retry(rdata, PTR_ERR(fp)); in fc_rport_prli_resp()
1156 rdata->ids.roles = FC_RPORT_ROLE_UNKNOWN; in fc_rport_prli_resp()
1165 FC_RPORT_DBG(rdata, "PRLI spp_flags = 0x%x spp_type 0x%x\n", in fc_rport_prli_resp()
1167 rdata->spp_type = pp->spp.spp_type; in fc_rport_prli_resp()
1170 fc_rport_error(rdata, -FC_EX_SEQ_ERR); in fc_rport_prli_resp()
1172 fc_rport_error_retry(rdata, -FC_EX_SEQ_ERR); in fc_rport_prli_resp()
1180 rdata->flags |= FC_RP_FLAGS_RETRY; in fc_rport_prli_resp()
1182 rdata->flags |= FC_RP_FLAGS_CONF_REQ; in fc_rport_prli_resp()
1187 prov = fc_passive_prov[rdata->spp_type]; in fc_rport_prli_resp()
1190 prov->prli(rdata, pp->prli.prli_spp_len, in fc_rport_prli_resp()
1196 if (rdata->spp_type != FC_TYPE_FCP || in fc_rport_prli_resp()
1203 rdata->supported_classes = FC_COS_CLASS3; in fc_rport_prli_resp()
1209 rdata->ids.roles = roles; in fc_rport_prli_resp()
1210 fc_rport_enter_rtv(rdata); in fc_rport_prli_resp()
1214 FC_RPORT_DBG(rdata, "PRLI ELS rejected, reason %x expl %x\n", in fc_rport_prli_resp()
1216 fc_rport_error_retry(rdata, FC_EX_ELS_RJT); in fc_rport_prli_resp()
1222 mutex_unlock(&rdata->rp_mutex); in fc_rport_prli_resp()
1224 kref_put(&rdata->kref, fc_rport_destroy); in fc_rport_prli_resp()
1233 static void fc_rport_enter_prli(struct fc_rport_priv *rdata) in fc_rport_enter_prli() argument
1235 struct fc_lport *lport = rdata->local_port; in fc_rport_enter_prli()
1243 lockdep_assert_held(&rdata->rp_mutex); in fc_rport_enter_prli()
1249 if (rdata->ids.port_id >= FC_FID_DOM_MGR) { in fc_rport_enter_prli()
1250 fc_rport_enter_ready(rdata); in fc_rport_enter_prli()
1259 fc_rport_enter_ready(rdata); in fc_rport_enter_prli()
1263 FC_RPORT_DBG(rdata, "Port entered PRLI state from %s state\n", in fc_rport_enter_prli()
1264 fc_rport_state(rdata)); in fc_rport_enter_prli()
1266 fc_rport_state_enter(rdata, RPORT_ST_PRLI); in fc_rport_enter_prli()
1270 fc_rport_error_retry(rdata, -FC_EX_ALLOC_ERR); in fc_rport_enter_prli()
1279 prov->prli(rdata, sizeof(pp->spp), NULL, &pp->spp); in fc_rport_enter_prli()
1282 fc_fill_fc_hdr(fp, FC_RCTL_ELS_REQ, rdata->ids.port_id, in fc_rport_enter_prli()
1286 kref_get(&rdata->kref); in fc_rport_enter_prli()
1288 NULL, rdata, 2 * lport->r_a_tov)) { in fc_rport_enter_prli()
1289 fc_rport_error_retry(rdata, -FC_EX_XMIT_ERR); in fc_rport_enter_prli()
1290 kref_put(&rdata->kref, fc_rport_destroy); in fc_rport_enter_prli()
1309 struct fc_rport_priv *rdata = rdata_arg; in fc_rport_rtv_resp() local
1312 FC_RPORT_DBG(rdata, "Received a RTV %s\n", fc_els_resp_type(fp)); in fc_rport_rtv_resp()
1317 mutex_lock(&rdata->rp_mutex); in fc_rport_rtv_resp()
1319 if (rdata->rp_state != RPORT_ST_RTV) { in fc_rport_rtv_resp()
1320 FC_RPORT_DBG(rdata, "Received a RTV response, but in state " in fc_rport_rtv_resp()
1321 "%s\n", fc_rport_state(rdata)); in fc_rport_rtv_resp()
1328 fc_rport_error(rdata, PTR_ERR(fp)); in fc_rport_rtv_resp()
1344 if (tov > rdata->r_a_tov) in fc_rport_rtv_resp()
1345 rdata->r_a_tov = tov; in fc_rport_rtv_resp()
1351 if (tov > rdata->e_d_tov) in fc_rport_rtv_resp()
1352 rdata->e_d_tov = tov; in fc_rport_rtv_resp()
1356 fc_rport_enter_ready(rdata); in fc_rport_rtv_resp()
1361 mutex_unlock(&rdata->rp_mutex); in fc_rport_rtv_resp()
1363 kref_put(&rdata->kref, fc_rport_destroy); in fc_rport_rtv_resp()
1372 static void fc_rport_enter_rtv(struct fc_rport_priv *rdata) in fc_rport_enter_rtv() argument
1375 struct fc_lport *lport = rdata->local_port; in fc_rport_enter_rtv()
1377 lockdep_assert_held(&rdata->rp_mutex); in fc_rport_enter_rtv()
1379 FC_RPORT_DBG(rdata, "Port entered RTV state from %s state\n", in fc_rport_enter_rtv()
1380 fc_rport_state(rdata)); in fc_rport_enter_rtv()
1382 fc_rport_state_enter(rdata, RPORT_ST_RTV); in fc_rport_enter_rtv()
1386 fc_rport_error_retry(rdata, -FC_EX_ALLOC_ERR); in fc_rport_enter_rtv()
1390 kref_get(&rdata->kref); in fc_rport_enter_rtv()
1391 if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, ELS_RTV, in fc_rport_enter_rtv()
1392 fc_rport_rtv_resp, rdata, in fc_rport_enter_rtv()
1394 fc_rport_error_retry(rdata, -FC_EX_XMIT_ERR); in fc_rport_enter_rtv()
1395 kref_put(&rdata->kref, fc_rport_destroy); in fc_rport_enter_rtv()
1404 static void fc_rport_recv_rtv_req(struct fc_rport_priv *rdata, in fc_rport_recv_rtv_req() argument
1407 struct fc_lport *lport = rdata->local_port; in fc_rport_recv_rtv_req()
1412 lockdep_assert_held(&rdata->rp_mutex); in fc_rport_recv_rtv_req()
1415 FC_RPORT_DBG(rdata, "Received RTV request\n"); in fc_rport_recv_rtv_req()
1444 struct fc_rport_priv *rdata = rdata_arg; in fc_rport_logo_resp() local
1445 struct fc_lport *lport = rdata->local_port; in fc_rport_logo_resp()
1451 kref_put(&rdata->kref, fc_rport_destroy); in fc_rport_logo_resp()
1460 static void fc_rport_enter_logo(struct fc_rport_priv *rdata) in fc_rport_enter_logo() argument
1462 struct fc_lport *lport = rdata->local_port; in fc_rport_enter_logo()
1465 lockdep_assert_held(&rdata->rp_mutex); in fc_rport_enter_logo()
1467 FC_RPORT_DBG(rdata, "Port sending LOGO from %s state\n", in fc_rport_enter_logo()
1468 fc_rport_state(rdata)); in fc_rport_enter_logo()
1473 kref_get(&rdata->kref); in fc_rport_enter_logo()
1474 if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, ELS_LOGO, in fc_rport_enter_logo()
1475 fc_rport_logo_resp, rdata, 0)) in fc_rport_enter_logo()
1476 kref_put(&rdata->kref, fc_rport_destroy); in fc_rport_enter_logo()
1492 struct fc_rport_priv *rdata = rdata_arg; in fc_rport_adisc_resp() local
1496 FC_RPORT_DBG(rdata, "Received a ADISC response\n"); in fc_rport_adisc_resp()
1501 mutex_lock(&rdata->rp_mutex); in fc_rport_adisc_resp()
1503 if (rdata->rp_state != RPORT_ST_ADISC) { in fc_rport_adisc_resp()
1504 FC_RPORT_DBG(rdata, "Received a ADISC resp but in state %s\n", in fc_rport_adisc_resp()
1505 fc_rport_state(rdata)); in fc_rport_adisc_resp()
1512 fc_rport_error(rdata, PTR_ERR(fp)); in fc_rport_adisc_resp()
1524 ntoh24(adisc->adisc_port_id) != rdata->ids.port_id || in fc_rport_adisc_resp()
1525 get_unaligned_be64(&adisc->adisc_wwpn) != rdata->ids.port_name || in fc_rport_adisc_resp()
1526 get_unaligned_be64(&adisc->adisc_wwnn) != rdata->ids.node_name) { in fc_rport_adisc_resp()
1527 FC_RPORT_DBG(rdata, "ADISC error or mismatch\n"); in fc_rport_adisc_resp()
1528 fc_rport_enter_flogi(rdata); in fc_rport_adisc_resp()
1530 FC_RPORT_DBG(rdata, "ADISC OK\n"); in fc_rport_adisc_resp()
1531 fc_rport_enter_ready(rdata); in fc_rport_adisc_resp()
1536 mutex_unlock(&rdata->rp_mutex); in fc_rport_adisc_resp()
1538 kref_put(&rdata->kref, fc_rport_destroy); in fc_rport_adisc_resp()
1547 static void fc_rport_enter_adisc(struct fc_rport_priv *rdata) in fc_rport_enter_adisc() argument
1549 struct fc_lport *lport = rdata->local_port; in fc_rport_enter_adisc()
1552 lockdep_assert_held(&rdata->rp_mutex); in fc_rport_enter_adisc()
1554 FC_RPORT_DBG(rdata, "sending ADISC from %s state\n", in fc_rport_enter_adisc()
1555 fc_rport_state(rdata)); in fc_rport_enter_adisc()
1557 fc_rport_state_enter(rdata, RPORT_ST_ADISC); in fc_rport_enter_adisc()
1561 fc_rport_error_retry(rdata, -FC_EX_ALLOC_ERR); in fc_rport_enter_adisc()
1564 kref_get(&rdata->kref); in fc_rport_enter_adisc()
1565 if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, ELS_ADISC, in fc_rport_enter_adisc()
1566 fc_rport_adisc_resp, rdata, in fc_rport_enter_adisc()
1568 fc_rport_error_retry(rdata, -FC_EX_XMIT_ERR); in fc_rport_enter_adisc()
1569 kref_put(&rdata->kref, fc_rport_destroy); in fc_rport_enter_adisc()
1578 static void fc_rport_recv_adisc_req(struct fc_rport_priv *rdata, in fc_rport_recv_adisc_req() argument
1581 struct fc_lport *lport = rdata->local_port; in fc_rport_recv_adisc_req()
1586 lockdep_assert_held(&rdata->rp_mutex); in fc_rport_recv_adisc_req()
1589 FC_RPORT_DBG(rdata, "Received ADISC request\n"); in fc_rport_recv_adisc_req()
1616 static void fc_rport_recv_rls_req(struct fc_rport_priv *rdata, in fc_rport_recv_rls_req() argument
1620 struct fc_lport *lport = rdata->local_port; in fc_rport_recv_rls_req()
1628 lockdep_assert_held(&rdata->rp_mutex); in fc_rport_recv_rls_req()
1630 FC_RPORT_DBG(rdata, "Received RLS request while in state %s\n", in fc_rport_recv_rls_req()
1631 fc_rport_state(rdata)); in fc_rport_recv_rls_req()
1687 struct fc_rport_priv *rdata; in fc_rport_recv_els_req() local
1692 rdata = fc_rport_lookup(lport, fc_frame_sid(fp)); in fc_rport_recv_els_req()
1693 if (!rdata) { in fc_rport_recv_els_req()
1700 mutex_lock(&rdata->rp_mutex); in fc_rport_recv_els_req()
1702 switch (rdata->rp_state) { in fc_rport_recv_els_req()
1710 FC_RPORT_DBG(rdata, "Reject ELS PRLI " in fc_rport_recv_els_req()
1712 fc_rport_state(rdata)); in fc_rport_recv_els_req()
1713 mutex_unlock(&rdata->rp_mutex); in fc_rport_recv_els_req()
1714 kref_put(&rdata->kref, fc_rport_destroy); in fc_rport_recv_els_req()
1718 FC_RPORT_DBG(rdata, in fc_rport_recv_els_req()
1720 fc_frame_payload_op(fp), fc_rport_state(rdata)); in fc_rport_recv_els_req()
1721 mutex_unlock(&rdata->rp_mutex); in fc_rport_recv_els_req()
1722 kref_put(&rdata->kref, fc_rport_destroy); in fc_rport_recv_els_req()
1728 fc_rport_recv_prli_req(rdata, fp); in fc_rport_recv_els_req()
1731 fc_rport_recv_prlo_req(rdata, fp); in fc_rport_recv_els_req()
1734 fc_rport_recv_adisc_req(rdata, fp); in fc_rport_recv_els_req()
1745 fc_rport_recv_rls_req(rdata, fp); in fc_rport_recv_els_req()
1748 fc_rport_recv_rtv_req(rdata, fp); in fc_rport_recv_els_req()
1755 mutex_unlock(&rdata->rp_mutex); in fc_rport_recv_els_req()
1756 kref_put(&rdata->kref, fc_rport_destroy); in fc_rport_recv_els_req()
1833 struct fc_rport_priv *rdata; in fc_rport_recv_plogi_req() local
1855 rdata = fc_rport_create(lport, sid); in fc_rport_recv_plogi_req()
1856 if (!rdata) { in fc_rport_recv_plogi_req()
1863 mutex_lock(&rdata->rp_mutex); in fc_rport_recv_plogi_req()
1866 rdata->ids.port_name = get_unaligned_be64(&pl->fl_wwpn); in fc_rport_recv_plogi_req()
1867 rdata->ids.node_name = get_unaligned_be64(&pl->fl_wwnn); in fc_rport_recv_plogi_req()
1880 switch (rdata->rp_state) { in fc_rport_recv_plogi_req()
1882 FC_RPORT_DBG(rdata, "Received PLOGI in INIT state\n"); in fc_rport_recv_plogi_req()
1885 FC_RPORT_DBG(rdata, "Received PLOGI in PLOGI_WAIT state\n"); in fc_rport_recv_plogi_req()
1888 FC_RPORT_DBG(rdata, "Received PLOGI in PLOGI state\n"); in fc_rport_recv_plogi_req()
1889 if (rdata->ids.port_name < lport->wwpn) { in fc_rport_recv_plogi_req()
1890 mutex_unlock(&rdata->rp_mutex); in fc_rport_recv_plogi_req()
1900 FC_RPORT_DBG(rdata, "Received PLOGI in logged-in state %d " in fc_rport_recv_plogi_req()
1901 "- ignored for now\n", rdata->rp_state); in fc_rport_recv_plogi_req()
1906 FC_RPORT_DBG(rdata, "Received PLOGI in state %s - send busy\n", in fc_rport_recv_plogi_req()
1907 fc_rport_state(rdata)); in fc_rport_recv_plogi_req()
1908 mutex_unlock(&rdata->rp_mutex); in fc_rport_recv_plogi_req()
1913 if (!fc_rport_compatible_roles(lport, rdata)) { in fc_rport_recv_plogi_req()
1914 FC_RPORT_DBG(rdata, "Received PLOGI for incompatible role\n"); in fc_rport_recv_plogi_req()
1915 mutex_unlock(&rdata->rp_mutex); in fc_rport_recv_plogi_req()
1924 rdata->maxframe_size = fc_plogi_get_maxframe(pl, lport->mfs); in fc_rport_recv_plogi_req()
1936 fc_rport_enter_prli(rdata); in fc_rport_recv_plogi_req()
1938 mutex_unlock(&rdata->rp_mutex); in fc_rport_recv_plogi_req()
1952 static void fc_rport_recv_prli_req(struct fc_rport_priv *rdata, in fc_rport_recv_prli_req() argument
1955 struct fc_lport *lport = rdata->local_port; in fc_rport_recv_prli_req()
1969 lockdep_assert_held(&rdata->rp_mutex); in fc_rport_recv_prli_req()
1971 FC_RPORT_DBG(rdata, "Received PRLI request while in state %s\n", in fc_rport_recv_prli_req()
1972 fc_rport_state(rdata)); in fc_rport_recv_prli_req()
2011 rdata->spp_type = rspp->spp_type; in fc_rport_recv_prli_req()
2021 active = prov->prli(rdata, plen, rspp, spp); in fc_rport_recv_prli_req()
2024 passive = prov->prli(rdata, plen, rspp, spp); in fc_rport_recv_prli_req()
2029 FC_RPORT_DBG(rdata, "PRLI rspp type %x " in fc_rport_recv_prli_req()
2068 static void fc_rport_recv_prlo_req(struct fc_rport_priv *rdata, in fc_rport_recv_prlo_req() argument
2071 struct fc_lport *lport = rdata->local_port; in fc_rport_recv_prlo_req()
2083 lockdep_assert_held(&rdata->rp_mutex); in fc_rport_recv_prlo_req()
2085 FC_RPORT_DBG(rdata, "Received PRLO request while in state %s\n", in fc_rport_recv_prlo_req()
2086 fc_rport_state(rdata)); in fc_rport_recv_prlo_req()
2118 fc_rport_enter_prli(rdata); in fc_rport_recv_prlo_req()
2142 struct fc_rport_priv *rdata; in fc_rport_recv_logo_req() local
2151 rdata = fc_rport_lookup(lport, sid); in fc_rport_recv_logo_req()
2152 if (rdata) { in fc_rport_recv_logo_req()
2153 mutex_lock(&rdata->rp_mutex); in fc_rport_recv_logo_req()
2154 FC_RPORT_DBG(rdata, "Received LOGO request while in state %s\n", in fc_rport_recv_logo_req()
2155 fc_rport_state(rdata)); in fc_rport_recv_logo_req()
2157 rdata->flags &= ~FC_RP_STARTED; in fc_rport_recv_logo_req()
2158 fc_rport_enter_delete(rdata, RPORT_EV_STOP); in fc_rport_recv_logo_req()
2159 mutex_unlock(&rdata->rp_mutex); in fc_rport_recv_logo_req()
2160 kref_put(&rdata->kref, fc_rport_destroy); in fc_rport_recv_logo_req()
2186 static int fc_rport_fcp_prli(struct fc_rport_priv *rdata, u32 spp_len, in fc_rport_fcp_prli() argument
2190 struct fc_lport *lport = rdata->local_port; in fc_rport_fcp_prli()
2194 rdata->ids.roles = FC_RPORT_ROLE_UNKNOWN; in fc_rport_fcp_prli()
2196 rdata->ids.roles |= FC_RPORT_ROLE_FCP_INITIATOR; in fc_rport_fcp_prli()
2198 rdata->ids.roles |= FC_RPORT_ROLE_FCP_TARGET; in fc_rport_fcp_prli()
2200 rdata->flags |= FC_RP_FLAGS_RETRY; in fc_rport_fcp_prli()
2201 rdata->supported_classes = FC_COS_CLASS3; in fc_rport_fcp_prli()
2230 static int fc_rport_t0_prli(struct fc_rport_priv *rdata, u32 spp_len, in fc_rport_t0_prli() argument