Lines Matching refs:sess
105 static int qlt_issue_task_mgmt(struct fc_port *sess, u64 lun,
121 void qlt_unreg_sess(struct fc_port *sess);
672 "%s create sess success %p", __func__, t);
673 /* create sess has an extra kref */
707 struct fc_port *sess = fcport;
724 if (!sess->se_sess) {
728 sess = qlt_create_sess(vha, fcport, false);
738 if (!kref_get_unless_zero(&sess->sess_kref)) {
740 "%s: kref_get fail sess %8phC \n",
741 __func__, sess->port_name);
749 sess->local ? "local " : "", sess->port_name, sess->loop_id);
752 "Reappeared sess %p\n", sess);
754 ha->tgt.tgt_ops->update_sess(sess, fcport->d_id,
759 if (sess && sess->local) {
763 fcport->port_name, sess->loop_id);
764 sess->local = 0;
768 ha->tgt.tgt_ops->put_sess(sess);
860 struct fc_port *sess, enum qlt_plogi_link_t link)
867 "Linking sess %p [%d] wwn %8phC with PLOGI ACK to wwn %8phC"
869 sess, link, sess->port_name,
875 switch (sess->disc_state) {
885 if (sess->plogi_link[link])
886 qlt_plogi_ack_unref(vha, sess->plogi_link[link]);
889 pla->fcport = sess;
891 sess->plogi_link[link] = pla;
948 struct fc_port *sess = container_of(work, struct fc_port,
950 struct qla_tgt *tgt = sess->tgt;
951 struct scsi_qla_host *vha = sess->vha;
957 sess->plogi_link[QLT_PLOGI_LINK_SAME_WWN];
960 "%s: se_sess %p / sess %p from port %8phC loop_id %#04x"
962 __func__, sess->se_sess, sess, sess->port_name, sess->loop_id,
963 sess->d_id.b.domain, sess->d_id.b.area, sess->d_id.b.al_pa,
964 sess->logout_on_delete, sess->keep_nport_handle,
965 sess->send_els_logo);
967 if (!IS_SW_RESV_ADDR(sess->d_id)) {
968 qla2x00_mark_device_lost(vha, sess, 0);
970 if (sess->send_els_logo) {
973 logo.id = sess->d_id;
978 sess->send_els_logo = 0;
981 if (sess->logout_on_delete && sess->loop_id != FC_NO_LOOP_ID) {
986 sess->logout_completed = 0;
987 rc = qla2x00_post_async_logout_work(vha, sess,
991 "Schedule logo failed sess %p rc %d\n",
992 sess, rc);
997 rc = qla2x00_post_async_prlo_work(vha, sess,
1001 "Schedule PRLO failed sess %p rc %d\n",
1002 sess, rc);
1006 } /* if sess->logout_on_delete */
1008 if (sess->nvme_flag & NVME_FLAG_REGISTERED &&
1009 !(sess->nvme_flag & NVME_FLAG_DELETING)) {
1010 sess->nvme_flag |= NVME_FLAG_DELETING;
1011 qla_nvme_unregister_remote_port(sess);
1016 sess->edif.authok = 0;
1020 __func__, sess->port_name);
1021 qla2x00_release_all_sadb(vha, sess);
1028 qla_edif_clear_appdata(vha, sess);
1029 qla_edif_sess_down(vha, sess);
1036 if (sess->se_sess != NULL)
1037 ha->tgt.tgt_ops->free_session(sess);
1043 while (!READ_ONCE(sess->logout_completed)) {
1046 "%s: waiting for sess %p logout\n",
1047 __func__, sess);
1062 "%s: sess %p logout completed\n", __func__, sess);
1065 if (sess->logo_ack_needed) {
1066 sess->logo_ack_needed = 0;
1067 qla24xx_async_notify_ack(vha, sess,
1068 (struct imm_ntfy_from_isp *)sess->iocb, SRB_NACK_LOGO);
1072 if (sess->se_sess) {
1073 sess->se_sess = NULL;
1074 if (tgt && !IS_SW_RESV_ADDR(sess->d_id))
1078 qla2x00_set_fcport_disc_state(sess, DSC_DELETED);
1079 sess->fw_login_state = DSC_LS_PORT_UNAVAIL;
1081 if (sess->login_succ && !IS_SW_RESV_ADDR(sess->d_id)) {
1083 sess->login_succ = 0;
1086 qla2x00_clear_loop_id(sess);
1088 if (sess->conflict) {
1089 sess->conflict->login_pause = 0;
1090 sess->conflict = NULL;
1097 sess->plogi_link[QLT_PLOGI_LINK_CONFLICT];
1100 own = sess->plogi_link[QLT_PLOGI_LINK_SAME_WWN];
1105 "se_sess %p / sess %p port %8phC is gone,"
1107 sess->se_sess, sess, sess->port_name,
1112 sess->plogi_link[QLT_PLOGI_LINK_CONFLICT] = NULL;
1115 "se_sess %p / sess %p port %8phC is gone, %s (ref=%d)\n",
1116 sess->se_sess, sess, sess->port_name,
1123 sess->fw_login_state = DSC_LS_PLOGI_PEND;
1125 sess->plogi_link[QLT_PLOGI_LINK_SAME_WWN] = NULL;
1129 sess->explicit_logout = 0;
1132 qla2x00_dfs_remove_rport(vha, sess);
1135 sess->flags &= ~FCF_ASYNC_SENT;
1136 sess->deleted = QLA_SESS_DELETED;
1137 sess->free_pending = 0;
1141 "Unregistration of sess %p %8phC finished fcp_cnt %d\n",
1142 sess, sess->port_name, vha->fcport_count);
1168 void qlt_unreg_sess(struct fc_port *sess)
1170 struct scsi_qla_host *vha = sess->vha;
1173 ql_dbg(ql_dbg_disc, sess->vha, 0x210a,
1174 "%s sess %p for deletion %8phC\n",
1175 __func__, sess, sess->port_name);
1177 spin_lock_irqsave(&sess->vha->work_lock, flags);
1178 if (sess->free_pending) {
1179 spin_unlock_irqrestore(&sess->vha->work_lock, flags);
1182 sess->free_pending = 1;
1184 * Use FCF_ASYNC_SENT flag to block other cmds used in sess
1187 sess->flags |= FCF_ASYNC_SENT;
1188 sess->deleted = QLA_SESS_DELETION_IN_PROGRESS;
1189 spin_unlock_irqrestore(&sess->vha->work_lock, flags);
1191 if (sess->se_sess)
1192 vha->hw->tgt.tgt_ops->clear_nacl_from_fcport_map(sess);
1194 qla2x00_set_fcport_disc_state(sess, DSC_DELETE_PEND);
1195 sess->last_rscn_gen = sess->rscn_gen;
1196 sess->last_login_gen = sess->login_gen;
1198 queue_work(sess->vha->hw->wq, &sess->free_work);
1205 struct fc_port *sess = NULL;
1220 sess = ha->tgt.tgt_ops->find_sess_by_loop_id(vha, loop_id);
1225 "Using sess for qla_tgt_reset: %p\n", sess);
1226 if (!sess) {
1233 "loop_id %d)\n", vha->host_no, sess, sess->port_name,
1236 return qlt_issue_task_mgmt(sess, 0, mcmd, iocb, QLA24XX_MGMT_SEND_NACK);
1239 static void qla24xx_chk_fcp_state(struct fc_port *sess)
1241 if (sess->chip_reset != sess->vha->hw->base_qpair->chip_reset) {
1242 sess->logout_on_delete = 0;
1243 sess->logo_ack_needed = 0;
1244 sess->fw_login_state = DSC_LS_PORT_UNAVAIL;
1248 void qlt_schedule_sess_for_deletion(struct fc_port *sess)
1250 struct qla_tgt *tgt = sess->tgt;
1254 switch (sess->disc_state) {
1258 if (!sess->plogi_link[QLT_PLOGI_LINK_SAME_WWN] &&
1259 !sess->plogi_link[QLT_PLOGI_LINK_CONFLICT]) {
1263 if (sess->vha->fcport_count == 0)
1264 wake_up_all(&sess->vha->fcport_waitQ);
1273 sess->next_disc_state = DSC_DELETE_PEND;
1275 sess->jiffies_at_registration)/1000;
1276 if (sess->sec_since_registration < sec && sec && !(sec % 5)) {
1277 sess->sec_since_registration = sec;
1278 ql_dbg(ql_dbg_disc, sess->vha, 0xffff,
1280 __func__, sess->port_name, sec);
1287 spin_lock_irqsave(&sess->vha->work_lock, flags);
1288 if (sess->deleted == QLA_SESS_DELETION_IN_PROGRESS) {
1289 spin_unlock_irqrestore(&sess->vha->work_lock, flags);
1292 sess->deleted = QLA_SESS_DELETION_IN_PROGRESS;
1293 spin_unlock_irqrestore(&sess->vha->work_lock, flags);
1295 sess->prli_pend_timer = 0;
1296 qla2x00_set_fcport_disc_state(sess, DSC_DELETE_PEND);
1298 qla24xx_chk_fcp_state(sess);
1300 ql_dbg(ql_log_warn, sess->vha, 0xe001,
1301 "Scheduling sess %p for deletion %8phC fc4_type %x\n",
1302 sess, sess->port_name, sess->fc4_type);
1304 WARN_ON(!queue_work(sess->vha->hw->wq, &sess->del_work));
1309 struct fc_port *sess;
1312 list_for_each_entry(sess, &vha->vp_fcports, list) {
1313 if (sess->se_sess)
1314 qlt_schedule_sess_for_deletion(sess);
1368 * Adds an extra ref to allow to drop hw lock after adding sess to the list.
1377 struct fc_port *sess = fcport;
1384 if (!kref_get_unless_zero(&sess->sess_kref)) {
1387 __func__, sess->port_name);
1392 sess->tgt = vha->vha_tgt.qla_tgt;
1393 sess->local = local;
1401 sess->logout_on_delete = 1;
1402 sess->keep_nport_handle = 0;
1403 sess->logout_completed = 0;
1406 &fcport->port_name[0], sess) < 0) {
1417 if (!kref_get_unless_zero(&sess->sess_kref)) {
1420 __func__, sess->port_name);
1425 if (!IS_SW_RESV_ADDR(sess->d_id))
1428 qlt_do_generation_tick(vha, &sess->generation);
1433 "Adding sess %p se_sess %p to tgt %p sess_count %d\n",
1434 sess, sess->se_sess, vha->vha_tgt.qla_tgt,
1441 fcport->loop_id, sess->d_id.b.domain, sess->d_id.b.area,
1442 sess->d_id.b.al_pa, sess->conf_compl_supported ? "" : "not ");
1444 return sess;
1455 struct fc_port *sess = fcport;
1469 if (!sess->se_sess) {
1474 if (max_gen - sess->generation < 0) {
1477 "Ignoring stale deletion request for se_sess %p / sess %p"
1479 sess->se_sess, sess, sess->port_name, max_gen,
1480 sess->generation);
1484 ql_dbg(ql_dbg_tgt_mgt, vha, 0xf008, "qla_tgt_fc_port_deleted %p", sess);
1486 sess->local = 1;
1488 qlt_schedule_sess_for_deletion(sess);
1541 "Waiting for sess works (tgt %p)", tgt);
2102 struct abts_recv_from_24xx *abts, struct fc_port *sess)
2122 mcmd->sess = sess;
2135 abort_cmd = ha->tgt.tgt_ops->find_cmd_by_tag(sess,
2163 struct fc_port *sess;
2196 sess = ha->tgt.tgt_ops->find_sess_by_s_id(vha, s_id);
2197 if (!sess) {
2210 if (sess->deleted) {
2216 rc = __qlt_24xx_handle_abts(vha, abts, sess);
2254 ctio->nport_handle = cpu_to_le16(mcmd->sess->loop_id);
2311 ctio->nport_handle = cpu_to_le16(cmd->sess->loop_id);
2354 struct scsi_qla_host *vha = mcmd->sess->vha;
2387 mcmd->sess->port_name, mcmd->fc_tm_rsp,
2389 qlt_schedule_sess_for_deletion(mcmd->sess);
2626 prm->cmd->sess->edif.rx_bytes += cmd->bufflen;
2628 prm->cmd->sess->edif.tx_bytes += cmd->bufflen;
3257 (cmd->sess && cmd->sess->deleted)) {
3418 (cmd->sess && cmd->sess->deleted)) {
3836 struct fc_port *sess = cmd->sess;
3851 if (!sess || !sess->se_sess) {
3972 cmd->sess) {
3973 qlt_chk_edif_rx_sa_delete_pending(vha, cmd->sess,
4019 if (logged_out && cmd->sess) {
4024 cmd->sess->send_els_logo = 1;
4026 "%s %d %8phC post del sess\n",
4027 __func__, __LINE__, cmd->sess->port_name);
4029 qlt_schedule_sess_for_deletion(cmd->sess);
4148 struct fc_port *sess = cmd->sess;
4192 ha->tgt.tgt_ops->put_sess(sess);
4209 ha->tgt.tgt_ops->put_sess(sess);
4330 struct fc_port *sess,
4335 cmd = vha->hw->tgt.tgt_ops->get_cmd(sess);
4346 cmd->sess = sess;
4347 cmd->loop_id = sess->loop_id;
4348 cmd->conf_compl_supported = sess->conf_compl_supported;
4358 cmd->edif = sess->edif.enable;
4369 struct fc_port *sess;
4384 sess = ha->tgt.tgt_ops->find_sess_by_s_id(vha, atio->u.isp24.fcp_hdr.s_id);
4385 if (unlikely(!sess))
4390 if (sess->deleted) {
4393 sess);
4400 if (!kref_get_unless_zero(&sess->sess_kref)) {
4403 __func__, sess->port_name,
4408 cmd = qlt_get_tag(vha, sess, atio);
4412 ha->tgt.tgt_ops->put_sess(sess);
4440 static int qlt_issue_task_mgmt(struct fc_port *sess, u64 lun,
4443 struct scsi_qla_host *vha = sess->vha;
4458 mcmd->sess = sess;
4505 struct fc_port *sess;
4513 sess = ha->tgt.tgt_ops->find_sess_by_s_id(vha,
4520 if (sess == NULL || sess->deleted)
4523 return qlt_issue_task_mgmt(sess, unpacked_lun, fn, iocb, 0);
4528 struct imm_ntfy_from_isp *iocb, struct fc_port *sess)
4545 mcmd->sess = sess;
4573 struct fc_port *sess;
4580 sess = ha->tgt.tgt_ops->find_sess_by_loop_id(vha, loop_id);
4583 if (sess == NULL) {
4591 return __qlt_abort_task(vha, iocb, sess);
4598 "%s: se_sess %p / sess %p from"
4623 struct fc_port *sess = NULL, *other_sess;
4633 WARN_ON(sess);
4634 sess = other_sess;
4638 /* find other sess with nport_id collision */
4642 "Invalidating sess %p loop_id %d wwn %llx.\n",
4658 "Invalidating sess %p loop_id %d wwn %llx.\n",
4669 /* find other sess with nport handle collision */
4673 "Invalidating sess %p loop_id %d wwn %llx.\n",
4682 return sess;
4724 struct fc_port *sess = NULL, *conflict_sess = NULL;
4748 sess = qlt_find_sess_invalidate_other(vha, wwn,
4808 if (!sess) {
4811 "%s %d %8phC post new sess\n",
4826 if (sess->disc_state == DSC_UPD_FCPORT) {
4834 sess->next_disc_state = DSC_DELETE_PEND;
4836 sess->jiffies_at_registration) / 1000;
4837 if (sess->sec_since_registration < sec && sec &&
4839 sess->sec_since_registration = sec;
4842 __func__, sess->port_name, sec);
4854 qlt_plogi_ack_link(vha, pla, sess, QLT_PLOGI_LINK_SAME_WWN);
4855 sess->d_id = port_id;
4856 sess->login_gen++;
4857 sess->loop_id = loop_id;
4861 if (N2N_TOPO(vha->hw) && fcport_is_bigger(sess))
4862 vha->d_id = sess->d_id;
4866 __func__, sess->port_name);
4869 sess->d_id.b24);
4873 sess->fw_login_state = DSC_LS_PRLI_PEND;
4874 sess->local = 0;
4875 sess->loop_id = loop_id;
4876 sess->d_id = port_id;
4877 sess->fw_login_state = DSC_LS_PRLI_PEND;
4881 sess->conf_compl_supported = 1;
4884 sess->port_type = FCT_INITIATOR;
4886 sess->port_type = FCT_TARGET;
4889 sess->fw_login_state = DSC_LS_PLOGI_PEND;
4894 __func__, __LINE__, sess->port_name, sess->disc_state);
4896 switch (sess->disc_state) {
4921 sess->keep_nport_handle = ((sess->loop_id == loop_id) &&
4922 (sess->d_id.b24 == port_id.b24));
4925 "%s %d %8phC post del sess\n",
4926 __func__, __LINE__, sess->port_name);
4929 qlt_schedule_sess_for_deletion(sess);
4944 struct fc_port *sess = NULL, *conflict_sess = NULL;
4980 sess = qla2x00_find_fcport_by_wwpn(vha,
4983 if (vha->hw->flags.edif_enabled && sess &&
4984 (!(sess->flags & FCF_FCSP_DEVICE) ||
4985 !sess->edif.authok)) {
4993 if (sess && sess->plogi_link[QLT_PLOGI_LINK_SAME_WWN]) {
5015 sess = qlt_find_sess_invalidate_other(vha, wwn, port_id,
5027 "PRLI with conflicting sess %p port %8phC\n",
5037 if (sess != NULL) {
5041 if (vha->hw->flags.edif_enabled && sess &&
5042 (!(sess->flags & FCF_FCSP_DEVICE) ||
5043 !sess->edif.authok)) {
5052 switch (sess->fw_login_state) {
5062 switch (sess->disc_state) {
5068 sess->jiffies_at_registration)/1000;
5069 if (sess->sec_since_registration < sec && sec &&
5071 sess->sec_since_registration = sec;
5072 ql_dbg(ql_dbg_disc, sess->vha, 0xffff,
5074 __func__, sess->port_name, sec);
5097 ql_log(ql_log_warn, sess->vha, 0xf095,
5098 "sess %p PRLI received, before plogi ack.\n",
5099 sess);
5110 "PRLI (loop_id %#04x) for existing sess %p (loop_id %#04x)\n",
5111 sess->loop_id, sess, iocb->u.isp24.nport_handle);
5113 sess->local = 0;
5114 sess->loop_id = loop_id;
5115 sess->d_id = port_id;
5116 sess->fw_login_state = DSC_LS_PRLI_PEND;
5119 sess->conf_compl_supported = 1;
5122 sess->port_type = FCT_INITIATOR;
5124 sess->port_type = FCT_TARGET;
5132 if (sess) {
5135 __func__, __LINE__, sess->port_name);
5136 qla24xx_post_nack_work(vha, sess, iocb,
5145 if (sess) {
5148 __func__, __LINE__, sess->port_name);
5149 qla24xx_post_nack_work(vha, sess, iocb,
5168 sess = qla2x00_find_fcport_by_loopid(vha, loop_id);
5171 if (sess) {
5172 sess->login_gen++;
5173 sess->fw_login_state = DSC_LS_LOGO_PEND;
5174 sess->logo_ack_needed = 1;
5175 memcpy(sess->iocb, iocb, IOCB_SIZE);
5181 "%s: logo %llx res %d sess %p ",
5182 __func__, wwn, res, sess);
5186 * for LOGO_ACK & sess delete
5188 BUG_ON(!sess);
5192 if (sess) {
5193 qlt_schedule_sess_for_deletion(sess);
5210 sess = qla2x00_find_fcport_by_wwpn(vha,
5212 if (sess) {
5214 "sess %p lid %d|%d DS %d LS %d\n",
5215 sess, sess->loop_id, loop_id,
5216 sess->disc_state, sess->fw_login_state);
5385 struct fc_port *sess = NULL;
5393 sess = qla2x00_find_fcport_by_nportid(vha, &id, 1);
5395 if (!sess) {
5415 ctio24->nport_handle = cpu_to_le16(sess->loop_id);
5457 struct fc_port *sess;
5483 sess = ha->tgt.tgt_ops->find_sess_by_s_id
5485 if (!sess)
5488 cmd = ha->tgt.tgt_ops->get_cmd(sess);
6194 struct fc_port *sess = NULL;
6253 sess = qlt_create_sess(vha, fcport, true);
6257 return sess;
6265 struct fc_port *sess = NULL;
6277 sess = ha->tgt.tgt_ops->find_sess_by_s_id(vha, s_id);
6278 if (!sess) {
6281 sess = qlt_make_local_sess(vha, s_id);
6282 /* sess has got an extra creation ref */
6285 if (!sess)
6288 if (sess->deleted) {
6289 sess = NULL;
6293 if (!kref_get_unless_zero(&sess->sess_kref)) {
6296 __func__, sess->port_name);
6297 sess = NULL;
6302 rc = __qlt_24xx_handle_abts(vha, &prm->abts, sess);
6305 ha->tgt.tgt_ops->put_sess(sess);