Lines Matching refs:lport
11 * These comments only apply to the 'port code' which consists of the lport,
16 * The lport, disc and rport blocks all have mutexes that are used to protect
18 * having an lport reset just before we send a frame. In that scenario the
19 * lport's FID would get set to zero and then we'd send a frame with an
29 * lport > disc, lport > rport, disc > rport
34 * from the rport (to either lport or disc) and a callback from disc
35 * (to the lport).
39 * cause the lport or disc to grab its lock we cannot hold the rport lock
46 * When discovery succeeds or fails a callback is made to the lport as
47 * notification. Currently, successful discovery causes the lport to take no
48 * action. A failure will cause the lport to reset. There is likely a circular
55 * The critical sections protected by the lport's mutex are quite broad and
56 * may be improved upon in the future. The lport code and its locking doesn't
64 * means that the entry points into the lport block manage the locks while
68 * When handling responses we also hold the lport mutex broadly. When the
69 * lport receives the response frame it locks the mutex and then calls the
74 * context and the work function will lock the lport and then retry the state
110 static void fc_lport_enter_fdmi(struct fc_lport *lport);
136 * @lport: The local port to pass through a command
144 struct fc_lport *lport;
153 * @lport: The local port the frame was received on
156 static int fc_frame_drop(struct fc_lport *lport, struct fc_frame *fp)
164 * @lport: The lport which is receiving the event
171 static void fc_lport_rport_callback(struct fc_lport *lport,
175 FC_LPORT_DBG(lport, "Received a %d event for port (%6.6x)\n", event,
178 mutex_lock(&lport->lp_mutex);
181 if (lport->state == LPORT_ST_DNS) {
182 lport->dns_rdata = rdata;
183 fc_lport_enter_ns(lport, LPORT_ST_RNN_ID);
184 } else if (lport->state == LPORT_ST_FDMI) {
185 lport->ms_rdata = rdata;
186 fc_lport_enter_ms(lport, LPORT_ST_DHBA);
188 FC_LPORT_DBG(lport, "Received an READY event "
190 "server, but the lport is not "
193 lport->state);
201 lport->dns_rdata = NULL;
203 lport->ms_rdata = NULL;
208 mutex_unlock(&lport->lp_mutex);
212 * fc_lport_state() - Return a string which represents the lport's state
213 * @lport: The lport whose state is to converted to a string
215 static const char *fc_lport_state(struct fc_lport *lport)
219 cp = fc_lport_state_names[lport->state];
227 * @lport: The lport to attach the ptp rport to
232 static void fc_lport_ptp_setup(struct fc_lport *lport,
236 lockdep_assert_held(&lport->lp_mutex);
238 if (lport->ptp_rdata) {
239 fc_rport_logoff(lport->ptp_rdata);
240 kref_put(&lport->ptp_rdata->kref, fc_rport_destroy);
242 mutex_lock(&lport->disc.disc_mutex);
243 lport->ptp_rdata = fc_rport_create(lport, remote_fid);
244 if (!lport->ptp_rdata) {
245 printk(KERN_WARNING "libfc: Failed to setup lport 0x%x\n",
246 lport->port_id);
247 mutex_unlock(&lport->disc.disc_mutex);
250 kref_get(&lport->ptp_rdata->kref);
251 lport->ptp_rdata->ids.port_name = remote_wwpn;
252 lport->ptp_rdata->ids.node_name = remote_wwnn;
253 mutex_unlock(&lport->disc.disc_mutex);
255 fc_rport_login(lport->ptp_rdata);
257 fc_lport_enter_ready(lport);
266 struct fc_lport *lport = shost_priv(shost);
268 mutex_lock(&lport->lp_mutex);
269 if (!lport->link_up)
272 switch (lport->state) {
279 mutex_unlock(&lport->lp_mutex);
289 struct fc_lport *lport = shost_priv(shost);
291 fc_host_speed(shost) = lport->link_speed;
302 struct fc_lport *lport = shost_priv(shost);
307 fc_stats = &lport->host_stats;
310 fc_stats->seconds_since_last_reset = (jiffies - lport->boot_time) / HZ;
315 stats = per_cpu_ptr(lport->stats, cpu);
343 fc_exch_update_stats(lport);
351 * @lport: The local port the FLOGI is for
355 static void fc_lport_flogi_fill(struct fc_lport *lport,
364 put_unaligned_be64(lport->wwpn, &flogi->fl_wwpn);
365 put_unaligned_be64(lport->wwnn, &flogi->fl_wwnn);
370 sp->sp_bb_data = htons((u16) lport->mfs);
377 sp->sp_e_d_tov = htonl(lport->e_d_tov);
379 cp->cp_rdfs = htons((u16) lport->mfs);
387 * @lport: The local port to add a new FC-4 type to
390 static void fc_lport_add_fc4_type(struct fc_lport *lport, enum fc_fh_type type)
394 mp = &lport->fcts.ff_type_map[type / FC_NS_BPW];
400 * @lport: Fibre Channel local port receiving the RLIR
403 static void fc_lport_recv_rlir_req(struct fc_lport *lport, struct fc_frame *fp)
405 lockdep_assert_held(&lport->lp_mutex);
407 FC_LPORT_DBG(lport, "Received RLIR request while in state %s\n",
408 fc_lport_state(lport));
416 * @lport: The local port receiving the ECHO
419 static void fc_lport_recv_echo_req(struct fc_lport *lport,
427 lockdep_assert_held(&lport->lp_mutex);
429 FC_LPORT_DBG(lport, "Received ECHO request while in state %s\n",
430 fc_lport_state(lport));
438 fp = fc_frame_alloc(lport, len);
444 lport->tt.frame_send(lport, fp);
451 * @lport: The local port receiving the RNID
454 static void fc_lport_recv_rnid_req(struct fc_lport *lport,
468 lockdep_assert_held(&lport->lp_mutex);
470 FC_LPORT_DBG(lport, "Received RNID request while in state %s\n",
471 fc_lport_state(lport));
482 ntohl(lport->rnid_gen.rnid_atype) == 0) {
486 fp = fc_frame_alloc(lport, len);
493 rp->cid.rnid_wwpn = htonll(lport->wwpn);
494 rp->cid.rnid_wwnn = htonll(lport->wwnn);
497 memcpy(&rp->gen, &lport->rnid_gen,
501 lport->tt.frame_send(lport, fp);
509 * @lport: The local port receiving the LOGO
512 static void fc_lport_recv_logo_req(struct fc_lport *lport, struct fc_frame *fp)
514 lockdep_assert_held(&lport->lp_mutex);
517 fc_lport_enter_reset(lport);
522 * fc_fabric_login() - Start the lport state machine
523 * @lport: The local port that should log into the fabric
526 * with the lport lock held.
528 int fc_fabric_login(struct fc_lport *lport)
532 mutex_lock(&lport->lp_mutex);
533 if (lport->state == LPORT_ST_DISABLED ||
534 lport->state == LPORT_ST_LOGO) {
535 fc_lport_state_enter(lport, LPORT_ST_RESET);
536 fc_lport_enter_reset(lport);
539 mutex_unlock(&lport->lp_mutex);
547 * @lport: The lport whose link is up
549 void __fc_linkup(struct fc_lport *lport)
551 lockdep_assert_held(&lport->lp_mutex);
553 if (!lport->link_up) {
554 lport->link_up = 1;
556 if (lport->state == LPORT_ST_RESET)
557 fc_lport_enter_flogi(lport);
563 * @lport: The local port whose link is up
565 void fc_linkup(struct fc_lport *lport)
568 lport->host->host_no, lport->port_id);
570 mutex_lock(&lport->lp_mutex);
571 __fc_linkup(lport);
572 mutex_unlock(&lport->lp_mutex);
578 * @lport: The lport whose link is down
580 void __fc_linkdown(struct fc_lport *lport)
582 lockdep_assert_held(&lport->lp_mutex);
584 if (lport->link_up) {
585 lport->link_up = 0;
586 fc_lport_enter_reset(lport);
587 lport->tt.fcp_cleanup(lport);
593 * @lport: The local port whose link is down
595 void fc_linkdown(struct fc_lport *lport)
598 lport->host->host_no, lport->port_id);
600 mutex_lock(&lport->lp_mutex);
601 __fc_linkdown(lport);
602 mutex_unlock(&lport->lp_mutex);
608 * @lport: The local port to logoff the fabric
613 int fc_fabric_logoff(struct fc_lport *lport)
615 lport->tt.disc_stop_final(lport);
616 mutex_lock(&lport->lp_mutex);
617 if (lport->dns_rdata)
618 fc_rport_logoff(lport->dns_rdata);
619 mutex_unlock(&lport->lp_mutex);
621 mutex_lock(&lport->lp_mutex);
622 fc_lport_enter_logo(lport);
623 mutex_unlock(&lport->lp_mutex);
624 cancel_delayed_work_sync(&lport->retry_work);
631 * @lport: The local port to unregister
639 int fc_lport_destroy(struct fc_lport *lport)
641 mutex_lock(&lport->lp_mutex);
642 lport->state = LPORT_ST_DISABLED;
643 lport->link_up = 0;
644 lport->tt.frame_send = fc_frame_drop;
645 mutex_unlock(&lport->lp_mutex);
647 lport->tt.fcp_abort_io(lport);
648 lport->tt.disc_stop_final(lport);
649 lport->tt.exch_mgr_reset(lport, 0, 0);
650 cancel_delayed_work_sync(&lport->retry_work);
651 fc_fc4_del_lport(lport);
658 * @lport: The local port to set the MFS for
661 int fc_set_mfs(struct fc_lport *lport, u32 mfs)
666 mutex_lock(&lport->lp_mutex);
668 old_mfs = lport->mfs;
675 lport->mfs = mfs;
680 fc_lport_enter_reset(lport);
682 mutex_unlock(&lport->lp_mutex);
690 * @lport: The local port receiving the event
693 static void fc_lport_disc_callback(struct fc_lport *lport,
698 FC_LPORT_DBG(lport, "Discovery succeeded\n");
703 lport->host->host_no, lport->port_id);
704 mutex_lock(&lport->lp_mutex);
705 fc_lport_enter_reset(lport);
706 mutex_unlock(&lport->lp_mutex);
716 * @lport: The local port that is ready
718 static void fc_lport_enter_ready(struct fc_lport *lport)
720 lockdep_assert_held(&lport->lp_mutex);
722 FC_LPORT_DBG(lport, "Entered READY from state %s\n",
723 fc_lport_state(lport));
725 fc_lport_state_enter(lport, LPORT_ST_READY);
726 if (lport->vport)
727 fc_vport_set_state(lport->vport, FC_VPORT_ACTIVE);
728 fc_vports_linkchange(lport);
730 if (!lport->ptp_rdata)
731 lport->tt.disc_start(fc_lport_disc_callback, lport);
736 * @lport: The local port which will have its Port ID set.
740 static void fc_lport_set_port_id(struct fc_lport *lport, u32 port_id,
743 lockdep_assert_held(&lport->lp_mutex);
747 lport->host->host_no, port_id);
749 lport->port_id = port_id;
752 fc_host_port_id(lport->host) = port_id;
754 if (lport->tt.lport_set_port_id)
755 lport->tt.lport_set_port_id(lport, port_id, fp);
760 * @lport: The local port which will have its Port ID set.
767 void fc_lport_set_local_id(struct fc_lport *lport, u32 port_id)
769 mutex_lock(&lport->lp_mutex);
771 fc_lport_set_port_id(lport, port_id, NULL);
773 switch (lport->state) {
777 fc_lport_enter_ready(lport);
782 mutex_unlock(&lport->lp_mutex);
788 * @lport: The local port that received the request
795 static void fc_lport_recv_flogi_req(struct fc_lport *lport,
806 lockdep_assert_held(&lport->lp_mutex);
808 FC_LPORT_DBG(lport, "Received FLOGI request while in state %s\n",
809 fc_lport_state(lport));
816 if (remote_wwpn == lport->wwpn) {
819 lport->host->host_no, remote_wwpn);
822 FC_LPORT_DBG(lport, "FLOGI from port WWPN %16.16llx\n", remote_wwpn);
830 if (remote_wwpn < lport->wwpn) {
838 fc_lport_set_port_id(lport, local_fid, rx_fp);
840 fp = fc_frame_alloc(lport, sizeof(*flp));
843 fc_lport_flogi_fill(lport, new_flp, ELS_FLOGI);
854 lport->tt.frame_send(lport, fp);
857 fc_lport_error(lport, fp);
859 fc_lport_ptp_setup(lport, remote_fid, remote_wwpn,
866 * fc_lport_recv_els_req() - The generic lport ELS request handler
867 * @lport: The local port that received the request
870 * This function will see if the lport handles the request or
873 * Locking Note: This function should not be called with the lport
876 static void fc_lport_recv_els_req(struct fc_lport *lport,
879 mutex_lock(&lport->lp_mutex);
886 if (!lport->link_up)
894 if (!lport->point_to_multipoint)
895 fc_lport_recv_flogi_req(lport, fp);
897 fc_rport_recv_req(lport, fp);
901 fc_lport_recv_logo_req(lport, fp);
903 fc_rport_recv_req(lport, fp);
906 lport->tt.disc_recv_req(lport, fp);
909 fc_lport_recv_echo_req(lport, fp);
912 fc_lport_recv_rlir_req(lport, fp);
915 fc_lport_recv_rnid_req(lport, fp);
918 fc_rport_recv_req(lport, fp);
922 mutex_unlock(&lport->lp_mutex);
938 * fc_lport_recv() - The generic lport request handler
939 * @lport: The lport that received the request
942 * Locking Note: This function should not be called with the lport
945 void fc_lport_recv(struct fc_lport *lport, struct fc_frame *fp)
966 prov->recv(lport, fp);
971 FC_LPORT_DBG(lport, "dropping unexpected frame type %x\n", fh->fh_type);
980 * @lport: The local port which should be reset
983 * lport lock held.
985 int fc_lport_reset(struct fc_lport *lport)
987 cancel_delayed_work_sync(&lport->retry_work);
988 mutex_lock(&lport->lp_mutex);
989 fc_lport_enter_reset(lport);
990 mutex_unlock(&lport->lp_mutex);
996 * fc_lport_reset_locked() - Reset the local port w/ the lport lock held
997 * @lport: The local port to be reset
999 static void fc_lport_reset_locked(struct fc_lport *lport)
1001 lockdep_assert_held(&lport->lp_mutex);
1003 if (lport->dns_rdata) {
1004 fc_rport_logoff(lport->dns_rdata);
1005 lport->dns_rdata = NULL;
1008 if (lport->ptp_rdata) {
1009 fc_rport_logoff(lport->ptp_rdata);
1010 kref_put(&lport->ptp_rdata->kref, fc_rport_destroy);
1011 lport->ptp_rdata = NULL;
1014 lport->tt.disc_stop(lport);
1016 lport->tt.exch_mgr_reset(lport, 0, 0);
1017 fc_host_fabric_name(lport->host) = 0;
1019 if (lport->port_id && (!lport->point_to_multipoint || !lport->link_up))
1020 fc_lport_set_port_id(lport, 0, NULL);
1025 * @lport: The local port to be reset
1027 static void fc_lport_enter_reset(struct fc_lport *lport)
1029 lockdep_assert_held(&lport->lp_mutex);
1031 FC_LPORT_DBG(lport, "Entered RESET state from %s state\n",
1032 fc_lport_state(lport));
1034 if (lport->state == LPORT_ST_DISABLED || lport->state == LPORT_ST_LOGO)
1037 if (lport->vport) {
1038 if (lport->link_up)
1039 fc_vport_set_state(lport->vport, FC_VPORT_INITIALIZING);
1041 fc_vport_set_state(lport->vport, FC_VPORT_LINKDOWN);
1043 fc_lport_state_enter(lport, LPORT_ST_RESET);
1044 fc_host_post_event(lport->host, fc_get_event_number(),
1046 fc_vports_linkchange(lport);
1047 fc_lport_reset_locked(lport);
1048 if (lport->link_up)
1049 fc_lport_enter_flogi(lport);
1054 * @lport: The local port to be reset
1056 static void fc_lport_enter_disabled(struct fc_lport *lport)
1058 lockdep_assert_held(&lport->lp_mutex);
1060 FC_LPORT_DBG(lport, "Entered disabled state from %s state\n",
1061 fc_lport_state(lport));
1063 fc_lport_state_enter(lport, LPORT_ST_DISABLED);
1064 fc_vports_linkchange(lport);
1065 fc_lport_reset_locked(lport);
1070 * @lport: The local port that the error was on
1077 static void fc_lport_error(struct fc_lport *lport, struct fc_frame *fp)
1080 FC_LPORT_DBG(lport, "Error %ld in state %s, retries %d\n",
1081 IS_ERR(fp) ? -PTR_ERR(fp) : 0, fc_lport_state(lport),
1082 lport->retry_count);
1092 if (lport->retry_count < lport->max_retry_count) {
1093 lport->retry_count++;
1097 delay = msecs_to_jiffies(lport->e_d_tov);
1099 schedule_delayed_work(&lport->retry_work, delay);
1101 fc_lport_enter_reset(lport);
1111 * Locking Note: This function will be called without the lport lock
1113 * and then unlock the lport.
1118 struct fc_lport *lport = lp_arg;
1122 FC_LPORT_DBG(lport, "Received a ns %s\n", fc_els_resp_type(fp));
1127 mutex_lock(&lport->lp_mutex);
1129 if (lport->state < LPORT_ST_RNN_ID || lport->state > LPORT_ST_RFF_ID) {
1130 FC_LPORT_DBG(lport, "Received a name server response, "
1131 "but in state %s\n", fc_lport_state(lport));
1138 fc_lport_error(lport, fp);
1149 switch (lport->state) {
1151 fc_lport_enter_ns(lport, LPORT_ST_RSNN_NN);
1154 fc_lport_enter_ns(lport, LPORT_ST_RSPN_ID);
1157 fc_lport_enter_ns(lport, LPORT_ST_RFT_ID);
1160 fc_lport_enter_ns(lport, LPORT_ST_RFF_ID);
1163 if (lport->fdmi_enabled)
1164 fc_lport_enter_fdmi(lport);
1166 fc_lport_enter_scr(lport);
1173 fc_lport_error(lport, fp);
1177 mutex_unlock(&lport->lp_mutex);
1187 * Locking Note: This function will be called without the lport lock
1189 * and then unlock the lport.
1194 struct fc_lport *lport = lp_arg;
1197 struct fc_host_attrs *fc_host = shost_to_fc_host(lport->host);
1198 FC_LPORT_DBG(lport, "Received a ms %s\n", fc_els_resp_type(fp));
1203 mutex_lock(&lport->lp_mutex);
1205 if (lport->state < LPORT_ST_RHBA || lport->state > LPORT_ST_DPRT) {
1206 FC_LPORT_DBG(lport, "Received a management server response, "
1207 "but in state %s\n", fc_lport_state(lport));
1214 fc_lport_error(lport, fp);
1224 FC_LPORT_DBG(lport, "Received a management server response, "
1229 switch (lport->state) {
1232 FC_LPORT_DBG(lport, "Error for FDMI-V2, fall back to FDMI-V1\n");
1235 fc_lport_enter_ms(lport, LPORT_ST_RHBA);
1238 fc_lport_enter_ms(lport, LPORT_ST_RPA);
1240 fc_lport_enter_scr(lport);
1243 fc_lport_enter_scr(lport);
1246 fc_lport_enter_ms(lport, LPORT_ST_RHBA);
1249 fc_lport_enter_ms(lport, LPORT_ST_DPRT);
1257 fc_lport_error(lport, fp);
1262 mutex_unlock(&lport->lp_mutex);
1269 * @lp_arg: Fibre Channel lport port instance that sent the registration request
1271 * Locking Note: This function will be called without the lport lock
1273 * and then unlock the lport.
1278 struct fc_lport *lport = lp_arg;
1281 FC_LPORT_DBG(lport, "Received a SCR %s\n", fc_els_resp_type(fp));
1286 mutex_lock(&lport->lp_mutex);
1288 if (lport->state != LPORT_ST_SCR) {
1289 FC_LPORT_DBG(lport, "Received a SCR response, but in state "
1290 "%s\n", fc_lport_state(lport));
1297 fc_lport_error(lport, fp);
1303 fc_lport_enter_ready(lport);
1305 fc_lport_error(lport, fp);
1310 mutex_unlock(&lport->lp_mutex);
1315 * @lport: The local port to register for state changes
1317 static void fc_lport_enter_scr(struct fc_lport *lport)
1321 lockdep_assert_held(&lport->lp_mutex);
1323 FC_LPORT_DBG(lport, "Entered SCR state from %s state\n",
1324 fc_lport_state(lport));
1326 fc_lport_state_enter(lport, LPORT_ST_SCR);
1328 fp = fc_frame_alloc(lport, sizeof(struct fc_els_scr));
1330 fc_lport_error(lport, fp);
1334 if (!lport->tt.elsct_send(lport, FC_FID_FCTRL, fp, ELS_SCR,
1335 fc_lport_scr_resp, lport,
1336 2 * lport->r_a_tov))
1337 fc_lport_error(lport, NULL);
1342 * @lport: Fibre Channel local port to register
1345 static void fc_lport_enter_ns(struct fc_lport *lport, enum fc_lport_state state)
1352 lockdep_assert_held(&lport->lp_mutex);
1354 FC_LPORT_DBG(lport, "Entered %s state from %s state\n",
1356 fc_lport_state(lport));
1358 fc_lport_state_enter(lport, state);
1366 len = strnlen(fc_host_symbolic_name(lport->host), 255);
1369 return fc_lport_enter_ns(lport, LPORT_ST_RFT_ID);
1374 len = strnlen(fc_host_symbolic_name(lport->host), 255);
1377 return fc_lport_enter_ns(lport, LPORT_ST_RFT_ID);
1390 fc_lport_error(lport, NULL);
1394 fp = fc_frame_alloc(lport, size);
1396 fc_lport_error(lport, fp);
1400 if (!lport->tt.elsct_send(lport, FC_FID_DIR_SERV, fp, cmd,
1402 lport, 3 * lport->r_a_tov))
1403 fc_lport_error(lport, fp);
1412 * @lport: The local port requesting a remote port for the name server
1414 static void fc_lport_enter_dns(struct fc_lport *lport)
1418 lockdep_assert_held(&lport->lp_mutex);
1420 FC_LPORT_DBG(lport, "Entered DNS state from %s state\n",
1421 fc_lport_state(lport));
1423 fc_lport_state_enter(lport, LPORT_ST_DNS);
1425 mutex_lock(&lport->disc.disc_mutex);
1426 rdata = fc_rport_create(lport, FC_FID_DIR_SERV);
1427 mutex_unlock(&lport->disc.disc_mutex);
1436 fc_lport_error(lport, NULL);
1441 * @lport: Fibre Channel local port to register
1444 static void fc_lport_enter_ms(struct fc_lport *lport, enum fc_lport_state state)
1451 struct fc_host_attrs *fc_host = shost_to_fc_host(lport->host);
1452 lockdep_assert_held(&lport->lp_mutex);
1454 FC_LPORT_DBG(lport, "Entered %s state from %s state\n",
1456 fc_lport_state(lport));
1458 fc_lport_state_enter(lport, state);
1538 fc_lport_error(lport, NULL);
1542 FC_LPORT_DBG(lport, "Cmd=0x%x Len %d size %d\n",
1544 fp = fc_frame_alloc(lport, size);
1546 fc_lport_error(lport, fp);
1550 if (!lport->tt.elsct_send(lport, FC_FID_MGMT_SERV, fp, cmd,
1552 lport, 3 * lport->r_a_tov))
1553 fc_lport_error(lport, fp);
1558 * @lport: The local port requesting a remote port for the management server
1560 static void fc_lport_enter_fdmi(struct fc_lport *lport)
1564 lockdep_assert_held(&lport->lp_mutex);
1566 FC_LPORT_DBG(lport, "Entered FDMI state from %s state\n",
1567 fc_lport_state(lport));
1569 fc_lport_state_enter(lport, LPORT_ST_FDMI);
1571 mutex_lock(&lport->disc.disc_mutex);
1572 rdata = fc_rport_create(lport, FC_FID_MGMT_SERV);
1573 mutex_unlock(&lport->disc.disc_mutex);
1582 fc_lport_error(lport, NULL);
1591 struct fc_lport *lport =
1594 struct fc_host_attrs *fc_host = shost_to_fc_host(lport->host);
1596 mutex_lock(&lport->lp_mutex);
1598 switch (lport->state) {
1606 fc_lport_enter_flogi(lport);
1609 fc_lport_enter_dns(lport);
1616 fc_lport_enter_ns(lport, lport->state);
1619 fc_lport_enter_fdmi(lport);
1623 FC_LPORT_DBG(lport, "timeout for FDMI-V2 RHBA,fall back to FDMI-V1\n");
1625 fc_lport_enter_ms(lport, LPORT_ST_RHBA);
1632 FC_LPORT_DBG(lport, "Skipping lport state %s to SCR\n",
1633 fc_lport_state(lport));
1636 fc_lport_enter_scr(lport);
1639 fc_lport_enter_logo(lport);
1643 mutex_unlock(&lport->lp_mutex);
1650 * @lp_arg: The lport port that received the LOGO request
1652 * Locking Note: This function will be called without the lport lock
1654 * and then unlock the lport.
1659 struct fc_lport *lport = lp_arg;
1662 FC_LPORT_DBG(lport, "Received a LOGO %s\n", fc_els_resp_type(fp));
1667 mutex_lock(&lport->lp_mutex);
1669 if (lport->state != LPORT_ST_LOGO) {
1670 FC_LPORT_DBG(lport, "Received a LOGO response, but in state "
1671 "%s\n", fc_lport_state(lport));
1678 fc_lport_error(lport, fp);
1684 fc_lport_enter_disabled(lport);
1686 fc_lport_error(lport, fp);
1691 mutex_unlock(&lport->lp_mutex);
1697 * @lport: The local port to be logged out
1699 static void fc_lport_enter_logo(struct fc_lport *lport)
1704 lockdep_assert_held(&lport->lp_mutex);
1706 FC_LPORT_DBG(lport, "Entered LOGO state from %s state\n",
1707 fc_lport_state(lport));
1709 fc_lport_state_enter(lport, LPORT_ST_LOGO);
1710 fc_vports_linkchange(lport);
1712 fp = fc_frame_alloc(lport, sizeof(*logo));
1714 fc_lport_error(lport, fp);
1718 if (!lport->tt.elsct_send(lport, FC_FID_FLOGI, fp, ELS_LOGO,
1719 fc_lport_logo_resp, lport,
1720 2 * lport->r_a_tov))
1721 fc_lport_error(lport, NULL);
1728 * @lp_arg: The lport port that received the FLOGI response
1730 * Locking Note: This function will be called without the lport lock
1732 * and then unlock the lport.
1737 struct fc_lport *lport = lp_arg;
1746 FC_LPORT_DBG(lport, "Received a FLOGI %s\n", fc_els_resp_type(fp));
1751 mutex_lock(&lport->lp_mutex);
1753 if (lport->state != LPORT_ST_FLOGI) {
1754 FC_LPORT_DBG(lport, "Received a FLOGI response, but in state "
1755 "%s\n", fc_lport_state(lport));
1762 fc_lport_error(lport, fp);
1770 FC_LPORT_DBG(lport, "FLOGI not accepted or bad response\n");
1771 fc_lport_error(lport, fp);
1777 FC_LPORT_DBG(lport, "FLOGI bad response\n");
1778 fc_lport_error(lport, fp);
1786 FC_LPORT_DBG(lport, "FLOGI bad mfs:%hu response, "
1787 "lport->mfs:%u\n", mfs, lport->mfs);
1788 fc_lport_error(lport, fp);
1792 if (mfs <= lport->mfs) {
1793 lport->mfs = mfs;
1794 fc_host_maxframe_size(lport->host) = mfs;
1803 lport->npiv_enabled = !!(csp_flags & FC_SP_FT_NPIV_ACC);
1806 if (e_d_tov > lport->e_d_tov)
1807 lport->e_d_tov = e_d_tov;
1808 lport->r_a_tov = 2 * lport->e_d_tov;
1809 fc_lport_set_port_id(lport, did, fp);
1813 lport->host->host_no, did);
1814 fc_lport_ptp_setup(lport, fc_frame_sid(fp),
1820 if (e_d_tov > lport->e_d_tov)
1821 lport->e_d_tov = e_d_tov;
1822 if (r_a_tov > lport->r_a_tov)
1823 lport->r_a_tov = r_a_tov;
1824 fc_host_fabric_name(lport->host) =
1826 fc_lport_set_port_id(lport, did, fp);
1827 fc_lport_enter_dns(lport);
1833 mutex_unlock(&lport->lp_mutex);
1839 * @lport: Fibre Channel local port to be logged in to the fabric
1841 static void fc_lport_enter_flogi(struct fc_lport *lport)
1845 lockdep_assert_held(&lport->lp_mutex);
1847 FC_LPORT_DBG(lport, "Entered FLOGI state from %s state\n",
1848 fc_lport_state(lport));
1850 fc_lport_state_enter(lport, LPORT_ST_FLOGI);
1852 if (lport->point_to_multipoint) {
1853 if (lport->port_id)
1854 fc_lport_enter_ready(lport);
1858 fp = fc_frame_alloc(lport, sizeof(struct fc_els_flogi));
1860 return fc_lport_error(lport, fp);
1862 if (!lport->tt.elsct_send(lport, FC_FID_FLOGI, fp,
1863 lport->vport ? ELS_FDISC : ELS_FLOGI,
1864 fc_lport_flogi_resp, lport,
1865 lport->vport ? 2 * lport->r_a_tov :
1866 lport->e_d_tov))
1867 fc_lport_error(lport, NULL);
1872 * @lport: The local port to be configured
1874 int fc_lport_config(struct fc_lport *lport)
1876 INIT_DELAYED_WORK(&lport->retry_work, fc_lport_timeout);
1877 mutex_init(&lport->lp_mutex);
1879 fc_lport_state_enter(lport, LPORT_ST_DISABLED);
1881 fc_lport_add_fc4_type(lport, FC_TYPE_FCP);
1882 fc_lport_add_fc4_type(lport, FC_TYPE_CT);
1883 fc_fc4_conf_lport_params(lport, FC_TYPE_FCP);
1890 * fc_lport_init() - Initialize the lport layer for a local port
1891 * @lport: The local port to initialize the exchange layer for
1893 int fc_lport_init(struct fc_lport *lport)
1897 fc_host = shost_to_fc_host(lport->host);
1902 fc_host_port_type(lport->host) = FC_PORTTYPE_NPORT;
1903 fc_host_node_name(lport->host) = lport->wwnn;
1904 fc_host_port_name(lport->host) = lport->wwpn;
1905 fc_host_supported_classes(lport->host) = FC_COS_CLASS3;
1906 memset(fc_host_supported_fc4s(lport->host), 0,
1907 sizeof(fc_host_supported_fc4s(lport->host)));
1908 fc_host_supported_fc4s(lport->host)[2] = 1;
1909 fc_host_supported_fc4s(lport->host)[7] = 1;
1910 fc_host_num_discovered_ports(lport->host) = 4;
1913 memset(fc_host_active_fc4s(lport->host), 0,
1914 sizeof(fc_host_active_fc4s(lport->host)));
1915 fc_host_active_fc4s(lport->host)[2] = 1;
1916 fc_host_active_fc4s(lport->host)[7] = 1;
1917 fc_host_maxframe_size(lport->host) = lport->mfs;
1918 fc_host_supported_speeds(lport->host) = 0;
1919 if (lport->link_supported_speeds & FC_PORTSPEED_1GBIT)
1920 fc_host_supported_speeds(lport->host) |= FC_PORTSPEED_1GBIT;
1921 if (lport->link_supported_speeds & FC_PORTSPEED_10GBIT)
1922 fc_host_supported_speeds(lport->host) |= FC_PORTSPEED_10GBIT;
1923 if (lport->link_supported_speeds & FC_PORTSPEED_40GBIT)
1924 fc_host_supported_speeds(lport->host) |= FC_PORTSPEED_40GBIT;
1925 if (lport->link_supported_speeds & FC_PORTSPEED_100GBIT)
1926 fc_host_supported_speeds(lport->host) |= FC_PORTSPEED_100GBIT;
1927 if (lport->link_supported_speeds & FC_PORTSPEED_25GBIT)
1928 fc_host_supported_speeds(lport->host) |= FC_PORTSPEED_25GBIT;
1929 if (lport->link_supported_speeds & FC_PORTSPEED_50GBIT)
1930 fc_host_supported_speeds(lport->host) |= FC_PORTSPEED_50GBIT;
1931 if (lport->link_supported_speeds & FC_PORTSPEED_100GBIT)
1932 fc_host_supported_speeds(lport->host) |= FC_PORTSPEED_100GBIT;
1934 fc_fc4_add_lport(lport);
1936 fc_host_num_discovered_ports(lport->host) = DISCOVERED_PORTS;
1937 fc_host_port_state(lport->host) = FC_PORTSTATE_ONLINE;
1938 fc_host_max_ct_payload(lport->host) = MAX_CT_PAYLOAD;
1939 fc_host_num_ports(lport->host) = NUMBER_OF_PORTS;
1940 fc_host_bootbios_state(lport->host) = 0X00000000;
1941 snprintf(fc_host_bootbios_version(lport->host),
1960 struct fc_lport *lport = info->lport;
1975 mutex_lock(&lport->lp_mutex);
2009 mutex_unlock(&lport->lp_mutex);
2015 * @lport: The local port sending the request
2020 struct fc_lport *lport,
2029 lockdep_assert_held(&lport->lp_mutex);
2031 fp = fc_frame_alloc(lport, job->request_payload.payload_len);
2045 hton24(fh->fh_s_id, lport->port_id);
2059 info->lport = lport;
2064 if (!fc_exch_seq_send(lport, fp, fc_lport_bsg_resp,
2075 * @lport: The local port sending the request
2080 struct fc_lport *lport, u32 did, u32 tov)
2088 lockdep_assert_held(&lport->lp_mutex);
2090 fp = fc_frame_alloc(lport, sizeof(struct fc_ct_hdr) +
2105 hton24(fh->fh_s_id, lport->port_id);
2119 info->lport = lport;
2124 if (!fc_exch_seq_send(lport, fp, fc_lport_bsg_resp,
2142 struct fc_lport *lport = shost_priv(shost);
2150 mutex_lock(&lport->lp_mutex);
2159 rc = fc_lport_els_request(job, lport, rport->port_id,
2169 rc = fc_lport_ct_request(job, lport, rport->port_id,
2176 rdata = lport->dns_rdata;
2181 rdata = fc_rport_lookup(lport, did);
2188 rc = fc_lport_ct_request(job, lport, did, tov);
2193 rc = fc_lport_els_request(job, lport, did, lport->e_d_tov);
2197 mutex_unlock(&lport->lp_mutex);