Lines Matching refs:fcport
154 sp = qla2xxx_get_qpair_sp(cmd_sp->vha, cmd_sp->qpair, cmd_sp->fcport,
201 fc_port_t *fcport = sp->fcport;
206 if (fcport) {
207 ql_dbg(ql_dbg_disc, fcport->vha, 0x2071,
209 sp->name, sp->handle, fcport->d_id.b24, fcport->port_name);
211 fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE);
274 "%s %8phC res %d \n", __func__, sp->fcport->port_name, res);
276 sp->fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE);
280 ea.fcport = sp->fcport;
293 fcport_is_smaller(fc_port_t *fcport)
295 if (wwn_to_u64(fcport->port_name) <
296 wwn_to_u64(fcport->vha->port_name))
303 fcport_is_bigger(fc_port_t *fcport)
305 return !fcport_is_smaller(fcport);
309 qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport,
316 if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT) ||
317 fcport->loop_id == FC_NO_LOOP_ID) {
320 __func__, fcport->port_name);
324 sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL);
328 qla2x00_set_fcport_disc_state(fcport, DSC_LOGIN_PEND);
329 fcport->flags |= FCF_ASYNC_SENT;
330 fcport->logout_completed = 0;
334 sp->gen1 = fcport->rscn_gen;
335 sp->gen2 = fcport->login_gen;
342 if (N2N_TOPO(fcport->vha->hw) && fcport_is_bigger(fcport))
347 if (NVME_TARGET(vha->hw, fcport))
352 "retries=%d.\n", fcport->port_name, sp->handle, fcport->loop_id,
353 fcport->d_id.b.domain, fcport->d_id.b.area, fcport->d_id.b.al_pa,
354 fcport->login_retry);
358 fcport->flags |= FCF_LOGIN_NEEDED;
367 fcport->flags &= ~FCF_ASYNC_SENT;
369 fcport->flags &= ~FCF_ASYNC_ACTIVE;
375 sp->fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE);
376 sp->fcport->login_gen++;
377 qlt_logo_completion_handler(sp->fcport, res);
382 qla2x00_async_logout(struct scsi_qla_host *vha, fc_port_t *fcport)
388 fcport->flags |= FCF_ASYNC_SENT;
389 sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL);
404 sp->handle, fcport->loop_id, fcport->d_id.b.domain,
405 fcport->d_id.b.area, fcport->d_id.b.al_pa,
406 fcport->port_name);
416 fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE);
421 qla2x00_async_prlo_done(struct scsi_qla_host *vha, fc_port_t *fcport,
424 fcport->flags &= ~FCF_ASYNC_ACTIVE;
426 if (!fcport->tgt_session)
427 qla2x00_mark_device_lost(vha, fcport, 1);
428 qlt_logo_completion_handler(fcport, data[0]);
436 sp->fcport->flags &= ~FCF_ASYNC_ACTIVE;
438 qla2x00_post_async_prlo_done_work(sp->fcport->vha, sp->fcport,
444 qla2x00_async_prlo(struct scsi_qla_host *vha, fc_port_t *fcport)
451 sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL);
466 sp->handle, fcport->loop_id, fcport->d_id.b.domain,
467 fcport->d_id.b.area, fcport->d_id.b.al_pa);
478 fcport->flags &= ~FCF_ASYNC_ACTIVE;
485 struct fc_port *fcport = ea->fcport;
490 __func__, fcport->port_name, fcport->disc_state,
491 fcport->fw_login_state, ea->rc, fcport->login_gen, ea->sp->gen2,
492 fcport->rscn_gen, ea->sp->gen1, fcport->loop_id);
500 __func__, ea->fcport->port_name);
504 if (fcport->deleted == QLA_SESS_DELETED)
505 fcport->deleted = 0;
507 fcport->logout_on_delete = 1;
510 qlt_schedule_sess_for_deletion(ea->fcport);
514 if (ea->fcport->disc_state == DSC_DELETE_PEND)
517 if (ea->sp->gen2 != ea->fcport->login_gen) {
521 __func__, ea->fcport->port_name);
523 } else if (ea->sp->gen1 != ea->fcport->rscn_gen) {
524 qla_rscn_replay(fcport);
525 qlt_schedule_sess_for_deletion(fcport);
532 static int qla_post_els_plogi_work(struct scsi_qla_host *vha, fc_port_t *fcport)
540 e->u.fcport.fcport = fcport;
541 fcport->flags |= FCF_ASYNC_ACTIVE;
542 qla2x00_set_fcport_disc_state(fcport, DSC_LOGIN_PEND);
554 sp->name, res, sp->fcport->port_name);
556 sp->fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE);
564 ea.fcport = sp->fcport;
573 qla2x00_async_adisc(struct scsi_qla_host *vha, fc_port_t *fcport,
580 if (IS_SESSION_DELETED(fcport)) {
583 __func__, fcport->port_name);
584 fcport->flags &= ~FCF_ASYNC_ACTIVE;
588 if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT))
591 fcport->flags |= FCF_ASYNC_SENT;
592 sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL);
601 sp->gen1 = fcport->rscn_gen;
602 sp->gen2 = fcport->login_gen;
611 sp->handle, fcport->loop_id, fcport->d_id.b24, fcport->port_name);
622 fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE);
623 qla2x00_post_async_adisc_work(vha, fcport, data);
681 void qla2x00_clear_loop_id(fc_port_t *fcport)
683 struct qla_hw_data *ha = fcport->vha->hw;
685 if (fcport->loop_id == FC_NO_LOOP_ID ||
686 qla2x00_is_reserved_id(fcport->vha, fcport->loop_id))
689 clear_bit(fcport->loop_id, ha->loop_id_map);
690 fcport->loop_id = FC_NO_LOOP_ID;
696 fc_port_t *fcport, *conflict_fcport;
704 fcport = ea->fcport;
707 __func__, fcport->port_name, fcport->disc_state,
708 fcport->fw_login_state, ea->rc,
709 fcport->login_gen, fcport->last_login_gen,
710 fcport->rscn_gen, fcport->last_rscn_gen, vha->loop_id);
712 if (fcport->disc_state == DSC_DELETE_PEND)
716 if (fcport->login_retry == 0) {
719 fcport->port_name, fcport->login_retry);
724 if (fcport->last_rscn_gen != fcport->rscn_gen) {
725 qla_rscn_replay(fcport);
726 qlt_schedule_sess_for_deletion(fcport);
728 } else if (fcport->last_login_gen != fcport->login_gen) {
731 __func__, fcport->port_name);
739 __func__, __LINE__, fcport->port_name, n,
740 fcport->d_id.b.domain, fcport->d_id.b.area,
741 fcport->d_id.b.al_pa, fcport->loop_id);
751 if (memcmp((u8 *)&wwn, fcport->port_name, WWN_SIZE))
766 fcport->fc4_type &= ~FS_FC4TYPE_FCP;
767 fcport->fc4_type |= FS_FC4TYPE_NVME;
769 fcport->fc4_type |= FS_FC4TYPE_FCP;
770 fcport->fc4_type &= ~FS_FC4TYPE_NVME;
775 __func__, fcport->port_name,
776 e->current_login_state, fcport->fw_login_state,
777 fcport->fc4_type, id.b24, fcport->d_id.b24,
778 loop_id, fcport->loop_id);
780 switch (fcport->disc_state) {
785 if ((id.b24 != fcport->d_id.b24 &&
786 fcport->d_id.b24 &&
787 fcport->loop_id != FC_NO_LOOP_ID) ||
788 (fcport->loop_id != FC_NO_LOOP_ID &&
789 fcport->loop_id != loop_id)) {
792 __func__, __LINE__, fcport->port_name);
793 if (fcport->n2n_flag)
794 fcport->d_id.b24 = 0;
795 qlt_schedule_sess_for_deletion(fcport);
801 fcport->loop_id = loop_id;
802 if (fcport->n2n_flag)
803 fcport->d_id.b24 = id.b24;
805 wwn = wwn_to_u64(fcport->port_name);
811 * Another share fcport share the same loop_id &
812 * nport id. Conflict fcport needs to finish
813 * cleanup before this fcport can proceed to login.
815 conflict_fcport->conflict = fcport;
816 fcport->login_pause = 1;
825 __func__, __LINE__, fcport->port_name);
828 fcport->port_type = FCT_INITIATOR;
830 fcport->port_type = FCT_TARGET;
832 qla2x00_post_async_adisc_work(vha, fcport,
837 if (fcport->loop_id == FC_NO_LOOP_ID) {
838 qla2x00_find_new_loop_id(vha, fcport);
839 fcport->fw_login_state =
844 fcport->port_name);
845 qla24xx_fcport_handle_login(vha, fcport);
850 fcport->fw_login_state = current_login_state;
851 fcport->d_id = id;
860 qla2x00_set_fcport_disc_state(fcport,
865 fcport->port_type = FCT_INITIATOR;
867 fcport->port_type = FCT_TARGET;
870 qla2x00_post_async_adisc_work(vha, fcport,
874 if (fcport_is_bigger(fcport)) {
876 if (fcport->loop_id != FC_NO_LOOP_ID)
877 qla2x00_clear_loop_id(fcport);
879 fcport->loop_id = loop_id;
881 fcport);
886 if (fcport_is_smaller(fcport)) {
888 if (fcport->loop_id != FC_NO_LOOP_ID)
889 qla2x00_clear_loop_id(fcport);
891 fcport->loop_id = loop_id;
893 fcport);
913 if (fcport->d_id.b24 == id.b24) {
929 * another fcport
931 if (fcport->loop_id == loop_id)
932 fcport->loop_id = FC_NO_LOOP_ID;
934 qla24xx_fcport_handle_login(vha, fcport);
937 qla2x00_set_fcport_disc_state(fcport, DSC_DELETED);
938 if (time_after_eq(jiffies, fcport->dm_login_expire)) {
939 if (fcport->n2n_link_reset_cnt < 2) {
940 fcport->n2n_link_reset_cnt++;
949 if (fcport->n2n_chip_reset < 1) {
954 fcport->n2n_chip_reset++;
958 fcport->port_name);
959 fcport->scan_state = 0;
972 qla24xx_fcport_handle_login(vha, fcport);
984 struct fc_port *fcport = NULL, *tf;
998 sp->fcport->flags &= ~(FCF_ASYNC_SENT|FCF_ASYNC_ACTIVE);
1028 fcport = tf = NULL;
1033 list_for_each_entry_safe(fcport, tf, &h, gnl_entry) {
1035 list_del_init(&fcport->gnl_entry);
1036 fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE);
1038 ea.fcport = fcport;
1043 /* create new fcport if fw has knowledge of new sessions */
1052 list_for_each_entry_safe(fcport, tf, &vha->vp_fcports, list) {
1053 if (!memcmp((u8 *)&wwn, fcport->port_name,
1079 list_for_each_entry_safe(fcport, tf, &vha->gnl.fcports,
1081 list_del_init(&fcport->gnl_entry);
1082 fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE);
1083 if (qla24xx_post_gnl_work(vha, fcport) == QLA_SUCCESS)
1092 int qla24xx_async_gnl(struct scsi_qla_host *vha, fc_port_t *fcport)
1100 if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT))
1104 "Async-gnlist WWPN %8phC \n", fcport->port_name);
1107 fcport->flags |= FCF_ASYNC_SENT;
1108 qla2x00_set_fcport_disc_state(fcport, DSC_GNL);
1109 fcport->last_rscn_gen = fcport->rscn_gen;
1110 fcport->last_login_gen = fcport->login_gen;
1112 list_add_tail(&fcport->gnl_entry, &vha->gnl.fcports);
1120 sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL);
1126 sp->gen1 = fcport->rscn_gen;
1127 sp->gen2 = fcport->login_gen;
1147 sp->name, fcport->port_name, sp->handle);
1158 fcport->flags &= ~(FCF_ASYNC_ACTIVE | FCF_ASYNC_SENT);
1162 int qla24xx_post_gnl_work(struct scsi_qla_host *vha, fc_port_t *fcport)
1170 e->u.fcport.fcport = fcport;
1171 fcport->flags |= FCF_ASYNC_ACTIVE;
1179 fc_port_t *fcport = sp->fcport;
1185 sp->name, res, fcport->port_name, mb[1], mb[2]);
1187 fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE);
1193 ea.fcport = fcport;
1205 static int qla24xx_post_prli_work(struct scsi_qla_host *vha, fc_port_t *fcport)
1216 e->u.fcport.fcport = fcport;
1229 sp->fcport->port_name, res);
1231 sp->fcport->flags &= ~FCF_ASYNC_SENT;
1235 ea.fcport = sp->fcport;
1249 qla24xx_async_prli(struct scsi_qla_host *vha, fc_port_t *fcport)
1257 __func__, __LINE__, fcport->port_name);
1261 if ((fcport->fw_login_state == DSC_LS_PLOGI_PEND ||
1262 fcport->fw_login_state == DSC_LS_PRLI_PEND) &&
1265 __func__, __LINE__, fcport->port_name);
1269 sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL);
1273 fcport->flags |= FCF_ASYNC_SENT;
1274 fcport->logout_completed = 0;
1286 if (NVME_TARGET(vha->hw, fcport))
1291 fcport->port_name, sp->handle, fcport->loop_id, fcport->d_id.b24,
1292 fcport->login_retry, fcport->fc4_type, vha->hw->fc4_type_priority,
1293 NVME_TARGET(vha->hw, fcport) ? "nvme" : "fcp");
1297 fcport->flags |= FCF_LOGIN_NEEDED;
1306 fcport->flags &= ~FCF_ASYNC_SENT;
1310 int qla24xx_post_gpdb_work(struct scsi_qla_host *vha, fc_port_t *fcport, u8 opt)
1318 e->u.fcport.fcport = fcport;
1319 e->u.fcport.opt = opt;
1320 fcport->flags |= FCF_ASYNC_ACTIVE;
1324 int qla24xx_async_gpdb(struct scsi_qla_host *vha, fc_port_t *fcport, u8 opt)
1334 if (IS_SESSION_DELETED(fcport)) {
1337 __func__, fcport->port_name);
1338 fcport->flags &= ~FCF_ASYNC_ACTIVE;
1342 if (!vha->flags.online || fcport->flags & FCF_ASYNC_SENT) {
1345 __func__, fcport->port_name, vha->flags.online, fcport->flags);
1349 sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL);
1353 qla2x00_set_fcport_disc_state(fcport, DSC_GPDB);
1355 fcport->flags |= FCF_ASYNC_SENT;
1358 sp->gen1 = fcport->rscn_gen;
1359 sp->gen2 = fcport->login_gen;
1374 mb[1] = fcport->loop_id;
1389 sp->name, fcport->port_name, sp->handle, opt);
1401 fcport->flags &= ~FCF_ASYNC_SENT;
1403 fcport->flags &= ~FCF_ASYNC_ACTIVE;
1404 qla24xx_post_gpdb_work(vha, fcport, opt);
1414 ea->fcport->login_gen++;
1415 ea->fcport->logout_on_delete = 1;
1417 if (!ea->fcport->login_succ && !IS_SW_RESV_ADDR(ea->fcport->d_id)) {
1419 ea->fcport->login_succ = 1;
1422 qla24xx_sched_upd_fcport(ea->fcport);
1424 } else if (ea->fcport->login_succ) {
1432 __func__, __LINE__, ea->fcport->port_name);
1433 qla2x00_set_fcport_disc_state(ea->fcport, DSC_LOGIN_COMPLETE);
1441 fc_port_t *fcport = ea->fcport;
1448 fcport->flags &= ~FCF_ASYNC_SENT;
1452 fcport->port_name, fcport->disc_state, pd->current_login_state,
1453 fcport->fc4_type, ea->rc);
1455 if (fcport->disc_state == DSC_DELETE_PEND)
1458 if (NVME_TARGET(vha->hw, fcport))
1463 if (ea->sp->gen2 != fcport->login_gen) {
1468 __func__, fcport->port_name);
1470 } else if (ea->sp->gen1 != fcport->rscn_gen) {
1471 qla_rscn_replay(fcport);
1472 qlt_schedule_sess_for_deletion(fcport);
1478 __qla24xx_parse_gpdb(vha, fcport, pd);
1487 qla2x00_set_fcport_disc_state(fcport, DSC_GNL);
1495 __func__, __LINE__, fcport->port_name);
1496 qlt_schedule_sess_for_deletion(fcport);
1502 static void qla_chk_n2n_b4_login(struct scsi_qla_host *vha, fc_port_t *fcport)
1509 __func__, fcport->port_name, fcport->disc_state,
1510 fcport->fw_login_state, fcport->loop_id, fcport->login_retry);
1520 wwn = wwn_to_u64(fcport->port_name);
1523 else if ((fcport->fw_login_state == DSC_LS_PLOGI_COMP)
1525 fcport->plogi_nack_done_deadline))
1535 if (login && fcport->login_retry) {
1536 fcport->login_retry--;
1537 if (fcport->loop_id == FC_NO_LOOP_ID) {
1538 fcport->fw_login_state = DSC_LS_PORT_UNAVAIL;
1539 rc = qla2x00_find_new_loop_id(vha, fcport);
1543 __func__, __LINE__, fcport->port_name);
1544 fcport->scan_state = 0;
1545 qlt_schedule_sess_for_deletion(fcport);
1551 __func__, __LINE__, fcport->port_name);
1552 qla2x00_post_async_login_work(vha, fcport, NULL);
1556 int qla24xx_fcport_handle_login(struct scsi_qla_host *vha, fc_port_t *fcport)
1564 __func__, fcport->port_name, fcport->disc_state,
1565 fcport->fw_login_state, fcport->login_pause, fcport->flags,
1566 fcport->conflict, fcport->last_rscn_gen, fcport->rscn_gen,
1567 fcport->login_gen, fcport->loop_id, fcport->scan_state);
1569 if (fcport->scan_state != QLA_FCPORT_FOUND ||
1570 fcport->disc_state == DSC_DELETE_PEND)
1573 if ((fcport->loop_id != FC_NO_LOOP_ID) &&
1575 ((fcport->fw_login_state == DSC_LS_PLOGI_PEND) ||
1576 (fcport->fw_login_state == DSC_LS_PRLI_PEND)))
1579 if (fcport->fw_login_state == DSC_LS_PLOGI_COMP &&
1581 if (time_before_eq(jiffies, fcport->plogi_nack_done_deadline)) {
1591 if (fcport->flags & (FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE)) {
1596 switch (fcport->disc_state) {
1598 wwn = wwn_to_u64(fcport->node_name);
1601 if (fcport_is_smaller(fcport)) {
1603 if (fcport->login_retry) {
1604 if (fcport->loop_id == FC_NO_LOOP_ID) {
1606 fcport);
1607 fcport->fw_login_state =
1610 fcport->login_retry--;
1611 qla_post_els_plogi_work(vha, fcport);
1615 fcport->port_name);
1618 qla24xx_post_gnl_work(vha, fcport);
1625 __func__, __LINE__, fcport->port_name);
1626 qla24xx_post_gnnid_work(vha, fcport);
1627 } else if (fcport->loop_id == FC_NO_LOOP_ID) {
1630 __func__, __LINE__, fcport->port_name);
1631 qla24xx_post_gnl_work(vha, fcport);
1633 qla_chk_n2n_b4_login(vha, fcport);
1642 if ((fcport->current_login_state & 0xf) == 0x6) {
1645 __func__, __LINE__, fcport->port_name);
1646 fcport->chip_reset =
1648 qla24xx_post_gpdb_work(vha, fcport, 0);
1652 __func__, __LINE__, fcport->port_name,
1653 NVME_TARGET(vha->hw, fcport) ? "NVME" :
1655 qla24xx_post_prli_work(vha, fcport);
1659 if (fcport->login_pause) {
1663 fcport->port_name);
1664 fcport->last_rscn_gen = fcport->rscn_gen;
1665 fcport->last_login_gen = fcport->login_gen;
1669 qla_chk_n2n_b4_login(vha, fcport);
1676 qla_chk_n2n_b4_login(vha, fcport);
1678 qlt_schedule_sess_for_deletion(fcport);
1684 qla2x00_post_async_adisc_work(vha, fcport, data);
1688 if (fcport->fw_login_state == DSC_LS_PLOGI_COMP)
1689 qla24xx_post_prli_work(vha, fcport);
1694 fcport->jiffies_at_registration)/1000;
1695 if (fcport->sec_since_registration < sec && sec &&
1697 fcport->sec_since_registration = sec;
1698 ql_dbg(ql_dbg_disc, fcport->vha, 0xffff,
1700 __func__, fcport->port_name, sec);
1703 if (fcport->next_disc_state != DSC_DELETE_PEND)
1704 fcport->next_disc_state = DSC_ADISC;
1736 fc_port_t *fcport;
1741 fcport = qla2x00_find_fcport_by_nportid(vha, &ea->id, 1);
1742 if (fcport) {
1743 if (fcport->flags & FCF_FCP2_DEVICE &&
1744 atomic_read(&fcport->state) == FCS_ONLINE) {
1747 fcport->d_id.b24, fcport->port_name);
1750 fcport->scan_needed = 1;
1751 fcport->rscn_gen++;
1755 list_for_each_entry(fcport, &vha->vp_fcports, list) {
1756 if (fcport->flags & FCF_FCP2_DEVICE &&
1757 atomic_read(&fcport->state) == FCS_ONLINE)
1760 if ((ea->id.b24 & 0xffff00) == (fcport->d_id.b24 & 0xffff00)) {
1761 fcport->scan_needed = 1;
1762 fcport->rscn_gen++;
1767 list_for_each_entry(fcport, &vha->vp_fcports, list) {
1768 if (fcport->flags & FCF_FCP2_DEVICE &&
1769 atomic_read(&fcport->state) == FCS_ONLINE)
1772 if ((ea->id.b24 & 0xff0000) == (fcport->d_id.b24 & 0xff0000)) {
1773 fcport->scan_needed = 1;
1774 fcport->rscn_gen++;
1780 list_for_each_entry(fcport, &vha->vp_fcports, list) {
1781 if (fcport->flags & FCF_FCP2_DEVICE &&
1782 atomic_read(&fcport->state) == FCS_ONLINE)
1785 fcport->scan_needed = 1;
1786 fcport->rscn_gen++;
1803 fc_port_t *fcport = ea->fcport;
1810 __func__, fcport->port_name, fcport->disc_state,
1811 fcport->fw_login_state, fcport->login_pause,
1812 fcport->deleted, fcport->conflict,
1813 fcport->last_rscn_gen, fcport->rscn_gen,
1814 fcport->last_login_gen, fcport->login_gen,
1815 fcport->flags);
1817 if (fcport->last_rscn_gen != fcport->rscn_gen) {
1819 __func__, __LINE__, fcport->port_name);
1820 qla24xx_post_gnl_work(vha, fcport);
1824 qla24xx_fcport_handle_login(vha, fcport);
1836 __func__, __LINE__, ea->fcport->port_name);
1837 qla24xx_post_prli_work(vha, ea->fcport);
1841 * RSCN(s) came in for this fcport, but the RSCN(s) was not able
1842 * to be consumed by the fcport
1844 void qla_rscn_replay(fc_port_t *fcport)
1848 switch (fcport->disc_state) {
1855 if (fcport->scan_needed) {
1857 ea.id = fcport->d_id;
1859 qla2x00_handle_rscn(fcport->vha, &ea);
1895 qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t flags, uint32_t lun,
1898 struct scsi_qla_host *vha = fcport->vha;
1903 sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL);
1922 sp->handle, fcport->loop_id, fcport->d_id.b.domain,
1923 fcport->d_id.b.area, fcport->d_id.b.al_pa);
1943 fcport->loop_id, lun,
1949 fcport->flags &= ~FCF_ASYNC_SENT;
1960 fc_port_t *fcport = sp->fcport;
1962 struct scsi_qla_host *vha = fcport->vha;
1977 return qlafx00_fx_disc(vha, &vha->hw->mr.fcport,
1993 __func__, __LINE__, ea->fcport->port_name);
1995 ea->fcport->chip_reset = vha->hw->base_qpair->chip_reset;
1996 ea->fcport->logout_on_delete = 1;
1997 ea->fcport->nvme_prli_service_param = ea->iop[0];
1999 ea->fcport->nvme_first_burst_size =
2002 ea->fcport->nvme_first_burst_size = 0;
2003 qla24xx_post_gpdb_work(vha, ea->fcport, 0);
2009 ea->fcport->fw_login_state = DSC_LS_PLOGI_COMP;
2015 __func__, __LINE__, ea->fcport->port_name,
2017 "FCP" : "NVMe", ea->fcport->fc4_type);
2021 ea->fcport->fc4_type &= ~FS_FC4TYPE_NVME;
2022 ea->fcport->fc4_type |= FS_FC4TYPE_FCP;
2024 ea->fcport->fc4_type &= ~FS_FC4TYPE_FCP;
2025 ea->fcport->fc4_type |= FS_FC4TYPE_NVME;
2028 if (ea->fcport->n2n_link_reset_cnt < 3) {
2029 ea->fcport->n2n_link_reset_cnt++;
2040 ea->fcport->port_name);
2047 if (NVME_FCP_TARGET(ea->fcport)) {
2051 ea->fcport->port_name,
2052 (ea->fcport->fc4_type & FS_FC4TYPE_NVME)
2055 ea->fcport->fc4_type &= ~FS_FC4TYPE_NVME;
2057 ea->fcport->fc4_type &= ~FS_FC4TYPE_FCP;
2060 ea->fcport->flags &= ~FCF_ASYNC_SENT;
2061 ea->fcport->keep_nport_handle = 0;
2062 ea->fcport->logout_on_delete = 1;
2063 qlt_schedule_sess_for_deletion(ea->fcport);
2076 struct fc_port *fcport = ea->fcport;
2080 __func__, fcport->port_name, fcport->disc_state,
2081 fcport->fw_login_state, ea->rc, ea->sp->gen2, fcport->login_gen,
2082 ea->sp->gen1, fcport->rscn_gen,
2085 if ((fcport->fw_login_state == DSC_LS_PLOGI_PEND) ||
2086 (fcport->fw_login_state == DSC_LS_PRLI_PEND)) {
2089 __func__, __LINE__, fcport->port_name);
2093 if ((fcport->disc_state == DSC_DELETE_PEND) ||
2094 (fcport->disc_state == DSC_DELETED)) {
2099 if (ea->sp->gen2 != fcport->login_gen) {
2103 __func__, fcport->port_name);
2106 } else if (ea->sp->gen1 != fcport->rscn_gen) {
2109 __func__, fcport->port_name);
2110 qla_rscn_replay(fcport);
2111 qlt_schedule_sess_for_deletion(fcport);
2125 if (NVME_TARGET(vha->hw, ea->fcport)) {
2128 __func__, __LINE__, ea->fcport->port_name);
2129 qla24xx_post_prli_work(vha, ea->fcport);
2133 __func__, __LINE__, ea->fcport->port_name,
2134 ea->fcport->loop_id, ea->fcport->d_id.b24);
2136 set_bit(ea->fcport->loop_id, vha->hw->loop_id_map);
2138 ea->fcport->chip_reset = vha->hw->base_qpair->chip_reset;
2139 ea->fcport->logout_on_delete = 1;
2140 ea->fcport->send_els_logo = 0;
2141 ea->fcport->fw_login_state = DSC_LS_PRLI_COMP;
2144 qla24xx_post_gpdb_work(vha, ea->fcport, 0);
2149 __func__, __LINE__, ea->fcport->port_name, ea->data[1]);
2151 qlt_schedule_sess_for_deletion(ea->fcport);
2162 __func__, __LINE__, ea->fcport->port_name,
2163 ea->fcport->loop_id, cid.b24);
2165 set_bit(ea->fcport->loop_id, vha->hw->loop_id_map);
2166 ea->fcport->loop_id = FC_NO_LOOP_ID;
2167 qla24xx_post_gnl_work(vha, ea->fcport);
2172 wwn_to_u64(ea->fcport->port_name),
2173 ea->fcport->d_id, lid, &conflict_fcport);
2177 * Another fcport share the same loop_id/nport id.
2178 * Conflict fcport needs to finish cleanup before this
2179 * fcport can proceed to login.
2181 conflict_fcport->conflict = ea->fcport;
2182 ea->fcport->login_pause = 1;
2186 __func__, __LINE__, ea->fcport->port_name,
2187 ea->fcport->d_id.b24, lid);
2191 __func__, __LINE__, ea->fcport->port_name,
2192 ea->fcport->d_id.b24, lid);
2194 qla2x00_clear_loop_id(ea->fcport);
2196 ea->fcport->loop_id = lid;
2197 ea->fcport->keep_nport_handle = 0;
2198 ea->fcport->logout_on_delete = 1;
2199 qlt_schedule_sess_for_deletion(ea->fcport);
5002 fc_port_t *fcport = data;
5006 spin_lock_irqsave(fcport->vha->host->host_lock, flags);
5007 rport = fcport->drport ? fcport->drport : fcport->rport;
5008 fcport->drport = NULL;
5009 spin_unlock_irqrestore(fcport->vha->host->host_lock, flags);
5011 ql_dbg(ql_dbg_disc, fcport->vha, 0x210b,
5013 __func__, fcport->port_name, rport,
5020 void qla2x00_set_fcport_state(fc_port_t *fcport, int state)
5024 old_state = atomic_read(&fcport->state);
5025 atomic_set(&fcport->state, state);
5027 /* Don't print state transitions during initial allocation of fcport */
5029 ql_dbg(ql_dbg_disc, fcport->vha, 0x207d,
5031 fcport->port_name, port_state_str[old_state],
5032 port_state_str[state], fcport->d_id.b.domain,
5033 fcport->d_id.b.area, fcport->d_id.b.al_pa);
5038 * qla2x00_alloc_fcport() - Allocate a generic fcport.
5042 * Returns a pointer to the allocated fcport, or NULL, if none available.
5047 fc_port_t *fcport;
5049 fcport = kzalloc(sizeof(fc_port_t), flags);
5050 if (!fcport)
5053 fcport->ct_desc.ct_sns = dma_alloc_coherent(&vha->hw->pdev->dev,
5054 sizeof(struct ct_sns_pkt), &fcport->ct_desc.ct_sns_dma,
5056 if (!fcport->ct_desc.ct_sns) {
5059 kfree(fcport);
5063 /* Setup fcport template structure. */
5064 fcport->vha = vha;
5065 fcport->port_type = FCT_UNKNOWN;
5066 fcport->loop_id = FC_NO_LOOP_ID;
5067 qla2x00_set_fcport_state(fcport, FCS_UNCONFIGURED);
5068 fcport->supported_classes = FC_COS_UNSPECIFIED;
5069 fcport->fp_speed = PORT_SPEED_UNKNOWN;
5071 fcport->disc_state = DSC_DELETED;
5072 fcport->fw_login_state = DSC_LS_PORT_UNAVAIL;
5073 fcport->deleted = QLA_SESS_DELETED;
5074 fcport->login_retry = vha->hw->login_retry_count;
5075 fcport->chip_reset = vha->hw->base_qpair->chip_reset;
5076 fcport->logout_on_delete = 1;
5078 if (!fcport->ct_desc.ct_sns) {
5081 kfree(fcport);
5085 INIT_WORK(&fcport->del_work, qla24xx_delete_sess_fn);
5086 INIT_WORK(&fcport->free_work, qlt_free_session_done);
5087 INIT_WORK(&fcport->reg_work, qla_register_fcport_fn);
5088 INIT_LIST_HEAD(&fcport->gnl_entry);
5089 INIT_LIST_HEAD(&fcport->list);
5091 return fcport;
5095 qla2x00_free_fcport(fc_port_t *fcport)
5097 if (fcport->ct_desc.ct_sns) {
5098 dma_free_coherent(&fcport->vha->hw->pdev->dev,
5099 sizeof(struct ct_sns_pkt), fcport->ct_desc.ct_sns,
5100 fcport->ct_desc.ct_sns_dma);
5102 fcport->ct_desc.ct_sns = NULL;
5104 list_del(&fcport->list);
5105 qla2x00_clear_loop_id(fcport);
5106 kfree(fcport);
5261 fc_port_t *fcport;
5266 list_for_each_entry(fcport, &vha->vp_fcports, list) {
5267 if (fcport->n2n_flag) {
5268 qla24xx_fcport_handle_login(vha, fcport);
5316 fc_port_t *fcport, *new_fcport;
5371 list_for_each_entry(fcport, &vha->vp_fcports, list) {
5372 fcport->scan_state = QLA_FCPORT_SCAN;
5375 /* Allocate temporary fcport for any new fcports discovered. */
5379 "Memory allocation failed for fcport.\n");
5424 "Failed to retrieve fcport information "
5439 fcport = NULL;
5440 list_for_each_entry(fcport, &vha->vp_fcports, list) {
5441 if (memcmp(new_fcport->port_name, fcport->port_name,
5445 fcport->flags &= ~FCF_FABRIC_DEVICE;
5446 fcport->loop_id = new_fcport->loop_id;
5447 fcport->port_type = new_fcport->port_type;
5448 fcport->d_id.b24 = new_fcport->d_id.b24;
5449 memcpy(fcport->node_name, new_fcport->node_name,
5451 fcport->scan_state = QLA_FCPORT_FOUND;
5452 if (fcport->login_retry == 0) {
5453 fcport->login_retry = vha->hw->login_retry_count;
5456 fcport->port_name, fcport->loop_id,
5457 fcport->login_retry);
5467 /* Allocate a new replacement fcport. */
5468 fcport = new_fcport;
5476 "Failed to allocate memory for fcport.\n");
5487 fcport->fp_speed = ha->link_data_rate;
5492 list_for_each_entry(fcport, &vha->vp_fcports, list) {
5496 if (fcport->scan_state == QLA_FCPORT_SCAN) {
5499 atomic_read(&fcport->state) == FCS_ONLINE) {
5500 qla2x00_mark_device_lost(vha, fcport,
5502 if (fcport->loop_id != FC_NO_LOOP_ID &&
5503 (fcport->flags & FCF_FCP2_DEVICE) == 0 &&
5504 fcport->port_type != FCT_INITIATOR &&
5505 fcport->port_type != FCT_BROADCAST) {
5509 fcport->port_name);
5511 qlt_schedule_sess_for_deletion(fcport);
5517 if (fcport->scan_state == QLA_FCPORT_FOUND)
5518 qla24xx_fcport_handle_login(vha, fcport);
5532 qla2x00_iidma_fcport(scsi_qla_host_t *vha, fc_port_t *fcport)
5541 if (atomic_read(&fcport->state) != FCS_ONLINE)
5544 if (fcport->fp_speed == PORT_SPEED_UNKNOWN ||
5545 fcport->fp_speed > ha->link_data_rate ||
5549 rval = qla2x00_set_idma_speed(vha, fcport->loop_id, fcport->fp_speed,
5554 fcport->port_name, rval, fcport->fp_speed, mb[0], mb[1]);
5558 qla2x00_get_link_speed_str(ha, fcport->fp_speed),
5559 fcport->fp_speed, fcport->port_name);
5563 void qla_do_iidma_work(struct scsi_qla_host *vha, fc_port_t *fcport)
5565 qla2x00_iidma_fcport(vha, fcport);
5566 qla24xx_update_fcport_fcp_prio(vha, fcport);
5569 int qla_post_iidma_work(struct scsi_qla_host *vha, fc_port_t *fcport)
5577 e->u.fcport.fcport = fcport;
5583 qla2x00_reg_remote_port(scsi_qla_host_t *vha, fc_port_t *fcport)
5589 if (atomic_read(&fcport->state) == FCS_ONLINE)
5592 rport_ids.node_name = wwn_to_u64(fcport->node_name);
5593 rport_ids.port_name = wwn_to_u64(fcport->port_name);
5594 rport_ids.port_id = fcport->d_id.b.domain << 16 |
5595 fcport->d_id.b.area << 8 | fcport->d_id.b.al_pa;
5597 fcport->rport = rport = fc_remote_port_add(vha->host, 0, &rport_ids);
5604 spin_lock_irqsave(fcport->vha->host->host_lock, flags);
5605 *((fc_port_t **)rport->dd_data) = fcport;
5606 spin_unlock_irqrestore(fcport->vha->host->host_lock, flags);
5608 rport->supported_classes = fcport->supported_classes;
5611 if (fcport->port_type == FCT_INITIATOR)
5613 if (fcport->port_type == FCT_TARGET)
5615 if (fcport->port_type & FCT_NVME_INITIATOR)
5617 if (fcport->port_type & FCT_NVME_TARGET)
5619 if (fcport->port_type & FCT_NVME_DISCOVERY)
5624 __func__, fcport->port_name, rport,
5625 (fcport->port_type == FCT_TARGET) ? "tgt" :
5626 ((fcport->port_type & FCT_NVME) ? "nvme" : "ini"));
5637 * fcport = port structure pointer.
5647 qla2x00_update_fcport(scsi_qla_host_t *vha, fc_port_t *fcport)
5651 if (IS_SW_RESV_ADDR(fcport->d_id))
5655 __func__, fcport->port_name);
5657 qla2x00_set_fcport_disc_state(fcport, DSC_UPD_FCPORT);
5658 fcport->login_retry = vha->hw->login_retry_count;
5659 fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT);
5662 fcport->deleted = 0;
5666 fcport->logout_on_delete = 0;
5668 fcport->logout_on_delete = 1;
5669 fcport->n2n_chip_reset = fcport->n2n_link_reset_cnt = 0;
5674 fcport->keep_nport_handle = 1;
5680 qla2x00_iidma_fcport(vha, fcport);
5682 qla2x00_dfs_create_rport(vha, fcport);
5684 if (NVME_TARGET(vha->hw, fcport)) {
5685 qla_nvme_register_remote(vha, fcport);
5686 qla2x00_set_fcport_disc_state(fcport, DSC_LOGIN_COMPLETE);
5687 qla2x00_set_fcport_state(fcport, FCS_ONLINE);
5691 qla24xx_update_fcport_fcp_prio(vha, fcport);
5695 qla2x00_reg_remote_port(vha, fcport);
5700 qlt_fc_port_added(vha, fcport);
5703 qla2x00_reg_remote_port(vha, fcport);
5706 qlt_fc_port_added(vha, fcport);
5712 qla2x00_set_fcport_state(fcport, FCS_ONLINE);
5715 if (fcport->id_changed) {
5716 fcport->id_changed = 0;
5719 __func__, __LINE__, fcport->port_name,
5721 qla24xx_post_gfpnid_work(vha, fcport);
5725 __func__, __LINE__, fcport->port_name,
5727 qla24xx_post_gpsc_work(vha, fcport);
5731 qla2x00_set_fcport_disc_state(fcport, DSC_LOGIN_COMPLETE);
5736 fc_port_t *fcport = container_of(work, struct fc_port, reg_work);
5737 u32 rscn_gen = fcport->rscn_gen;
5740 if (IS_SW_RESV_ADDR(fcport->d_id))
5743 qla2x00_update_fcport(fcport->vha, fcport);
5745 if (rscn_gen != fcport->rscn_gen) {
5747 switch (fcport->next_disc_state) {
5749 qlt_schedule_sess_for_deletion(fcport);
5753 qla2x00_post_async_adisc_work(fcport->vha, fcport,
5777 fc_port_t *fcport;
5886 list_for_each_entry(fcport, &vha->vp_fcports, list)
5887 fcport->scan_state = QLA_FCPORT_SCAN;
5923 fc_port_t *fcport, *new_fcport;
5974 /* Allocate temporary fcport for any new fcports discovered. */
5978 "Failed to allocate memory for fcport.\n");
6081 list_for_each_entry(fcport, &vha->vp_fcports, list) {
6082 if (memcmp(new_fcport->port_name, fcport->port_name,
6086 fcport->scan_state = QLA_FCPORT_FOUND;
6091 memcpy(fcport->fabric_port_name,
6093 fcport->fp_speed = new_fcport->fp_speed;
6099 if (fcport->d_id.b24 == new_fcport->d_id.b24 &&
6100 (atomic_read(&fcport->state) == FCS_ONLINE ||
6108 if ((fcport->flags & FCF_FABRIC_DEVICE) == 0) {
6109 fcport->d_id.b24 = new_fcport->d_id.b24;
6110 qla2x00_clear_loop_id(fcport);
6111 fcport->flags |= (FCF_FABRIC_DEVICE |
6125 fcport->port_name,
6126 fcport->d_id.b.domain,
6127 fcport->d_id.b.area,
6128 fcport->d_id.b.al_pa,
6129 fcport->loop_id,
6133 fcport->d_id.b24 = new_fcport->d_id.b24;
6137 fcport->d_id.b24 = new_fcport->d_id.b24;
6138 fcport->flags |= FCF_LOGIN_NEEDED;
6142 if (found && NVME_TARGET(vha->hw, fcport)) {
6143 if (fcport->disc_state == DSC_DELETE_PEND) {
6144 qla2x00_set_fcport_disc_state(fcport, DSC_GNL);
6146 fcport->login_succ = 0;
6161 /* Allocate a new replacement fcport. */
6166 "Memory allocation failed for fcport.\n");
6178 list_for_each_entry(fcport, &vha->vp_fcports, list) {
6182 if ((fcport->flags & FCF_FABRIC_DEVICE) == 0)
6185 if (fcport->scan_state == QLA_FCPORT_SCAN) {
6188 atomic_read(&fcport->state) == FCS_ONLINE) {
6189 qla2x00_mark_device_lost(vha, fcport,
6191 if (fcport->loop_id != FC_NO_LOOP_ID &&
6192 (fcport->flags & FCF_FCP2_DEVICE) == 0 &&
6193 fcport->port_type != FCT_INITIATOR &&
6194 fcport->port_type != FCT_BROADCAST) {
6198 fcport->port_name);
6199 qlt_schedule_sess_for_deletion(fcport);
6205 if (fcport->scan_state == QLA_FCPORT_FOUND &&
6206 (fcport->flags & FCF_LOGIN_NEEDED) != 0)
6207 qla24xx_fcport_handle_login(vha, fcport);
6255 qla2x00_fabric_login(scsi_qla_host_t *vha, fc_port_t *fcport,
6271 fcport->loop_id, fcport->d_id.b.domain,
6272 fcport->d_id.b.area, fcport->d_id.b.al_pa);
6274 /* Login fcport on switch. */
6275 rval = ha->isp_ops->fabric_login(vha, fcport->loop_id,
6276 fcport->d_id.b.domain, fcport->d_id.b.area,
6277 fcport->d_id.b.al_pa, mb, BIT_0);
6290 tmp_loopid = fcport->loop_id;
6291 fcport->loop_id = mb[1];
6296 fcport->loop_id, fcport->d_id.b.domain,
6297 fcport->d_id.b.area, fcport->d_id.b.al_pa);
6311 *next_loopid = (fcport->loop_id + 1);
6315 fcport->port_type = FCT_INITIATOR;
6317 fcport->port_type = FCT_TARGET;
6319 fcport->flags |= FCF_FCP2_DEVICE;
6324 fcport->supported_classes |= FC_COS_CLASS2;
6326 fcport->supported_classes |= FC_COS_CLASS3;
6330 fcport->flags |=
6340 fcport->loop_id++;
6341 rval = qla2x00_find_new_loop_id(vha, fcport);
6352 *next_loopid = fcport->loop_id;
6353 ha->isp_ops->fabric_logout(vha, fcport->loop_id,
6354 fcport->d_id.b.domain, fcport->d_id.b.area,
6355 fcport->d_id.b.al_pa);
6356 qla2x00_mark_device_lost(vha, fcport, 1);
6366 "jiffies=%lx.\n", mb[0], fcport->d_id.b.domain,
6367 fcport->d_id.b.area, fcport->d_id.b.al_pa,
6368 fcport->loop_id, jiffies);
6370 *next_loopid = fcport->loop_id;
6371 ha->isp_ops->fabric_logout(vha, fcport->loop_id,
6372 fcport->d_id.b.domain, fcport->d_id.b.area,
6373 fcport->d_id.b.al_pa);
6374 qla2x00_clear_loop_id(fcport);
6375 fcport->login_retry = 0;
6399 qla2x00_local_device_login(scsi_qla_host_t *vha, fc_port_t *fcport)
6405 rval = qla2x00_login_local_device(vha, fcport, mb, BIT_0);
6510 fc_port_t *fcport;
6519 list_for_each_entry(fcport, &vha->vp_fcports, list) {
6520 if (fcport->drport &&
6521 atomic_read(&fcport->state) != FCS_UNCONFIGURED) {
6523 qla2x00_rport_del(fcport);
6889 fc_port_t *fcport;
6969 list_for_each_entry(fcport, &vha->vp_fcports, list) {
6970 fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT);
6971 fcport->scan_state = 0;
6978 list_for_each_entry(fcport, &vp->vp_fcports, list)
6979 fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT);
8958 * fcport = port structure pointer.
8968 qla24xx_get_fcp_prio(scsi_qla_host_t *vha, fc_port_t *fcport)
9006 pid2 = fcport->d_id.b24 & INVALID_PORT_ID;
9025 wwn1 = wwn_to_u64(fcport->port_name);
9061 qla24xx_update_fcport_fcp_prio(scsi_qla_host_t *vha, fc_port_t *fcport)
9067 if (fcport->port_type != FCT_TARGET ||
9068 fcport->loop_id == FC_NO_LOOP_ID)
9071 priority = qla24xx_get_fcp_prio(vha, fcport);
9076 fcport->fcp_prio = priority & 0xf;
9080 ret = qla24xx_set_fcp_prio(vha, fcport->loop_id, priority, mb);
9082 if (fcport->fcp_prio != priority)
9086 fcport->loop_id, fcport->d_id.b.domain,
9087 fcport->d_id.b.area, fcport->d_id.b.al_pa);
9088 fcport->fcp_prio = priority & 0xf;
9092 "loop_id=%d port_id=%02x%02x%02x.\n", ret, fcport->loop_id,
9093 fcport->d_id.b.domain, fcport->d_id.b.area,
9094 fcport->d_id.b.al_pa);
9115 fc_port_t *fcport;
9119 list_for_each_entry(fcport, &vha->vp_fcports, list)
9120 ret = qla24xx_update_fcport_fcp_prio(vha, fcport);