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 kref_get(&lport->ptp_rdata->kref); in fc_lport_ptp_setup()
245 lport->ptp_rdata->ids.port_name = remote_wwpn; in fc_lport_ptp_setup()
246 lport->ptp_rdata->ids.node_name = remote_wwnn; in fc_lport_ptp_setup()
247 mutex_unlock(&lport->disc.disc_mutex); in fc_lport_ptp_setup()
249 fc_rport_login(lport->ptp_rdata); in fc_lport_ptp_setup()
251 fc_lport_enter_ready(lport); in fc_lport_ptp_setup()
260 struct fc_lport *lport = shost_priv(shost); in fc_get_host_port_state() local
262 mutex_lock(&lport->lp_mutex); in fc_get_host_port_state()
263 if (!lport->link_up) in fc_get_host_port_state()
266 switch (lport->state) { in fc_get_host_port_state()
273 mutex_unlock(&lport->lp_mutex); in fc_get_host_port_state()
283 struct fc_lport *lport = shost_priv(shost); in fc_get_host_speed() local
285 fc_host_speed(shost) = lport->link_speed; in fc_get_host_speed()
296 struct fc_lport *lport = shost_priv(shost); in fc_get_host_stats() local
301 fc_stats = &lport->host_stats; in fc_get_host_stats()
304 fc_stats->seconds_since_last_reset = (jiffies - lport->boot_time) / HZ; in fc_get_host_stats()
309 stats = per_cpu_ptr(lport->stats, cpu); in fc_get_host_stats()
337 fc_exch_update_stats(lport); in fc_get_host_stats()
349 static void fc_lport_flogi_fill(struct fc_lport *lport, in fc_lport_flogi_fill() argument
358 put_unaligned_be64(lport->wwpn, &flogi->fl_wwpn); in fc_lport_flogi_fill()
359 put_unaligned_be64(lport->wwnn, &flogi->fl_wwnn); in fc_lport_flogi_fill()
364 sp->sp_bb_data = htons((u16) lport->mfs); in fc_lport_flogi_fill()
371 sp->sp_e_d_tov = htonl(lport->e_d_tov); in fc_lport_flogi_fill()
373 cp->cp_rdfs = htons((u16) lport->mfs); in fc_lport_flogi_fill()
384 static void fc_lport_add_fc4_type(struct fc_lport *lport, enum fc_fh_type type) in fc_lport_add_fc4_type() argument
388 mp = &lport->fcts.ff_type_map[type / FC_NS_BPW]; in fc_lport_add_fc4_type()
397 static void fc_lport_recv_rlir_req(struct fc_lport *lport, struct fc_frame *fp) in fc_lport_recv_rlir_req() argument
399 lockdep_assert_held(&lport->lp_mutex); in fc_lport_recv_rlir_req()
401 FC_LPORT_DBG(lport, "Received RLIR request while in state %s\n", in fc_lport_recv_rlir_req()
402 fc_lport_state(lport)); in fc_lport_recv_rlir_req()
413 static void fc_lport_recv_echo_req(struct fc_lport *lport, in fc_lport_recv_echo_req() argument
421 lockdep_assert_held(&lport->lp_mutex); in fc_lport_recv_echo_req()
423 FC_LPORT_DBG(lport, "Received ECHO request while in state %s\n", in fc_lport_recv_echo_req()
424 fc_lport_state(lport)); in fc_lport_recv_echo_req()
432 fp = fc_frame_alloc(lport, len); in fc_lport_recv_echo_req()
438 lport->tt.frame_send(lport, fp); in fc_lport_recv_echo_req()
448 static void fc_lport_recv_rnid_req(struct fc_lport *lport, in fc_lport_recv_rnid_req() argument
462 lockdep_assert_held(&lport->lp_mutex); in fc_lport_recv_rnid_req()
464 FC_LPORT_DBG(lport, "Received RNID request while in state %s\n", in fc_lport_recv_rnid_req()
465 fc_lport_state(lport)); in fc_lport_recv_rnid_req()
476 ntohl(lport->rnid_gen.rnid_atype) == 0) { in fc_lport_recv_rnid_req()
480 fp = fc_frame_alloc(lport, len); in fc_lport_recv_rnid_req()
487 rp->cid.rnid_wwpn = htonll(lport->wwpn); in fc_lport_recv_rnid_req()
488 rp->cid.rnid_wwnn = htonll(lport->wwnn); in fc_lport_recv_rnid_req()
491 memcpy(&rp->gen, &lport->rnid_gen, in fc_lport_recv_rnid_req()
495 lport->tt.frame_send(lport, fp); in fc_lport_recv_rnid_req()
506 static void fc_lport_recv_logo_req(struct fc_lport *lport, struct fc_frame *fp) in fc_lport_recv_logo_req() argument
508 lockdep_assert_held(&lport->lp_mutex); in fc_lport_recv_logo_req()
511 fc_lport_enter_reset(lport); in fc_lport_recv_logo_req()
522 int fc_fabric_login(struct fc_lport *lport) in fc_fabric_login() argument
526 mutex_lock(&lport->lp_mutex); in fc_fabric_login()
527 if (lport->state == LPORT_ST_DISABLED || in fc_fabric_login()
528 lport->state == LPORT_ST_LOGO) { in fc_fabric_login()
529 fc_lport_state_enter(lport, LPORT_ST_RESET); in fc_fabric_login()
530 fc_lport_enter_reset(lport); in fc_fabric_login()
533 mutex_unlock(&lport->lp_mutex); in fc_fabric_login()
543 void __fc_linkup(struct fc_lport *lport) in __fc_linkup() argument
545 lockdep_assert_held(&lport->lp_mutex); in __fc_linkup()
547 if (!lport->link_up) { in __fc_linkup()
548 lport->link_up = 1; in __fc_linkup()
550 if (lport->state == LPORT_ST_RESET) in __fc_linkup()
551 fc_lport_enter_flogi(lport); in __fc_linkup()
559 void fc_linkup(struct fc_lport *lport) in fc_linkup() argument
562 lport->host->host_no, lport->port_id); in fc_linkup()
564 mutex_lock(&lport->lp_mutex); in fc_linkup()
565 __fc_linkup(lport); in fc_linkup()
566 mutex_unlock(&lport->lp_mutex); in fc_linkup()
574 void __fc_linkdown(struct fc_lport *lport) in __fc_linkdown() argument
576 lockdep_assert_held(&lport->lp_mutex); in __fc_linkdown()
578 if (lport->link_up) { in __fc_linkdown()
579 lport->link_up = 0; in __fc_linkdown()
580 fc_lport_enter_reset(lport); in __fc_linkdown()
581 lport->tt.fcp_cleanup(lport); in __fc_linkdown()
589 void fc_linkdown(struct fc_lport *lport) in fc_linkdown() argument
592 lport->host->host_no, lport->port_id); in fc_linkdown()
594 mutex_lock(&lport->lp_mutex); in fc_linkdown()
595 __fc_linkdown(lport); in fc_linkdown()
596 mutex_unlock(&lport->lp_mutex); in fc_linkdown()
607 int fc_fabric_logoff(struct fc_lport *lport) in fc_fabric_logoff() argument
609 lport->tt.disc_stop_final(lport); in fc_fabric_logoff()
610 mutex_lock(&lport->lp_mutex); in fc_fabric_logoff()
611 if (lport->dns_rdata) in fc_fabric_logoff()
612 fc_rport_logoff(lport->dns_rdata); in fc_fabric_logoff()
613 mutex_unlock(&lport->lp_mutex); in fc_fabric_logoff()
615 mutex_lock(&lport->lp_mutex); in fc_fabric_logoff()
616 fc_lport_enter_logo(lport); in fc_fabric_logoff()
617 mutex_unlock(&lport->lp_mutex); in fc_fabric_logoff()
618 cancel_delayed_work_sync(&lport->retry_work); in fc_fabric_logoff()
633 int fc_lport_destroy(struct fc_lport *lport) in fc_lport_destroy() argument
635 mutex_lock(&lport->lp_mutex); in fc_lport_destroy()
636 lport->state = LPORT_ST_DISABLED; in fc_lport_destroy()
637 lport->link_up = 0; in fc_lport_destroy()
638 lport->tt.frame_send = fc_frame_drop; in fc_lport_destroy()
639 mutex_unlock(&lport->lp_mutex); in fc_lport_destroy()
641 lport->tt.fcp_abort_io(lport); in fc_lport_destroy()
642 lport->tt.disc_stop_final(lport); in fc_lport_destroy()
643 lport->tt.exch_mgr_reset(lport, 0, 0); in fc_lport_destroy()
644 cancel_delayed_work_sync(&lport->retry_work); in fc_lport_destroy()
645 fc_fc4_del_lport(lport); in fc_lport_destroy()
655 int fc_set_mfs(struct fc_lport *lport, u32 mfs) in fc_set_mfs() argument
660 mutex_lock(&lport->lp_mutex); in fc_set_mfs()
662 old_mfs = lport->mfs; in fc_set_mfs()
669 lport->mfs = mfs; in fc_set_mfs()
674 fc_lport_enter_reset(lport); in fc_set_mfs()
676 mutex_unlock(&lport->lp_mutex); in fc_set_mfs()
687 static void fc_lport_disc_callback(struct fc_lport *lport, in fc_lport_disc_callback() argument
692 FC_LPORT_DBG(lport, "Discovery succeeded\n"); in fc_lport_disc_callback()
697 lport->host->host_no, lport->port_id); in fc_lport_disc_callback()
698 mutex_lock(&lport->lp_mutex); in fc_lport_disc_callback()
699 fc_lport_enter_reset(lport); in fc_lport_disc_callback()
700 mutex_unlock(&lport->lp_mutex); in fc_lport_disc_callback()
712 static void fc_lport_enter_ready(struct fc_lport *lport) in fc_lport_enter_ready() argument
714 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_ready()
716 FC_LPORT_DBG(lport, "Entered READY from state %s\n", in fc_lport_enter_ready()
717 fc_lport_state(lport)); in fc_lport_enter_ready()
719 fc_lport_state_enter(lport, LPORT_ST_READY); in fc_lport_enter_ready()
720 if (lport->vport) in fc_lport_enter_ready()
721 fc_vport_set_state(lport->vport, FC_VPORT_ACTIVE); in fc_lport_enter_ready()
722 fc_vports_linkchange(lport); in fc_lport_enter_ready()
724 if (!lport->ptp_rdata) in fc_lport_enter_ready()
725 lport->tt.disc_start(fc_lport_disc_callback, lport); in fc_lport_enter_ready()
734 static void fc_lport_set_port_id(struct fc_lport *lport, u32 port_id, in fc_lport_set_port_id() argument
737 lockdep_assert_held(&lport->lp_mutex); in fc_lport_set_port_id()
741 lport->host->host_no, port_id); in fc_lport_set_port_id()
743 lport->port_id = port_id; in fc_lport_set_port_id()
746 fc_host_port_id(lport->host) = port_id; in fc_lport_set_port_id()
748 if (lport->tt.lport_set_port_id) in fc_lport_set_port_id()
749 lport->tt.lport_set_port_id(lport, port_id, fp); in fc_lport_set_port_id()
761 void fc_lport_set_local_id(struct fc_lport *lport, u32 port_id) in fc_lport_set_local_id() argument
763 mutex_lock(&lport->lp_mutex); in fc_lport_set_local_id()
765 fc_lport_set_port_id(lport, port_id, NULL); in fc_lport_set_local_id()
767 switch (lport->state) { in fc_lport_set_local_id()
771 fc_lport_enter_ready(lport); in fc_lport_set_local_id()
776 mutex_unlock(&lport->lp_mutex); in fc_lport_set_local_id()
789 static void fc_lport_recv_flogi_req(struct fc_lport *lport, in fc_lport_recv_flogi_req() argument
800 lockdep_assert_held(&lport->lp_mutex); in fc_lport_recv_flogi_req()
802 FC_LPORT_DBG(lport, "Received FLOGI request while in state %s\n", in fc_lport_recv_flogi_req()
803 fc_lport_state(lport)); in fc_lport_recv_flogi_req()
810 if (remote_wwpn == lport->wwpn) { in fc_lport_recv_flogi_req()
813 lport->host->host_no, remote_wwpn); in fc_lport_recv_flogi_req()
816 FC_LPORT_DBG(lport, "FLOGI from port WWPN %16.16llx\n", remote_wwpn); in fc_lport_recv_flogi_req()
824 if (remote_wwpn < lport->wwpn) { in fc_lport_recv_flogi_req()
832 fc_lport_set_port_id(lport, local_fid, rx_fp); in fc_lport_recv_flogi_req()
834 fp = fc_frame_alloc(lport, sizeof(*flp)); in fc_lport_recv_flogi_req()
837 fc_lport_flogi_fill(lport, new_flp, ELS_FLOGI); in fc_lport_recv_flogi_req()
848 lport->tt.frame_send(lport, fp); in fc_lport_recv_flogi_req()
851 fc_lport_error(lport, fp); in fc_lport_recv_flogi_req()
853 fc_lport_ptp_setup(lport, remote_fid, remote_wwpn, in fc_lport_recv_flogi_req()
870 static void fc_lport_recv_els_req(struct fc_lport *lport, in fc_lport_recv_els_req() argument
873 mutex_lock(&lport->lp_mutex); in fc_lport_recv_els_req()
880 if (!lport->link_up) in fc_lport_recv_els_req()
888 if (!lport->point_to_multipoint) in fc_lport_recv_els_req()
889 fc_lport_recv_flogi_req(lport, fp); in fc_lport_recv_els_req()
891 fc_rport_recv_req(lport, fp); in fc_lport_recv_els_req()
895 fc_lport_recv_logo_req(lport, fp); in fc_lport_recv_els_req()
897 fc_rport_recv_req(lport, fp); in fc_lport_recv_els_req()
900 lport->tt.disc_recv_req(lport, fp); in fc_lport_recv_els_req()
903 fc_lport_recv_echo_req(lport, fp); in fc_lport_recv_els_req()
906 fc_lport_recv_rlir_req(lport, fp); in fc_lport_recv_els_req()
909 fc_lport_recv_rnid_req(lport, fp); in fc_lport_recv_els_req()
912 fc_rport_recv_req(lport, fp); in fc_lport_recv_els_req()
916 mutex_unlock(&lport->lp_mutex); in fc_lport_recv_els_req()
939 void fc_lport_recv(struct fc_lport *lport, struct fc_frame *fp) in fc_lport_recv() argument
960 prov->recv(lport, fp); in fc_lport_recv()
965 FC_LPORT_DBG(lport, "dropping unexpected frame type %x\n", fh->fh_type); in fc_lport_recv()
979 int fc_lport_reset(struct fc_lport *lport) in fc_lport_reset() argument
981 cancel_delayed_work_sync(&lport->retry_work); in fc_lport_reset()
982 mutex_lock(&lport->lp_mutex); in fc_lport_reset()
983 fc_lport_enter_reset(lport); in fc_lport_reset()
984 mutex_unlock(&lport->lp_mutex); in fc_lport_reset()
993 static void fc_lport_reset_locked(struct fc_lport *lport) in fc_lport_reset_locked() argument
995 lockdep_assert_held(&lport->lp_mutex); in fc_lport_reset_locked()
997 if (lport->dns_rdata) { in fc_lport_reset_locked()
998 fc_rport_logoff(lport->dns_rdata); in fc_lport_reset_locked()
999 lport->dns_rdata = NULL; in fc_lport_reset_locked()
1002 if (lport->ptp_rdata) { in fc_lport_reset_locked()
1003 fc_rport_logoff(lport->ptp_rdata); in fc_lport_reset_locked()
1004 kref_put(&lport->ptp_rdata->kref, fc_rport_destroy); in fc_lport_reset_locked()
1005 lport->ptp_rdata = NULL; in fc_lport_reset_locked()
1008 lport->tt.disc_stop(lport); in fc_lport_reset_locked()
1010 lport->tt.exch_mgr_reset(lport, 0, 0); in fc_lport_reset_locked()
1011 fc_host_fabric_name(lport->host) = 0; in fc_lport_reset_locked()
1013 if (lport->port_id && (!lport->point_to_multipoint || !lport->link_up)) in fc_lport_reset_locked()
1014 fc_lport_set_port_id(lport, 0, NULL); in fc_lport_reset_locked()
1021 static void fc_lport_enter_reset(struct fc_lport *lport) in fc_lport_enter_reset() argument
1023 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_reset()
1025 FC_LPORT_DBG(lport, "Entered RESET state from %s state\n", in fc_lport_enter_reset()
1026 fc_lport_state(lport)); in fc_lport_enter_reset()
1028 if (lport->state == LPORT_ST_DISABLED || lport->state == LPORT_ST_LOGO) in fc_lport_enter_reset()
1031 if (lport->vport) { in fc_lport_enter_reset()
1032 if (lport->link_up) in fc_lport_enter_reset()
1033 fc_vport_set_state(lport->vport, FC_VPORT_INITIALIZING); in fc_lport_enter_reset()
1035 fc_vport_set_state(lport->vport, FC_VPORT_LINKDOWN); in fc_lport_enter_reset()
1037 fc_lport_state_enter(lport, LPORT_ST_RESET); in fc_lport_enter_reset()
1038 fc_host_post_event(lport->host, fc_get_event_number(), in fc_lport_enter_reset()
1040 fc_vports_linkchange(lport); in fc_lport_enter_reset()
1041 fc_lport_reset_locked(lport); in fc_lport_enter_reset()
1042 if (lport->link_up) in fc_lport_enter_reset()
1043 fc_lport_enter_flogi(lport); in fc_lport_enter_reset()
1050 static void fc_lport_enter_disabled(struct fc_lport *lport) in fc_lport_enter_disabled() argument
1052 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_disabled()
1054 FC_LPORT_DBG(lport, "Entered disabled state from %s state\n", in fc_lport_enter_disabled()
1055 fc_lport_state(lport)); in fc_lport_enter_disabled()
1057 fc_lport_state_enter(lport, LPORT_ST_DISABLED); in fc_lport_enter_disabled()
1058 fc_vports_linkchange(lport); in fc_lport_enter_disabled()
1059 fc_lport_reset_locked(lport); in fc_lport_enter_disabled()
1071 static void fc_lport_error(struct fc_lport *lport, struct fc_frame *fp) in fc_lport_error() argument
1074 FC_LPORT_DBG(lport, "Error %ld in state %s, retries %d\n", in fc_lport_error()
1075 IS_ERR(fp) ? -PTR_ERR(fp) : 0, fc_lport_state(lport), in fc_lport_error()
1076 lport->retry_count); in fc_lport_error()
1086 if (lport->retry_count < lport->max_retry_count) { in fc_lport_error()
1087 lport->retry_count++; in fc_lport_error()
1091 delay = msecs_to_jiffies(lport->e_d_tov); in fc_lport_error()
1093 schedule_delayed_work(&lport->retry_work, delay); in fc_lport_error()
1095 fc_lport_enter_reset(lport); in fc_lport_error()
1112 struct fc_lport *lport = lp_arg; in fc_lport_ns_resp() local
1116 FC_LPORT_DBG(lport, "Received a ns %s\n", fc_els_resp_type(fp)); in fc_lport_ns_resp()
1121 mutex_lock(&lport->lp_mutex); in fc_lport_ns_resp()
1123 if (lport->state < LPORT_ST_RNN_ID || lport->state > LPORT_ST_RFF_ID) { in fc_lport_ns_resp()
1124 FC_LPORT_DBG(lport, "Received a name server response, " in fc_lport_ns_resp()
1125 "but in state %s\n", fc_lport_state(lport)); in fc_lport_ns_resp()
1132 fc_lport_error(lport, fp); in fc_lport_ns_resp()
1143 switch (lport->state) { in fc_lport_ns_resp()
1145 fc_lport_enter_ns(lport, LPORT_ST_RSNN_NN); in fc_lport_ns_resp()
1148 fc_lport_enter_ns(lport, LPORT_ST_RSPN_ID); in fc_lport_ns_resp()
1151 fc_lport_enter_ns(lport, LPORT_ST_RFT_ID); in fc_lport_ns_resp()
1154 fc_lport_enter_ns(lport, LPORT_ST_RFF_ID); in fc_lport_ns_resp()
1157 if (lport->fdmi_enabled) in fc_lport_ns_resp()
1158 fc_lport_enter_fdmi(lport); in fc_lport_ns_resp()
1160 fc_lport_enter_scr(lport); in fc_lport_ns_resp()
1167 fc_lport_error(lport, fp); in fc_lport_ns_resp()
1171 mutex_unlock(&lport->lp_mutex); in fc_lport_ns_resp()
1188 struct fc_lport *lport = lp_arg; in fc_lport_ms_resp() local
1191 struct fc_host_attrs *fc_host = shost_to_fc_host(lport->host); in fc_lport_ms_resp()
1192 FC_LPORT_DBG(lport, "Received a ms %s\n", fc_els_resp_type(fp)); in fc_lport_ms_resp()
1197 mutex_lock(&lport->lp_mutex); in fc_lport_ms_resp()
1199 if (lport->state < LPORT_ST_RHBA || lport->state > LPORT_ST_DPRT) { in fc_lport_ms_resp()
1200 FC_LPORT_DBG(lport, "Received a management server response, " in fc_lport_ms_resp()
1201 "but in state %s\n", fc_lport_state(lport)); in fc_lport_ms_resp()
1208 fc_lport_error(lport, fp); in fc_lport_ms_resp()
1218 FC_LPORT_DBG(lport, "Received a management server response, " in fc_lport_ms_resp()
1223 switch (lport->state) { in fc_lport_ms_resp()
1226 FC_LPORT_DBG(lport, "Error for FDMI-V2, fall back to FDMI-V1\n"); in fc_lport_ms_resp()
1229 fc_lport_enter_ms(lport, LPORT_ST_RHBA); in fc_lport_ms_resp()
1232 fc_lport_enter_ms(lport, LPORT_ST_RPA); in fc_lport_ms_resp()
1234 fc_lport_enter_scr(lport); in fc_lport_ms_resp()
1237 fc_lport_enter_scr(lport); in fc_lport_ms_resp()
1240 fc_lport_enter_ms(lport, LPORT_ST_RHBA); in fc_lport_ms_resp()
1243 fc_lport_enter_ms(lport, LPORT_ST_DPRT); in fc_lport_ms_resp()
1251 fc_lport_error(lport, fp); in fc_lport_ms_resp()
1256 mutex_unlock(&lport->lp_mutex); in fc_lport_ms_resp()
1272 struct fc_lport *lport = lp_arg; in fc_lport_scr_resp() local
1275 FC_LPORT_DBG(lport, "Received a SCR %s\n", fc_els_resp_type(fp)); in fc_lport_scr_resp()
1280 mutex_lock(&lport->lp_mutex); in fc_lport_scr_resp()
1282 if (lport->state != LPORT_ST_SCR) { in fc_lport_scr_resp()
1283 FC_LPORT_DBG(lport, "Received a SCR response, but in state " in fc_lport_scr_resp()
1284 "%s\n", fc_lport_state(lport)); in fc_lport_scr_resp()
1291 fc_lport_error(lport, fp); in fc_lport_scr_resp()
1297 fc_lport_enter_ready(lport); in fc_lport_scr_resp()
1299 fc_lport_error(lport, fp); in fc_lport_scr_resp()
1304 mutex_unlock(&lport->lp_mutex); in fc_lport_scr_resp()
1311 static void fc_lport_enter_scr(struct fc_lport *lport) in fc_lport_enter_scr() argument
1315 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_scr()
1317 FC_LPORT_DBG(lport, "Entered SCR state from %s state\n", in fc_lport_enter_scr()
1318 fc_lport_state(lport)); in fc_lport_enter_scr()
1320 fc_lport_state_enter(lport, LPORT_ST_SCR); in fc_lport_enter_scr()
1322 fp = fc_frame_alloc(lport, sizeof(struct fc_els_scr)); in fc_lport_enter_scr()
1324 fc_lport_error(lport, fp); in fc_lport_enter_scr()
1328 if (!lport->tt.elsct_send(lport, FC_FID_FCTRL, fp, ELS_SCR, in fc_lport_enter_scr()
1329 fc_lport_scr_resp, lport, in fc_lport_enter_scr()
1330 2 * lport->r_a_tov)) in fc_lport_enter_scr()
1331 fc_lport_error(lport, NULL); in fc_lport_enter_scr()
1339 static void fc_lport_enter_ns(struct fc_lport *lport, enum fc_lport_state state) in fc_lport_enter_ns() argument
1346 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_ns()
1348 FC_LPORT_DBG(lport, "Entered %s state from %s state\n", in fc_lport_enter_ns()
1350 fc_lport_state(lport)); in fc_lport_enter_ns()
1352 fc_lport_state_enter(lport, state); in fc_lport_enter_ns()
1360 len = strnlen(fc_host_symbolic_name(lport->host), 255); in fc_lport_enter_ns()
1363 return fc_lport_enter_ns(lport, LPORT_ST_RFT_ID); in fc_lport_enter_ns()
1368 len = strnlen(fc_host_symbolic_name(lport->host), 255); in fc_lport_enter_ns()
1371 return fc_lport_enter_ns(lport, LPORT_ST_RFT_ID); in fc_lport_enter_ns()
1384 fc_lport_error(lport, NULL); in fc_lport_enter_ns()
1388 fp = fc_frame_alloc(lport, size); in fc_lport_enter_ns()
1390 fc_lport_error(lport, fp); in fc_lport_enter_ns()
1394 if (!lport->tt.elsct_send(lport, FC_FID_DIR_SERV, fp, cmd, in fc_lport_enter_ns()
1396 lport, 3 * lport->r_a_tov)) in fc_lport_enter_ns()
1397 fc_lport_error(lport, fp); in fc_lport_enter_ns()
1408 static void fc_lport_enter_dns(struct fc_lport *lport) in fc_lport_enter_dns() argument
1412 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_dns()
1414 FC_LPORT_DBG(lport, "Entered DNS state from %s state\n", in fc_lport_enter_dns()
1415 fc_lport_state(lport)); in fc_lport_enter_dns()
1417 fc_lport_state_enter(lport, LPORT_ST_DNS); in fc_lport_enter_dns()
1419 mutex_lock(&lport->disc.disc_mutex); in fc_lport_enter_dns()
1420 rdata = fc_rport_create(lport, FC_FID_DIR_SERV); in fc_lport_enter_dns()
1421 mutex_unlock(&lport->disc.disc_mutex); in fc_lport_enter_dns()
1430 fc_lport_error(lport, NULL); in fc_lport_enter_dns()
1438 static void fc_lport_enter_ms(struct fc_lport *lport, enum fc_lport_state state) in fc_lport_enter_ms() argument
1445 struct fc_host_attrs *fc_host = shost_to_fc_host(lport->host); in fc_lport_enter_ms()
1446 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_ms()
1448 FC_LPORT_DBG(lport, "Entered %s state from %s state\n", in fc_lport_enter_ms()
1450 fc_lport_state(lport)); in fc_lport_enter_ms()
1452 fc_lport_state_enter(lport, state); in fc_lport_enter_ms()
1532 fc_lport_error(lport, NULL); in fc_lport_enter_ms()
1536 FC_LPORT_DBG(lport, "Cmd=0x%x Len %d size %d\n", in fc_lport_enter_ms()
1538 fp = fc_frame_alloc(lport, size); in fc_lport_enter_ms()
1540 fc_lport_error(lport, fp); in fc_lport_enter_ms()
1544 if (!lport->tt.elsct_send(lport, FC_FID_MGMT_SERV, fp, cmd, in fc_lport_enter_ms()
1546 lport, 3 * lport->r_a_tov)) in fc_lport_enter_ms()
1547 fc_lport_error(lport, fp); in fc_lport_enter_ms()
1554 static void fc_lport_enter_fdmi(struct fc_lport *lport) in fc_lport_enter_fdmi() argument
1558 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_fdmi()
1560 FC_LPORT_DBG(lport, "Entered FDMI state from %s state\n", in fc_lport_enter_fdmi()
1561 fc_lport_state(lport)); in fc_lport_enter_fdmi()
1563 fc_lport_state_enter(lport, LPORT_ST_FDMI); in fc_lport_enter_fdmi()
1565 mutex_lock(&lport->disc.disc_mutex); in fc_lport_enter_fdmi()
1566 rdata = fc_rport_create(lport, FC_FID_MGMT_SERV); in fc_lport_enter_fdmi()
1567 mutex_unlock(&lport->disc.disc_mutex); in fc_lport_enter_fdmi()
1576 fc_lport_error(lport, NULL); in fc_lport_enter_fdmi()
1585 struct fc_lport *lport = in fc_lport_timeout() local
1588 struct fc_host_attrs *fc_host = shost_to_fc_host(lport->host); in fc_lport_timeout()
1590 mutex_lock(&lport->lp_mutex); in fc_lport_timeout()
1592 switch (lport->state) { in fc_lport_timeout()
1600 fc_lport_enter_flogi(lport); in fc_lport_timeout()
1603 fc_lport_enter_dns(lport); in fc_lport_timeout()
1610 fc_lport_enter_ns(lport, lport->state); in fc_lport_timeout()
1613 fc_lport_enter_fdmi(lport); in fc_lport_timeout()
1617 FC_LPORT_DBG(lport, "timeout for FDMI-V2 RHBA,fall back to FDMI-V1\n"); in fc_lport_timeout()
1619 fc_lport_enter_ms(lport, LPORT_ST_RHBA); in fc_lport_timeout()
1626 FC_LPORT_DBG(lport, "Skipping lport state %s to SCR\n", in fc_lport_timeout()
1627 fc_lport_state(lport)); in fc_lport_timeout()
1630 fc_lport_enter_scr(lport); in fc_lport_timeout()
1633 fc_lport_enter_logo(lport); in fc_lport_timeout()
1637 mutex_unlock(&lport->lp_mutex); in fc_lport_timeout()
1653 struct fc_lport *lport = lp_arg; in fc_lport_logo_resp() local
1656 FC_LPORT_DBG(lport, "Received a LOGO %s\n", fc_els_resp_type(fp)); in fc_lport_logo_resp()
1661 mutex_lock(&lport->lp_mutex); in fc_lport_logo_resp()
1663 if (lport->state != LPORT_ST_LOGO) { in fc_lport_logo_resp()
1664 FC_LPORT_DBG(lport, "Received a LOGO response, but in state " in fc_lport_logo_resp()
1665 "%s\n", fc_lport_state(lport)); in fc_lport_logo_resp()
1672 fc_lport_error(lport, fp); in fc_lport_logo_resp()
1678 fc_lport_enter_disabled(lport); in fc_lport_logo_resp()
1680 fc_lport_error(lport, fp); in fc_lport_logo_resp()
1685 mutex_unlock(&lport->lp_mutex); in fc_lport_logo_resp()
1693 static void fc_lport_enter_logo(struct fc_lport *lport) in fc_lport_enter_logo() argument
1698 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_logo()
1700 FC_LPORT_DBG(lport, "Entered LOGO state from %s state\n", in fc_lport_enter_logo()
1701 fc_lport_state(lport)); in fc_lport_enter_logo()
1703 fc_lport_state_enter(lport, LPORT_ST_LOGO); in fc_lport_enter_logo()
1704 fc_vports_linkchange(lport); in fc_lport_enter_logo()
1706 fp = fc_frame_alloc(lport, sizeof(*logo)); in fc_lport_enter_logo()
1708 fc_lport_error(lport, fp); in fc_lport_enter_logo()
1712 if (!lport->tt.elsct_send(lport, FC_FID_FLOGI, fp, ELS_LOGO, in fc_lport_enter_logo()
1713 fc_lport_logo_resp, lport, in fc_lport_enter_logo()
1714 2 * lport->r_a_tov)) in fc_lport_enter_logo()
1715 fc_lport_error(lport, NULL); in fc_lport_enter_logo()
1731 struct fc_lport *lport = lp_arg; in fc_lport_flogi_resp() local
1740 FC_LPORT_DBG(lport, "Received a FLOGI %s\n", fc_els_resp_type(fp)); in fc_lport_flogi_resp()
1745 mutex_lock(&lport->lp_mutex); in fc_lport_flogi_resp()
1747 if (lport->state != LPORT_ST_FLOGI) { in fc_lport_flogi_resp()
1748 FC_LPORT_DBG(lport, "Received a FLOGI response, but in state " in fc_lport_flogi_resp()
1749 "%s\n", fc_lport_state(lport)); in fc_lport_flogi_resp()
1756 fc_lport_error(lport, fp); in fc_lport_flogi_resp()
1764 FC_LPORT_DBG(lport, "FLOGI not accepted or bad response\n"); in fc_lport_flogi_resp()
1765 fc_lport_error(lport, fp); in fc_lport_flogi_resp()
1771 FC_LPORT_DBG(lport, "FLOGI bad response\n"); in fc_lport_flogi_resp()
1772 fc_lport_error(lport, fp); in fc_lport_flogi_resp()
1780 FC_LPORT_DBG(lport, "FLOGI bad mfs:%hu response, " in fc_lport_flogi_resp()
1781 "lport->mfs:%u\n", mfs, lport->mfs); in fc_lport_flogi_resp()
1782 fc_lport_error(lport, fp); in fc_lport_flogi_resp()
1786 if (mfs <= lport->mfs) { in fc_lport_flogi_resp()
1787 lport->mfs = mfs; in fc_lport_flogi_resp()
1788 fc_host_maxframe_size(lport->host) = mfs; in fc_lport_flogi_resp()
1797 lport->npiv_enabled = !!(csp_flags & FC_SP_FT_NPIV_ACC); in fc_lport_flogi_resp()
1800 if (e_d_tov > lport->e_d_tov) in fc_lport_flogi_resp()
1801 lport->e_d_tov = e_d_tov; in fc_lport_flogi_resp()
1802 lport->r_a_tov = 2 * lport->e_d_tov; in fc_lport_flogi_resp()
1803 fc_lport_set_port_id(lport, did, fp); in fc_lport_flogi_resp()
1807 lport->host->host_no, did); in fc_lport_flogi_resp()
1808 fc_lport_ptp_setup(lport, fc_frame_sid(fp), in fc_lport_flogi_resp()
1814 if (e_d_tov > lport->e_d_tov) in fc_lport_flogi_resp()
1815 lport->e_d_tov = e_d_tov; in fc_lport_flogi_resp()
1816 if (r_a_tov > lport->r_a_tov) in fc_lport_flogi_resp()
1817 lport->r_a_tov = r_a_tov; in fc_lport_flogi_resp()
1818 fc_host_fabric_name(lport->host) = in fc_lport_flogi_resp()
1820 fc_lport_set_port_id(lport, did, fp); in fc_lport_flogi_resp()
1821 fc_lport_enter_dns(lport); in fc_lport_flogi_resp()
1827 mutex_unlock(&lport->lp_mutex); in fc_lport_flogi_resp()
1835 static void fc_lport_enter_flogi(struct fc_lport *lport) in fc_lport_enter_flogi() argument
1839 lockdep_assert_held(&lport->lp_mutex); in fc_lport_enter_flogi()
1841 FC_LPORT_DBG(lport, "Entered FLOGI state from %s state\n", in fc_lport_enter_flogi()
1842 fc_lport_state(lport)); in fc_lport_enter_flogi()
1844 fc_lport_state_enter(lport, LPORT_ST_FLOGI); in fc_lport_enter_flogi()
1846 if (lport->point_to_multipoint) { in fc_lport_enter_flogi()
1847 if (lport->port_id) in fc_lport_enter_flogi()
1848 fc_lport_enter_ready(lport); in fc_lport_enter_flogi()
1852 fp = fc_frame_alloc(lport, sizeof(struct fc_els_flogi)); in fc_lport_enter_flogi()
1854 return fc_lport_error(lport, fp); in fc_lport_enter_flogi()
1856 if (!lport->tt.elsct_send(lport, FC_FID_FLOGI, fp, in fc_lport_enter_flogi()
1857 lport->vport ? ELS_FDISC : ELS_FLOGI, in fc_lport_enter_flogi()
1858 fc_lport_flogi_resp, lport, in fc_lport_enter_flogi()
1859 lport->vport ? 2 * lport->r_a_tov : in fc_lport_enter_flogi()
1860 lport->e_d_tov)) in fc_lport_enter_flogi()
1861 fc_lport_error(lport, NULL); in fc_lport_enter_flogi()
1868 int fc_lport_config(struct fc_lport *lport) in fc_lport_config() argument
1870 INIT_DELAYED_WORK(&lport->retry_work, fc_lport_timeout); in fc_lport_config()
1871 mutex_init(&lport->lp_mutex); in fc_lport_config()
1873 fc_lport_state_enter(lport, LPORT_ST_DISABLED); in fc_lport_config()
1875 fc_lport_add_fc4_type(lport, FC_TYPE_FCP); in fc_lport_config()
1876 fc_lport_add_fc4_type(lport, FC_TYPE_CT); in fc_lport_config()
1877 fc_fc4_conf_lport_params(lport, FC_TYPE_FCP); in fc_lport_config()
1887 int fc_lport_init(struct fc_lport *lport) in fc_lport_init() argument
1891 fc_host = shost_to_fc_host(lport->host); in fc_lport_init()
1896 fc_host_port_type(lport->host) = FC_PORTTYPE_NPORT; in fc_lport_init()
1897 fc_host_node_name(lport->host) = lport->wwnn; in fc_lport_init()
1898 fc_host_port_name(lport->host) = lport->wwpn; in fc_lport_init()
1899 fc_host_supported_classes(lport->host) = FC_COS_CLASS3; in fc_lport_init()
1900 memset(fc_host_supported_fc4s(lport->host), 0, in fc_lport_init()
1901 sizeof(fc_host_supported_fc4s(lport->host))); in fc_lport_init()
1902 fc_host_supported_fc4s(lport->host)[2] = 1; in fc_lport_init() local
1903 fc_host_supported_fc4s(lport->host)[7] = 1; in fc_lport_init() local
1904 fc_host_num_discovered_ports(lport->host) = 4; in fc_lport_init()
1907 memset(fc_host_active_fc4s(lport->host), 0, in fc_lport_init()
1908 sizeof(fc_host_active_fc4s(lport->host))); in fc_lport_init()
1909 fc_host_active_fc4s(lport->host)[2] = 1; in fc_lport_init() local
1910 fc_host_active_fc4s(lport->host)[7] = 1; in fc_lport_init() local
1911 fc_host_maxframe_size(lport->host) = lport->mfs; in fc_lport_init()
1912 fc_host_supported_speeds(lport->host) = 0; in fc_lport_init()
1913 if (lport->link_supported_speeds & FC_PORTSPEED_1GBIT) in fc_lport_init()
1914 fc_host_supported_speeds(lport->host) |= FC_PORTSPEED_1GBIT; in fc_lport_init()
1915 if (lport->link_supported_speeds & FC_PORTSPEED_10GBIT) in fc_lport_init()
1916 fc_host_supported_speeds(lport->host) |= FC_PORTSPEED_10GBIT; in fc_lport_init()
1917 if (lport->link_supported_speeds & FC_PORTSPEED_40GBIT) in fc_lport_init()
1918 fc_host_supported_speeds(lport->host) |= FC_PORTSPEED_40GBIT; in fc_lport_init()
1919 if (lport->link_supported_speeds & FC_PORTSPEED_100GBIT) in fc_lport_init()
1920 fc_host_supported_speeds(lport->host) |= FC_PORTSPEED_100GBIT; in fc_lport_init()
1921 if (lport->link_supported_speeds & FC_PORTSPEED_25GBIT) in fc_lport_init()
1922 fc_host_supported_speeds(lport->host) |= FC_PORTSPEED_25GBIT; in fc_lport_init()
1923 if (lport->link_supported_speeds & FC_PORTSPEED_50GBIT) in fc_lport_init()
1924 fc_host_supported_speeds(lport->host) |= FC_PORTSPEED_50GBIT; 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()
1928 fc_fc4_add_lport(lport); in fc_lport_init()
1930 fc_host_num_discovered_ports(lport->host) = DISCOVERED_PORTS; in fc_lport_init()
1931 fc_host_port_state(lport->host) = FC_PORTSTATE_ONLINE; in fc_lport_init()
1932 fc_host_max_ct_payload(lport->host) = MAX_CT_PAYLOAD; in fc_lport_init()
1933 fc_host_num_ports(lport->host) = NUMBER_OF_PORTS; in fc_lport_init()
1934 fc_host_bootbios_state(lport->host) = 0X00000000; in fc_lport_init()
1935 snprintf(fc_host_bootbios_version(lport->host), in fc_lport_init()
1954 struct fc_lport *lport = info->lport; in fc_lport_bsg_resp() local
1969 mutex_lock(&lport->lp_mutex); in fc_lport_bsg_resp()
2003 mutex_unlock(&lport->lp_mutex); in fc_lport_bsg_resp()
2014 struct fc_lport *lport, in fc_lport_els_request() argument
2023 lockdep_assert_held(&lport->lp_mutex); in fc_lport_els_request()
2025 fp = fc_frame_alloc(lport, job->request_payload.payload_len); in fc_lport_els_request()
2039 hton24(fh->fh_s_id, lport->port_id); in fc_lport_els_request()
2053 info->lport = lport; in fc_lport_els_request()
2058 if (!fc_exch_seq_send(lport, fp, fc_lport_bsg_resp, in fc_lport_els_request()
2074 struct fc_lport *lport, u32 did, u32 tov) in fc_lport_ct_request() argument
2082 lockdep_assert_held(&lport->lp_mutex); in fc_lport_ct_request()
2084 fp = fc_frame_alloc(lport, sizeof(struct fc_ct_hdr) + in fc_lport_ct_request()
2099 hton24(fh->fh_s_id, lport->port_id); in fc_lport_ct_request()
2113 info->lport = lport; in fc_lport_ct_request()
2118 if (!fc_exch_seq_send(lport, fp, fc_lport_bsg_resp, in fc_lport_ct_request()
2136 struct fc_lport *lport = shost_priv(shost); in fc_lport_bsg_request() local
2144 mutex_lock(&lport->lp_mutex); in fc_lport_bsg_request()
2153 rc = fc_lport_els_request(job, lport, rport->port_id, in fc_lport_bsg_request()
2163 rc = fc_lport_ct_request(job, lport, rport->port_id, in fc_lport_bsg_request()
2170 rdata = lport->dns_rdata; in fc_lport_bsg_request()
2175 rdata = fc_rport_lookup(lport, did); in fc_lport_bsg_request()
2182 rc = fc_lport_ct_request(job, lport, did, tov); in fc_lport_bsg_request()
2187 rc = fc_lport_els_request(job, lport, did, lport->e_d_tov); in fc_lport_bsg_request()
2191 mutex_unlock(&lport->lp_mutex); in fc_lport_bsg_request()