Lines Matching refs:sess

112 static int qlt_issue_task_mgmt(struct fc_port *sess, u64 lun,
128 void qlt_unreg_sess(struct fc_port *sess);
683 "%s create sess success %p", __func__, t);
684 /* create sess has an extra kref */
713 struct fc_port *sess = fcport;
730 if (!sess->se_sess) {
734 sess = qlt_create_sess(vha, fcport, false);
744 if (!kref_get_unless_zero(&sess->sess_kref)) {
746 "%s: kref_get fail sess %8phC \n",
747 __func__, sess->port_name);
755 sess->local ? "local " : "", sess->port_name, sess->loop_id);
758 "Reappeared sess %p\n", sess);
760 ha->tgt.tgt_ops->update_sess(sess, fcport->d_id,
765 if (sess && sess->local) {
769 fcport->port_name, sess->loop_id);
770 sess->local = 0;
774 ha->tgt.tgt_ops->put_sess(sess);
866 struct fc_port *sess, enum qlt_plogi_link_t link)
873 "Linking sess %p [%d] wwn %8phC with PLOGI ACK to wwn %8phC"
875 sess, link, sess->port_name,
881 switch (sess->disc_state) {
891 if (sess->plogi_link[link])
892 qlt_plogi_ack_unref(vha, sess->plogi_link[link]);
895 pla->fcport = sess;
897 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;
977 sess->send_els_logo = 0;
980 if (sess->logout_on_delete && sess->loop_id != FC_NO_LOOP_ID) {
986 rc = qla2x00_post_async_logout_work(vha, sess,
990 "Schedule logo failed sess %p rc %d\n",
991 sess, rc);
996 rc = qla2x00_post_async_prlo_work(vha, sess,
1000 "Schedule PRLO failed sess %p rc %d\n",
1001 sess, rc);
1005 } /* if sess->logout_on_delete */
1007 if (sess->nvme_flag & NVME_FLAG_REGISTERED &&
1008 !(sess->nvme_flag & NVME_FLAG_DELETING)) {
1009 sess->nvme_flag |= NVME_FLAG_DELETING;
1010 qla_nvme_unregister_remote_port(sess);
1017 if (sess->se_sess != NULL)
1018 ha->tgt.tgt_ops->free_session(sess);
1024 while (!READ_ONCE(sess->logout_completed)) {
1027 "%s: waiting for sess %p logout\n",
1028 __func__, sess);
1038 "%s: sess %p logout completed\n", __func__, sess);
1041 if (sess->logo_ack_needed) {
1042 sess->logo_ack_needed = 0;
1043 qla24xx_async_notify_ack(vha, sess,
1044 (struct imm_ntfy_from_isp *)sess->iocb, SRB_NACK_LOGO);
1048 if (sess->se_sess) {
1049 sess->se_sess = NULL;
1050 if (tgt && !IS_SW_RESV_ADDR(sess->d_id))
1054 qla2x00_set_fcport_disc_state(sess, DSC_DELETED);
1055 sess->fw_login_state = DSC_LS_PORT_UNAVAIL;
1057 if (sess->login_succ && !IS_SW_RESV_ADDR(sess->d_id)) {
1059 sess->login_succ = 0;
1062 qla2x00_clear_loop_id(sess);
1064 if (sess->conflict) {
1065 sess->conflict->login_pause = 0;
1066 sess->conflict = NULL;
1073 sess->plogi_link[QLT_PLOGI_LINK_CONFLICT];
1076 own = sess->plogi_link[QLT_PLOGI_LINK_SAME_WWN];
1081 "se_sess %p / sess %p port %8phC is gone,"
1083 sess->se_sess, sess, sess->port_name,
1088 sess->plogi_link[QLT_PLOGI_LINK_CONFLICT] = NULL;
1091 "se_sess %p / sess %p port %8phC is gone, %s (ref=%d)\n",
1092 sess->se_sess, sess, sess->port_name,
1099 sess->fw_login_state = DSC_LS_PLOGI_PEND;
1101 sess->plogi_link[QLT_PLOGI_LINK_SAME_WWN] = NULL;
1105 sess->explicit_logout = 0;
1108 qla2x00_dfs_remove_rport(vha, sess);
1111 sess->flags &= ~FCF_ASYNC_SENT;
1112 sess->deleted = QLA_SESS_DELETED;
1113 sess->free_pending = 0;
1117 "Unregistration of sess %p %8phC finished fcp_cnt %d\n",
1118 sess, sess->port_name, vha->fcport_count);
1144 void qlt_unreg_sess(struct fc_port *sess)
1146 struct scsi_qla_host *vha = sess->vha;
1149 ql_dbg(ql_dbg_disc, sess->vha, 0x210a,
1150 "%s sess %p for deletion %8phC\n",
1151 __func__, sess, sess->port_name);
1153 spin_lock_irqsave(&sess->vha->work_lock, flags);
1154 if (sess->free_pending) {
1155 spin_unlock_irqrestore(&sess->vha->work_lock, flags);
1158 sess->free_pending = 1;
1160 * Use FCF_ASYNC_SENT flag to block other cmds used in sess
1163 sess->flags |= FCF_ASYNC_SENT;
1164 sess->deleted = QLA_SESS_DELETION_IN_PROGRESS;
1165 spin_unlock_irqrestore(&sess->vha->work_lock, flags);
1167 if (sess->se_sess)
1168 vha->hw->tgt.tgt_ops->clear_nacl_from_fcport_map(sess);
1170 qla2x00_set_fcport_disc_state(sess, DSC_DELETE_PEND);
1171 sess->last_rscn_gen = sess->rscn_gen;
1172 sess->last_login_gen = sess->login_gen;
1174 queue_work(sess->vha->hw->wq, &sess->free_work);
1181 struct fc_port *sess = NULL;
1196 sess = ha->tgt.tgt_ops->find_sess_by_loop_id(vha, loop_id);
1201 "Using sess for qla_tgt_reset: %p\n", sess);
1202 if (!sess) {
1209 "loop_id %d)\n", vha->host_no, sess, sess->port_name,
1212 return qlt_issue_task_mgmt(sess, 0, mcmd, iocb, QLA24XX_MGMT_SEND_NACK);
1215 static void qla24xx_chk_fcp_state(struct fc_port *sess)
1217 if (sess->chip_reset != sess->vha->hw->base_qpair->chip_reset) {
1218 sess->logout_on_delete = 0;
1219 sess->logo_ack_needed = 0;
1220 sess->fw_login_state = DSC_LS_PORT_UNAVAIL;
1224 void qlt_schedule_sess_for_deletion(struct fc_port *sess)
1226 struct qla_tgt *tgt = sess->tgt;
1230 switch (sess->disc_state) {
1234 if (!sess->plogi_link[QLT_PLOGI_LINK_SAME_WWN] &&
1235 !sess->plogi_link[QLT_PLOGI_LINK_CONFLICT]) {
1239 if (sess->vha->fcport_count == 0)
1240 wake_up_all(&sess->vha->fcport_waitQ);
1249 sess->next_disc_state = DSC_DELETE_PEND;
1251 sess->jiffies_at_registration)/1000;
1252 if (sess->sec_since_registration < sec && sec && !(sec % 5)) {
1253 sess->sec_since_registration = sec;
1254 ql_dbg(ql_dbg_disc, sess->vha, 0xffff,
1256 __func__, sess->port_name, sec);
1263 spin_lock_irqsave(&sess->vha->work_lock, flags);
1264 if (sess->deleted == QLA_SESS_DELETION_IN_PROGRESS) {
1265 spin_unlock_irqrestore(&sess->vha->work_lock, flags);
1268 sess->deleted = QLA_SESS_DELETION_IN_PROGRESS;
1269 spin_unlock_irqrestore(&sess->vha->work_lock, flags);
1271 sess->prli_pend_timer = 0;
1272 qla2x00_set_fcport_disc_state(sess, DSC_DELETE_PEND);
1274 qla24xx_chk_fcp_state(sess);
1276 ql_dbg(ql_dbg_disc, sess->vha, 0xe001,
1277 "Scheduling sess %p for deletion %8phC\n",
1278 sess, sess->port_name);
1280 WARN_ON(!queue_work(sess->vha->hw->wq, &sess->del_work));
1285 struct fc_port *sess;
1288 list_for_each_entry(sess, &vha->vp_fcports, list) {
1289 if (sess->se_sess)
1290 qlt_schedule_sess_for_deletion(sess);
1344 * Adds an extra ref to allow to drop hw lock after adding sess to the list.
1353 struct fc_port *sess = fcport;
1360 if (!kref_get_unless_zero(&sess->sess_kref)) {
1363 __func__, sess->port_name);
1368 sess->tgt = vha->vha_tgt.qla_tgt;
1369 sess->local = local;
1377 sess->logout_on_delete = 1;
1378 sess->keep_nport_handle = 0;
1379 sess->logout_completed = 0;
1382 &fcport->port_name[0], sess) < 0) {
1393 if (!kref_get_unless_zero(&sess->sess_kref)) {
1396 __func__, sess->port_name);
1401 if (!IS_SW_RESV_ADDR(sess->d_id))
1404 qlt_do_generation_tick(vha, &sess->generation);
1409 "Adding sess %p se_sess %p to tgt %p sess_count %d\n",
1410 sess, sess->se_sess, vha->vha_tgt.qla_tgt,
1417 fcport->loop_id, sess->d_id.b.domain, sess->d_id.b.area,
1418 sess->d_id.b.al_pa, sess->conf_compl_supported ? "" : "not ");
1420 return sess;
1431 struct fc_port *sess = fcport;
1445 if (!sess->se_sess) {
1450 if (max_gen - sess->generation < 0) {
1453 "Ignoring stale deletion request for se_sess %p / sess %p"
1455 sess->se_sess, sess, sess->port_name, max_gen,
1456 sess->generation);
1460 ql_dbg(ql_dbg_tgt_mgt, vha, 0xf008, "qla_tgt_fc_port_deleted %p", sess);
1462 sess->local = 1;
1464 qlt_schedule_sess_for_deletion(sess);
1517 "Waiting for sess works (tgt %p)", tgt);
2083 struct abts_recv_from_24xx *abts, struct fc_port *sess)
2102 mcmd->sess = sess;
2118 abort_cmd = ha->tgt.tgt_ops->find_cmd_by_tag(sess,
2141 struct fc_port *sess;
2174 sess = ha->tgt.tgt_ops->find_sess_by_s_id(vha, s_id);
2175 if (!sess) {
2188 if (sess->deleted) {
2194 rc = __qlt_24xx_handle_abts(vha, abts, sess);
2232 ctio->nport_handle = cpu_to_le16(mcmd->sess->loop_id);
2289 ctio->nport_handle = cpu_to_le16(cmd->sess->loop_id);
2332 struct scsi_qla_host *vha = mcmd->sess->vha;
2365 mcmd->sess->port_name, mcmd->fc_tm_rsp,
2367 qlt_schedule_sess_for_deletion(mcmd->sess);
3225 (cmd->sess && cmd->sess->deleted)) {
3384 (cmd->sess && cmd->sess->deleted)) {
3802 struct fc_port *sess = cmd->sess;
3819 if (!sess || !sess->se_sess) {
3981 if (logged_out && cmd->sess) {
3986 cmd->sess->send_els_logo = 1;
3988 "%s %d %8phC post del sess\n",
3989 __func__, __LINE__, cmd->sess->port_name);
3991 qlt_schedule_sess_for_deletion(cmd->sess);
4100 struct fc_port *sess = cmd->sess;
4144 ha->tgt.tgt_ops->put_sess(sess);
4161 ha->tgt.tgt_ops->put_sess(sess);
4282 struct fc_port *sess,
4287 cmd = vha->hw->tgt.tgt_ops->get_cmd(sess);
4297 cmd->sess = sess;
4298 cmd->loop_id = sess->loop_id;
4299 cmd->conf_compl_supported = sess->conf_compl_supported;
4319 struct fc_port *sess;
4334 sess = ha->tgt.tgt_ops->find_sess_by_s_id(vha, atio->u.isp24.fcp_hdr.s_id);
4335 if (unlikely(!sess))
4340 if (sess->deleted) {
4343 sess);
4350 if (!kref_get_unless_zero(&sess->sess_kref)) {
4353 __func__, sess->port_name,
4358 cmd = qlt_get_tag(vha, sess, atio);
4362 ha->tgt.tgt_ops->put_sess(sess);
4391 static int qlt_issue_task_mgmt(struct fc_port *sess, u64 lun,
4394 struct scsi_qla_host *vha = sess->vha;
4409 mcmd->sess = sess;
4456 struct fc_port *sess;
4464 sess = ha->tgt.tgt_ops->find_sess_by_s_id(vha,
4471 if (sess == NULL || sess->deleted)
4474 return qlt_issue_task_mgmt(sess, unpacked_lun, fn, iocb, 0);
4479 struct imm_ntfy_from_isp *iocb, struct fc_port *sess)
4496 mcmd->sess = sess;
4524 struct fc_port *sess;
4531 sess = ha->tgt.tgt_ops->find_sess_by_loop_id(vha, loop_id);
4534 if (sess == NULL) {
4542 return __qlt_abort_task(vha, iocb, sess);
4549 "%s: se_sess %p / sess %p from"
4574 struct fc_port *sess = NULL, *other_sess;
4584 WARN_ON(sess);
4585 sess = other_sess;
4589 /* find other sess with nport_id collision */
4593 "Invalidating sess %p loop_id %d wwn %llx.\n",
4609 "Invalidating sess %p loop_id %d wwn %llx.\n",
4620 /* find other sess with nport handle collision */
4624 "Invalidating sess %p loop_id %d wwn %llx.\n",
4633 return sess;
4684 struct fc_port *sess = NULL, *conflict_sess = NULL;
4708 sess = qlt_find_sess_invalidate_other(vha, wwn,
4740 if (!sess) {
4743 "%s %d %8phC post new sess\n",
4758 if (sess->disc_state == DSC_UPD_FCPORT) {
4766 sess->next_disc_state = DSC_DELETE_PEND;
4768 sess->jiffies_at_registration) / 1000;
4769 if (sess->sec_since_registration < sec && sec &&
4771 sess->sec_since_registration = sec;
4774 __func__, sess->port_name, sec);
4786 qlt_plogi_ack_link(vha, pla, sess, QLT_PLOGI_LINK_SAME_WWN);
4787 sess->d_id = port_id;
4788 sess->login_gen++;
4791 sess->fw_login_state = DSC_LS_PRLI_PEND;
4792 sess->local = 0;
4793 sess->loop_id = loop_id;
4794 sess->d_id = port_id;
4795 sess->fw_login_state = DSC_LS_PRLI_PEND;
4799 sess->conf_compl_supported = 1;
4802 sess->port_type = FCT_INITIATOR;
4804 sess->port_type = FCT_TARGET;
4807 sess->fw_login_state = DSC_LS_PLOGI_PEND;
4812 __func__, __LINE__, sess->port_name, sess->disc_state);
4814 switch (sess->disc_state) {
4839 sess->keep_nport_handle = ((sess->loop_id == loop_id) &&
4840 (sess->d_id.b24 == port_id.b24));
4843 "%s %d %8phC post del sess\n",
4844 __func__, __LINE__, sess->port_name);
4847 qlt_schedule_sess_for_deletion(sess);
4862 struct fc_port *sess = NULL, *conflict_sess = NULL;
4898 sess = qla2x00_find_fcport_by_wwpn(vha,
4901 if (sess && sess->plogi_link[QLT_PLOGI_LINK_SAME_WWN]) {
4923 sess = qlt_find_sess_invalidate_other(vha, wwn, port_id,
4935 "PRLI with conflicting sess %p port %8phC\n",
4945 if (sess != NULL) {
4950 switch (sess->fw_login_state) {
4960 switch (sess->disc_state) {
4966 sess->jiffies_at_registration)/1000;
4967 if (sess->sec_since_registration < sec && sec &&
4969 sess->sec_since_registration = sec;
4970 ql_dbg(ql_dbg_disc, sess->vha, 0xffff,
4972 __func__, sess->port_name, sec);
4995 ql_log(ql_log_warn, sess->vha, 0xf095,
4996 "sess %p PRLI received, before plogi ack.\n",
4997 sess);
5008 "PRLI (loop_id %#04x) for existing sess %p (loop_id %#04x)\n",
5009 sess->loop_id, sess, iocb->u.isp24.nport_handle);
5011 sess->local = 0;
5012 sess->loop_id = loop_id;
5013 sess->d_id = port_id;
5014 sess->fw_login_state = DSC_LS_PRLI_PEND;
5017 sess->conf_compl_supported = 1;
5020 sess->port_type = FCT_INITIATOR;
5022 sess->port_type = FCT_TARGET;
5030 if (sess) {
5033 __func__, __LINE__, sess->port_name);
5034 qla24xx_post_nack_work(vha, sess, iocb,
5043 if (sess) {
5046 __func__, __LINE__, sess->port_name);
5047 qla24xx_post_nack_work(vha, sess, iocb,
5066 sess = qla2x00_find_fcport_by_loopid(vha, loop_id);
5069 if (sess) {
5070 sess->login_gen++;
5071 sess->fw_login_state = DSC_LS_LOGO_PEND;
5072 sess->logo_ack_needed = 1;
5073 memcpy(sess->iocb, iocb, IOCB_SIZE);
5079 "%s: logo %llx res %d sess %p ",
5080 __func__, wwn, res, sess);
5084 * for LOGO_ACK & sess delete
5086 BUG_ON(!sess);
5090 if (sess) {
5091 qlt_schedule_sess_for_deletion(sess);
5108 sess = qla2x00_find_fcport_by_wwpn(vha,
5110 if (sess) {
5112 "sess %p lid %d|%d DS %d LS %d\n",
5113 sess, sess->loop_id, loop_id,
5114 sess->disc_state, sess->fw_login_state);
5282 struct fc_port *sess = NULL;
5290 sess = qla2x00_find_fcport_by_nportid(vha, &id, 1);
5292 if (!sess) {
5312 ctio24->nport_handle = cpu_to_le16(sess->loop_id);
5354 struct fc_port *sess;
5380 sess = ha->tgt.tgt_ops->find_sess_by_s_id
5382 if (!sess)
5385 cmd = ha->tgt.tgt_ops->get_cmd(sess);
6092 struct fc_port *sess = NULL;
6151 sess = qlt_create_sess(vha, fcport, true);
6155 return sess;
6163 struct fc_port *sess = NULL;
6175 sess = ha->tgt.tgt_ops->find_sess_by_s_id(vha, s_id);
6176 if (!sess) {
6179 sess = qlt_make_local_sess(vha, s_id);
6180 /* sess has got an extra creation ref */
6183 if (!sess)
6186 if (sess->deleted) {
6187 sess = NULL;
6191 if (!kref_get_unless_zero(&sess->sess_kref)) {
6194 __func__, sess->port_name);
6195 sess = NULL;
6200 rc = __qlt_24xx_handle_abts(vha, &prm->abts, sess);
6203 ha->tgt.tgt_ops->put_sess(sess);
6225 struct fc_port *sess;
6239 sess = ha->tgt.tgt_ops->find_sess_by_s_id(vha, s_id);
6240 if (!sess) {
6243 sess = qlt_make_local_sess(vha, s_id);
6244 /* sess has got an extra creation ref */
6247 if (!sess)
6250 if (sess->deleted) {
6254 if (!kref_get_unless_zero(&sess->sess_kref)) {
6257 __func__, sess->port_name);
6267 rc = qlt_issue_task_mgmt(sess, unpacked_lun, fn, iocb, 0);
6270 ha->tgt.tgt_ops->put_sess(sess);