Lines Matching refs:lport

110 static void fc_lport_enter_fdmi(struct fc_lport *lport);
144 struct fc_lport *lport; member
156 static int fc_frame_drop(struct fc_lport *lport, struct fc_frame *fp) in fc_frame_drop() argument
171 static void fc_lport_rport_callback(struct fc_lport *lport, in fc_lport_rport_callback() argument
175 FC_LPORT_DBG(lport, "Received a %d event for port (%6.6x)\n", event, in fc_lport_rport_callback()
178 mutex_lock(&lport->lp_mutex); in fc_lport_rport_callback()
181 if (lport->state == LPORT_ST_DNS) { in fc_lport_rport_callback()
182 lport->dns_rdata = rdata; in fc_lport_rport_callback()
183 fc_lport_enter_ns(lport, LPORT_ST_RNN_ID); in fc_lport_rport_callback()
184 } else if (lport->state == LPORT_ST_FDMI) { in fc_lport_rport_callback()
185 lport->ms_rdata = rdata; in fc_lport_rport_callback()
186 fc_lport_enter_ms(lport, LPORT_ST_DHBA); in fc_lport_rport_callback()
188 FC_LPORT_DBG(lport, "Received an READY event " in fc_lport_rport_callback()
193 lport->state); in fc_lport_rport_callback()
201 lport->dns_rdata = NULL; in fc_lport_rport_callback()
203 lport->ms_rdata = NULL; in fc_lport_rport_callback()
208 mutex_unlock(&lport->lp_mutex); in fc_lport_rport_callback()
215 static const char *fc_lport_state(struct fc_lport *lport) in fc_lport_state() argument
219 cp = fc_lport_state_names[lport->state]; in fc_lport_state()
232 static void fc_lport_ptp_setup(struct fc_lport *lport, in fc_lport_ptp_setup() argument
236 lockdep_assert_held(&lport->lp_mutex); in fc_lport_ptp_setup()
238 if (lport->ptp_rdata) { in fc_lport_ptp_setup()
239 fc_rport_logoff(lport->ptp_rdata); in fc_lport_ptp_setup()
240 kref_put(&lport->ptp_rdata->kref, fc_rport_destroy); in fc_lport_ptp_setup()
242 mutex_lock(&lport->disc.disc_mutex); in fc_lport_ptp_setup()
243 lport->ptp_rdata = fc_rport_create(lport, remote_fid); in fc_lport_ptp_setup()
244 if (!lport->ptp_rdata) { in fc_lport_ptp_setup()
246 lport->port_id); in fc_lport_ptp_setup()
247 mutex_unlock(&lport->disc.disc_mutex); in fc_lport_ptp_setup()
250 kref_get(&lport->ptp_rdata->kref); in fc_lport_ptp_setup()
251 lport->ptp_rdata->ids.port_name = remote_wwpn; in fc_lport_ptp_setup()
252 lport->ptp_rdata->ids.node_name = remote_wwnn; in fc_lport_ptp_setup()
253 mutex_unlock(&lport->disc.disc_mutex); in fc_lport_ptp_setup()
255 fc_rport_login(lport->ptp_rdata); in fc_lport_ptp_setup()
257 fc_lport_enter_ready(lport); in fc_lport_ptp_setup()
266 struct fc_lport *lport = shost_priv(shost); in fc_get_host_port_state() local
268 mutex_lock(&lport->lp_mutex); in fc_get_host_port_state()
269 if (!lport->link_up) in fc_get_host_port_state()
272 switch (lport->state) { in fc_get_host_port_state()
279 mutex_unlock(&lport->lp_mutex); in fc_get_host_port_state()
289 struct fc_lport *lport = shost_priv(shost); in fc_get_host_speed() local
291 fc_host_speed(shost) = lport->link_speed; in fc_get_host_speed()
302 struct fc_lport *lport = shost_priv(shost); in fc_get_host_stats() local
307 fc_stats = &lport->host_stats; in fc_get_host_stats()
310 fc_stats->seconds_since_last_reset = (jiffies - lport->boot_time) / HZ; in fc_get_host_stats()
315 stats = per_cpu_ptr(lport->stats, cpu); in fc_get_host_stats()
343 fc_exch_update_stats(lport); in fc_get_host_stats()
355 static void fc_lport_flogi_fill(struct fc_lport *lport, in fc_lport_flogi_fill() argument
364 put_unaligned_be64(lport->wwpn, &flogi->fl_wwpn); in fc_lport_flogi_fill()
365 put_unaligned_be64(lport->wwnn, &flogi->fl_wwnn); in fc_lport_flogi_fill()
370 sp->sp_bb_data = htons((u16) lport->mfs); in fc_lport_flogi_fill()
377 sp->sp_e_d_tov = htonl(lport->e_d_tov); in fc_lport_flogi_fill()
379 cp->cp_rdfs = htons((u16) lport->mfs); in fc_lport_flogi_fill()
390 static void fc_lport_add_fc4_type(struct fc_lport *lport, enum fc_fh_type type) in fc_lport_add_fc4_type() argument
394 mp = &lport->fcts.ff_type_map[type / FC_NS_BPW]; in fc_lport_add_fc4_type()
403 static void fc_lport_recv_rlir_req(struct fc_lport *lport, struct fc_frame *fp) in fc_lport_recv_rlir_req() argument
405 lockdep_assert_held(&lport->lp_mutex); in fc_lport_recv_rlir_req()
407 FC_LPORT_DBG(lport, "Received RLIR request while in state %s\n", in fc_lport_recv_rlir_req()
408 fc_lport_state(lport)); in fc_lport_recv_rlir_req()
419 static void fc_lport_recv_echo_req(struct fc_lport *lport, in fc_lport_recv_echo_req() argument
427 lockdep_assert_held(&lport->lp_mutex); in fc_lport_recv_echo_req()
429 FC_LPORT_DBG(lport, "Received ECHO request while in state %s\n", in fc_lport_recv_echo_req()
430 fc_lport_state(lport)); in fc_lport_recv_echo_req()
438 fp = fc_frame_alloc(lport, len); in fc_lport_recv_echo_req()
444 lport->tt.frame_send(lport, fp); in fc_lport_recv_echo_req()
454 static void fc_lport_recv_rnid_req(struct fc_lport *lport, in fc_lport_recv_rnid_req() argument
468 lockdep_assert_held(&lport->lp_mutex); in fc_lport_recv_rnid_req()
470 FC_LPORT_DBG(lport, "Received RNID request while in state %s\n", in fc_lport_recv_rnid_req()
471 fc_lport_state(lport)); in fc_lport_recv_rnid_req()
482 ntohl(lport->rnid_gen.rnid_atype) == 0) { in fc_lport_recv_rnid_req()
486 fp = fc_frame_alloc(lport, len); in fc_lport_recv_rnid_req()
493 rp->cid.rnid_wwpn = htonll(lport->wwpn); in fc_lport_recv_rnid_req()
494 rp->cid.rnid_wwnn = htonll(lport->wwnn); in fc_lport_recv_rnid_req()
497 memcpy(&rp->gen, &lport->rnid_gen, in fc_lport_recv_rnid_req()
501 lport->tt.frame_send(lport, fp); in fc_lport_recv_rnid_req()
512 static void fc_lport_recv_logo_req(struct fc_lport *lport, struct fc_frame *fp) in fc_lport_recv_logo_req() argument
514 lockdep_assert_held(&lport->lp_mutex); in fc_lport_recv_logo_req()
517 fc_lport_enter_reset(lport); in fc_lport_recv_logo_req()
528 int fc_fabric_login(struct fc_lport *lport) in fc_fabric_login() argument
532 mutex_lock(&lport->lp_mutex); in fc_fabric_login()
533 if (lport->state == LPORT_ST_DISABLED || in fc_fabric_login()
534 lport->state == LPORT_ST_LOGO) { in fc_fabric_login()
535 fc_lport_state_enter(lport, LPORT_ST_RESET); in fc_fabric_login()
536 fc_lport_enter_reset(lport); in fc_fabric_login()
539 mutex_unlock(&lport->lp_mutex); in fc_fabric_login()
549 void __fc_linkup(struct fc_lport *lport) in __fc_linkup() argument
551 lockdep_assert_held(&lport->lp_mutex); in __fc_linkup()
553 if (!lport->link_up) { in __fc_linkup()
554 lport->link_up = 1; in __fc_linkup()
556 if (lport->state == LPORT_ST_RESET) in __fc_linkup()
557 fc_lport_enter_flogi(lport); in __fc_linkup()
565 void fc_linkup(struct fc_lport *lport) in fc_linkup() argument
568 lport->host->host_no, lport->port_id); in fc_linkup()
570 mutex_lock(&lport->lp_mutex); in fc_linkup()
571 __fc_linkup(lport); in fc_linkup()
572 mutex_unlock(&lport->lp_mutex); in fc_linkup()
580 void __fc_linkdown(struct fc_lport *lport) in __fc_linkdown() argument
582 lockdep_assert_held(&lport->lp_mutex); in __fc_linkdown()
584 if (lport->link_up) { in __fc_linkdown()
585 lport->link_up = 0; in __fc_linkdown()
586 fc_lport_enter_reset(lport); in __fc_linkdown()
587 lport->tt.fcp_cleanup(lport); in __fc_linkdown()
595 void fc_linkdown(struct fc_lport *lport) in fc_linkdown() argument
598 lport->host->host_no, lport->port_id); in fc_linkdown()
600 mutex_lock(&lport->lp_mutex); in fc_linkdown()
601 __fc_linkdown(lport); in fc_linkdown()
602 mutex_unlock(&lport->lp_mutex); in fc_linkdown()
613 int fc_fabric_logoff(struct fc_lport *lport) in fc_fabric_logoff() argument
615 lport->tt.disc_stop_final(lport); in fc_fabric_logoff()
616 mutex_lock(&lport->lp_mutex); in fc_fabric_logoff()
617 if (lport->dns_rdata) in fc_fabric_logoff()
618 fc_rport_logoff(lport->dns_rdata); in fc_fabric_logoff()
619 mutex_unlock(&lport->lp_mutex); in fc_fabric_logoff()
621 mutex_lock(&lport->lp_mutex); in fc_fabric_logoff()
622 fc_lport_enter_logo(lport); in fc_fabric_logoff()
623 mutex_unlock(&lport->lp_mutex); in fc_fabric_logoff()
624 cancel_delayed_work_sync(&lport->retry_work); in fc_fabric_logoff()
639 int fc_lport_destroy(struct fc_lport *lport) in fc_lport_destroy() argument
641 mutex_lock(&lport->lp_mutex); in fc_lport_destroy()
642 lport->state = LPORT_ST_DISABLED; in fc_lport_destroy()
643 lport->link_up = 0; in fc_lport_destroy()
644 lport->tt.frame_send = fc_frame_drop; in fc_lport_destroy()
645 mutex_unlock(&lport->lp_mutex); in fc_lport_destroy()
647 lport->tt.fcp_abort_io(lport); in fc_lport_destroy()
648 lport->tt.disc_stop_final(lport); in fc_lport_destroy()
649 lport->tt.exch_mgr_reset(lport, 0, 0); in fc_lport_destroy()
650 cancel_delayed_work_sync(&lport->retry_work); in fc_lport_destroy()
651 fc_fc4_del_lport(lport); in fc_lport_destroy()
661 int fc_set_mfs(struct fc_lport *lport, u32 mfs) in fc_set_mfs() argument
666 mutex_lock(&lport->lp_mutex); in fc_set_mfs()
668 old_mfs = lport->mfs; in fc_set_mfs()
675 lport->mfs = mfs; in fc_set_mfs()
680 fc_lport_enter_reset(lport); in fc_set_mfs()
682 mutex_unlock(&lport->lp_mutex); in fc_set_mfs()
693 static void fc_lport_disc_callback(struct fc_lport *lport, in fc_lport_disc_callback() argument
698 FC_LPORT_DBG(lport, "Discovery succeeded\n"); in fc_lport_disc_callback()
703 lport->host->host_no, lport->port_id); in fc_lport_disc_callback()
704 mutex_lock(&lport->lp_mutex); in fc_lport_disc_callback()
705 fc_lport_enter_reset(lport); in fc_lport_disc_callback()
706 mutex_unlock(&lport->lp_mutex); in fc_lport_disc_callback()
718 static void fc_lport_enter_ready(struct fc_lport *lport) in fc_lport_enter_ready() argument
720 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_ready()
722 FC_LPORT_DBG(lport, "Entered READY from state %s\n", in fc_lport_enter_ready()
723 fc_lport_state(lport)); in fc_lport_enter_ready()
725 fc_lport_state_enter(lport, LPORT_ST_READY); in fc_lport_enter_ready()
726 if (lport->vport) in fc_lport_enter_ready()
727 fc_vport_set_state(lport->vport, FC_VPORT_ACTIVE); in fc_lport_enter_ready()
728 fc_vports_linkchange(lport); in fc_lport_enter_ready()
730 if (!lport->ptp_rdata) in fc_lport_enter_ready()
731 lport->tt.disc_start(fc_lport_disc_callback, lport); in fc_lport_enter_ready()
740 static void fc_lport_set_port_id(struct fc_lport *lport, u32 port_id, in fc_lport_set_port_id() argument
743 lockdep_assert_held(&lport->lp_mutex); in fc_lport_set_port_id()
747 lport->host->host_no, port_id); in fc_lport_set_port_id()
749 lport->port_id = port_id; in fc_lport_set_port_id()
752 fc_host_port_id(lport->host) = port_id; in fc_lport_set_port_id()
754 if (lport->tt.lport_set_port_id) in fc_lport_set_port_id()
755 lport->tt.lport_set_port_id(lport, port_id, fp); in fc_lport_set_port_id()
767 void fc_lport_set_local_id(struct fc_lport *lport, u32 port_id) in fc_lport_set_local_id() argument
769 mutex_lock(&lport->lp_mutex); in fc_lport_set_local_id()
771 fc_lport_set_port_id(lport, port_id, NULL); in fc_lport_set_local_id()
773 switch (lport->state) { in fc_lport_set_local_id()
777 fc_lport_enter_ready(lport); in fc_lport_set_local_id()
782 mutex_unlock(&lport->lp_mutex); in fc_lport_set_local_id()
795 static void fc_lport_recv_flogi_req(struct fc_lport *lport, in fc_lport_recv_flogi_req() argument
806 lockdep_assert_held(&lport->lp_mutex); in fc_lport_recv_flogi_req()
808 FC_LPORT_DBG(lport, "Received FLOGI request while in state %s\n", in fc_lport_recv_flogi_req()
809 fc_lport_state(lport)); in fc_lport_recv_flogi_req()
816 if (remote_wwpn == lport->wwpn) { in fc_lport_recv_flogi_req()
819 lport->host->host_no, remote_wwpn); in fc_lport_recv_flogi_req()
822 FC_LPORT_DBG(lport, "FLOGI from port WWPN %16.16llx\n", remote_wwpn); in fc_lport_recv_flogi_req()
830 if (remote_wwpn < lport->wwpn) { in fc_lport_recv_flogi_req()
838 fc_lport_set_port_id(lport, local_fid, rx_fp); in fc_lport_recv_flogi_req()
840 fp = fc_frame_alloc(lport, sizeof(*flp)); in fc_lport_recv_flogi_req()
843 fc_lport_flogi_fill(lport, new_flp, ELS_FLOGI); in fc_lport_recv_flogi_req()
854 lport->tt.frame_send(lport, fp); in fc_lport_recv_flogi_req()
857 fc_lport_error(lport, fp); in fc_lport_recv_flogi_req()
859 fc_lport_ptp_setup(lport, remote_fid, remote_wwpn, in fc_lport_recv_flogi_req()
876 static void fc_lport_recv_els_req(struct fc_lport *lport, in fc_lport_recv_els_req() argument
879 mutex_lock(&lport->lp_mutex); in fc_lport_recv_els_req()
886 if (!lport->link_up) in fc_lport_recv_els_req()
894 if (!lport->point_to_multipoint) in fc_lport_recv_els_req()
895 fc_lport_recv_flogi_req(lport, fp); in fc_lport_recv_els_req()
897 fc_rport_recv_req(lport, fp); in fc_lport_recv_els_req()
901 fc_lport_recv_logo_req(lport, fp); in fc_lport_recv_els_req()
903 fc_rport_recv_req(lport, fp); in fc_lport_recv_els_req()
906 lport->tt.disc_recv_req(lport, fp); in fc_lport_recv_els_req()
909 fc_lport_recv_echo_req(lport, fp); in fc_lport_recv_els_req()
912 fc_lport_recv_rlir_req(lport, fp); in fc_lport_recv_els_req()
915 fc_lport_recv_rnid_req(lport, fp); in fc_lport_recv_els_req()
918 fc_rport_recv_req(lport, fp); in fc_lport_recv_els_req()
922 mutex_unlock(&lport->lp_mutex); in fc_lport_recv_els_req()
945 void fc_lport_recv(struct fc_lport *lport, struct fc_frame *fp) in fc_lport_recv() argument
966 prov->recv(lport, fp); in fc_lport_recv()
971 FC_LPORT_DBG(lport, "dropping unexpected frame type %x\n", fh->fh_type); in fc_lport_recv()
985 int fc_lport_reset(struct fc_lport *lport) in fc_lport_reset() argument
987 cancel_delayed_work_sync(&lport->retry_work); in fc_lport_reset()
988 mutex_lock(&lport->lp_mutex); in fc_lport_reset()
989 fc_lport_enter_reset(lport); in fc_lport_reset()
990 mutex_unlock(&lport->lp_mutex); in fc_lport_reset()
999 static void fc_lport_reset_locked(struct fc_lport *lport) in fc_lport_reset_locked() argument
1001 lockdep_assert_held(&lport->lp_mutex); in fc_lport_reset_locked()
1003 if (lport->dns_rdata) { in fc_lport_reset_locked()
1004 fc_rport_logoff(lport->dns_rdata); in fc_lport_reset_locked()
1005 lport->dns_rdata = NULL; in fc_lport_reset_locked()
1008 if (lport->ptp_rdata) { in fc_lport_reset_locked()
1009 fc_rport_logoff(lport->ptp_rdata); in fc_lport_reset_locked()
1010 kref_put(&lport->ptp_rdata->kref, fc_rport_destroy); in fc_lport_reset_locked()
1011 lport->ptp_rdata = NULL; in fc_lport_reset_locked()
1014 lport->tt.disc_stop(lport); in fc_lport_reset_locked()
1016 lport->tt.exch_mgr_reset(lport, 0, 0); in fc_lport_reset_locked()
1017 fc_host_fabric_name(lport->host) = 0; in fc_lport_reset_locked()
1019 if (lport->port_id && (!lport->point_to_multipoint || !lport->link_up)) in fc_lport_reset_locked()
1020 fc_lport_set_port_id(lport, 0, NULL); in fc_lport_reset_locked()
1027 static void fc_lport_enter_reset(struct fc_lport *lport) in fc_lport_enter_reset() argument
1029 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_reset()
1031 FC_LPORT_DBG(lport, "Entered RESET state from %s state\n", in fc_lport_enter_reset()
1032 fc_lport_state(lport)); in fc_lport_enter_reset()
1034 if (lport->state == LPORT_ST_DISABLED || lport->state == LPORT_ST_LOGO) in fc_lport_enter_reset()
1037 if (lport->vport) { in fc_lport_enter_reset()
1038 if (lport->link_up) in fc_lport_enter_reset()
1039 fc_vport_set_state(lport->vport, FC_VPORT_INITIALIZING); in fc_lport_enter_reset()
1041 fc_vport_set_state(lport->vport, FC_VPORT_LINKDOWN); in fc_lport_enter_reset()
1043 fc_lport_state_enter(lport, LPORT_ST_RESET); in fc_lport_enter_reset()
1044 fc_host_post_event(lport->host, fc_get_event_number(), in fc_lport_enter_reset()
1046 fc_vports_linkchange(lport); in fc_lport_enter_reset()
1047 fc_lport_reset_locked(lport); in fc_lport_enter_reset()
1048 if (lport->link_up) in fc_lport_enter_reset()
1049 fc_lport_enter_flogi(lport); in fc_lport_enter_reset()
1056 static void fc_lport_enter_disabled(struct fc_lport *lport) in fc_lport_enter_disabled() argument
1058 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_disabled()
1060 FC_LPORT_DBG(lport, "Entered disabled state from %s state\n", in fc_lport_enter_disabled()
1061 fc_lport_state(lport)); in fc_lport_enter_disabled()
1063 fc_lport_state_enter(lport, LPORT_ST_DISABLED); in fc_lport_enter_disabled()
1064 fc_vports_linkchange(lport); in fc_lport_enter_disabled()
1065 fc_lport_reset_locked(lport); in fc_lport_enter_disabled()
1077 static void fc_lport_error(struct fc_lport *lport, struct fc_frame *fp) in fc_lport_error() argument
1080 FC_LPORT_DBG(lport, "Error %ld in state %s, retries %d\n", in fc_lport_error()
1081 IS_ERR(fp) ? -PTR_ERR(fp) : 0, fc_lport_state(lport), in fc_lport_error()
1082 lport->retry_count); in fc_lport_error()
1092 if (lport->retry_count < lport->max_retry_count) { in fc_lport_error()
1093 lport->retry_count++; in fc_lport_error()
1097 delay = msecs_to_jiffies(lport->e_d_tov); in fc_lport_error()
1099 schedule_delayed_work(&lport->retry_work, delay); in fc_lport_error()
1101 fc_lport_enter_reset(lport); in fc_lport_error()
1118 struct fc_lport *lport = lp_arg; in fc_lport_ns_resp() local
1122 FC_LPORT_DBG(lport, "Received a ns %s\n", fc_els_resp_type(fp)); in fc_lport_ns_resp()
1127 mutex_lock(&lport->lp_mutex); in fc_lport_ns_resp()
1129 if (lport->state < LPORT_ST_RNN_ID || lport->state > LPORT_ST_RFF_ID) { in fc_lport_ns_resp()
1130 FC_LPORT_DBG(lport, "Received a name server response, " in fc_lport_ns_resp()
1131 "but in state %s\n", fc_lport_state(lport)); in fc_lport_ns_resp()
1138 fc_lport_error(lport, fp); in fc_lport_ns_resp()
1149 switch (lport->state) { in fc_lport_ns_resp()
1151 fc_lport_enter_ns(lport, LPORT_ST_RSNN_NN); in fc_lport_ns_resp()
1154 fc_lport_enter_ns(lport, LPORT_ST_RSPN_ID); in fc_lport_ns_resp()
1157 fc_lport_enter_ns(lport, LPORT_ST_RFT_ID); in fc_lport_ns_resp()
1160 fc_lport_enter_ns(lport, LPORT_ST_RFF_ID); in fc_lport_ns_resp()
1163 if (lport->fdmi_enabled) in fc_lport_ns_resp()
1164 fc_lport_enter_fdmi(lport); in fc_lport_ns_resp()
1166 fc_lport_enter_scr(lport); in fc_lport_ns_resp()
1173 fc_lport_error(lport, fp); in fc_lport_ns_resp()
1177 mutex_unlock(&lport->lp_mutex); in fc_lport_ns_resp()
1194 struct fc_lport *lport = lp_arg; in fc_lport_ms_resp() local
1197 struct fc_host_attrs *fc_host = shost_to_fc_host(lport->host); in fc_lport_ms_resp()
1198 FC_LPORT_DBG(lport, "Received a ms %s\n", fc_els_resp_type(fp)); in fc_lport_ms_resp()
1203 mutex_lock(&lport->lp_mutex); in fc_lport_ms_resp()
1205 if (lport->state < LPORT_ST_RHBA || lport->state > LPORT_ST_DPRT) { in fc_lport_ms_resp()
1206 FC_LPORT_DBG(lport, "Received a management server response, " in fc_lport_ms_resp()
1207 "but in state %s\n", fc_lport_state(lport)); in fc_lport_ms_resp()
1214 fc_lport_error(lport, fp); in fc_lport_ms_resp()
1224 FC_LPORT_DBG(lport, "Received a management server response, " in fc_lport_ms_resp()
1229 switch (lport->state) { in fc_lport_ms_resp()
1232 FC_LPORT_DBG(lport, "Error for FDMI-V2, fall back to FDMI-V1\n"); in fc_lport_ms_resp()
1235 fc_lport_enter_ms(lport, LPORT_ST_RHBA); in fc_lport_ms_resp()
1238 fc_lport_enter_ms(lport, LPORT_ST_RPA); in fc_lport_ms_resp()
1240 fc_lport_enter_scr(lport); in fc_lport_ms_resp()
1243 fc_lport_enter_scr(lport); in fc_lport_ms_resp()
1246 fc_lport_enter_ms(lport, LPORT_ST_RHBA); in fc_lport_ms_resp()
1249 fc_lport_enter_ms(lport, LPORT_ST_DPRT); in fc_lport_ms_resp()
1257 fc_lport_error(lport, fp); in fc_lport_ms_resp()
1262 mutex_unlock(&lport->lp_mutex); in fc_lport_ms_resp()
1278 struct fc_lport *lport = lp_arg; in fc_lport_scr_resp() local
1281 FC_LPORT_DBG(lport, "Received a SCR %s\n", fc_els_resp_type(fp)); in fc_lport_scr_resp()
1286 mutex_lock(&lport->lp_mutex); in fc_lport_scr_resp()
1288 if (lport->state != LPORT_ST_SCR) { in fc_lport_scr_resp()
1289 FC_LPORT_DBG(lport, "Received a SCR response, but in state " in fc_lport_scr_resp()
1290 "%s\n", fc_lport_state(lport)); in fc_lport_scr_resp()
1297 fc_lport_error(lport, fp); in fc_lport_scr_resp()
1303 fc_lport_enter_ready(lport); in fc_lport_scr_resp()
1305 fc_lport_error(lport, fp); in fc_lport_scr_resp()
1310 mutex_unlock(&lport->lp_mutex); in fc_lport_scr_resp()
1317 static void fc_lport_enter_scr(struct fc_lport *lport) in fc_lport_enter_scr() argument
1321 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_scr()
1323 FC_LPORT_DBG(lport, "Entered SCR state from %s state\n", in fc_lport_enter_scr()
1324 fc_lport_state(lport)); in fc_lport_enter_scr()
1326 fc_lport_state_enter(lport, LPORT_ST_SCR); in fc_lport_enter_scr()
1328 fp = fc_frame_alloc(lport, sizeof(struct fc_els_scr)); in fc_lport_enter_scr()
1330 fc_lport_error(lport, fp); in fc_lport_enter_scr()
1334 if (!lport->tt.elsct_send(lport, FC_FID_FCTRL, fp, ELS_SCR, in fc_lport_enter_scr()
1335 fc_lport_scr_resp, lport, in fc_lport_enter_scr()
1336 2 * lport->r_a_tov)) in fc_lport_enter_scr()
1337 fc_lport_error(lport, NULL); in fc_lport_enter_scr()
1345 static void fc_lport_enter_ns(struct fc_lport *lport, enum fc_lport_state state) in fc_lport_enter_ns() argument
1352 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_ns()
1354 FC_LPORT_DBG(lport, "Entered %s state from %s state\n", in fc_lport_enter_ns()
1356 fc_lport_state(lport)); in fc_lport_enter_ns()
1358 fc_lport_state_enter(lport, state); in fc_lport_enter_ns()
1366 len = strnlen(fc_host_symbolic_name(lport->host), 255); in fc_lport_enter_ns()
1369 return fc_lport_enter_ns(lport, LPORT_ST_RFT_ID); in fc_lport_enter_ns()
1374 len = strnlen(fc_host_symbolic_name(lport->host), 255); in fc_lport_enter_ns()
1377 return fc_lport_enter_ns(lport, LPORT_ST_RFT_ID); in fc_lport_enter_ns()
1390 fc_lport_error(lport, NULL); in fc_lport_enter_ns()
1394 fp = fc_frame_alloc(lport, size); in fc_lport_enter_ns()
1396 fc_lport_error(lport, fp); in fc_lport_enter_ns()
1400 if (!lport->tt.elsct_send(lport, FC_FID_DIR_SERV, fp, cmd, in fc_lport_enter_ns()
1402 lport, 3 * lport->r_a_tov)) in fc_lport_enter_ns()
1403 fc_lport_error(lport, fp); in fc_lport_enter_ns()
1414 static void fc_lport_enter_dns(struct fc_lport *lport) in fc_lport_enter_dns() argument
1418 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_dns()
1420 FC_LPORT_DBG(lport, "Entered DNS state from %s state\n", in fc_lport_enter_dns()
1421 fc_lport_state(lport)); in fc_lport_enter_dns()
1423 fc_lport_state_enter(lport, LPORT_ST_DNS); in fc_lport_enter_dns()
1425 mutex_lock(&lport->disc.disc_mutex); in fc_lport_enter_dns()
1426 rdata = fc_rport_create(lport, FC_FID_DIR_SERV); in fc_lport_enter_dns()
1427 mutex_unlock(&lport->disc.disc_mutex); in fc_lport_enter_dns()
1436 fc_lport_error(lport, NULL); in fc_lport_enter_dns()
1444 static void fc_lport_enter_ms(struct fc_lport *lport, enum fc_lport_state state) in fc_lport_enter_ms() argument
1451 struct fc_host_attrs *fc_host = shost_to_fc_host(lport->host); in fc_lport_enter_ms()
1452 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_ms()
1454 FC_LPORT_DBG(lport, "Entered %s state from %s state\n", in fc_lport_enter_ms()
1456 fc_lport_state(lport)); in fc_lport_enter_ms()
1458 fc_lport_state_enter(lport, state); in fc_lport_enter_ms()
1538 fc_lport_error(lport, NULL); in fc_lport_enter_ms()
1542 FC_LPORT_DBG(lport, "Cmd=0x%x Len %d size %d\n", in fc_lport_enter_ms()
1544 fp = fc_frame_alloc(lport, size); in fc_lport_enter_ms()
1546 fc_lport_error(lport, fp); in fc_lport_enter_ms()
1550 if (!lport->tt.elsct_send(lport, FC_FID_MGMT_SERV, fp, cmd, in fc_lport_enter_ms()
1552 lport, 3 * lport->r_a_tov)) in fc_lport_enter_ms()
1553 fc_lport_error(lport, fp); in fc_lport_enter_ms()
1560 static void fc_lport_enter_fdmi(struct fc_lport *lport) in fc_lport_enter_fdmi() argument
1564 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_fdmi()
1566 FC_LPORT_DBG(lport, "Entered FDMI state from %s state\n", in fc_lport_enter_fdmi()
1567 fc_lport_state(lport)); in fc_lport_enter_fdmi()
1569 fc_lport_state_enter(lport, LPORT_ST_FDMI); in fc_lport_enter_fdmi()
1571 mutex_lock(&lport->disc.disc_mutex); in fc_lport_enter_fdmi()
1572 rdata = fc_rport_create(lport, FC_FID_MGMT_SERV); in fc_lport_enter_fdmi()
1573 mutex_unlock(&lport->disc.disc_mutex); in fc_lport_enter_fdmi()
1582 fc_lport_error(lport, NULL); in fc_lport_enter_fdmi()
1591 struct fc_lport *lport = in fc_lport_timeout() local
1594 struct fc_host_attrs *fc_host = shost_to_fc_host(lport->host); in fc_lport_timeout()
1596 mutex_lock(&lport->lp_mutex); in fc_lport_timeout()
1598 switch (lport->state) { in fc_lport_timeout()
1606 fc_lport_enter_flogi(lport); in fc_lport_timeout()
1609 fc_lport_enter_dns(lport); in fc_lport_timeout()
1616 fc_lport_enter_ns(lport, lport->state); in fc_lport_timeout()
1619 fc_lport_enter_fdmi(lport); in fc_lport_timeout()
1623 FC_LPORT_DBG(lport, "timeout for FDMI-V2 RHBA,fall back to FDMI-V1\n"); in fc_lport_timeout()
1625 fc_lport_enter_ms(lport, LPORT_ST_RHBA); in fc_lport_timeout()
1632 FC_LPORT_DBG(lport, "Skipping lport state %s to SCR\n", in fc_lport_timeout()
1633 fc_lport_state(lport)); in fc_lport_timeout()
1636 fc_lport_enter_scr(lport); in fc_lport_timeout()
1639 fc_lport_enter_logo(lport); in fc_lport_timeout()
1643 mutex_unlock(&lport->lp_mutex); in fc_lport_timeout()
1659 struct fc_lport *lport = lp_arg; in fc_lport_logo_resp() local
1662 FC_LPORT_DBG(lport, "Received a LOGO %s\n", fc_els_resp_type(fp)); in fc_lport_logo_resp()
1667 mutex_lock(&lport->lp_mutex); in fc_lport_logo_resp()
1669 if (lport->state != LPORT_ST_LOGO) { in fc_lport_logo_resp()
1670 FC_LPORT_DBG(lport, "Received a LOGO response, but in state " in fc_lport_logo_resp()
1671 "%s\n", fc_lport_state(lport)); in fc_lport_logo_resp()
1678 fc_lport_error(lport, fp); in fc_lport_logo_resp()
1684 fc_lport_enter_disabled(lport); in fc_lport_logo_resp()
1686 fc_lport_error(lport, fp); in fc_lport_logo_resp()
1691 mutex_unlock(&lport->lp_mutex); in fc_lport_logo_resp()
1699 static void fc_lport_enter_logo(struct fc_lport *lport) in fc_lport_enter_logo() argument
1704 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_logo()
1706 FC_LPORT_DBG(lport, "Entered LOGO state from %s state\n", in fc_lport_enter_logo()
1707 fc_lport_state(lport)); in fc_lport_enter_logo()
1709 fc_lport_state_enter(lport, LPORT_ST_LOGO); in fc_lport_enter_logo()
1710 fc_vports_linkchange(lport); in fc_lport_enter_logo()
1712 fp = fc_frame_alloc(lport, sizeof(*logo)); in fc_lport_enter_logo()
1714 fc_lport_error(lport, fp); in fc_lport_enter_logo()
1718 if (!lport->tt.elsct_send(lport, FC_FID_FLOGI, fp, ELS_LOGO, in fc_lport_enter_logo()
1719 fc_lport_logo_resp, lport, in fc_lport_enter_logo()
1720 2 * lport->r_a_tov)) in fc_lport_enter_logo()
1721 fc_lport_error(lport, NULL); in fc_lport_enter_logo()
1737 struct fc_lport *lport = lp_arg; in fc_lport_flogi_resp() local
1746 FC_LPORT_DBG(lport, "Received a FLOGI %s\n", fc_els_resp_type(fp)); in fc_lport_flogi_resp()
1751 mutex_lock(&lport->lp_mutex); in fc_lport_flogi_resp()
1753 if (lport->state != LPORT_ST_FLOGI) { in fc_lport_flogi_resp()
1754 FC_LPORT_DBG(lport, "Received a FLOGI response, but in state " in fc_lport_flogi_resp()
1755 "%s\n", fc_lport_state(lport)); in fc_lport_flogi_resp()
1762 fc_lport_error(lport, fp); in fc_lport_flogi_resp()
1770 FC_LPORT_DBG(lport, "FLOGI not accepted or bad response\n"); in fc_lport_flogi_resp()
1771 fc_lport_error(lport, fp); in fc_lport_flogi_resp()
1777 FC_LPORT_DBG(lport, "FLOGI bad response\n"); in fc_lport_flogi_resp()
1778 fc_lport_error(lport, fp); in fc_lport_flogi_resp()
1786 FC_LPORT_DBG(lport, "FLOGI bad mfs:%hu response, " in fc_lport_flogi_resp()
1787 "lport->mfs:%u\n", mfs, lport->mfs); in fc_lport_flogi_resp()
1788 fc_lport_error(lport, fp); in fc_lport_flogi_resp()
1792 if (mfs <= lport->mfs) { in fc_lport_flogi_resp()
1793 lport->mfs = mfs; in fc_lport_flogi_resp()
1794 fc_host_maxframe_size(lport->host) = mfs; in fc_lport_flogi_resp()
1803 lport->npiv_enabled = !!(csp_flags & FC_SP_FT_NPIV_ACC); in fc_lport_flogi_resp()
1806 if (e_d_tov > lport->e_d_tov) in fc_lport_flogi_resp()
1807 lport->e_d_tov = e_d_tov; in fc_lport_flogi_resp()
1808 lport->r_a_tov = 2 * lport->e_d_tov; in fc_lport_flogi_resp()
1809 fc_lport_set_port_id(lport, did, fp); in fc_lport_flogi_resp()
1813 lport->host->host_no, did); in fc_lport_flogi_resp()
1814 fc_lport_ptp_setup(lport, fc_frame_sid(fp), in fc_lport_flogi_resp()
1820 if (e_d_tov > lport->e_d_tov) in fc_lport_flogi_resp()
1821 lport->e_d_tov = e_d_tov; in fc_lport_flogi_resp()
1822 if (r_a_tov > lport->r_a_tov) in fc_lport_flogi_resp()
1823 lport->r_a_tov = r_a_tov; in fc_lport_flogi_resp()
1824 fc_host_fabric_name(lport->host) = in fc_lport_flogi_resp()
1826 fc_lport_set_port_id(lport, did, fp); in fc_lport_flogi_resp()
1827 fc_lport_enter_dns(lport); in fc_lport_flogi_resp()
1833 mutex_unlock(&lport->lp_mutex); in fc_lport_flogi_resp()
1841 static void fc_lport_enter_flogi(struct fc_lport *lport) in fc_lport_enter_flogi() argument
1845 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_flogi()
1847 FC_LPORT_DBG(lport, "Entered FLOGI state from %s state\n", in fc_lport_enter_flogi()
1848 fc_lport_state(lport)); in fc_lport_enter_flogi()
1850 fc_lport_state_enter(lport, LPORT_ST_FLOGI); in fc_lport_enter_flogi()
1852 if (lport->point_to_multipoint) { in fc_lport_enter_flogi()
1853 if (lport->port_id) in fc_lport_enter_flogi()
1854 fc_lport_enter_ready(lport); in fc_lport_enter_flogi()
1858 fp = fc_frame_alloc(lport, sizeof(struct fc_els_flogi)); in fc_lport_enter_flogi()
1860 return fc_lport_error(lport, fp); in fc_lport_enter_flogi()
1862 if (!lport->tt.elsct_send(lport, FC_FID_FLOGI, fp, in fc_lport_enter_flogi()
1863 lport->vport ? ELS_FDISC : ELS_FLOGI, in fc_lport_enter_flogi()
1864 fc_lport_flogi_resp, lport, in fc_lport_enter_flogi()
1865 lport->vport ? 2 * lport->r_a_tov : in fc_lport_enter_flogi()
1866 lport->e_d_tov)) in fc_lport_enter_flogi()
1867 fc_lport_error(lport, NULL); in fc_lport_enter_flogi()
1874 int fc_lport_config(struct fc_lport *lport) in fc_lport_config() argument
1876 INIT_DELAYED_WORK(&lport->retry_work, fc_lport_timeout); in fc_lport_config()
1877 mutex_init(&lport->lp_mutex); in fc_lport_config()
1879 fc_lport_state_enter(lport, LPORT_ST_DISABLED); in fc_lport_config()
1881 fc_lport_add_fc4_type(lport, FC_TYPE_FCP); in fc_lport_config()
1882 fc_lport_add_fc4_type(lport, FC_TYPE_CT); in fc_lport_config()
1883 fc_fc4_conf_lport_params(lport, FC_TYPE_FCP); in fc_lport_config()
1893 int fc_lport_init(struct fc_lport *lport) in fc_lport_init() argument
1897 fc_host = shost_to_fc_host(lport->host); in fc_lport_init()
1902 fc_host_port_type(lport->host) = FC_PORTTYPE_NPORT; in fc_lport_init()
1903 fc_host_node_name(lport->host) = lport->wwnn; in fc_lport_init()
1904 fc_host_port_name(lport->host) = lport->wwpn; in fc_lport_init()
1905 fc_host_supported_classes(lport->host) = FC_COS_CLASS3; in fc_lport_init()
1906 memset(fc_host_supported_fc4s(lport->host), 0, in fc_lport_init()
1907 sizeof(fc_host_supported_fc4s(lport->host))); in fc_lport_init()
1908 fc_host_supported_fc4s(lport->host)[2] = 1; in fc_lport_init() local
1909 fc_host_supported_fc4s(lport->host)[7] = 1; in fc_lport_init() local
1910 fc_host_num_discovered_ports(lport->host) = 4; in fc_lport_init()
1913 memset(fc_host_active_fc4s(lport->host), 0, in fc_lport_init()
1914 sizeof(fc_host_active_fc4s(lport->host))); in fc_lport_init()
1915 fc_host_active_fc4s(lport->host)[2] = 1; in fc_lport_init() local
1916 fc_host_active_fc4s(lport->host)[7] = 1; in fc_lport_init() local
1917 fc_host_maxframe_size(lport->host) = lport->mfs; in fc_lport_init()
1918 fc_host_supported_speeds(lport->host) = 0; in fc_lport_init()
1919 if (lport->link_supported_speeds & FC_PORTSPEED_1GBIT) in fc_lport_init()
1920 fc_host_supported_speeds(lport->host) |= FC_PORTSPEED_1GBIT; in fc_lport_init()
1921 if (lport->link_supported_speeds & FC_PORTSPEED_10GBIT) in fc_lport_init()
1922 fc_host_supported_speeds(lport->host) |= FC_PORTSPEED_10GBIT; in fc_lport_init()
1923 if (lport->link_supported_speeds & FC_PORTSPEED_40GBIT) in fc_lport_init()
1924 fc_host_supported_speeds(lport->host) |= FC_PORTSPEED_40GBIT; in fc_lport_init()
1925 if (lport->link_supported_speeds & FC_PORTSPEED_100GBIT) in fc_lport_init()
1926 fc_host_supported_speeds(lport->host) |= FC_PORTSPEED_100GBIT; in fc_lport_init()
1927 if (lport->link_supported_speeds & FC_PORTSPEED_25GBIT) in fc_lport_init()
1928 fc_host_supported_speeds(lport->host) |= FC_PORTSPEED_25GBIT; in fc_lport_init()
1929 if (lport->link_supported_speeds & FC_PORTSPEED_50GBIT) in fc_lport_init()
1930 fc_host_supported_speeds(lport->host) |= FC_PORTSPEED_50GBIT; in fc_lport_init()
1931 if (lport->link_supported_speeds & FC_PORTSPEED_100GBIT) in fc_lport_init()
1932 fc_host_supported_speeds(lport->host) |= FC_PORTSPEED_100GBIT; in fc_lport_init()
1934 fc_fc4_add_lport(lport); in fc_lport_init()
1936 fc_host_num_discovered_ports(lport->host) = DISCOVERED_PORTS; in fc_lport_init()
1937 fc_host_port_state(lport->host) = FC_PORTSTATE_ONLINE; in fc_lport_init()
1938 fc_host_max_ct_payload(lport->host) = MAX_CT_PAYLOAD; in fc_lport_init()
1939 fc_host_num_ports(lport->host) = NUMBER_OF_PORTS; in fc_lport_init()
1940 fc_host_bootbios_state(lport->host) = 0X00000000; in fc_lport_init()
1941 snprintf(fc_host_bootbios_version(lport->host), in fc_lport_init()
1960 struct fc_lport *lport = info->lport; in fc_lport_bsg_resp() local
1975 mutex_lock(&lport->lp_mutex); in fc_lport_bsg_resp()
2009 mutex_unlock(&lport->lp_mutex); in fc_lport_bsg_resp()
2020 struct fc_lport *lport, in fc_lport_els_request() argument
2029 lockdep_assert_held(&lport->lp_mutex); in fc_lport_els_request()
2031 fp = fc_frame_alloc(lport, job->request_payload.payload_len); in fc_lport_els_request()
2045 hton24(fh->fh_s_id, lport->port_id); in fc_lport_els_request()
2059 info->lport = lport; in fc_lport_els_request()
2064 if (!fc_exch_seq_send(lport, fp, fc_lport_bsg_resp, in fc_lport_els_request()
2080 struct fc_lport *lport, u32 did, u32 tov) in fc_lport_ct_request() argument
2088 lockdep_assert_held(&lport->lp_mutex); in fc_lport_ct_request()
2090 fp = fc_frame_alloc(lport, sizeof(struct fc_ct_hdr) + in fc_lport_ct_request()
2105 hton24(fh->fh_s_id, lport->port_id); in fc_lport_ct_request()
2119 info->lport = lport; in fc_lport_ct_request()
2124 if (!fc_exch_seq_send(lport, fp, fc_lport_bsg_resp, in fc_lport_ct_request()
2142 struct fc_lport *lport = shost_priv(shost); in fc_lport_bsg_request() local
2150 mutex_lock(&lport->lp_mutex); in fc_lport_bsg_request()
2159 rc = fc_lport_els_request(job, lport, rport->port_id, in fc_lport_bsg_request()
2169 rc = fc_lport_ct_request(job, lport, rport->port_id, in fc_lport_bsg_request()
2176 rdata = lport->dns_rdata; in fc_lport_bsg_request()
2181 rdata = fc_rport_lookup(lport, did); in fc_lport_bsg_request()
2188 rc = fc_lport_ct_request(job, lport, did, tov); in fc_lport_bsg_request()
2193 rc = fc_lport_els_request(job, lport, did, lport->e_d_tov); in fc_lport_bsg_request()
2197 mutex_unlock(&lport->lp_mutex); in fc_lport_bsg_request()