Lines Matching refs:tgt
493 static int ibmvfc_set_tgt_action(struct ibmvfc_target *tgt, in ibmvfc_set_tgt_action() argument
498 switch (tgt->action) { in ibmvfc_set_tgt_action()
502 tgt->action = action; in ibmvfc_set_tgt_action()
509 tgt->action = action; in ibmvfc_set_tgt_action()
515 tgt->action = action; in ibmvfc_set_tgt_action()
521 tgt->action = action; in ibmvfc_set_tgt_action()
527 tgt->action = action; in ibmvfc_set_tgt_action()
534 tgt->action = action; in ibmvfc_set_tgt_action()
540 tgt->add_rport = 0; in ibmvfc_set_tgt_action()
655 static void ibmvfc_del_tgt(struct ibmvfc_target *tgt) in ibmvfc_del_tgt() argument
657 if (!ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_LOGOUT_RPORT)) { in ibmvfc_del_tgt()
658 tgt->job_step = ibmvfc_tgt_implicit_logout_and_del; in ibmvfc_del_tgt()
659 tgt->init_retries = 0; in ibmvfc_del_tgt()
661 wake_up(&tgt->vhost->work_wait_q); in ibmvfc_del_tgt()
673 struct ibmvfc_target *tgt; in ibmvfc_link_down() local
677 list_for_each_entry(tgt, &vhost->targets, queue) in ibmvfc_link_down()
678 ibmvfc_del_tgt(tgt); in ibmvfc_link_down()
695 struct ibmvfc_target *tgt; in ibmvfc_init_host() local
710 list_for_each_entry(tgt, &vhost->targets, queue) { in ibmvfc_init_host()
712 tgt->need_login = 1; in ibmvfc_init_host()
714 ibmvfc_del_tgt(tgt); in ibmvfc_init_host()
1219 struct ibmvfc_target *tgt; in __ibmvfc_get_target() local
1221 list_for_each_entry(tgt, &vhost->targets, queue) in __ibmvfc_get_target()
1222 if (tgt->target_id == starget->id) { in __ibmvfc_get_target()
1223 kref_get(&tgt->kref); in __ibmvfc_get_target()
1224 return tgt; in __ibmvfc_get_target()
1239 struct ibmvfc_target *tgt; in ibmvfc_get_target() local
1243 tgt = __ibmvfc_get_target(starget); in ibmvfc_get_target()
1245 return tgt; in ibmvfc_get_target()
1354 struct ibmvfc_target *tgt = container_of(kref, struct ibmvfc_target, kref); in ibmvfc_release_tgt() local
1355 kfree(tgt); in ibmvfc_release_tgt()
1367 struct ibmvfc_target *tgt = ibmvfc_get_target(starget); in ibmvfc_get_starget_node_name() local
1368 fc_starget_port_name(starget) = tgt ? tgt->ids.node_name : 0; in ibmvfc_get_starget_node_name()
1369 if (tgt) in ibmvfc_get_starget_node_name()
1370 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_get_starget_node_name()
1382 struct ibmvfc_target *tgt = ibmvfc_get_target(starget); in ibmvfc_get_starget_port_name() local
1383 fc_starget_port_name(starget) = tgt ? tgt->ids.port_name : 0; in ibmvfc_get_starget_port_name()
1384 if (tgt) in ibmvfc_get_starget_port_name()
1385 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_get_starget_port_name()
1397 struct ibmvfc_target *tgt = ibmvfc_get_target(starget); in ibmvfc_get_starget_port_id() local
1398 fc_starget_port_id(starget) = tgt ? tgt->scsi_id : -1; in ibmvfc_get_starget_port_id()
1399 if (tgt) in ibmvfc_get_starget_port_id()
1400 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_get_starget_port_id()
1799 struct ibmvfc_target *tgt; in ibmvfc_relogin() local
1803 list_for_each_entry(tgt, &vhost->targets, queue) { in ibmvfc_relogin()
1804 if (rport == tgt->rport) { in ibmvfc_relogin()
1805 ibmvfc_del_tgt(tgt); in ibmvfc_relogin()
2092 struct ibmvfc_target *tgt; in ibmvfc_bsg_plogi() local
2100 list_for_each_entry(tgt, &vhost->targets, queue) { in ibmvfc_bsg_plogi()
2101 if (tgt->scsi_id == port_id) { in ibmvfc_bsg_plogi()
3049 struct ibmvfc_target *tgt; in ibmvfc_terminate_rport_io() local
3068 list_for_each_entry(tgt, &vhost->targets, queue) { in ibmvfc_terminate_rport_io()
3069 if (tgt->scsi_id == rport->port_id) { in ibmvfc_terminate_rport_io()
3075 if (found && tgt->action == IBMVFC_TGT_ACTION_LOGOUT_DELETED_RPORT) { in ibmvfc_terminate_rport_io()
3081 ibmvfc_del_tgt(tgt); in ibmvfc_terminate_rport_io()
3161 struct ibmvfc_target *tgt; in ibmvfc_handle_async() local
3208 list_for_each_entry(tgt, &vhost->targets, queue) { in ibmvfc_handle_async()
3211 if (crq->scsi_id && cpu_to_be64(tgt->scsi_id) != crq->scsi_id) in ibmvfc_handle_async()
3213 if (crq->wwpn && cpu_to_be64(tgt->ids.port_name) != crq->wwpn) in ibmvfc_handle_async()
3215 if (crq->node_name && cpu_to_be64(tgt->ids.node_name) != crq->node_name) in ibmvfc_handle_async()
3217 if (tgt->need_login && be64_to_cpu(crq->event) == IBMVFC_AE_ELS_LOGO) in ibmvfc_handle_async()
3218 tgt->logo_rcvd = 1; in ibmvfc_handle_async()
3219 if (!tgt->need_login || be64_to_cpu(crq->event) == IBMVFC_AE_ELS_PLOGI) { in ibmvfc_handle_async()
3220 ibmvfc_del_tgt(tgt); in ibmvfc_handle_async()
3927 static void ibmvfc_init_tgt(struct ibmvfc_target *tgt, in ibmvfc_init_tgt() argument
3930 if (!ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_INIT)) in ibmvfc_init_tgt()
3931 tgt->job_step = job_step; in ibmvfc_init_tgt()
3932 wake_up(&tgt->vhost->work_wait_q); in ibmvfc_init_tgt()
3943 static int ibmvfc_retry_tgt_init(struct ibmvfc_target *tgt, in ibmvfc_retry_tgt_init() argument
3946 if (++tgt->init_retries > IBMVFC_MAX_TGT_INIT_RETRIES) { in ibmvfc_retry_tgt_init()
3947 ibmvfc_del_tgt(tgt); in ibmvfc_retry_tgt_init()
3948 wake_up(&tgt->vhost->work_wait_q); in ibmvfc_retry_tgt_init()
3951 ibmvfc_init_tgt(tgt, job_step); in ibmvfc_retry_tgt_init()
3996 struct ibmvfc_target *tgt = evt->tgt; in ibmvfc_tgt_prli_done() local
4004 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_NONE); in ibmvfc_tgt_prli_done()
4007 tgt_dbg(tgt, "Process Login succeeded: %X %02X %04X\n", in ibmvfc_tgt_prli_done()
4014 tgt->need_login = 0; in ibmvfc_tgt_prli_done()
4015 tgt->ids.roles = 0; in ibmvfc_tgt_prli_done()
4017 tgt->ids.roles |= FC_PORT_ROLE_FCP_TARGET; in ibmvfc_tgt_prli_done()
4019 tgt->ids.roles |= FC_PORT_ROLE_FCP_INITIATOR; in ibmvfc_tgt_prli_done()
4020 tgt->add_rport = 1; in ibmvfc_tgt_prli_done()
4022 ibmvfc_del_tgt(tgt); in ibmvfc_tgt_prli_done()
4024 ibmvfc_retry_tgt_init(tgt, ibmvfc_tgt_send_prli); in ibmvfc_tgt_prli_done()
4026 ibmvfc_del_tgt(tgt); in ibmvfc_tgt_prli_done()
4028 ibmvfc_del_tgt(tgt); in ibmvfc_tgt_prli_done()
4033 ibmvfc_retry_tgt_init(tgt, ibmvfc_tgt_send_prli); in ibmvfc_tgt_prli_done()
4039 level += ibmvfc_retry_tgt_init(tgt, ibmvfc_tgt_send_plogi); in ibmvfc_tgt_prli_done()
4040 else if (tgt->logo_rcvd) in ibmvfc_tgt_prli_done()
4041 level += ibmvfc_retry_tgt_init(tgt, ibmvfc_tgt_send_plogi); in ibmvfc_tgt_prli_done()
4043 level += ibmvfc_retry_tgt_init(tgt, ibmvfc_tgt_send_prli); in ibmvfc_tgt_prli_done()
4045 ibmvfc_del_tgt(tgt); in ibmvfc_tgt_prli_done()
4047 tgt_log(tgt, level, "Process Login failed: %s (%x:%x) rc=0x%02X\n", in ibmvfc_tgt_prli_done()
4053 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_tgt_prli_done()
4063 static void ibmvfc_tgt_send_prli(struct ibmvfc_target *tgt) in ibmvfc_tgt_send_prli() argument
4066 struct ibmvfc_host *vhost = tgt->vhost; in ibmvfc_tgt_send_prli()
4072 kref_get(&tgt->kref); in ibmvfc_tgt_send_prli()
4075 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_NONE); in ibmvfc_tgt_send_prli()
4076 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_tgt_send_prli()
4082 evt->tgt = tgt; in ibmvfc_tgt_send_prli()
4087 prli->target_wwpn = cpu_to_be64(tgt->wwpn); in ibmvfc_tgt_send_prli()
4093 prli->scsi_id = cpu_to_be64(tgt->scsi_id); in ibmvfc_tgt_send_prli()
4103 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_INIT_WAIT); in ibmvfc_tgt_send_prli()
4106 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_NONE); in ibmvfc_tgt_send_prli()
4107 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_tgt_send_prli()
4109 tgt_dbg(tgt, "Sent process login\n"); in ibmvfc_tgt_send_prli()
4119 struct ibmvfc_target *tgt = evt->tgt; in ibmvfc_tgt_plogi_done() local
4126 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_NONE); in ibmvfc_tgt_plogi_done()
4129 tgt_dbg(tgt, "Port Login succeeded\n"); in ibmvfc_tgt_plogi_done()
4130 if (tgt->ids.port_name && in ibmvfc_tgt_plogi_done()
4131 tgt->ids.port_name != wwn_to_u64(rsp->service_parms.port_name)) { in ibmvfc_tgt_plogi_done()
4133 tgt_dbg(tgt, "Port re-init required\n"); in ibmvfc_tgt_plogi_done()
4136 tgt->ids.node_name = wwn_to_u64(rsp->service_parms.node_name); in ibmvfc_tgt_plogi_done()
4137 tgt->ids.port_name = wwn_to_u64(rsp->service_parms.port_name); in ibmvfc_tgt_plogi_done()
4138 tgt->ids.port_id = tgt->scsi_id; in ibmvfc_tgt_plogi_done()
4139 memcpy(&tgt->service_parms, &rsp->service_parms, in ibmvfc_tgt_plogi_done()
4140 sizeof(tgt->service_parms)); in ibmvfc_tgt_plogi_done()
4141 memcpy(&tgt->service_parms_change, &rsp->service_parms_change, in ibmvfc_tgt_plogi_done()
4142 sizeof(tgt->service_parms_change)); in ibmvfc_tgt_plogi_done()
4143 ibmvfc_init_tgt(tgt, ibmvfc_tgt_send_prli); in ibmvfc_tgt_plogi_done()
4148 ibmvfc_retry_tgt_init(tgt, ibmvfc_tgt_send_plogi); in ibmvfc_tgt_plogi_done()
4153 level += ibmvfc_retry_tgt_init(tgt, ibmvfc_tgt_send_plogi); in ibmvfc_tgt_plogi_done()
4155 ibmvfc_del_tgt(tgt); in ibmvfc_tgt_plogi_done()
4157 tgt_log(tgt, level, "Port Login failed: %s (%x:%x) %s (%x) %s (%x) rc=0x%02X\n", in ibmvfc_tgt_plogi_done()
4165 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_tgt_plogi_done()
4175 static void ibmvfc_tgt_send_plogi(struct ibmvfc_target *tgt) in ibmvfc_tgt_send_plogi() argument
4178 struct ibmvfc_host *vhost = tgt->vhost; in ibmvfc_tgt_send_plogi()
4184 kref_get(&tgt->kref); in ibmvfc_tgt_send_plogi()
4185 tgt->logo_rcvd = 0; in ibmvfc_tgt_send_plogi()
4188 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_NONE); in ibmvfc_tgt_send_plogi()
4189 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_tgt_send_plogi()
4194 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_INIT_WAIT); in ibmvfc_tgt_send_plogi()
4196 evt->tgt = tgt; in ibmvfc_tgt_send_plogi()
4201 plogi->target_wwpn = cpu_to_be64(tgt->wwpn); in ibmvfc_tgt_send_plogi()
4207 plogi->scsi_id = cpu_to_be64(tgt->scsi_id); in ibmvfc_tgt_send_plogi()
4211 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_NONE); in ibmvfc_tgt_send_plogi()
4212 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_tgt_send_plogi()
4214 tgt_dbg(tgt, "Sent port login\n"); in ibmvfc_tgt_send_plogi()
4224 struct ibmvfc_target *tgt = evt->tgt; in ibmvfc_tgt_implicit_logout_done() local
4231 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_NONE); in ibmvfc_tgt_implicit_logout_done()
4235 tgt_dbg(tgt, "Implicit Logout succeeded\n"); in ibmvfc_tgt_implicit_logout_done()
4238 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_tgt_implicit_logout_done()
4243 tgt_err(tgt, "Implicit Logout failed: rc=0x%02X\n", status); in ibmvfc_tgt_implicit_logout_done()
4247 ibmvfc_init_tgt(tgt, ibmvfc_tgt_send_plogi); in ibmvfc_tgt_implicit_logout_done()
4248 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_tgt_implicit_logout_done()
4260 static struct ibmvfc_event *__ibmvfc_tgt_get_implicit_logout_evt(struct ibmvfc_target *tgt, in __ibmvfc_tgt_get_implicit_logout_evt() argument
4264 struct ibmvfc_host *vhost = tgt->vhost; in __ibmvfc_tgt_get_implicit_logout_evt()
4267 kref_get(&tgt->kref); in __ibmvfc_tgt_get_implicit_logout_evt()
4272 evt->tgt = tgt; in __ibmvfc_tgt_get_implicit_logout_evt()
4278 mad->old_scsi_id = cpu_to_be64(tgt->scsi_id); in __ibmvfc_tgt_get_implicit_logout_evt()
4287 static void ibmvfc_tgt_implicit_logout(struct ibmvfc_target *tgt) in ibmvfc_tgt_implicit_logout() argument
4289 struct ibmvfc_host *vhost = tgt->vhost; in ibmvfc_tgt_implicit_logout()
4296 evt = __ibmvfc_tgt_get_implicit_logout_evt(tgt, in ibmvfc_tgt_implicit_logout()
4300 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_NONE); in ibmvfc_tgt_implicit_logout()
4301 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_tgt_implicit_logout()
4306 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_INIT_WAIT); in ibmvfc_tgt_implicit_logout()
4309 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_NONE); in ibmvfc_tgt_implicit_logout()
4310 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_tgt_implicit_logout()
4312 tgt_dbg(tgt, "Sent Implicit Logout\n"); in ibmvfc_tgt_implicit_logout()
4322 struct ibmvfc_target *tgt = evt->tgt; in ibmvfc_tgt_implicit_logout_and_del_done() local
4338 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_DEL_RPORT); in ibmvfc_tgt_implicit_logout_and_del_done()
4340 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_DEL_AND_LOGOUT_RPORT); in ibmvfc_tgt_implicit_logout_and_del_done()
4342 tgt_dbg(tgt, "Implicit Logout %s\n", (status == IBMVFC_MAD_SUCCESS) ? "succeeded" : "failed"); in ibmvfc_tgt_implicit_logout_and_del_done()
4343 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_tgt_implicit_logout_and_del_done()
4352 static void ibmvfc_tgt_implicit_logout_and_del(struct ibmvfc_target *tgt) in ibmvfc_tgt_implicit_logout_and_del() argument
4354 struct ibmvfc_host *vhost = tgt->vhost; in ibmvfc_tgt_implicit_logout_and_del()
4358 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_DEL_RPORT); in ibmvfc_tgt_implicit_logout_and_del()
4366 evt = __ibmvfc_tgt_get_implicit_logout_evt(tgt, in ibmvfc_tgt_implicit_logout_and_del()
4369 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_LOGOUT_RPORT_WAIT); in ibmvfc_tgt_implicit_logout_and_del()
4372 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_DEL_RPORT); in ibmvfc_tgt_implicit_logout_and_del()
4373 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_tgt_implicit_logout_and_del()
4375 tgt_dbg(tgt, "Sent Implicit Logout\n"); in ibmvfc_tgt_implicit_logout_and_del()
4385 struct ibmvfc_target *tgt = evt->tgt; in ibmvfc_tgt_move_login_done() local
4392 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_NONE); in ibmvfc_tgt_move_login_done()
4395 tgt_dbg(tgt, "Move Login succeeded for new scsi_id: %llX\n", tgt->new_scsi_id); in ibmvfc_tgt_move_login_done()
4396 tgt->ids.node_name = wwn_to_u64(rsp->service_parms.node_name); in ibmvfc_tgt_move_login_done()
4397 tgt->ids.port_name = wwn_to_u64(rsp->service_parms.port_name); in ibmvfc_tgt_move_login_done()
4398 tgt->scsi_id = tgt->new_scsi_id; in ibmvfc_tgt_move_login_done()
4399 tgt->ids.port_id = tgt->scsi_id; in ibmvfc_tgt_move_login_done()
4400 memcpy(&tgt->service_parms, &rsp->service_parms, in ibmvfc_tgt_move_login_done()
4401 sizeof(tgt->service_parms)); in ibmvfc_tgt_move_login_done()
4402 memcpy(&tgt->service_parms_change, &rsp->service_parms_change, in ibmvfc_tgt_move_login_done()
4403 sizeof(tgt->service_parms_change)); in ibmvfc_tgt_move_login_done()
4404 ibmvfc_init_tgt(tgt, ibmvfc_tgt_send_prli); in ibmvfc_tgt_move_login_done()
4409 ibmvfc_retry_tgt_init(tgt, ibmvfc_tgt_move_login); in ibmvfc_tgt_move_login_done()
4413 level += ibmvfc_retry_tgt_init(tgt, ibmvfc_tgt_move_login); in ibmvfc_tgt_move_login_done()
4415 tgt_log(tgt, level, in ibmvfc_tgt_move_login_done()
4417 tgt->new_scsi_id, be32_to_cpu(rsp->flags), be16_to_cpu(rsp->vios_flags), in ibmvfc_tgt_move_login_done()
4422 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_tgt_move_login_done()
4433 static void ibmvfc_tgt_move_login(struct ibmvfc_target *tgt) in ibmvfc_tgt_move_login() argument
4435 struct ibmvfc_host *vhost = tgt->vhost; in ibmvfc_tgt_move_login()
4442 kref_get(&tgt->kref); in ibmvfc_tgt_move_login()
4445 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_DEL_RPORT); in ibmvfc_tgt_move_login()
4446 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_tgt_move_login()
4451 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_INIT_WAIT); in ibmvfc_tgt_move_login()
4453 evt->tgt = tgt; in ibmvfc_tgt_move_login()
4460 move->old_scsi_id = cpu_to_be64(tgt->scsi_id); in ibmvfc_tgt_move_login()
4461 move->new_scsi_id = cpu_to_be64(tgt->new_scsi_id); in ibmvfc_tgt_move_login()
4462 move->wwpn = cpu_to_be64(tgt->wwpn); in ibmvfc_tgt_move_login()
4463 move->node_name = cpu_to_be64(tgt->ids.node_name); in ibmvfc_tgt_move_login()
4467 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_DEL_RPORT); in ibmvfc_tgt_move_login()
4468 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_tgt_move_login()
4470 tgt_dbg(tgt, "Sent Move Login for new scsi_id: %llX\n", tgt->new_scsi_id); in ibmvfc_tgt_move_login()
4482 struct ibmvfc_target *tgt) in ibmvfc_adisc_needs_plogi() argument
4484 if (wwn_to_u64((u8 *)&mad->fc_iu.response[2]) != tgt->ids.port_name) in ibmvfc_adisc_needs_plogi()
4486 if (wwn_to_u64((u8 *)&mad->fc_iu.response[4]) != tgt->ids.node_name) in ibmvfc_adisc_needs_plogi()
4488 if (be32_to_cpu(mad->fc_iu.response[6]) != tgt->scsi_id) in ibmvfc_adisc_needs_plogi()
4500 struct ibmvfc_target *tgt = evt->tgt; in ibmvfc_tgt_adisc_done() local
4507 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_NONE); in ibmvfc_tgt_adisc_done()
4508 del_timer(&tgt->timer); in ibmvfc_tgt_adisc_done()
4512 tgt_dbg(tgt, "ADISC succeeded\n"); in ibmvfc_tgt_adisc_done()
4513 if (ibmvfc_adisc_needs_plogi(mad, tgt)) in ibmvfc_tgt_adisc_done()
4514 ibmvfc_del_tgt(tgt); in ibmvfc_tgt_adisc_done()
4520 ibmvfc_del_tgt(tgt); in ibmvfc_tgt_adisc_done()
4523 tgt_info(tgt, "ADISC failed: %s (%x:%x) %s (%x) %s (%x) rc=0x%02X\n", in ibmvfc_tgt_adisc_done()
4531 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_tgt_adisc_done()
4577 struct ibmvfc_target *tgt = evt->tgt; in ibmvfc_tgt_adisc_cancel_done() local
4579 tgt_dbg(tgt, "ADISC cancel complete\n"); in ibmvfc_tgt_adisc_cancel_done()
4582 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_tgt_adisc_cancel_done()
4596 struct ibmvfc_target *tgt = from_timer(tgt, t, timer); in ibmvfc_adisc_timeout() local
4597 struct ibmvfc_host *vhost = tgt->vhost; in ibmvfc_adisc_timeout()
4603 tgt_dbg(tgt, "ADISC timeout\n"); in ibmvfc_adisc_timeout()
4606 tgt->action != IBMVFC_TGT_ACTION_INIT_WAIT || in ibmvfc_adisc_timeout()
4614 kref_get(&tgt->kref); in ibmvfc_adisc_timeout()
4617 tgt_err(tgt, "Failed to get cancel event for ADISC.\n"); in ibmvfc_adisc_timeout()
4619 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_adisc_timeout()
4626 evt->tgt = tgt; in ibmvfc_adisc_timeout()
4631 tmf->target_wwpn = cpu_to_be64(tgt->wwpn); in ibmvfc_adisc_timeout()
4637 tmf->scsi_id = cpu_to_be64(tgt->scsi_id); in ibmvfc_adisc_timeout()
4638 tmf->cancel_key = cpu_to_be32(tgt->cancel_key); in ibmvfc_adisc_timeout()
4643 tgt_err(tgt, "Failed to send cancel event for ADISC. rc=%d\n", rc); in ibmvfc_adisc_timeout()
4645 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_adisc_timeout()
4648 tgt_dbg(tgt, "Attempting to cancel ADISC\n"); in ibmvfc_adisc_timeout()
4663 static void ibmvfc_tgt_adisc(struct ibmvfc_target *tgt) in ibmvfc_tgt_adisc() argument
4666 struct ibmvfc_host *vhost = tgt->vhost; in ibmvfc_tgt_adisc()
4672 kref_get(&tgt->kref); in ibmvfc_tgt_adisc()
4675 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_NONE); in ibmvfc_tgt_adisc()
4676 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_tgt_adisc()
4682 evt->tgt = tgt; in ibmvfc_tgt_adisc()
4687 mad->iu.scsi_id = cpu_to_be64(tgt->scsi_id); in ibmvfc_tgt_adisc()
4688 mad->iu.cancel_key = cpu_to_be32(tgt->cancel_key); in ibmvfc_tgt_adisc()
4697 if (timer_pending(&tgt->timer)) in ibmvfc_tgt_adisc()
4698 mod_timer(&tgt->timer, jiffies + (IBMVFC_ADISC_TIMEOUT * HZ)); in ibmvfc_tgt_adisc()
4700 tgt->timer.expires = jiffies + (IBMVFC_ADISC_TIMEOUT * HZ); in ibmvfc_tgt_adisc()
4701 add_timer(&tgt->timer); in ibmvfc_tgt_adisc()
4704 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_INIT_WAIT); in ibmvfc_tgt_adisc()
4707 del_timer(&tgt->timer); in ibmvfc_tgt_adisc()
4708 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_NONE); in ibmvfc_tgt_adisc()
4709 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_tgt_adisc()
4711 tgt_dbg(tgt, "Sent ADISC\n"); in ibmvfc_tgt_adisc()
4721 struct ibmvfc_target *tgt = evt->tgt; in ibmvfc_tgt_query_target_done() local
4728 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_NONE); in ibmvfc_tgt_query_target_done()
4731 tgt_dbg(tgt, "Query Target succeeded\n"); in ibmvfc_tgt_query_target_done()
4732 if (be64_to_cpu(rsp->scsi_id) != tgt->scsi_id) in ibmvfc_tgt_query_target_done()
4733 ibmvfc_del_tgt(tgt); in ibmvfc_tgt_query_target_done()
4735 ibmvfc_init_tgt(tgt, ibmvfc_tgt_adisc); in ibmvfc_tgt_query_target_done()
4740 ibmvfc_retry_tgt_init(tgt, ibmvfc_tgt_query_target); in ibmvfc_tgt_query_target_done()
4747 ibmvfc_del_tgt(tgt); in ibmvfc_tgt_query_target_done()
4749 level += ibmvfc_retry_tgt_init(tgt, ibmvfc_tgt_query_target); in ibmvfc_tgt_query_target_done()
4751 ibmvfc_del_tgt(tgt); in ibmvfc_tgt_query_target_done()
4753 tgt_log(tgt, level, "Query Target failed: %s (%x:%x) %s (%x) %s (%x) rc=0x%02X\n", in ibmvfc_tgt_query_target_done()
4762 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_tgt_query_target_done()
4772 static void ibmvfc_tgt_query_target(struct ibmvfc_target *tgt) in ibmvfc_tgt_query_target() argument
4775 struct ibmvfc_host *vhost = tgt->vhost; in ibmvfc_tgt_query_target()
4781 kref_get(&tgt->kref); in ibmvfc_tgt_query_target()
4784 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_NONE); in ibmvfc_tgt_query_target()
4785 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_tgt_query_target()
4790 evt->tgt = tgt; in ibmvfc_tgt_query_target()
4797 query_tgt->wwpn = cpu_to_be64(tgt->ids.port_name); in ibmvfc_tgt_query_target()
4799 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_INIT_WAIT); in ibmvfc_tgt_query_target()
4802 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_NONE); in ibmvfc_tgt_query_target()
4803 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_tgt_query_target()
4805 tgt_dbg(tgt, "Sent Query Target\n"); in ibmvfc_tgt_query_target()
4821 struct ibmvfc_target *tgt; in ibmvfc_alloc_target() local
4828 list_for_each_entry(tgt, &vhost->targets, queue) { in ibmvfc_alloc_target()
4829 if (tgt->wwpn == wwpn) { in ibmvfc_alloc_target()
4830 wtgt = tgt; in ibmvfc_alloc_target()
4835 list_for_each_entry(tgt, &vhost->targets, queue) { in ibmvfc_alloc_target()
4836 if (tgt->scsi_id == scsi_id) { in ibmvfc_alloc_target()
4837 stgt = tgt; in ibmvfc_alloc_target()
4875 if (tgt->need_login) in ibmvfc_alloc_target()
4876 ibmvfc_init_tgt(tgt, ibmvfc_tgt_implicit_logout); in ibmvfc_alloc_target()
4881 tgt = mempool_alloc(vhost->tgt_pool, GFP_NOIO); in ibmvfc_alloc_target()
4882 memset(tgt, 0, sizeof(*tgt)); in ibmvfc_alloc_target()
4883 tgt->scsi_id = scsi_id; in ibmvfc_alloc_target()
4884 tgt->wwpn = wwpn; in ibmvfc_alloc_target()
4885 tgt->vhost = vhost; in ibmvfc_alloc_target()
4886 tgt->need_login = 1; in ibmvfc_alloc_target()
4887 timer_setup(&tgt->timer, ibmvfc_adisc_timeout, 0); in ibmvfc_alloc_target()
4888 kref_init(&tgt->kref); in ibmvfc_alloc_target()
4889 ibmvfc_init_tgt(tgt, ibmvfc_tgt_implicit_logout); in ibmvfc_alloc_target()
4891 tgt->cancel_key = vhost->task_set++; in ibmvfc_alloc_target()
4892 list_add_tail(&tgt->queue, &vhost->targets); in ibmvfc_alloc_target()
5345 struct ibmvfc_target *tgt; in ibmvfc_dev_init_to_do() local
5347 list_for_each_entry(tgt, &vhost->targets, queue) { in ibmvfc_dev_init_to_do()
5348 if (tgt->action == IBMVFC_TGT_ACTION_INIT || in ibmvfc_dev_init_to_do()
5349 tgt->action == IBMVFC_TGT_ACTION_INIT_WAIT) in ibmvfc_dev_init_to_do()
5365 struct ibmvfc_target *tgt; in ibmvfc_dev_logo_to_do() local
5367 list_for_each_entry(tgt, &vhost->targets, queue) { in ibmvfc_dev_logo_to_do()
5368 if (tgt->action == IBMVFC_TGT_ACTION_LOGOUT_RPORT || in ibmvfc_dev_logo_to_do()
5369 tgt->action == IBMVFC_TGT_ACTION_LOGOUT_RPORT_WAIT) in ibmvfc_dev_logo_to_do()
5384 struct ibmvfc_target *tgt; in __ibmvfc_work_to_do() local
5397 list_for_each_entry(tgt, &vhost->targets, queue) in __ibmvfc_work_to_do()
5398 if (tgt->action == IBMVFC_TGT_ACTION_INIT) in __ibmvfc_work_to_do()
5400 list_for_each_entry(tgt, &vhost->targets, queue) in __ibmvfc_work_to_do()
5401 if (tgt->action == IBMVFC_TGT_ACTION_INIT_WAIT) in __ibmvfc_work_to_do()
5408 list_for_each_entry(tgt, &vhost->targets, queue) in __ibmvfc_work_to_do()
5409 if (tgt->action == IBMVFC_TGT_ACTION_LOGOUT_RPORT) in __ibmvfc_work_to_do()
5411 list_for_each_entry(tgt, &vhost->targets, queue) in __ibmvfc_work_to_do()
5412 if (tgt->action == IBMVFC_TGT_ACTION_LOGOUT_RPORT_WAIT) in __ibmvfc_work_to_do()
5469 static void ibmvfc_tgt_add_rport(struct ibmvfc_target *tgt) in ibmvfc_tgt_add_rport() argument
5471 struct ibmvfc_host *vhost = tgt->vhost; in ibmvfc_tgt_add_rport()
5475 tgt_dbg(tgt, "Adding rport\n"); in ibmvfc_tgt_add_rport()
5476 rport = fc_remote_port_add(vhost->host, 0, &tgt->ids); in ibmvfc_tgt_add_rport()
5479 if (rport && tgt->action == IBMVFC_TGT_ACTION_DEL_RPORT) { in ibmvfc_tgt_add_rport()
5480 tgt_dbg(tgt, "Deleting rport\n"); in ibmvfc_tgt_add_rport()
5481 list_del(&tgt->queue); in ibmvfc_tgt_add_rport()
5482 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_DELETED_RPORT); in ibmvfc_tgt_add_rport()
5485 del_timer_sync(&tgt->timer); in ibmvfc_tgt_add_rport()
5486 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_tgt_add_rport()
5488 } else if (rport && tgt->action == IBMVFC_TGT_ACTION_DEL_AND_LOGOUT_RPORT) { in ibmvfc_tgt_add_rport()
5489 tgt_dbg(tgt, "Deleting rport with outstanding I/O\n"); in ibmvfc_tgt_add_rport()
5490 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_LOGOUT_DELETED_RPORT); in ibmvfc_tgt_add_rport()
5491 tgt->rport = NULL; in ibmvfc_tgt_add_rport()
5492 tgt->init_retries = 0; in ibmvfc_tgt_add_rport()
5496 } else if (rport && tgt->action == IBMVFC_TGT_ACTION_DELETED_RPORT) { in ibmvfc_tgt_add_rport()
5502 tgt_dbg(tgt, "rport add succeeded\n"); in ibmvfc_tgt_add_rport()
5503 tgt->rport = rport; in ibmvfc_tgt_add_rport()
5504 rport->maxframe_size = be16_to_cpu(tgt->service_parms.common.bb_rcv_sz) & 0x0fff; in ibmvfc_tgt_add_rport()
5506 tgt->target_id = rport->scsi_target_id; in ibmvfc_tgt_add_rport()
5507 if (be32_to_cpu(tgt->service_parms.class1_parms[0]) & 0x80000000) in ibmvfc_tgt_add_rport()
5509 if (be32_to_cpu(tgt->service_parms.class2_parms[0]) & 0x80000000) in ibmvfc_tgt_add_rport()
5511 if (be32_to_cpu(tgt->service_parms.class3_parms[0]) & 0x80000000) in ibmvfc_tgt_add_rport()
5516 tgt_dbg(tgt, "rport add failed\n"); in ibmvfc_tgt_add_rport()
5527 struct ibmvfc_target *tgt; in ibmvfc_do_work() local
5601 list_for_each_entry(tgt, &vhost->targets, queue) in ibmvfc_do_work()
5602 ibmvfc_init_tgt(tgt, ibmvfc_tgt_query_target); in ibmvfc_do_work()
5606 list_for_each_entry(tgt, &vhost->targets, queue) { in ibmvfc_do_work()
5607 if (tgt->action == IBMVFC_TGT_ACTION_INIT) { in ibmvfc_do_work()
5608 tgt->job_step(tgt); in ibmvfc_do_work()
5618 list_for_each_entry(tgt, &vhost->targets, queue) { in ibmvfc_do_work()
5619 if (tgt->action == IBMVFC_TGT_ACTION_LOGOUT_RPORT) { in ibmvfc_do_work()
5620 tgt->job_step(tgt); in ibmvfc_do_work()
5630 list_for_each_entry(tgt, &vhost->targets, queue) { in ibmvfc_do_work()
5631 if (tgt->action == IBMVFC_TGT_ACTION_DEL_RPORT) { in ibmvfc_do_work()
5632 tgt_dbg(tgt, "Deleting rport\n"); in ibmvfc_do_work()
5633 rport = tgt->rport; in ibmvfc_do_work()
5634 tgt->rport = NULL; in ibmvfc_do_work()
5635 list_del(&tgt->queue); in ibmvfc_do_work()
5636 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_DELETED_RPORT); in ibmvfc_do_work()
5640 del_timer_sync(&tgt->timer); in ibmvfc_do_work()
5641 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_do_work()
5643 } else if (tgt->action == IBMVFC_TGT_ACTION_DEL_AND_LOGOUT_RPORT) { in ibmvfc_do_work()
5644 tgt_dbg(tgt, "Deleting rport with I/O outstanding\n"); in ibmvfc_do_work()
5645 rport = tgt->rport; in ibmvfc_do_work()
5646 tgt->rport = NULL; in ibmvfc_do_work()
5647 tgt->init_retries = 0; in ibmvfc_do_work()
5648 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_LOGOUT_DELETED_RPORT); in ibmvfc_do_work()
5660 tgt->move_login = 1; in ibmvfc_do_work()
5705 list_for_each_entry(tgt, &vhost->targets, queue) { in ibmvfc_do_work()
5706 if (tgt->action == IBMVFC_TGT_ACTION_INIT) { in ibmvfc_do_work()
5707 tgt->job_step(tgt); in ibmvfc_do_work()
6178 struct ibmvfc_target *tgt; in ibmvfc_rport_add_thread() local
6190 list_for_each_entry(tgt, &vhost->targets, queue) { in ibmvfc_rport_add_thread()
6191 if (tgt->add_rport) { in ibmvfc_rport_add_thread()
6193 tgt->add_rport = 0; in ibmvfc_rport_add_thread()
6194 kref_get(&tgt->kref); in ibmvfc_rport_add_thread()
6195 rport = tgt->rport; in ibmvfc_rport_add_thread()
6198 ibmvfc_tgt_add_rport(tgt); in ibmvfc_rport_add_thread()
6201 tgt_dbg(tgt, "Setting rport roles\n"); in ibmvfc_rport_add_thread()
6202 fc_remote_port_rolechg(rport, tgt->ids.roles); in ibmvfc_rport_add_thread()
6208 kref_put(&tgt->kref, ibmvfc_release_tgt); in ibmvfc_rport_add_thread()