Lines Matching refs:lport

107 static void fc_lport_enter_fdmi(struct fc_lport *lport);
141 struct fc_lport *lport; member
153 static int fc_frame_drop(struct fc_lport *lport, struct fc_frame *fp) in fc_frame_drop() argument
168 static void fc_lport_rport_callback(struct fc_lport *lport, in fc_lport_rport_callback() argument
172 FC_LPORT_DBG(lport, "Received a %d event for port (%6.6x)\n", event, in fc_lport_rport_callback()
175 mutex_lock(&lport->lp_mutex); in fc_lport_rport_callback()
178 if (lport->state == LPORT_ST_DNS) { in fc_lport_rport_callback()
179 lport->dns_rdata = rdata; in fc_lport_rport_callback()
180 fc_lport_enter_ns(lport, LPORT_ST_RNN_ID); in fc_lport_rport_callback()
181 } else if (lport->state == LPORT_ST_FDMI) { in fc_lport_rport_callback()
182 lport->ms_rdata = rdata; in fc_lport_rport_callback()
183 fc_lport_enter_ms(lport, LPORT_ST_DHBA); in fc_lport_rport_callback()
185 FC_LPORT_DBG(lport, "Received an READY event " in fc_lport_rport_callback()
190 lport->state); in fc_lport_rport_callback()
198 lport->dns_rdata = NULL; in fc_lport_rport_callback()
200 lport->ms_rdata = NULL; in fc_lport_rport_callback()
205 mutex_unlock(&lport->lp_mutex); in fc_lport_rport_callback()
212 static const char *fc_lport_state(struct fc_lport *lport) in fc_lport_state() argument
216 cp = fc_lport_state_names[lport->state]; in fc_lport_state()
229 static void fc_lport_ptp_setup(struct fc_lport *lport, in fc_lport_ptp_setup() argument
233 lockdep_assert_held(&lport->lp_mutex); in fc_lport_ptp_setup()
235 if (lport->ptp_rdata) { in fc_lport_ptp_setup()
236 fc_rport_logoff(lport->ptp_rdata); in fc_lport_ptp_setup()
237 kref_put(&lport->ptp_rdata->kref, fc_rport_destroy); in fc_lport_ptp_setup()
239 mutex_lock(&lport->disc.disc_mutex); in fc_lport_ptp_setup()
240 lport->ptp_rdata = fc_rport_create(lport, remote_fid); in fc_lport_ptp_setup()
241 kref_get(&lport->ptp_rdata->kref); in fc_lport_ptp_setup()
242 lport->ptp_rdata->ids.port_name = remote_wwpn; in fc_lport_ptp_setup()
243 lport->ptp_rdata->ids.node_name = remote_wwnn; in fc_lport_ptp_setup()
244 mutex_unlock(&lport->disc.disc_mutex); in fc_lport_ptp_setup()
246 fc_rport_login(lport->ptp_rdata); in fc_lport_ptp_setup()
248 fc_lport_enter_ready(lport); in fc_lport_ptp_setup()
257 struct fc_lport *lport = shost_priv(shost); in fc_get_host_port_state() local
259 mutex_lock(&lport->lp_mutex); in fc_get_host_port_state()
260 if (!lport->link_up) in fc_get_host_port_state()
263 switch (lport->state) { in fc_get_host_port_state()
270 mutex_unlock(&lport->lp_mutex); in fc_get_host_port_state()
280 struct fc_lport *lport = shost_priv(shost); in fc_get_host_speed() local
282 fc_host_speed(shost) = lport->link_speed; in fc_get_host_speed()
293 struct fc_lport *lport = shost_priv(shost); in fc_get_host_stats() local
298 fc_stats = &lport->host_stats; in fc_get_host_stats()
301 fc_stats->seconds_since_last_reset = (jiffies - lport->boot_time) / HZ; in fc_get_host_stats()
306 stats = per_cpu_ptr(lport->stats, cpu); in fc_get_host_stats()
334 fc_exch_update_stats(lport); in fc_get_host_stats()
346 static void fc_lport_flogi_fill(struct fc_lport *lport, in fc_lport_flogi_fill() argument
355 put_unaligned_be64(lport->wwpn, &flogi->fl_wwpn); in fc_lport_flogi_fill()
356 put_unaligned_be64(lport->wwnn, &flogi->fl_wwnn); in fc_lport_flogi_fill()
361 sp->sp_bb_data = htons((u16) lport->mfs); in fc_lport_flogi_fill()
368 sp->sp_e_d_tov = htonl(lport->e_d_tov); in fc_lport_flogi_fill()
370 cp->cp_rdfs = htons((u16) lport->mfs); in fc_lport_flogi_fill()
381 static void fc_lport_add_fc4_type(struct fc_lport *lport, enum fc_fh_type type) in fc_lport_add_fc4_type() argument
385 mp = &lport->fcts.ff_type_map[type / FC_NS_BPW]; in fc_lport_add_fc4_type()
394 static void fc_lport_recv_rlir_req(struct fc_lport *lport, struct fc_frame *fp) in fc_lport_recv_rlir_req() argument
396 lockdep_assert_held(&lport->lp_mutex); in fc_lport_recv_rlir_req()
398 FC_LPORT_DBG(lport, "Received RLIR request while in state %s\n", in fc_lport_recv_rlir_req()
399 fc_lport_state(lport)); in fc_lport_recv_rlir_req()
410 static void fc_lport_recv_echo_req(struct fc_lport *lport, in fc_lport_recv_echo_req() argument
418 lockdep_assert_held(&lport->lp_mutex); in fc_lport_recv_echo_req()
420 FC_LPORT_DBG(lport, "Received ECHO request while in state %s\n", in fc_lport_recv_echo_req()
421 fc_lport_state(lport)); in fc_lport_recv_echo_req()
429 fp = fc_frame_alloc(lport, len); in fc_lport_recv_echo_req()
435 lport->tt.frame_send(lport, fp); in fc_lport_recv_echo_req()
445 static void fc_lport_recv_rnid_req(struct fc_lport *lport, in fc_lport_recv_rnid_req() argument
459 lockdep_assert_held(&lport->lp_mutex); in fc_lport_recv_rnid_req()
461 FC_LPORT_DBG(lport, "Received RNID request while in state %s\n", in fc_lport_recv_rnid_req()
462 fc_lport_state(lport)); in fc_lport_recv_rnid_req()
473 ntohl(lport->rnid_gen.rnid_atype) == 0) { in fc_lport_recv_rnid_req()
477 fp = fc_frame_alloc(lport, len); in fc_lport_recv_rnid_req()
484 rp->cid.rnid_wwpn = htonll(lport->wwpn); in fc_lport_recv_rnid_req()
485 rp->cid.rnid_wwnn = htonll(lport->wwnn); in fc_lport_recv_rnid_req()
488 memcpy(&rp->gen, &lport->rnid_gen, in fc_lport_recv_rnid_req()
492 lport->tt.frame_send(lport, fp); in fc_lport_recv_rnid_req()
503 static void fc_lport_recv_logo_req(struct fc_lport *lport, struct fc_frame *fp) in fc_lport_recv_logo_req() argument
505 lockdep_assert_held(&lport->lp_mutex); in fc_lport_recv_logo_req()
508 fc_lport_enter_reset(lport); in fc_lport_recv_logo_req()
519 int fc_fabric_login(struct fc_lport *lport) in fc_fabric_login() argument
523 mutex_lock(&lport->lp_mutex); in fc_fabric_login()
524 if (lport->state == LPORT_ST_DISABLED || in fc_fabric_login()
525 lport->state == LPORT_ST_LOGO) { in fc_fabric_login()
526 fc_lport_state_enter(lport, LPORT_ST_RESET); in fc_fabric_login()
527 fc_lport_enter_reset(lport); in fc_fabric_login()
530 mutex_unlock(&lport->lp_mutex); in fc_fabric_login()
540 void __fc_linkup(struct fc_lport *lport) in __fc_linkup() argument
542 lockdep_assert_held(&lport->lp_mutex); in __fc_linkup()
544 if (!lport->link_up) { in __fc_linkup()
545 lport->link_up = 1; in __fc_linkup()
547 if (lport->state == LPORT_ST_RESET) in __fc_linkup()
548 fc_lport_enter_flogi(lport); in __fc_linkup()
556 void fc_linkup(struct fc_lport *lport) in fc_linkup() argument
559 lport->host->host_no, lport->port_id); in fc_linkup()
561 mutex_lock(&lport->lp_mutex); in fc_linkup()
562 __fc_linkup(lport); in fc_linkup()
563 mutex_unlock(&lport->lp_mutex); in fc_linkup()
571 void __fc_linkdown(struct fc_lport *lport) in __fc_linkdown() argument
573 lockdep_assert_held(&lport->lp_mutex); in __fc_linkdown()
575 if (lport->link_up) { in __fc_linkdown()
576 lport->link_up = 0; in __fc_linkdown()
577 fc_lport_enter_reset(lport); in __fc_linkdown()
578 lport->tt.fcp_cleanup(lport); in __fc_linkdown()
586 void fc_linkdown(struct fc_lport *lport) in fc_linkdown() argument
589 lport->host->host_no, lport->port_id); in fc_linkdown()
591 mutex_lock(&lport->lp_mutex); in fc_linkdown()
592 __fc_linkdown(lport); in fc_linkdown()
593 mutex_unlock(&lport->lp_mutex); in fc_linkdown()
604 int fc_fabric_logoff(struct fc_lport *lport) in fc_fabric_logoff() argument
606 lport->tt.disc_stop_final(lport); in fc_fabric_logoff()
607 mutex_lock(&lport->lp_mutex); in fc_fabric_logoff()
608 if (lport->dns_rdata) in fc_fabric_logoff()
609 fc_rport_logoff(lport->dns_rdata); in fc_fabric_logoff()
610 mutex_unlock(&lport->lp_mutex); in fc_fabric_logoff()
612 mutex_lock(&lport->lp_mutex); in fc_fabric_logoff()
613 fc_lport_enter_logo(lport); in fc_fabric_logoff()
614 mutex_unlock(&lport->lp_mutex); in fc_fabric_logoff()
615 cancel_delayed_work_sync(&lport->retry_work); in fc_fabric_logoff()
630 int fc_lport_destroy(struct fc_lport *lport) in fc_lport_destroy() argument
632 mutex_lock(&lport->lp_mutex); in fc_lport_destroy()
633 lport->state = LPORT_ST_DISABLED; in fc_lport_destroy()
634 lport->link_up = 0; in fc_lport_destroy()
635 lport->tt.frame_send = fc_frame_drop; in fc_lport_destroy()
636 mutex_unlock(&lport->lp_mutex); in fc_lport_destroy()
638 lport->tt.fcp_abort_io(lport); in fc_lport_destroy()
639 lport->tt.disc_stop_final(lport); in fc_lport_destroy()
640 lport->tt.exch_mgr_reset(lport, 0, 0); in fc_lport_destroy()
641 cancel_delayed_work_sync(&lport->retry_work); in fc_lport_destroy()
642 fc_fc4_del_lport(lport); in fc_lport_destroy()
652 int fc_set_mfs(struct fc_lport *lport, u32 mfs) in fc_set_mfs() argument
657 mutex_lock(&lport->lp_mutex); in fc_set_mfs()
659 old_mfs = lport->mfs; in fc_set_mfs()
666 lport->mfs = mfs; in fc_set_mfs()
671 fc_lport_enter_reset(lport); in fc_set_mfs()
673 mutex_unlock(&lport->lp_mutex); in fc_set_mfs()
684 static void fc_lport_disc_callback(struct fc_lport *lport, in fc_lport_disc_callback() argument
689 FC_LPORT_DBG(lport, "Discovery succeeded\n"); in fc_lport_disc_callback()
694 lport->host->host_no, lport->port_id); in fc_lport_disc_callback()
695 mutex_lock(&lport->lp_mutex); in fc_lport_disc_callback()
696 fc_lport_enter_reset(lport); in fc_lport_disc_callback()
697 mutex_unlock(&lport->lp_mutex); in fc_lport_disc_callback()
709 static void fc_lport_enter_ready(struct fc_lport *lport) in fc_lport_enter_ready() argument
711 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_ready()
713 FC_LPORT_DBG(lport, "Entered READY from state %s\n", in fc_lport_enter_ready()
714 fc_lport_state(lport)); in fc_lport_enter_ready()
716 fc_lport_state_enter(lport, LPORT_ST_READY); in fc_lport_enter_ready()
717 if (lport->vport) in fc_lport_enter_ready()
718 fc_vport_set_state(lport->vport, FC_VPORT_ACTIVE); in fc_lport_enter_ready()
719 fc_vports_linkchange(lport); in fc_lport_enter_ready()
721 if (!lport->ptp_rdata) in fc_lport_enter_ready()
722 lport->tt.disc_start(fc_lport_disc_callback, lport); in fc_lport_enter_ready()
731 static void fc_lport_set_port_id(struct fc_lport *lport, u32 port_id, in fc_lport_set_port_id() argument
734 lockdep_assert_held(&lport->lp_mutex); in fc_lport_set_port_id()
738 lport->host->host_no, port_id); in fc_lport_set_port_id()
740 lport->port_id = port_id; in fc_lport_set_port_id()
743 fc_host_port_id(lport->host) = port_id; in fc_lport_set_port_id()
745 if (lport->tt.lport_set_port_id) in fc_lport_set_port_id()
746 lport->tt.lport_set_port_id(lport, port_id, fp); in fc_lport_set_port_id()
758 void fc_lport_set_local_id(struct fc_lport *lport, u32 port_id) in fc_lport_set_local_id() argument
760 mutex_lock(&lport->lp_mutex); in fc_lport_set_local_id()
762 fc_lport_set_port_id(lport, port_id, NULL); in fc_lport_set_local_id()
764 switch (lport->state) { in fc_lport_set_local_id()
768 fc_lport_enter_ready(lport); in fc_lport_set_local_id()
773 mutex_unlock(&lport->lp_mutex); in fc_lport_set_local_id()
786 static void fc_lport_recv_flogi_req(struct fc_lport *lport, in fc_lport_recv_flogi_req() argument
797 lockdep_assert_held(&lport->lp_mutex); in fc_lport_recv_flogi_req()
799 FC_LPORT_DBG(lport, "Received FLOGI request while in state %s\n", in fc_lport_recv_flogi_req()
800 fc_lport_state(lport)); in fc_lport_recv_flogi_req()
807 if (remote_wwpn == lport->wwpn) { in fc_lport_recv_flogi_req()
810 lport->host->host_no, remote_wwpn); in fc_lport_recv_flogi_req()
813 FC_LPORT_DBG(lport, "FLOGI from port WWPN %16.16llx\n", remote_wwpn); in fc_lport_recv_flogi_req()
821 if (remote_wwpn < lport->wwpn) { in fc_lport_recv_flogi_req()
829 fc_lport_set_port_id(lport, local_fid, rx_fp); in fc_lport_recv_flogi_req()
831 fp = fc_frame_alloc(lport, sizeof(*flp)); in fc_lport_recv_flogi_req()
834 fc_lport_flogi_fill(lport, new_flp, ELS_FLOGI); in fc_lport_recv_flogi_req()
845 lport->tt.frame_send(lport, fp); in fc_lport_recv_flogi_req()
848 fc_lport_error(lport, fp); in fc_lport_recv_flogi_req()
850 fc_lport_ptp_setup(lport, remote_fid, remote_wwpn, in fc_lport_recv_flogi_req()
867 static void fc_lport_recv_els_req(struct fc_lport *lport, in fc_lport_recv_els_req() argument
870 mutex_lock(&lport->lp_mutex); in fc_lport_recv_els_req()
877 if (!lport->link_up) in fc_lport_recv_els_req()
885 if (!lport->point_to_multipoint) in fc_lport_recv_els_req()
886 fc_lport_recv_flogi_req(lport, fp); in fc_lport_recv_els_req()
888 fc_rport_recv_req(lport, fp); in fc_lport_recv_els_req()
892 fc_lport_recv_logo_req(lport, fp); in fc_lport_recv_els_req()
894 fc_rport_recv_req(lport, fp); in fc_lport_recv_els_req()
897 lport->tt.disc_recv_req(lport, fp); in fc_lport_recv_els_req()
900 fc_lport_recv_echo_req(lport, fp); in fc_lport_recv_els_req()
903 fc_lport_recv_rlir_req(lport, fp); in fc_lport_recv_els_req()
906 fc_lport_recv_rnid_req(lport, fp); in fc_lport_recv_els_req()
909 fc_rport_recv_req(lport, fp); in fc_lport_recv_els_req()
913 mutex_unlock(&lport->lp_mutex); in fc_lport_recv_els_req()
936 void fc_lport_recv(struct fc_lport *lport, struct fc_frame *fp) in fc_lport_recv() argument
957 prov->recv(lport, fp); in fc_lport_recv()
962 FC_LPORT_DBG(lport, "dropping unexpected frame type %x\n", fh->fh_type); in fc_lport_recv()
976 int fc_lport_reset(struct fc_lport *lport) in fc_lport_reset() argument
978 cancel_delayed_work_sync(&lport->retry_work); in fc_lport_reset()
979 mutex_lock(&lport->lp_mutex); in fc_lport_reset()
980 fc_lport_enter_reset(lport); in fc_lport_reset()
981 mutex_unlock(&lport->lp_mutex); in fc_lport_reset()
990 static void fc_lport_reset_locked(struct fc_lport *lport) in fc_lport_reset_locked() argument
992 lockdep_assert_held(&lport->lp_mutex); in fc_lport_reset_locked()
994 if (lport->dns_rdata) { in fc_lport_reset_locked()
995 fc_rport_logoff(lport->dns_rdata); in fc_lport_reset_locked()
996 lport->dns_rdata = NULL; in fc_lport_reset_locked()
999 if (lport->ptp_rdata) { in fc_lport_reset_locked()
1000 fc_rport_logoff(lport->ptp_rdata); in fc_lport_reset_locked()
1001 kref_put(&lport->ptp_rdata->kref, fc_rport_destroy); in fc_lport_reset_locked()
1002 lport->ptp_rdata = NULL; in fc_lport_reset_locked()
1005 lport->tt.disc_stop(lport); in fc_lport_reset_locked()
1007 lport->tt.exch_mgr_reset(lport, 0, 0); in fc_lport_reset_locked()
1008 fc_host_fabric_name(lport->host) = 0; in fc_lport_reset_locked()
1010 if (lport->port_id && (!lport->point_to_multipoint || !lport->link_up)) in fc_lport_reset_locked()
1011 fc_lport_set_port_id(lport, 0, NULL); in fc_lport_reset_locked()
1018 static void fc_lport_enter_reset(struct fc_lport *lport) in fc_lport_enter_reset() argument
1020 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_reset()
1022 FC_LPORT_DBG(lport, "Entered RESET state from %s state\n", in fc_lport_enter_reset()
1023 fc_lport_state(lport)); in fc_lport_enter_reset()
1025 if (lport->state == LPORT_ST_DISABLED || lport->state == LPORT_ST_LOGO) in fc_lport_enter_reset()
1028 if (lport->vport) { in fc_lport_enter_reset()
1029 if (lport->link_up) in fc_lport_enter_reset()
1030 fc_vport_set_state(lport->vport, FC_VPORT_INITIALIZING); in fc_lport_enter_reset()
1032 fc_vport_set_state(lport->vport, FC_VPORT_LINKDOWN); in fc_lport_enter_reset()
1034 fc_lport_state_enter(lport, LPORT_ST_RESET); in fc_lport_enter_reset()
1035 fc_host_post_event(lport->host, fc_get_event_number(), in fc_lport_enter_reset()
1037 fc_vports_linkchange(lport); in fc_lport_enter_reset()
1038 fc_lport_reset_locked(lport); in fc_lport_enter_reset()
1039 if (lport->link_up) in fc_lport_enter_reset()
1040 fc_lport_enter_flogi(lport); in fc_lport_enter_reset()
1047 static void fc_lport_enter_disabled(struct fc_lport *lport) in fc_lport_enter_disabled() argument
1049 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_disabled()
1051 FC_LPORT_DBG(lport, "Entered disabled state from %s state\n", in fc_lport_enter_disabled()
1052 fc_lport_state(lport)); in fc_lport_enter_disabled()
1054 fc_lport_state_enter(lport, LPORT_ST_DISABLED); in fc_lport_enter_disabled()
1055 fc_vports_linkchange(lport); in fc_lport_enter_disabled()
1056 fc_lport_reset_locked(lport); in fc_lport_enter_disabled()
1068 static void fc_lport_error(struct fc_lport *lport, struct fc_frame *fp) in fc_lport_error() argument
1071 FC_LPORT_DBG(lport, "Error %ld in state %s, retries %d\n", in fc_lport_error()
1072 IS_ERR(fp) ? -PTR_ERR(fp) : 0, fc_lport_state(lport), in fc_lport_error()
1073 lport->retry_count); in fc_lport_error()
1083 if (lport->retry_count < lport->max_retry_count) { in fc_lport_error()
1084 lport->retry_count++; in fc_lport_error()
1088 delay = msecs_to_jiffies(lport->e_d_tov); in fc_lport_error()
1090 schedule_delayed_work(&lport->retry_work, delay); in fc_lport_error()
1092 fc_lport_enter_reset(lport); in fc_lport_error()
1109 struct fc_lport *lport = lp_arg; in fc_lport_ns_resp() local
1113 FC_LPORT_DBG(lport, "Received a ns %s\n", fc_els_resp_type(fp)); in fc_lport_ns_resp()
1118 mutex_lock(&lport->lp_mutex); in fc_lport_ns_resp()
1120 if (lport->state < LPORT_ST_RNN_ID || lport->state > LPORT_ST_RFF_ID) { in fc_lport_ns_resp()
1121 FC_LPORT_DBG(lport, "Received a name server response, " in fc_lport_ns_resp()
1122 "but in state %s\n", fc_lport_state(lport)); in fc_lport_ns_resp()
1129 fc_lport_error(lport, fp); in fc_lport_ns_resp()
1140 switch (lport->state) { in fc_lport_ns_resp()
1142 fc_lport_enter_ns(lport, LPORT_ST_RSNN_NN); in fc_lport_ns_resp()
1145 fc_lport_enter_ns(lport, LPORT_ST_RSPN_ID); in fc_lport_ns_resp()
1148 fc_lport_enter_ns(lport, LPORT_ST_RFT_ID); in fc_lport_ns_resp()
1151 fc_lport_enter_ns(lport, LPORT_ST_RFF_ID); in fc_lport_ns_resp()
1154 if (lport->fdmi_enabled) in fc_lport_ns_resp()
1155 fc_lport_enter_fdmi(lport); in fc_lport_ns_resp()
1157 fc_lport_enter_scr(lport); in fc_lport_ns_resp()
1164 fc_lport_error(lport, fp); in fc_lport_ns_resp()
1168 mutex_unlock(&lport->lp_mutex); in fc_lport_ns_resp()
1185 struct fc_lport *lport = lp_arg; in fc_lport_ms_resp() local
1189 FC_LPORT_DBG(lport, "Received a ms %s\n", fc_els_resp_type(fp)); in fc_lport_ms_resp()
1194 mutex_lock(&lport->lp_mutex); in fc_lport_ms_resp()
1196 if (lport->state < LPORT_ST_RHBA || lport->state > LPORT_ST_DPRT) { in fc_lport_ms_resp()
1197 FC_LPORT_DBG(lport, "Received a management server response, " in fc_lport_ms_resp()
1198 "but in state %s\n", fc_lport_state(lport)); in fc_lport_ms_resp()
1205 fc_lport_error(lport, fp); in fc_lport_ms_resp()
1215 FC_LPORT_DBG(lport, "Received a management server response, " in fc_lport_ms_resp()
1220 switch (lport->state) { in fc_lport_ms_resp()
1223 fc_lport_enter_ms(lport, LPORT_ST_RPA); in fc_lport_ms_resp()
1225 fc_lport_enter_scr(lport); in fc_lport_ms_resp()
1228 fc_lport_enter_scr(lport); in fc_lport_ms_resp()
1231 fc_lport_enter_ms(lport, LPORT_ST_RHBA); in fc_lport_ms_resp()
1234 fc_lport_enter_ms(lport, LPORT_ST_DPRT); in fc_lport_ms_resp()
1242 fc_lport_error(lport, fp); in fc_lport_ms_resp()
1247 mutex_unlock(&lport->lp_mutex); in fc_lport_ms_resp()
1263 struct fc_lport *lport = lp_arg; in fc_lport_scr_resp() local
1266 FC_LPORT_DBG(lport, "Received a SCR %s\n", fc_els_resp_type(fp)); in fc_lport_scr_resp()
1271 mutex_lock(&lport->lp_mutex); in fc_lport_scr_resp()
1273 if (lport->state != LPORT_ST_SCR) { in fc_lport_scr_resp()
1274 FC_LPORT_DBG(lport, "Received a SCR response, but in state " in fc_lport_scr_resp()
1275 "%s\n", fc_lport_state(lport)); in fc_lport_scr_resp()
1282 fc_lport_error(lport, fp); in fc_lport_scr_resp()
1288 fc_lport_enter_ready(lport); in fc_lport_scr_resp()
1290 fc_lport_error(lport, fp); in fc_lport_scr_resp()
1295 mutex_unlock(&lport->lp_mutex); in fc_lport_scr_resp()
1302 static void fc_lport_enter_scr(struct fc_lport *lport) in fc_lport_enter_scr() argument
1306 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_scr()
1308 FC_LPORT_DBG(lport, "Entered SCR state from %s state\n", in fc_lport_enter_scr()
1309 fc_lport_state(lport)); in fc_lport_enter_scr()
1311 fc_lport_state_enter(lport, LPORT_ST_SCR); in fc_lport_enter_scr()
1313 fp = fc_frame_alloc(lport, sizeof(struct fc_els_scr)); in fc_lport_enter_scr()
1315 fc_lport_error(lport, fp); in fc_lport_enter_scr()
1319 if (!lport->tt.elsct_send(lport, FC_FID_FCTRL, fp, ELS_SCR, in fc_lport_enter_scr()
1320 fc_lport_scr_resp, lport, in fc_lport_enter_scr()
1321 2 * lport->r_a_tov)) in fc_lport_enter_scr()
1322 fc_lport_error(lport, NULL); in fc_lport_enter_scr()
1330 static void fc_lport_enter_ns(struct fc_lport *lport, enum fc_lport_state state) in fc_lport_enter_ns() argument
1337 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_ns()
1339 FC_LPORT_DBG(lport, "Entered %s state from %s state\n", in fc_lport_enter_ns()
1341 fc_lport_state(lport)); in fc_lport_enter_ns()
1343 fc_lport_state_enter(lport, state); in fc_lport_enter_ns()
1351 len = strnlen(fc_host_symbolic_name(lport->host), 255); in fc_lport_enter_ns()
1354 return fc_lport_enter_ns(lport, LPORT_ST_RFT_ID); in fc_lport_enter_ns()
1359 len = strnlen(fc_host_symbolic_name(lport->host), 255); in fc_lport_enter_ns()
1362 return fc_lport_enter_ns(lport, LPORT_ST_RFT_ID); in fc_lport_enter_ns()
1375 fc_lport_error(lport, NULL); in fc_lport_enter_ns()
1379 fp = fc_frame_alloc(lport, size); in fc_lport_enter_ns()
1381 fc_lport_error(lport, fp); in fc_lport_enter_ns()
1385 if (!lport->tt.elsct_send(lport, FC_FID_DIR_SERV, fp, cmd, in fc_lport_enter_ns()
1387 lport, 3 * lport->r_a_tov)) in fc_lport_enter_ns()
1388 fc_lport_error(lport, fp); in fc_lport_enter_ns()
1399 static void fc_lport_enter_dns(struct fc_lport *lport) in fc_lport_enter_dns() argument
1403 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_dns()
1405 FC_LPORT_DBG(lport, "Entered DNS state from %s state\n", in fc_lport_enter_dns()
1406 fc_lport_state(lport)); in fc_lport_enter_dns()
1408 fc_lport_state_enter(lport, LPORT_ST_DNS); in fc_lport_enter_dns()
1410 mutex_lock(&lport->disc.disc_mutex); in fc_lport_enter_dns()
1411 rdata = fc_rport_create(lport, FC_FID_DIR_SERV); in fc_lport_enter_dns()
1412 mutex_unlock(&lport->disc.disc_mutex); in fc_lport_enter_dns()
1421 fc_lport_error(lport, NULL); in fc_lport_enter_dns()
1429 static void fc_lport_enter_ms(struct fc_lport *lport, enum fc_lport_state state) in fc_lport_enter_ms() argument
1437 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_ms()
1439 FC_LPORT_DBG(lport, "Entered %s state from %s state\n", in fc_lport_enter_ms()
1441 fc_lport_state(lport)); in fc_lport_enter_ms()
1443 fc_lport_state_enter(lport, state); in fc_lport_enter_ms()
1493 fc_lport_error(lport, NULL); in fc_lport_enter_ms()
1497 FC_LPORT_DBG(lport, "Cmd=0x%x Len %d size %d\n", in fc_lport_enter_ms()
1499 fp = fc_frame_alloc(lport, size); in fc_lport_enter_ms()
1501 fc_lport_error(lport, fp); in fc_lport_enter_ms()
1505 if (!lport->tt.elsct_send(lport, FC_FID_MGMT_SERV, fp, cmd, in fc_lport_enter_ms()
1507 lport, 3 * lport->r_a_tov)) in fc_lport_enter_ms()
1508 fc_lport_error(lport, fp); in fc_lport_enter_ms()
1515 static void fc_lport_enter_fdmi(struct fc_lport *lport) in fc_lport_enter_fdmi() argument
1519 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_fdmi()
1521 FC_LPORT_DBG(lport, "Entered FDMI state from %s state\n", in fc_lport_enter_fdmi()
1522 fc_lport_state(lport)); in fc_lport_enter_fdmi()
1524 fc_lport_state_enter(lport, LPORT_ST_FDMI); in fc_lport_enter_fdmi()
1526 mutex_lock(&lport->disc.disc_mutex); in fc_lport_enter_fdmi()
1527 rdata = fc_rport_create(lport, FC_FID_MGMT_SERV); in fc_lport_enter_fdmi()
1528 mutex_unlock(&lport->disc.disc_mutex); in fc_lport_enter_fdmi()
1537 fc_lport_error(lport, NULL); in fc_lport_enter_fdmi()
1546 struct fc_lport *lport = in fc_lport_timeout() local
1550 mutex_lock(&lport->lp_mutex); in fc_lport_timeout()
1552 switch (lport->state) { in fc_lport_timeout()
1560 fc_lport_enter_flogi(lport); in fc_lport_timeout()
1563 fc_lport_enter_dns(lport); in fc_lport_timeout()
1570 fc_lport_enter_ns(lport, lport->state); in fc_lport_timeout()
1573 fc_lport_enter_fdmi(lport); in fc_lport_timeout()
1579 FC_LPORT_DBG(lport, "Skipping lport state %s to SCR\n", in fc_lport_timeout()
1580 fc_lport_state(lport)); in fc_lport_timeout()
1583 fc_lport_enter_scr(lport); in fc_lport_timeout()
1586 fc_lport_enter_logo(lport); in fc_lport_timeout()
1590 mutex_unlock(&lport->lp_mutex); in fc_lport_timeout()
1606 struct fc_lport *lport = lp_arg; in fc_lport_logo_resp() local
1609 FC_LPORT_DBG(lport, "Received a LOGO %s\n", fc_els_resp_type(fp)); in fc_lport_logo_resp()
1614 mutex_lock(&lport->lp_mutex); in fc_lport_logo_resp()
1616 if (lport->state != LPORT_ST_LOGO) { in fc_lport_logo_resp()
1617 FC_LPORT_DBG(lport, "Received a LOGO response, but in state " in fc_lport_logo_resp()
1618 "%s\n", fc_lport_state(lport)); in fc_lport_logo_resp()
1625 fc_lport_error(lport, fp); in fc_lport_logo_resp()
1631 fc_lport_enter_disabled(lport); in fc_lport_logo_resp()
1633 fc_lport_error(lport, fp); in fc_lport_logo_resp()
1638 mutex_unlock(&lport->lp_mutex); in fc_lport_logo_resp()
1646 static void fc_lport_enter_logo(struct fc_lport *lport) in fc_lport_enter_logo() argument
1651 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_logo()
1653 FC_LPORT_DBG(lport, "Entered LOGO state from %s state\n", in fc_lport_enter_logo()
1654 fc_lport_state(lport)); in fc_lport_enter_logo()
1656 fc_lport_state_enter(lport, LPORT_ST_LOGO); in fc_lport_enter_logo()
1657 fc_vports_linkchange(lport); in fc_lport_enter_logo()
1659 fp = fc_frame_alloc(lport, sizeof(*logo)); in fc_lport_enter_logo()
1661 fc_lport_error(lport, fp); in fc_lport_enter_logo()
1665 if (!lport->tt.elsct_send(lport, FC_FID_FLOGI, fp, ELS_LOGO, in fc_lport_enter_logo()
1666 fc_lport_logo_resp, lport, in fc_lport_enter_logo()
1667 2 * lport->r_a_tov)) in fc_lport_enter_logo()
1668 fc_lport_error(lport, NULL); in fc_lport_enter_logo()
1684 struct fc_lport *lport = lp_arg; in fc_lport_flogi_resp() local
1693 FC_LPORT_DBG(lport, "Received a FLOGI %s\n", fc_els_resp_type(fp)); in fc_lport_flogi_resp()
1698 mutex_lock(&lport->lp_mutex); in fc_lport_flogi_resp()
1700 if (lport->state != LPORT_ST_FLOGI) { in fc_lport_flogi_resp()
1701 FC_LPORT_DBG(lport, "Received a FLOGI response, but in state " in fc_lport_flogi_resp()
1702 "%s\n", fc_lport_state(lport)); in fc_lport_flogi_resp()
1709 fc_lport_error(lport, fp); in fc_lport_flogi_resp()
1717 FC_LPORT_DBG(lport, "FLOGI not accepted or bad response\n"); in fc_lport_flogi_resp()
1718 fc_lport_error(lport, fp); in fc_lport_flogi_resp()
1724 FC_LPORT_DBG(lport, "FLOGI bad response\n"); in fc_lport_flogi_resp()
1725 fc_lport_error(lport, fp); in fc_lport_flogi_resp()
1733 FC_LPORT_DBG(lport, "FLOGI bad mfs:%hu response, " in fc_lport_flogi_resp()
1734 "lport->mfs:%u\n", mfs, lport->mfs); in fc_lport_flogi_resp()
1735 fc_lport_error(lport, fp); in fc_lport_flogi_resp()
1739 if (mfs <= lport->mfs) { in fc_lport_flogi_resp()
1740 lport->mfs = mfs; in fc_lport_flogi_resp()
1741 fc_host_maxframe_size(lport->host) = mfs; in fc_lport_flogi_resp()
1750 lport->npiv_enabled = !!(csp_flags & FC_SP_FT_NPIV_ACC); in fc_lport_flogi_resp()
1753 if (e_d_tov > lport->e_d_tov) in fc_lport_flogi_resp()
1754 lport->e_d_tov = e_d_tov; in fc_lport_flogi_resp()
1755 lport->r_a_tov = 2 * lport->e_d_tov; in fc_lport_flogi_resp()
1756 fc_lport_set_port_id(lport, did, fp); in fc_lport_flogi_resp()
1760 lport->host->host_no, did); in fc_lport_flogi_resp()
1761 fc_lport_ptp_setup(lport, fc_frame_sid(fp), in fc_lport_flogi_resp()
1767 if (e_d_tov > lport->e_d_tov) in fc_lport_flogi_resp()
1768 lport->e_d_tov = e_d_tov; in fc_lport_flogi_resp()
1769 if (r_a_tov > lport->r_a_tov) in fc_lport_flogi_resp()
1770 lport->r_a_tov = r_a_tov; in fc_lport_flogi_resp()
1771 fc_host_fabric_name(lport->host) = in fc_lport_flogi_resp()
1773 fc_lport_set_port_id(lport, did, fp); in fc_lport_flogi_resp()
1774 fc_lport_enter_dns(lport); in fc_lport_flogi_resp()
1780 mutex_unlock(&lport->lp_mutex); in fc_lport_flogi_resp()
1788 static void fc_lport_enter_flogi(struct fc_lport *lport) in fc_lport_enter_flogi() argument
1792 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_flogi()
1794 FC_LPORT_DBG(lport, "Entered FLOGI state from %s state\n", in fc_lport_enter_flogi()
1795 fc_lport_state(lport)); in fc_lport_enter_flogi()
1797 fc_lport_state_enter(lport, LPORT_ST_FLOGI); in fc_lport_enter_flogi()
1799 if (lport->point_to_multipoint) { in fc_lport_enter_flogi()
1800 if (lport->port_id) in fc_lport_enter_flogi()
1801 fc_lport_enter_ready(lport); in fc_lport_enter_flogi()
1805 fp = fc_frame_alloc(lport, sizeof(struct fc_els_flogi)); in fc_lport_enter_flogi()
1807 return fc_lport_error(lport, fp); in fc_lport_enter_flogi()
1809 if (!lport->tt.elsct_send(lport, FC_FID_FLOGI, fp, in fc_lport_enter_flogi()
1810 lport->vport ? ELS_FDISC : ELS_FLOGI, in fc_lport_enter_flogi()
1811 fc_lport_flogi_resp, lport, in fc_lport_enter_flogi()
1812 lport->vport ? 2 * lport->r_a_tov : in fc_lport_enter_flogi()
1813 lport->e_d_tov)) in fc_lport_enter_flogi()
1814 fc_lport_error(lport, NULL); in fc_lport_enter_flogi()
1821 int fc_lport_config(struct fc_lport *lport) in fc_lport_config() argument
1823 INIT_DELAYED_WORK(&lport->retry_work, fc_lport_timeout); in fc_lport_config()
1824 mutex_init(&lport->lp_mutex); in fc_lport_config()
1826 fc_lport_state_enter(lport, LPORT_ST_DISABLED); in fc_lport_config()
1828 fc_lport_add_fc4_type(lport, FC_TYPE_FCP); in fc_lport_config()
1829 fc_lport_add_fc4_type(lport, FC_TYPE_CT); in fc_lport_config()
1830 fc_fc4_conf_lport_params(lport, FC_TYPE_FCP); in fc_lport_config()
1840 int fc_lport_init(struct fc_lport *lport) in fc_lport_init() argument
1842 fc_host_port_type(lport->host) = FC_PORTTYPE_NPORT; in fc_lport_init()
1843 fc_host_node_name(lport->host) = lport->wwnn; in fc_lport_init()
1844 fc_host_port_name(lport->host) = lport->wwpn; in fc_lport_init()
1845 fc_host_supported_classes(lport->host) = FC_COS_CLASS3; in fc_lport_init()
1846 memset(fc_host_supported_fc4s(lport->host), 0, in fc_lport_init()
1847 sizeof(fc_host_supported_fc4s(lport->host))); in fc_lport_init()
1848 fc_host_supported_fc4s(lport->host)[2] = 1; in fc_lport_init() local
1849 fc_host_supported_fc4s(lport->host)[7] = 1; in fc_lport_init() local
1852 memset(fc_host_active_fc4s(lport->host), 0, in fc_lport_init()
1853 sizeof(fc_host_active_fc4s(lport->host))); in fc_lport_init()
1854 fc_host_active_fc4s(lport->host)[2] = 1; in fc_lport_init() local
1855 fc_host_active_fc4s(lport->host)[7] = 1; in fc_lport_init() local
1856 fc_host_maxframe_size(lport->host) = lport->mfs; in fc_lport_init()
1857 fc_host_supported_speeds(lport->host) = 0; in fc_lport_init()
1858 if (lport->link_supported_speeds & FC_PORTSPEED_1GBIT) in fc_lport_init()
1859 fc_host_supported_speeds(lport->host) |= FC_PORTSPEED_1GBIT; in fc_lport_init()
1860 if (lport->link_supported_speeds & FC_PORTSPEED_10GBIT) in fc_lport_init()
1861 fc_host_supported_speeds(lport->host) |= FC_PORTSPEED_10GBIT; in fc_lport_init()
1862 fc_fc4_add_lport(lport); in fc_lport_init()
1880 struct fc_lport *lport = info->lport; in fc_lport_bsg_resp() local
1895 mutex_lock(&lport->lp_mutex); in fc_lport_bsg_resp()
1929 mutex_unlock(&lport->lp_mutex); in fc_lport_bsg_resp()
1940 struct fc_lport *lport, in fc_lport_els_request() argument
1949 lockdep_assert_held(&lport->lp_mutex); in fc_lport_els_request()
1951 fp = fc_frame_alloc(lport, job->request_payload.payload_len); in fc_lport_els_request()
1965 hton24(fh->fh_s_id, lport->port_id); in fc_lport_els_request()
1979 info->lport = lport; in fc_lport_els_request()
1984 if (!fc_exch_seq_send(lport, fp, fc_lport_bsg_resp, in fc_lport_els_request()
2000 struct fc_lport *lport, u32 did, u32 tov) in fc_lport_ct_request() argument
2008 lockdep_assert_held(&lport->lp_mutex); in fc_lport_ct_request()
2010 fp = fc_frame_alloc(lport, sizeof(struct fc_ct_hdr) + in fc_lport_ct_request()
2025 hton24(fh->fh_s_id, lport->port_id); in fc_lport_ct_request()
2039 info->lport = lport; in fc_lport_ct_request()
2044 if (!fc_exch_seq_send(lport, fp, fc_lport_bsg_resp, in fc_lport_ct_request()
2062 struct fc_lport *lport = shost_priv(shost); in fc_lport_bsg_request() local
2070 mutex_lock(&lport->lp_mutex); in fc_lport_bsg_request()
2079 rc = fc_lport_els_request(job, lport, rport->port_id, in fc_lport_bsg_request()
2089 rc = fc_lport_ct_request(job, lport, rport->port_id, in fc_lport_bsg_request()
2096 rdata = lport->dns_rdata; in fc_lport_bsg_request()
2101 rdata = fc_rport_lookup(lport, did); in fc_lport_bsg_request()
2108 rc = fc_lport_ct_request(job, lport, did, tov); in fc_lport_bsg_request()
2113 rc = fc_lport_els_request(job, lport, did, lport->e_d_tov); in fc_lport_bsg_request()
2117 mutex_unlock(&lport->lp_mutex); in fc_lport_bsg_request()