Lines Matching full:ctrl
36 struct nvme_fc_ctrl *ctrl; member
100 struct nvme_fc_ctrl *ctrl; member
180 struct nvme_ctrl ctrl; member
184 to_fc_ctrl(struct nvme_ctrl *ctrl) in to_fc_ctrl() argument
186 return container_of(ctrl, struct nvme_fc_ctrl, ctrl); in to_fc_ctrl()
551 nvme_fc_resume_controller(struct nvme_fc_ctrl *ctrl) in nvme_fc_resume_controller() argument
553 switch (nvme_ctrl_state(&ctrl->ctrl)) { in nvme_fc_resume_controller()
560 dev_info(ctrl->ctrl.device, in nvme_fc_resume_controller()
562 "Attempting reconnect\n", ctrl->cnum); in nvme_fc_resume_controller()
564 queue_delayed_work(nvme_wq, &ctrl->connect_work, 0); in nvme_fc_resume_controller()
586 struct nvme_fc_ctrl *ctrl; in nvme_fc_attach_to_suspended_rport() local
622 list_for_each_entry(ctrl, &rport->ctrl_list, ctrl_list) in nvme_fc_attach_to_suspended_rport()
623 nvme_fc_resume_controller(ctrl); in nvme_fc_attach_to_suspended_rport()
783 nvme_fc_ctrl_connectivity_loss(struct nvme_fc_ctrl *ctrl) in nvme_fc_ctrl_connectivity_loss() argument
785 dev_info(ctrl->ctrl.device, in nvme_fc_ctrl_connectivity_loss()
787 "Reconnect", ctrl->cnum); in nvme_fc_ctrl_connectivity_loss()
789 switch (nvme_ctrl_state(&ctrl->ctrl)) { in nvme_fc_ctrl_connectivity_loss()
799 if (nvme_reset_ctrl(&ctrl->ctrl)) { in nvme_fc_ctrl_connectivity_loss()
800 dev_warn(ctrl->ctrl.device, in nvme_fc_ctrl_connectivity_loss()
802 ctrl->cnum); in nvme_fc_ctrl_connectivity_loss()
803 nvme_delete_ctrl(&ctrl->ctrl); in nvme_fc_ctrl_connectivity_loss()
849 struct nvme_fc_ctrl *ctrl; in nvme_fc_unregister_remoteport() local
865 list_for_each_entry(ctrl, &rport->ctrl_list, ctrl_list) { in nvme_fc_unregister_remoteport()
868 dev_warn(ctrl->ctrl.device, in nvme_fc_unregister_remoteport()
870 ctrl->cnum); in nvme_fc_unregister_remoteport()
871 nvme_delete_ctrl(&ctrl->ctrl); in nvme_fc_unregister_remoteport()
873 nvme_fc_ctrl_connectivity_loss(ctrl); in nvme_fc_unregister_remoteport()
1028 static void nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl, char *errmsg);
1170 nvme_fc_connect_admin_queue(struct nvme_fc_ctrl *ctrl, in nvme_fc_connect_admin_queue() argument
1182 ctrl->lport->ops->lsrqst_priv_sz), GFP_KERNEL); in nvme_fc_connect_admin_queue()
1184 dev_info(ctrl->ctrl.device, in nvme_fc_connect_admin_queue()
1186 ctrl->cnum); in nvme_fc_connect_admin_queue()
1194 if (ctrl->lport->ops->lsrqst_priv_sz) in nvme_fc_connect_admin_queue()
1213 uuid_copy(&assoc_rqst->assoc_cmd.hostid, &ctrl->ctrl.opts->host->id); in nvme_fc_connect_admin_queue()
1214 strscpy(assoc_rqst->assoc_cmd.hostnqn, ctrl->ctrl.opts->host->nqn, in nvme_fc_connect_admin_queue()
1216 strscpy(assoc_rqst->assoc_cmd.subnqn, ctrl->ctrl.opts->subsysnqn, in nvme_fc_connect_admin_queue()
1226 ret = nvme_fc_send_ls_req(ctrl->rport, lsop); in nvme_fc_connect_admin_queue()
1263 dev_err(ctrl->dev, in nvme_fc_connect_admin_queue()
1267 spin_lock_irqsave(&ctrl->lock, flags); in nvme_fc_connect_admin_queue()
1268 ctrl->association_id = in nvme_fc_connect_admin_queue()
1273 spin_unlock_irqrestore(&ctrl->lock, flags); in nvme_fc_connect_admin_queue()
1280 dev_err(ctrl->dev, in nvme_fc_connect_admin_queue()
1287 nvme_fc_connect_queue(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue, in nvme_fc_connect_queue() argument
1298 ctrl->lport->ops->lsrqst_priv_sz), GFP_KERNEL); in nvme_fc_connect_queue()
1300 dev_info(ctrl->ctrl.device, in nvme_fc_connect_queue()
1302 ctrl->cnum); in nvme_fc_connect_queue()
1310 if (ctrl->lport->ops->lsrqst_priv_sz) in nvme_fc_connect_queue()
1324 conn_rqst->associd.association_id = cpu_to_be64(ctrl->association_id); in nvme_fc_connect_queue()
1341 ret = nvme_fc_send_ls_req(ctrl->rport, lsop); in nvme_fc_connect_queue()
1369 dev_err(ctrl->dev, in nvme_fc_connect_queue()
1382 dev_err(ctrl->dev, in nvme_fc_connect_queue()
1418 nvme_fc_xmt_disconnect_assoc(struct nvme_fc_ctrl *ctrl) in nvme_fc_xmt_disconnect_assoc() argument
1428 ctrl->lport->ops->lsrqst_priv_sz), GFP_KERNEL); in nvme_fc_xmt_disconnect_assoc()
1430 dev_info(ctrl->ctrl.device, in nvme_fc_xmt_disconnect_assoc()
1433 ctrl->cnum); in nvme_fc_xmt_disconnect_assoc()
1440 if (ctrl->lport->ops->lsrqst_priv_sz) in nvme_fc_xmt_disconnect_assoc()
1446 ctrl->association_id); in nvme_fc_xmt_disconnect_assoc()
1448 ret = nvme_fc_send_ls_req_async(ctrl->rport, lsop, in nvme_fc_xmt_disconnect_assoc()
1506 struct nvme_fc_ctrl *ctrl, *ret = NULL; in nvme_fc_match_disconn_ls() local
1513 list_for_each_entry(ctrl, &rport->ctrl_list, ctrl_list) { in nvme_fc_match_disconn_ls()
1514 if (!nvme_fc_ctrl_get(ctrl)) in nvme_fc_match_disconn_ls()
1516 spin_lock(&ctrl->lock); in nvme_fc_match_disconn_ls()
1517 if (association_id == ctrl->association_id) { in nvme_fc_match_disconn_ls()
1518 oldls = ctrl->rcv_disconn; in nvme_fc_match_disconn_ls()
1519 ctrl->rcv_disconn = lsop; in nvme_fc_match_disconn_ls()
1520 ret = ctrl; in nvme_fc_match_disconn_ls()
1522 spin_unlock(&ctrl->lock); in nvme_fc_match_disconn_ls()
1524 /* leave the ctrl get reference */ in nvme_fc_match_disconn_ls()
1526 nvme_fc_ctrl_put(ctrl); in nvme_fc_match_disconn_ls()
1535 "LS's received\n", ctrl->cnum); in nvme_fc_match_disconn_ls()
1561 struct nvme_fc_ctrl *ctrl = NULL; in nvme_fc_ls_disconnect_assoc() local
1569 ctrl = nvme_fc_match_disconn_ls(rport, lsop); in nvme_fc_ls_disconnect_assoc()
1570 if (!ctrl) in nvme_fc_ls_disconnect_assoc()
1603 nvme_fc_error_recovery(ctrl, "Disconnect Association LS received"); in nvme_fc_ls_disconnect_assoc()
1606 nvme_fc_ctrl_put(ctrl); in nvme_fc_ls_disconnect_assoc()
1818 /* *********************** NVME Ctrl Routines **************************** */
1821 __nvme_fc_exit_request(struct nvme_fc_ctrl *ctrl, in __nvme_fc_exit_request() argument
1824 fc_dma_unmap_single(ctrl->lport->dev, op->fcp_req.rspdma, in __nvme_fc_exit_request()
1826 fc_dma_unmap_single(ctrl->lport->dev, op->fcp_req.cmddma, in __nvme_fc_exit_request()
1842 __nvme_fc_abort_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_fcp_op *op) in __nvme_fc_abort_op() argument
1847 spin_lock_irqsave(&ctrl->lock, flags); in __nvme_fc_abort_op()
1851 else if (test_bit(FCCTRL_TERMIO, &ctrl->flags)) { in __nvme_fc_abort_op()
1853 ctrl->iocnt++; in __nvme_fc_abort_op()
1855 spin_unlock_irqrestore(&ctrl->lock, flags); in __nvme_fc_abort_op()
1860 ctrl->lport->ops->fcp_abort(&ctrl->lport->localport, in __nvme_fc_abort_op()
1861 &ctrl->rport->remoteport, in __nvme_fc_abort_op()
1869 nvme_fc_abort_aen_ops(struct nvme_fc_ctrl *ctrl) in nvme_fc_abort_aen_ops() argument
1871 struct nvme_fc_fcp_op *aen_op = ctrl->aen_ops; in nvme_fc_abort_aen_ops()
1879 __nvme_fc_abort_op(ctrl, aen_op); in nvme_fc_abort_aen_ops()
1883 __nvme_fc_fcpop_chk_teardowns(struct nvme_fc_ctrl *ctrl, in __nvme_fc_fcpop_chk_teardowns() argument
1889 spin_lock_irqsave(&ctrl->lock, flags); in __nvme_fc_fcpop_chk_teardowns()
1890 if (test_bit(FCCTRL_TERMIO, &ctrl->flags) && in __nvme_fc_fcpop_chk_teardowns()
1892 if (!--ctrl->iocnt) in __nvme_fc_fcpop_chk_teardowns()
1893 wake_up(&ctrl->ioabort_wait); in __nvme_fc_fcpop_chk_teardowns()
1895 spin_unlock_irqrestore(&ctrl->lock, flags); in __nvme_fc_fcpop_chk_teardowns()
1902 struct nvme_fc_ctrl *ctrl = in nvme_fc_ctrl_ioerr_work() local
1905 nvme_fc_error_recovery(ctrl, "transport detected io error"); in nvme_fc_ctrl_ioerr_work()
1932 struct nvme_fc_ctrl *ctrl = op->ctrl; in nvme_fc_fcpio_done() local
1980 fc_dma_sync_single_for_cpu(ctrl->lport->dev, op->fcp_req.rspdma, in nvme_fc_fcpio_done()
1987 dev_info(ctrl->ctrl.device, in nvme_fc_fcpio_done()
1989 ctrl->cnum, freq->status); in nvme_fc_fcpio_done()
2019 dev_info(ctrl->ctrl.device, in nvme_fc_fcpio_done()
2022 ctrl->cnum, freq->transferred_length, in nvme_fc_fcpio_done()
2041 dev_info(ctrl->ctrl.device, in nvme_fc_fcpio_done()
2045 ctrl->cnum, be16_to_cpu(op->rsp_iu.iu_len), in nvme_fc_fcpio_done()
2059 dev_info(ctrl->ctrl.device, in nvme_fc_fcpio_done()
2062 ctrl->cnum, freq->rcv_rsplen); in nvme_fc_fcpio_done()
2070 nvme_complete_async_event(&queue->ctrl->ctrl, status, &result); in nvme_fc_fcpio_done()
2071 __nvme_fc_fcpop_chk_teardowns(ctrl, op, opstate); in nvme_fc_fcpio_done()
2074 nvme_fc_ctrl_put(ctrl); in nvme_fc_fcpio_done()
2078 __nvme_fc_fcpop_chk_teardowns(ctrl, op, opstate); in nvme_fc_fcpio_done()
2083 if (terminate_assoc && ctrl->ctrl.state != NVME_CTRL_RESETTING) in nvme_fc_fcpio_done()
2084 queue_work(nvme_reset_wq, &ctrl->ioerr_work); in nvme_fc_fcpio_done()
2088 __nvme_fc_init_request(struct nvme_fc_ctrl *ctrl, in __nvme_fc_init_request() argument
2103 op->ctrl = ctrl; in __nvme_fc_init_request()
2117 op->fcp_req.cmddma = fc_dma_map_single(ctrl->lport->dev, in __nvme_fc_init_request()
2119 if (fc_dma_mapping_error(ctrl->lport->dev, op->fcp_req.cmddma)) { in __nvme_fc_init_request()
2120 dev_err(ctrl->dev, in __nvme_fc_init_request()
2126 op->fcp_req.rspdma = fc_dma_map_single(ctrl->lport->dev, in __nvme_fc_init_request()
2129 if (fc_dma_mapping_error(ctrl->lport->dev, op->fcp_req.rspdma)) { in __nvme_fc_init_request()
2130 dev_err(ctrl->dev, in __nvme_fc_init_request()
2144 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(set->driver_data); in nvme_fc_init_request() local
2146 int queue_idx = (set == &ctrl->tag_set) ? hctx_idx + 1 : 0; in nvme_fc_init_request()
2147 struct nvme_fc_queue *queue = &ctrl->queues[queue_idx]; in nvme_fc_init_request()
2150 res = __nvme_fc_init_request(ctrl, queue, &op->op, rq, queue->rqcnt++); in nvme_fc_init_request()
2155 nvme_req(rq)->ctrl = &ctrl->ctrl; in nvme_fc_init_request()
2161 nvme_fc_init_aen_ops(struct nvme_fc_ctrl *ctrl) in nvme_fc_init_aen_ops() argument
2169 aen_op = ctrl->aen_ops; in nvme_fc_init_aen_ops()
2171 if (ctrl->lport->ops->fcprqst_priv_sz) { in nvme_fc_init_aen_ops()
2172 private = kzalloc(ctrl->lport->ops->fcprqst_priv_sz, in nvme_fc_init_aen_ops()
2180 ret = __nvme_fc_init_request(ctrl, &ctrl->queues[0], in nvme_fc_init_aen_ops()
2200 nvme_fc_term_aen_ops(struct nvme_fc_ctrl *ctrl) in nvme_fc_term_aen_ops() argument
2205 cancel_work_sync(&ctrl->ctrl.async_event_work); in nvme_fc_term_aen_ops()
2206 aen_op = ctrl->aen_ops; in nvme_fc_term_aen_ops()
2208 __nvme_fc_exit_request(ctrl, aen_op); in nvme_fc_term_aen_ops()
2218 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(data); in __nvme_fc_init_hctx() local
2219 struct nvme_fc_queue *queue = &ctrl->queues[qidx]; in __nvme_fc_init_hctx()
2240 nvme_fc_init_queue(struct nvme_fc_ctrl *ctrl, int idx) in nvme_fc_init_queue() argument
2244 queue = &ctrl->queues[idx]; in nvme_fc_init_queue()
2246 queue->ctrl = ctrl; in nvme_fc_init_queue()
2249 queue->dev = ctrl->dev; in nvme_fc_init_queue()
2252 queue->cmnd_capsule_len = ctrl->ctrl.ioccsz * 16; in nvme_fc_init_queue()
2294 __nvme_fc_delete_hw_queue(struct nvme_fc_ctrl *ctrl, in __nvme_fc_delete_hw_queue() argument
2297 if (ctrl->lport->ops->delete_queue) in __nvme_fc_delete_hw_queue()
2298 ctrl->lport->ops->delete_queue(&ctrl->lport->localport, qidx, in __nvme_fc_delete_hw_queue()
2304 nvme_fc_free_io_queues(struct nvme_fc_ctrl *ctrl) in nvme_fc_free_io_queues() argument
2308 for (i = 1; i < ctrl->ctrl.queue_count; i++) in nvme_fc_free_io_queues()
2309 nvme_fc_free_queue(&ctrl->queues[i]); in nvme_fc_free_io_queues()
2313 __nvme_fc_create_hw_queue(struct nvme_fc_ctrl *ctrl, in __nvme_fc_create_hw_queue() argument
2319 if (ctrl->lport->ops->create_queue) in __nvme_fc_create_hw_queue()
2320 ret = ctrl->lport->ops->create_queue(&ctrl->lport->localport, in __nvme_fc_create_hw_queue()
2327 nvme_fc_delete_hw_io_queues(struct nvme_fc_ctrl *ctrl) in nvme_fc_delete_hw_io_queues() argument
2329 struct nvme_fc_queue *queue = &ctrl->queues[ctrl->ctrl.queue_count - 1]; in nvme_fc_delete_hw_io_queues()
2332 for (i = ctrl->ctrl.queue_count - 1; i >= 1; i--, queue--) in nvme_fc_delete_hw_io_queues()
2333 __nvme_fc_delete_hw_queue(ctrl, queue, i); in nvme_fc_delete_hw_io_queues()
2337 nvme_fc_create_hw_io_queues(struct nvme_fc_ctrl *ctrl, u16 qsize) in nvme_fc_create_hw_io_queues() argument
2339 struct nvme_fc_queue *queue = &ctrl->queues[1]; in nvme_fc_create_hw_io_queues()
2342 for (i = 1; i < ctrl->ctrl.queue_count; i++, queue++) { in nvme_fc_create_hw_io_queues()
2343 ret = __nvme_fc_create_hw_queue(ctrl, queue, i, qsize); in nvme_fc_create_hw_io_queues()
2352 __nvme_fc_delete_hw_queue(ctrl, &ctrl->queues[i], i); in nvme_fc_create_hw_io_queues()
2357 nvme_fc_connect_io_queues(struct nvme_fc_ctrl *ctrl, u16 qsize) in nvme_fc_connect_io_queues() argument
2361 for (i = 1; i < ctrl->ctrl.queue_count; i++) { in nvme_fc_connect_io_queues()
2362 ret = nvme_fc_connect_queue(ctrl, &ctrl->queues[i], qsize, in nvme_fc_connect_io_queues()
2366 ret = nvmf_connect_io_queue(&ctrl->ctrl, i); in nvme_fc_connect_io_queues()
2370 set_bit(NVME_FC_Q_LIVE, &ctrl->queues[i].flags); in nvme_fc_connect_io_queues()
2377 nvme_fc_init_io_queues(struct nvme_fc_ctrl *ctrl) in nvme_fc_init_io_queues() argument
2381 for (i = 1; i < ctrl->ctrl.queue_count; i++) in nvme_fc_init_io_queues()
2382 nvme_fc_init_queue(ctrl, i); in nvme_fc_init_io_queues()
2388 struct nvme_fc_ctrl *ctrl = in nvme_fc_ctrl_free() local
2392 if (ctrl->ctrl.tagset) in nvme_fc_ctrl_free()
2393 nvme_remove_io_tag_set(&ctrl->ctrl); in nvme_fc_ctrl_free()
2396 spin_lock_irqsave(&ctrl->rport->lock, flags); in nvme_fc_ctrl_free()
2397 list_del(&ctrl->ctrl_list); in nvme_fc_ctrl_free()
2398 spin_unlock_irqrestore(&ctrl->rport->lock, flags); in nvme_fc_ctrl_free()
2400 nvme_unquiesce_admin_queue(&ctrl->ctrl); in nvme_fc_ctrl_free()
2401 nvme_remove_admin_tag_set(&ctrl->ctrl); in nvme_fc_ctrl_free()
2403 kfree(ctrl->queues); in nvme_fc_ctrl_free()
2405 put_device(ctrl->dev); in nvme_fc_ctrl_free()
2406 nvme_fc_rport_put(ctrl->rport); in nvme_fc_ctrl_free()
2408 ida_free(&nvme_fc_ctrl_cnt, ctrl->cnum); in nvme_fc_ctrl_free()
2409 if (ctrl->ctrl.opts) in nvme_fc_ctrl_free()
2410 nvmf_free_options(ctrl->ctrl.opts); in nvme_fc_ctrl_free()
2411 kfree(ctrl); in nvme_fc_ctrl_free()
2415 nvme_fc_ctrl_put(struct nvme_fc_ctrl *ctrl) in nvme_fc_ctrl_put() argument
2417 kref_put(&ctrl->ref, nvme_fc_ctrl_free); in nvme_fc_ctrl_put()
2421 nvme_fc_ctrl_get(struct nvme_fc_ctrl *ctrl) in nvme_fc_ctrl_get() argument
2423 return kref_get_unless_zero(&ctrl->ref); in nvme_fc_ctrl_get()
2433 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl); in nvme_fc_free_ctrl() local
2435 WARN_ON(nctrl != &ctrl->ctrl); in nvme_fc_free_ctrl()
2437 nvme_fc_ctrl_put(ctrl); in nvme_fc_free_ctrl()
2456 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl); in nvme_fc_terminate_exchange() local
2460 __nvme_fc_abort_op(ctrl, op); in nvme_fc_terminate_exchange()
2474 __nvme_fc_abort_outstanding_ios(struct nvme_fc_ctrl *ctrl, bool start_queues) in __nvme_fc_abort_outstanding_ios() argument
2482 if (ctrl->ctrl.queue_count > 1) { in __nvme_fc_abort_outstanding_ios()
2483 for (q = 1; q < ctrl->ctrl.queue_count; q++) in __nvme_fc_abort_outstanding_ios()
2484 clear_bit(NVME_FC_Q_LIVE, &ctrl->queues[q].flags); in __nvme_fc_abort_outstanding_ios()
2486 clear_bit(NVME_FC_Q_LIVE, &ctrl->queues[0].flags); in __nvme_fc_abort_outstanding_ios()
2500 if (ctrl->ctrl.queue_count > 1) { in __nvme_fc_abort_outstanding_ios()
2501 nvme_quiesce_io_queues(&ctrl->ctrl); in __nvme_fc_abort_outstanding_ios()
2502 nvme_sync_io_queues(&ctrl->ctrl); in __nvme_fc_abort_outstanding_ios()
2503 blk_mq_tagset_busy_iter(&ctrl->tag_set, in __nvme_fc_abort_outstanding_ios()
2504 nvme_fc_terminate_exchange, &ctrl->ctrl); in __nvme_fc_abort_outstanding_ios()
2505 blk_mq_tagset_wait_completed_request(&ctrl->tag_set); in __nvme_fc_abort_outstanding_ios()
2507 nvme_unquiesce_io_queues(&ctrl->ctrl); in __nvme_fc_abort_outstanding_ios()
2525 nvme_quiesce_admin_queue(&ctrl->ctrl); in __nvme_fc_abort_outstanding_ios()
2526 blk_sync_queue(ctrl->ctrl.admin_q); in __nvme_fc_abort_outstanding_ios()
2527 blk_mq_tagset_busy_iter(&ctrl->admin_tag_set, in __nvme_fc_abort_outstanding_ios()
2528 nvme_fc_terminate_exchange, &ctrl->ctrl); in __nvme_fc_abort_outstanding_ios()
2529 blk_mq_tagset_wait_completed_request(&ctrl->admin_tag_set); in __nvme_fc_abort_outstanding_ios()
2531 nvme_unquiesce_admin_queue(&ctrl->ctrl); in __nvme_fc_abort_outstanding_ios()
2535 nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl, char *errmsg) in nvme_fc_error_recovery() argument
2544 if (ctrl->ctrl.state == NVME_CTRL_CONNECTING) { in nvme_fc_error_recovery()
2545 __nvme_fc_abort_outstanding_ios(ctrl, true); in nvme_fc_error_recovery()
2546 set_bit(ASSOC_FAILED, &ctrl->flags); in nvme_fc_error_recovery()
2547 dev_warn(ctrl->ctrl.device, in nvme_fc_error_recovery()
2549 ctrl->cnum); in nvme_fc_error_recovery()
2554 if (ctrl->ctrl.state != NVME_CTRL_LIVE) in nvme_fc_error_recovery()
2557 dev_warn(ctrl->ctrl.device, in nvme_fc_error_recovery()
2559 ctrl->cnum, errmsg); in nvme_fc_error_recovery()
2560 dev_warn(ctrl->ctrl.device, in nvme_fc_error_recovery()
2561 "NVME-FC{%d}: resetting controller\n", ctrl->cnum); in nvme_fc_error_recovery()
2563 nvme_reset_ctrl(&ctrl->ctrl); in nvme_fc_error_recovery()
2569 struct nvme_fc_ctrl *ctrl = op->ctrl; in nvme_fc_timeout() local
2578 dev_info(ctrl->ctrl.device, in nvme_fc_timeout()
2581 ctrl->cnum, qnum, sqe->common.opcode, sqe->fabrics.fctype, in nvme_fc_timeout()
2584 if (__nvme_fc_abort_op(ctrl, op)) in nvme_fc_timeout()
2585 nvme_fc_error_recovery(ctrl, "io timeout abort failed"); in nvme_fc_timeout()
2596 nvme_fc_map_data(struct nvme_fc_ctrl *ctrl, struct request *rq, in nvme_fc_map_data() argument
2616 freq->sg_cnt = fc_dma_map_sg(ctrl->lport->dev, freq->sg_table.sgl, in nvme_fc_map_data()
2631 nvme_fc_unmap_data(struct nvme_fc_ctrl *ctrl, struct request *rq, in nvme_fc_unmap_data() argument
2639 fc_dma_unmap_sg(ctrl->lport->dev, freq->sg_table.sgl, op->nents, in nvme_fc_unmap_data()
2671 nvme_fc_start_fcp_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue, in nvme_fc_start_fcp_op() argument
2683 if (ctrl->rport->remoteport.port_state != FC_OBJSTATE_ONLINE) in nvme_fc_start_fcp_op()
2686 if (!nvme_fc_ctrl_get(ctrl)) in nvme_fc_start_fcp_op()
2730 ret = nvme_fc_map_data(ctrl, op->rq, op); in nvme_fc_start_fcp_op()
2733 nvme_fc_ctrl_put(ctrl); in nvme_fc_start_fcp_op()
2740 fc_dma_sync_single_for_device(ctrl->lport->dev, op->fcp_req.cmddma, in nvme_fc_start_fcp_op()
2749 ret = ctrl->lport->ops->fcp_io(&ctrl->lport->localport, in nvme_fc_start_fcp_op()
2750 &ctrl->rport->remoteport, in nvme_fc_start_fcp_op()
2767 __nvme_fc_fcpop_chk_teardowns(ctrl, op, opstate); in nvme_fc_start_fcp_op()
2770 nvme_fc_unmap_data(ctrl, op->rq, op); in nvme_fc_start_fcp_op()
2774 nvme_fc_ctrl_put(ctrl); in nvme_fc_start_fcp_op()
2776 if (ctrl->rport->remoteport.port_state == FC_OBJSTATE_ONLINE && in nvme_fc_start_fcp_op()
2792 struct nvme_fc_ctrl *ctrl = queue->ctrl; in nvme_fc_queue_rq() local
2800 if (ctrl->rport->remoteport.port_state != FC_OBJSTATE_ONLINE || in nvme_fc_queue_rq()
2801 !nvme_check_ready(&queue->ctrl->ctrl, rq, queue_ready)) in nvme_fc_queue_rq()
2802 return nvme_fail_nonready_command(&queue->ctrl->ctrl, rq); in nvme_fc_queue_rq()
2826 return nvme_fc_start_fcp_op(ctrl, queue, op, data_len, io_dir); in nvme_fc_queue_rq()
2832 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(arg); in nvme_fc_submit_async_event() local
2836 if (test_bit(FCCTRL_TERMIO, &ctrl->flags)) in nvme_fc_submit_async_event()
2839 aen_op = &ctrl->aen_ops[0]; in nvme_fc_submit_async_event()
2841 ret = nvme_fc_start_fcp_op(ctrl, aen_op->queue, aen_op, 0, in nvme_fc_submit_async_event()
2844 dev_err(ctrl->ctrl.device, in nvme_fc_submit_async_event()
2852 struct nvme_fc_ctrl *ctrl = op->ctrl; in nvme_fc_complete_rq() local
2857 nvme_fc_unmap_data(ctrl, rq, op); in nvme_fc_complete_rq()
2859 nvme_fc_ctrl_put(ctrl); in nvme_fc_complete_rq()
2864 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(set->driver_data); in nvme_fc_map_queues() local
2876 if (ctrl->lport->ops->map_queues) in nvme_fc_map_queues()
2877 ctrl->lport->ops->map_queues(&ctrl->lport->localport, in nvme_fc_map_queues()
2895 nvme_fc_create_io_queues(struct nvme_fc_ctrl *ctrl) in nvme_fc_create_io_queues() argument
2897 struct nvmf_ctrl_options *opts = ctrl->ctrl.opts; in nvme_fc_create_io_queues()
2902 ctrl->lport->ops->max_hw_queues); in nvme_fc_create_io_queues()
2903 ret = nvme_set_queue_count(&ctrl->ctrl, &nr_io_queues); in nvme_fc_create_io_queues()
2905 dev_info(ctrl->ctrl.device, in nvme_fc_create_io_queues()
2910 ctrl->ctrl.queue_count = nr_io_queues + 1; in nvme_fc_create_io_queues()
2914 nvme_fc_init_io_queues(ctrl); in nvme_fc_create_io_queues()
2916 ret = nvme_alloc_io_tag_set(&ctrl->ctrl, &ctrl->tag_set, in nvme_fc_create_io_queues()
2919 ctrl->lport->ops->fcprqst_priv_sz)); in nvme_fc_create_io_queues()
2923 ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize + 1); in nvme_fc_create_io_queues()
2927 ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize + 1); in nvme_fc_create_io_queues()
2931 ctrl->ioq_live = true; in nvme_fc_create_io_queues()
2936 nvme_fc_delete_hw_io_queues(ctrl); in nvme_fc_create_io_queues()
2938 nvme_remove_io_tag_set(&ctrl->ctrl); in nvme_fc_create_io_queues()
2939 nvme_fc_free_io_queues(ctrl); in nvme_fc_create_io_queues()
2942 ctrl->ctrl.tagset = NULL; in nvme_fc_create_io_queues()
2948 nvme_fc_recreate_io_queues(struct nvme_fc_ctrl *ctrl) in nvme_fc_recreate_io_queues() argument
2950 struct nvmf_ctrl_options *opts = ctrl->ctrl.opts; in nvme_fc_recreate_io_queues()
2951 u32 prior_ioq_cnt = ctrl->ctrl.queue_count - 1; in nvme_fc_recreate_io_queues()
2956 ctrl->lport->ops->max_hw_queues); in nvme_fc_recreate_io_queues()
2957 ret = nvme_set_queue_count(&ctrl->ctrl, &nr_io_queues); in nvme_fc_recreate_io_queues()
2959 dev_info(ctrl->ctrl.device, in nvme_fc_recreate_io_queues()
2965 dev_info(ctrl->ctrl.device, in nvme_fc_recreate_io_queues()
2971 ctrl->ctrl.queue_count = nr_io_queues + 1; in nvme_fc_recreate_io_queues()
2973 if (ctrl->ctrl.queue_count == 1) in nvme_fc_recreate_io_queues()
2977 dev_info(ctrl->ctrl.device, in nvme_fc_recreate_io_queues()
2980 blk_mq_update_nr_hw_queues(&ctrl->tag_set, nr_io_queues); in nvme_fc_recreate_io_queues()
2983 ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize + 1); in nvme_fc_recreate_io_queues()
2987 ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize + 1); in nvme_fc_recreate_io_queues()
2994 nvme_fc_delete_hw_io_queues(ctrl); in nvme_fc_recreate_io_queues()
2996 nvme_fc_free_io_queues(ctrl); in nvme_fc_recreate_io_queues()
3020 nvme_fc_ctlr_active_on_rport(struct nvme_fc_ctrl *ctrl) in nvme_fc_ctlr_active_on_rport() argument
3022 struct nvme_fc_rport *rport = ctrl->rport; in nvme_fc_ctlr_active_on_rport()
3025 if (test_and_set_bit(ASSOC_ACTIVE, &ctrl->flags)) in nvme_fc_ctlr_active_on_rport()
3036 nvme_fc_ctlr_inactive_on_rport(struct nvme_fc_ctrl *ctrl) in nvme_fc_ctlr_inactive_on_rport() argument
3038 struct nvme_fc_rport *rport = ctrl->rport; in nvme_fc_ctlr_inactive_on_rport()
3042 /* clearing of ctrl->flags ASSOC_ACTIVE bit is in association delete */ in nvme_fc_ctlr_inactive_on_rport()
3059 nvme_fc_create_association(struct nvme_fc_ctrl *ctrl) in nvme_fc_create_association() argument
3061 struct nvmf_ctrl_options *opts = ctrl->ctrl.opts; in nvme_fc_create_association()
3067 ++ctrl->ctrl.nr_reconnects; in nvme_fc_create_association()
3069 if (ctrl->rport->remoteport.port_state != FC_OBJSTATE_ONLINE) in nvme_fc_create_association()
3072 if (nvme_fc_ctlr_active_on_rport(ctrl)) in nvme_fc_create_association()
3075 dev_info(ctrl->ctrl.device, in nvme_fc_create_association()
3078 ctrl->cnum, ctrl->lport->localport.port_name, in nvme_fc_create_association()
3079 ctrl->rport->remoteport.port_name, ctrl->ctrl.opts->subsysnqn); in nvme_fc_create_association()
3081 clear_bit(ASSOC_FAILED, &ctrl->flags); in nvme_fc_create_association()
3087 ret = __nvme_fc_create_hw_queue(ctrl, &ctrl->queues[0], 0, in nvme_fc_create_association()
3092 ret = nvme_fc_connect_admin_queue(ctrl, &ctrl->queues[0], in nvme_fc_create_association()
3097 ret = nvmf_connect_admin_queue(&ctrl->ctrl); in nvme_fc_create_association()
3101 set_bit(NVME_FC_Q_LIVE, &ctrl->queues[0].flags); in nvme_fc_create_association()
3106 * todo:- add code to check if ctrl attributes changed from in nvme_fc_create_association()
3110 ret = nvme_enable_ctrl(&ctrl->ctrl); in nvme_fc_create_association()
3111 if (!ret && test_bit(ASSOC_FAILED, &ctrl->flags)) in nvme_fc_create_association()
3116 ctrl->ctrl.max_segments = ctrl->lport->ops->max_sgl_segments; in nvme_fc_create_association()
3117 ctrl->ctrl.max_hw_sectors = ctrl->ctrl.max_segments << in nvme_fc_create_association()
3120 nvme_unquiesce_admin_queue(&ctrl->ctrl); in nvme_fc_create_association()
3122 ret = nvme_init_ctrl_finish(&ctrl->ctrl, false); in nvme_fc_create_association()
3125 if (test_bit(ASSOC_FAILED, &ctrl->flags)) { in nvme_fc_create_association()
3132 if (ctrl->ctrl.icdoff) { in nvme_fc_create_association()
3133 dev_err(ctrl->ctrl.device, "icdoff %d is not supported!\n", in nvme_fc_create_association()
3134 ctrl->ctrl.icdoff); in nvme_fc_create_association()
3140 if (!nvme_ctrl_sgl_supported(&ctrl->ctrl)) { in nvme_fc_create_association()
3141 dev_err(ctrl->ctrl.device, in nvme_fc_create_association()
3147 if (opts->queue_size > ctrl->ctrl.maxcmd) { in nvme_fc_create_association()
3149 dev_warn(ctrl->ctrl.device, in nvme_fc_create_association()
3150 "queue_size %zu > ctrl maxcmd %u, reducing " in nvme_fc_create_association()
3152 opts->queue_size, ctrl->ctrl.maxcmd); in nvme_fc_create_association()
3153 opts->queue_size = ctrl->ctrl.maxcmd; in nvme_fc_create_association()
3154 ctrl->ctrl.sqsize = opts->queue_size - 1; in nvme_fc_create_association()
3157 ret = nvme_fc_init_aen_ops(ctrl); in nvme_fc_create_association()
3165 if (ctrl->ctrl.queue_count > 1) { in nvme_fc_create_association()
3166 if (!ctrl->ioq_live) in nvme_fc_create_association()
3167 ret = nvme_fc_create_io_queues(ctrl); in nvme_fc_create_association()
3169 ret = nvme_fc_recreate_io_queues(ctrl); in nvme_fc_create_association()
3171 if (!ret && test_bit(ASSOC_FAILED, &ctrl->flags)) in nvme_fc_create_association()
3176 changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE); in nvme_fc_create_association()
3178 ctrl->ctrl.nr_reconnects = 0; in nvme_fc_create_association()
3181 nvme_start_ctrl(&ctrl->ctrl); in nvme_fc_create_association()
3186 nvme_fc_term_aen_ops(ctrl); in nvme_fc_create_association()
3188 nvme_stop_keep_alive(&ctrl->ctrl); in nvme_fc_create_association()
3190 dev_warn(ctrl->ctrl.device, in nvme_fc_create_association()
3192 ctrl->cnum, ctrl->association_id, ret); in nvme_fc_create_association()
3194 nvme_fc_xmt_disconnect_assoc(ctrl); in nvme_fc_create_association()
3195 spin_lock_irqsave(&ctrl->lock, flags); in nvme_fc_create_association()
3196 ctrl->association_id = 0; in nvme_fc_create_association()
3197 disls = ctrl->rcv_disconn; in nvme_fc_create_association()
3198 ctrl->rcv_disconn = NULL; in nvme_fc_create_association()
3199 spin_unlock_irqrestore(&ctrl->lock, flags); in nvme_fc_create_association()
3203 __nvme_fc_delete_hw_queue(ctrl, &ctrl->queues[0], 0); in nvme_fc_create_association()
3205 nvme_fc_free_queue(&ctrl->queues[0]); in nvme_fc_create_association()
3206 clear_bit(ASSOC_ACTIVE, &ctrl->flags); in nvme_fc_create_association()
3207 nvme_fc_ctlr_inactive_on_rport(ctrl); in nvme_fc_create_association()
3220 nvme_fc_delete_association(struct nvme_fc_ctrl *ctrl) in nvme_fc_delete_association() argument
3225 if (!test_and_clear_bit(ASSOC_ACTIVE, &ctrl->flags)) in nvme_fc_delete_association()
3228 spin_lock_irqsave(&ctrl->lock, flags); in nvme_fc_delete_association()
3229 set_bit(FCCTRL_TERMIO, &ctrl->flags); in nvme_fc_delete_association()
3230 ctrl->iocnt = 0; in nvme_fc_delete_association()
3231 spin_unlock_irqrestore(&ctrl->lock, flags); in nvme_fc_delete_association()
3233 __nvme_fc_abort_outstanding_ios(ctrl, false); in nvme_fc_delete_association()
3236 nvme_fc_abort_aen_ops(ctrl); in nvme_fc_delete_association()
3239 spin_lock_irq(&ctrl->lock); in nvme_fc_delete_association()
3240 wait_event_lock_irq(ctrl->ioabort_wait, ctrl->iocnt == 0, ctrl->lock); in nvme_fc_delete_association()
3241 clear_bit(FCCTRL_TERMIO, &ctrl->flags); in nvme_fc_delete_association()
3242 spin_unlock_irq(&ctrl->lock); in nvme_fc_delete_association()
3244 nvme_fc_term_aen_ops(ctrl); in nvme_fc_delete_association()
3252 if (ctrl->association_id) in nvme_fc_delete_association()
3253 nvme_fc_xmt_disconnect_assoc(ctrl); in nvme_fc_delete_association()
3255 spin_lock_irqsave(&ctrl->lock, flags); in nvme_fc_delete_association()
3256 ctrl->association_id = 0; in nvme_fc_delete_association()
3257 disls = ctrl->rcv_disconn; in nvme_fc_delete_association()
3258 ctrl->rcv_disconn = NULL; in nvme_fc_delete_association()
3259 spin_unlock_irqrestore(&ctrl->lock, flags); in nvme_fc_delete_association()
3267 if (ctrl->ctrl.tagset) { in nvme_fc_delete_association()
3268 nvme_fc_delete_hw_io_queues(ctrl); in nvme_fc_delete_association()
3269 nvme_fc_free_io_queues(ctrl); in nvme_fc_delete_association()
3272 __nvme_fc_delete_hw_queue(ctrl, &ctrl->queues[0], 0); in nvme_fc_delete_association()
3273 nvme_fc_free_queue(&ctrl->queues[0]); in nvme_fc_delete_association()
3276 nvme_unquiesce_admin_queue(&ctrl->ctrl); in nvme_fc_delete_association()
3279 nvme_unquiesce_io_queues(&ctrl->ctrl); in nvme_fc_delete_association()
3281 nvme_fc_ctlr_inactive_on_rport(ctrl); in nvme_fc_delete_association()
3287 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl); in nvme_fc_delete_ctrl() local
3289 cancel_work_sync(&ctrl->ioerr_work); in nvme_fc_delete_ctrl()
3290 cancel_delayed_work_sync(&ctrl->connect_work); in nvme_fc_delete_ctrl()
3295 nvme_fc_delete_association(ctrl); in nvme_fc_delete_ctrl()
3299 nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status) in nvme_fc_reconnect_or_delete() argument
3301 struct nvme_fc_rport *rport = ctrl->rport; in nvme_fc_reconnect_or_delete()
3303 unsigned long recon_delay = ctrl->ctrl.opts->reconnect_delay * HZ; in nvme_fc_reconnect_or_delete()
3306 if (nvme_ctrl_state(&ctrl->ctrl) != NVME_CTRL_CONNECTING) in nvme_fc_reconnect_or_delete()
3310 dev_info(ctrl->ctrl.device, in nvme_fc_reconnect_or_delete()
3312 ctrl->cnum, status); in nvme_fc_reconnect_or_delete()
3316 if (recon && nvmf_should_reconnect(&ctrl->ctrl, status)) { in nvme_fc_reconnect_or_delete()
3318 dev_info(ctrl->ctrl.device, in nvme_fc_reconnect_or_delete()
3321 ctrl->cnum, recon_delay / HZ); in nvme_fc_reconnect_or_delete()
3325 queue_delayed_work(nvme_wq, &ctrl->connect_work, recon_delay); in nvme_fc_reconnect_or_delete()
3329 dev_warn(ctrl->ctrl.device, in nvme_fc_reconnect_or_delete()
3331 ctrl->cnum); in nvme_fc_reconnect_or_delete()
3333 dev_warn(ctrl->ctrl.device, in nvme_fc_reconnect_or_delete()
3336 ctrl->cnum, ctrl->ctrl.nr_reconnects); in nvme_fc_reconnect_or_delete()
3338 dev_warn(ctrl->ctrl.device, in nvme_fc_reconnect_or_delete()
3341 ctrl->cnum, min_t(int, portptr->dev_loss_tmo, in nvme_fc_reconnect_or_delete()
3342 (ctrl->ctrl.opts->max_reconnects * in nvme_fc_reconnect_or_delete()
3343 ctrl->ctrl.opts->reconnect_delay))); in nvme_fc_reconnect_or_delete()
3344 WARN_ON(nvme_delete_ctrl(&ctrl->ctrl)); in nvme_fc_reconnect_or_delete()
3351 struct nvme_fc_ctrl *ctrl = in nvme_fc_reset_ctrl_work() local
3352 container_of(work, struct nvme_fc_ctrl, ctrl.reset_work); in nvme_fc_reset_ctrl_work()
3354 nvme_stop_ctrl(&ctrl->ctrl); in nvme_fc_reset_ctrl_work()
3357 nvme_fc_delete_association(ctrl); in nvme_fc_reset_ctrl_work()
3359 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) in nvme_fc_reset_ctrl_work()
3360 dev_err(ctrl->ctrl.device, in nvme_fc_reset_ctrl_work()
3362 "to CONNECTING\n", ctrl->cnum); in nvme_fc_reset_ctrl_work()
3364 if (ctrl->rport->remoteport.port_state == FC_OBJSTATE_ONLINE) { in nvme_fc_reset_ctrl_work()
3365 if (!queue_delayed_work(nvme_wq, &ctrl->connect_work, 0)) { in nvme_fc_reset_ctrl_work()
3366 dev_err(ctrl->ctrl.device, in nvme_fc_reset_ctrl_work()
3368 "after reset\n", ctrl->cnum); in nvme_fc_reset_ctrl_work()
3370 flush_delayed_work(&ctrl->connect_work); in nvme_fc_reset_ctrl_work()
3373 nvme_fc_reconnect_or_delete(ctrl, -ENOTCONN); in nvme_fc_reset_ctrl_work()
3397 struct nvme_fc_ctrl *ctrl = in nvme_fc_connect_ctrl_work() local
3401 ret = nvme_fc_create_association(ctrl); in nvme_fc_connect_ctrl_work()
3403 nvme_fc_reconnect_or_delete(ctrl, ret); in nvme_fc_connect_ctrl_work()
3405 dev_info(ctrl->ctrl.device, in nvme_fc_connect_ctrl_work()
3407 ctrl->cnum); in nvme_fc_connect_ctrl_work()
3433 struct nvme_fc_ctrl *ctrl; in nvme_fc_existing_controller() local
3438 list_for_each_entry(ctrl, &rport->ctrl_list, ctrl_list) { in nvme_fc_existing_controller()
3439 found = nvmf_ctlr_matches_baseopts(&ctrl->ctrl, opts); in nvme_fc_existing_controller()
3452 struct nvme_fc_ctrl *ctrl; in nvme_fc_alloc_ctrl() local
3467 ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); in nvme_fc_alloc_ctrl()
3468 if (!ctrl) { in nvme_fc_alloc_ctrl()
3492 ctrl->ctrl.opts = opts; in nvme_fc_alloc_ctrl()
3493 ctrl->ctrl.nr_reconnects = 0; in nvme_fc_alloc_ctrl()
3494 INIT_LIST_HEAD(&ctrl->ctrl_list); in nvme_fc_alloc_ctrl()
3495 ctrl->lport = lport; in nvme_fc_alloc_ctrl()
3496 ctrl->rport = rport; in nvme_fc_alloc_ctrl()
3497 ctrl->dev = lport->dev; in nvme_fc_alloc_ctrl()
3498 ctrl->cnum = idx; in nvme_fc_alloc_ctrl()
3499 ctrl->ioq_live = false; in nvme_fc_alloc_ctrl()
3500 init_waitqueue_head(&ctrl->ioabort_wait); in nvme_fc_alloc_ctrl()
3502 get_device(ctrl->dev); in nvme_fc_alloc_ctrl()
3503 kref_init(&ctrl->ref); in nvme_fc_alloc_ctrl()
3505 INIT_WORK(&ctrl->ctrl.reset_work, nvme_fc_reset_ctrl_work); in nvme_fc_alloc_ctrl()
3506 INIT_DELAYED_WORK(&ctrl->connect_work, nvme_fc_connect_ctrl_work); in nvme_fc_alloc_ctrl()
3507 INIT_WORK(&ctrl->ioerr_work, nvme_fc_ctrl_ioerr_work); in nvme_fc_alloc_ctrl()
3508 spin_lock_init(&ctrl->lock); in nvme_fc_alloc_ctrl()
3511 ctrl->ctrl.queue_count = min_t(unsigned int, in nvme_fc_alloc_ctrl()
3514 ctrl->ctrl.queue_count++; /* +1 for admin queue */ in nvme_fc_alloc_ctrl()
3516 ctrl->ctrl.sqsize = opts->queue_size - 1; in nvme_fc_alloc_ctrl()
3517 ctrl->ctrl.kato = opts->kato; in nvme_fc_alloc_ctrl()
3518 ctrl->ctrl.cntlid = 0xffff; in nvme_fc_alloc_ctrl()
3521 ctrl->queues = kcalloc(ctrl->ctrl.queue_count, in nvme_fc_alloc_ctrl()
3523 if (!ctrl->queues) in nvme_fc_alloc_ctrl()
3526 nvme_fc_init_queue(ctrl, 0); in nvme_fc_alloc_ctrl()
3535 ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_fc_ctrl_ops, 0); in nvme_fc_alloc_ctrl()
3539 ctrl->ctrl.numa_node = dev_to_node(lport->dev); in nvme_fc_alloc_ctrl()
3541 return ctrl; in nvme_fc_alloc_ctrl()
3544 kfree(ctrl->queues); in nvme_fc_alloc_ctrl()
3546 put_device(ctrl->dev); in nvme_fc_alloc_ctrl()
3547 ida_free(&nvme_fc_ctrl_cnt, ctrl->cnum); in nvme_fc_alloc_ctrl()
3549 kfree(ctrl); in nvme_fc_alloc_ctrl()
3559 struct nvme_fc_ctrl *ctrl; in nvme_fc_init_ctrl() local
3563 ctrl = nvme_fc_alloc_ctrl(dev, opts, lport, rport); in nvme_fc_init_ctrl()
3564 if (IS_ERR(ctrl)) in nvme_fc_init_ctrl()
3565 return ERR_CAST(ctrl); in nvme_fc_init_ctrl()
3567 ret = nvme_add_ctrl(&ctrl->ctrl); in nvme_fc_init_ctrl()
3571 ret = nvme_alloc_admin_tag_set(&ctrl->ctrl, &ctrl->admin_tag_set, in nvme_fc_init_ctrl()
3574 ctrl->lport->ops->fcprqst_priv_sz)); in nvme_fc_init_ctrl()
3579 list_add_tail(&ctrl->ctrl_list, &rport->ctrl_list); in nvme_fc_init_ctrl()
3582 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RESETTING) || in nvme_fc_init_ctrl()
3583 !nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) { in nvme_fc_init_ctrl()
3584 dev_err(ctrl->ctrl.device, in nvme_fc_init_ctrl()
3585 "NVME-FC{%d}: failed to init ctrl state\n", ctrl->cnum); in nvme_fc_init_ctrl()
3589 if (!queue_delayed_work(nvme_wq, &ctrl->connect_work, 0)) { in nvme_fc_init_ctrl()
3590 dev_err(ctrl->ctrl.device, in nvme_fc_init_ctrl()
3592 ctrl->cnum); in nvme_fc_init_ctrl()
3596 flush_delayed_work(&ctrl->connect_work); in nvme_fc_init_ctrl()
3598 dev_info(ctrl->ctrl.device, in nvme_fc_init_ctrl()
3599 "NVME-FC{%d}: new ctrl: NQN \"%s\", hostnqn: %s\n", in nvme_fc_init_ctrl()
3600 ctrl->cnum, nvmf_ctrl_subsysnqn(&ctrl->ctrl), opts->host->nqn); in nvme_fc_init_ctrl()
3602 return &ctrl->ctrl; in nvme_fc_init_ctrl()
3605 nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_DELETING); in nvme_fc_init_ctrl()
3606 cancel_work_sync(&ctrl->ioerr_work); in nvme_fc_init_ctrl()
3607 cancel_work_sync(&ctrl->ctrl.reset_work); in nvme_fc_init_ctrl()
3608 cancel_delayed_work_sync(&ctrl->connect_work); in nvme_fc_init_ctrl()
3610 ctrl->ctrl.opts = NULL; in nvme_fc_init_ctrl()
3612 /* initiate nvme ctrl ref counting teardown */ in nvme_fc_init_ctrl()
3613 nvme_uninit_ctrl(&ctrl->ctrl); in nvme_fc_init_ctrl()
3616 /* Remove core ctrl ref. */ in nvme_fc_init_ctrl()
3617 nvme_put_ctrl(&ctrl->ctrl); in nvme_fc_init_ctrl()
3701 struct nvme_ctrl *ctrl; in nvme_fc_create_ctrl() local
3735 ctrl = nvme_fc_init_ctrl(dev, opts, lport, rport); in nvme_fc_create_ctrl()
3736 if (IS_ERR(ctrl)) in nvme_fc_create_ctrl()
3738 return ctrl; in nvme_fc_create_ctrl()
3955 struct nvme_fc_ctrl *ctrl; in nvme_fc_delete_controllers() local
3958 list_for_each_entry(ctrl, &rport->ctrl_list, ctrl_list) { in nvme_fc_delete_controllers()
3959 dev_warn(ctrl->ctrl.device, in nvme_fc_delete_controllers()
3960 "NVME-FC{%d}: transport unloading: deleting ctrl\n", in nvme_fc_delete_controllers()
3961 ctrl->cnum); in nvme_fc_delete_controllers()
3962 nvme_delete_ctrl(&ctrl->ctrl); in nvme_fc_delete_controllers()