Lines Matching full:ctrl

35 	struct nvme_fc_ctrl	*ctrl;  member
99 struct nvme_fc_ctrl *ctrl; member
179 struct nvme_ctrl ctrl; member
183 to_fc_ctrl(struct nvme_ctrl *ctrl) in to_fc_ctrl() argument
185 return container_of(ctrl, struct nvme_fc_ctrl, ctrl); in to_fc_ctrl()
552 nvme_fc_resume_controller(struct nvme_fc_ctrl *ctrl) in nvme_fc_resume_controller() argument
554 switch (nvme_ctrl_state(&ctrl->ctrl)) { in nvme_fc_resume_controller()
561 dev_info(ctrl->ctrl.device, in nvme_fc_resume_controller()
563 "Attempting reconnect\n", ctrl->cnum); in nvme_fc_resume_controller()
565 queue_delayed_work(nvme_wq, &ctrl->connect_work, 0); in nvme_fc_resume_controller()
587 struct nvme_fc_ctrl *ctrl; in nvme_fc_attach_to_suspended_rport() local
623 list_for_each_entry(ctrl, &rport->ctrl_list, ctrl_list) in nvme_fc_attach_to_suspended_rport()
624 nvme_fc_resume_controller(ctrl); in nvme_fc_attach_to_suspended_rport()
784 nvme_fc_ctrl_connectivity_loss(struct nvme_fc_ctrl *ctrl) in nvme_fc_ctrl_connectivity_loss() argument
786 dev_info(ctrl->ctrl.device, in nvme_fc_ctrl_connectivity_loss()
788 "Reconnect", ctrl->cnum); in nvme_fc_ctrl_connectivity_loss()
790 set_bit(ASSOC_FAILED, &ctrl->flags); in nvme_fc_ctrl_connectivity_loss()
791 nvme_reset_ctrl(&ctrl->ctrl); in nvme_fc_ctrl_connectivity_loss()
809 struct nvme_fc_ctrl *ctrl; in nvme_fc_unregister_remoteport() local
825 list_for_each_entry(ctrl, &rport->ctrl_list, ctrl_list) { in nvme_fc_unregister_remoteport()
828 dev_warn(ctrl->ctrl.device, in nvme_fc_unregister_remoteport()
830 ctrl->cnum); in nvme_fc_unregister_remoteport()
831 nvme_delete_ctrl(&ctrl->ctrl); in nvme_fc_unregister_remoteport()
833 nvme_fc_ctrl_connectivity_loss(ctrl); in nvme_fc_unregister_remoteport()
988 static void nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl, char *errmsg);
1130 nvme_fc_connect_admin_queue(struct nvme_fc_ctrl *ctrl, in nvme_fc_connect_admin_queue() argument
1142 ctrl->lport->ops->lsrqst_priv_sz), GFP_KERNEL); in nvme_fc_connect_admin_queue()
1144 dev_info(ctrl->ctrl.device, in nvme_fc_connect_admin_queue()
1146 ctrl->cnum); in nvme_fc_connect_admin_queue()
1154 if (ctrl->lport->ops->lsrqst_priv_sz) in nvme_fc_connect_admin_queue()
1173 uuid_copy(&assoc_rqst->assoc_cmd.hostid, &ctrl->ctrl.opts->host->id); in nvme_fc_connect_admin_queue()
1174 strscpy(assoc_rqst->assoc_cmd.hostnqn, ctrl->ctrl.opts->host->nqn, in nvme_fc_connect_admin_queue()
1176 strscpy(assoc_rqst->assoc_cmd.subnqn, ctrl->ctrl.opts->subsysnqn, in nvme_fc_connect_admin_queue()
1186 ret = nvme_fc_send_ls_req(ctrl->rport, lsop); in nvme_fc_connect_admin_queue()
1223 dev_err(ctrl->dev, in nvme_fc_connect_admin_queue()
1227 spin_lock_irqsave(&ctrl->lock, flags); in nvme_fc_connect_admin_queue()
1228 ctrl->association_id = in nvme_fc_connect_admin_queue()
1233 spin_unlock_irqrestore(&ctrl->lock, flags); in nvme_fc_connect_admin_queue()
1240 dev_err(ctrl->dev, in nvme_fc_connect_admin_queue()
1247 nvme_fc_connect_queue(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue, in nvme_fc_connect_queue() argument
1258 ctrl->lport->ops->lsrqst_priv_sz), GFP_KERNEL); in nvme_fc_connect_queue()
1260 dev_info(ctrl->ctrl.device, in nvme_fc_connect_queue()
1262 ctrl->cnum); in nvme_fc_connect_queue()
1270 if (ctrl->lport->ops->lsrqst_priv_sz) in nvme_fc_connect_queue()
1284 conn_rqst->associd.association_id = cpu_to_be64(ctrl->association_id); in nvme_fc_connect_queue()
1301 ret = nvme_fc_send_ls_req(ctrl->rport, lsop); in nvme_fc_connect_queue()
1329 dev_err(ctrl->dev, in nvme_fc_connect_queue()
1342 dev_err(ctrl->dev, in nvme_fc_connect_queue()
1378 nvme_fc_xmt_disconnect_assoc(struct nvme_fc_ctrl *ctrl) in nvme_fc_xmt_disconnect_assoc() argument
1388 ctrl->lport->ops->lsrqst_priv_sz), GFP_KERNEL); in nvme_fc_xmt_disconnect_assoc()
1390 dev_info(ctrl->ctrl.device, in nvme_fc_xmt_disconnect_assoc()
1393 ctrl->cnum); in nvme_fc_xmt_disconnect_assoc()
1400 if (ctrl->lport->ops->lsrqst_priv_sz) in nvme_fc_xmt_disconnect_assoc()
1406 ctrl->association_id); in nvme_fc_xmt_disconnect_assoc()
1408 ret = nvme_fc_send_ls_req_async(ctrl->rport, lsop, in nvme_fc_xmt_disconnect_assoc()
1473 struct nvme_fc_ctrl *ctrl, *tmp, *ret = NULL; in nvme_fc_match_disconn_ls() local
1480 list_for_each_entry_safe(ctrl, tmp, &rport->ctrl_list, ctrl_list) { in nvme_fc_match_disconn_ls()
1481 if (!nvme_fc_ctrl_get(ctrl)) in nvme_fc_match_disconn_ls()
1483 spin_lock(&ctrl->lock); in nvme_fc_match_disconn_ls()
1484 if (association_id == ctrl->association_id) { in nvme_fc_match_disconn_ls()
1485 oldls = ctrl->rcv_disconn; in nvme_fc_match_disconn_ls()
1486 ctrl->rcv_disconn = lsop; in nvme_fc_match_disconn_ls()
1487 ret = ctrl; in nvme_fc_match_disconn_ls()
1489 spin_unlock(&ctrl->lock); in nvme_fc_match_disconn_ls()
1491 /* leave the ctrl get reference */ in nvme_fc_match_disconn_ls()
1494 nvme_fc_ctrl_put(ctrl); in nvme_fc_match_disconn_ls()
1504 "LS's received\n", ctrl->cnum); in nvme_fc_match_disconn_ls()
1530 struct nvme_fc_ctrl *ctrl = NULL; in nvme_fc_ls_disconnect_assoc() local
1538 ctrl = nvme_fc_match_disconn_ls(rport, lsop); in nvme_fc_ls_disconnect_assoc()
1539 if (!ctrl) in nvme_fc_ls_disconnect_assoc()
1572 nvme_fc_error_recovery(ctrl, "Disconnect Association LS received"); in nvme_fc_ls_disconnect_assoc()
1575 nvme_fc_ctrl_put(ctrl); in nvme_fc_ls_disconnect_assoc()
1787 /* *********************** NVME Ctrl Routines **************************** */
1790 __nvme_fc_exit_request(struct nvme_fc_ctrl *ctrl, in __nvme_fc_exit_request() argument
1793 fc_dma_unmap_single(ctrl->lport->dev, op->fcp_req.rspdma, in __nvme_fc_exit_request()
1795 fc_dma_unmap_single(ctrl->lport->dev, op->fcp_req.cmddma, in __nvme_fc_exit_request()
1811 __nvme_fc_abort_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_fcp_op *op) in __nvme_fc_abort_op() argument
1816 spin_lock_irqsave(&ctrl->lock, flags); in __nvme_fc_abort_op()
1820 else if (test_bit(FCCTRL_TERMIO, &ctrl->flags)) { in __nvme_fc_abort_op()
1822 ctrl->iocnt++; in __nvme_fc_abort_op()
1824 spin_unlock_irqrestore(&ctrl->lock, flags); in __nvme_fc_abort_op()
1829 ctrl->lport->ops->fcp_abort(&ctrl->lport->localport, in __nvme_fc_abort_op()
1830 &ctrl->rport->remoteport, in __nvme_fc_abort_op()
1838 nvme_fc_abort_aen_ops(struct nvme_fc_ctrl *ctrl) in nvme_fc_abort_aen_ops() argument
1840 struct nvme_fc_fcp_op *aen_op = ctrl->aen_ops; in nvme_fc_abort_aen_ops()
1848 __nvme_fc_abort_op(ctrl, aen_op); in nvme_fc_abort_aen_ops()
1852 __nvme_fc_fcpop_chk_teardowns(struct nvme_fc_ctrl *ctrl, in __nvme_fc_fcpop_chk_teardowns() argument
1858 spin_lock_irqsave(&ctrl->lock, flags); in __nvme_fc_fcpop_chk_teardowns()
1859 if (test_bit(FCCTRL_TERMIO, &ctrl->flags) && in __nvme_fc_fcpop_chk_teardowns()
1861 if (!--ctrl->iocnt) in __nvme_fc_fcpop_chk_teardowns()
1862 wake_up(&ctrl->ioabort_wait); in __nvme_fc_fcpop_chk_teardowns()
1864 spin_unlock_irqrestore(&ctrl->lock, flags); in __nvme_fc_fcpop_chk_teardowns()
1871 struct nvme_fc_ctrl *ctrl = in nvme_fc_ctrl_ioerr_work() local
1874 nvme_fc_error_recovery(ctrl, "transport detected io error"); in nvme_fc_ctrl_ioerr_work()
1901 struct nvme_fc_ctrl *ctrl = op->ctrl; in nvme_fc_fcpio_done() local
1949 fc_dma_sync_single_for_cpu(ctrl->lport->dev, op->fcp_req.rspdma, in nvme_fc_fcpio_done()
1956 dev_info(ctrl->ctrl.device, in nvme_fc_fcpio_done()
1958 ctrl->cnum, freq->status); in nvme_fc_fcpio_done()
1988 dev_info(ctrl->ctrl.device, in nvme_fc_fcpio_done()
1991 ctrl->cnum, freq->transferred_length, in nvme_fc_fcpio_done()
2010 dev_info(ctrl->ctrl.device, in nvme_fc_fcpio_done()
2014 ctrl->cnum, be16_to_cpu(op->rsp_iu.iu_len), in nvme_fc_fcpio_done()
2028 dev_info(ctrl->ctrl.device, in nvme_fc_fcpio_done()
2031 ctrl->cnum, freq->rcv_rsplen); in nvme_fc_fcpio_done()
2039 nvme_complete_async_event(&queue->ctrl->ctrl, status, &result); in nvme_fc_fcpio_done()
2040 __nvme_fc_fcpop_chk_teardowns(ctrl, op, opstate); in nvme_fc_fcpio_done()
2043 nvme_fc_ctrl_put(ctrl); in nvme_fc_fcpio_done()
2047 __nvme_fc_fcpop_chk_teardowns(ctrl, op, opstate); in nvme_fc_fcpio_done()
2053 nvme_ctrl_state(&ctrl->ctrl) != NVME_CTRL_RESETTING) in nvme_fc_fcpio_done()
2054 queue_work(nvme_reset_wq, &ctrl->ioerr_work); in nvme_fc_fcpio_done()
2058 __nvme_fc_init_request(struct nvme_fc_ctrl *ctrl, in __nvme_fc_init_request() argument
2073 op->ctrl = ctrl; in __nvme_fc_init_request()
2087 op->fcp_req.cmddma = fc_dma_map_single(ctrl->lport->dev, in __nvme_fc_init_request()
2089 if (fc_dma_mapping_error(ctrl->lport->dev, op->fcp_req.cmddma)) { in __nvme_fc_init_request()
2090 dev_err(ctrl->dev, in __nvme_fc_init_request()
2096 op->fcp_req.rspdma = fc_dma_map_single(ctrl->lport->dev, in __nvme_fc_init_request()
2099 if (fc_dma_mapping_error(ctrl->lport->dev, op->fcp_req.rspdma)) { in __nvme_fc_init_request()
2100 dev_err(ctrl->dev, in __nvme_fc_init_request()
2114 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(set->driver_data); in nvme_fc_init_request() local
2116 int queue_idx = (set == &ctrl->tag_set) ? hctx_idx + 1 : 0; in nvme_fc_init_request()
2117 struct nvme_fc_queue *queue = &ctrl->queues[queue_idx]; in nvme_fc_init_request()
2120 res = __nvme_fc_init_request(ctrl, queue, &op->op, rq, queue->rqcnt++); in nvme_fc_init_request()
2125 nvme_req(rq)->ctrl = &ctrl->ctrl; in nvme_fc_init_request()
2131 nvme_fc_init_aen_ops(struct nvme_fc_ctrl *ctrl) in nvme_fc_init_aen_ops() argument
2139 aen_op = ctrl->aen_ops; in nvme_fc_init_aen_ops()
2141 if (ctrl->lport->ops->fcprqst_priv_sz) { in nvme_fc_init_aen_ops()
2142 private = kzalloc(ctrl->lport->ops->fcprqst_priv_sz, in nvme_fc_init_aen_ops()
2150 ret = __nvme_fc_init_request(ctrl, &ctrl->queues[0], in nvme_fc_init_aen_ops()
2170 nvme_fc_term_aen_ops(struct nvme_fc_ctrl *ctrl) in nvme_fc_term_aen_ops() argument
2175 cancel_work_sync(&ctrl->ctrl.async_event_work); in nvme_fc_term_aen_ops()
2176 aen_op = ctrl->aen_ops; in nvme_fc_term_aen_ops()
2178 __nvme_fc_exit_request(ctrl, aen_op); in nvme_fc_term_aen_ops()
2188 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(data); in __nvme_fc_init_hctx() local
2189 struct nvme_fc_queue *queue = &ctrl->queues[qidx]; in __nvme_fc_init_hctx()
2210 nvme_fc_init_queue(struct nvme_fc_ctrl *ctrl, int idx) in nvme_fc_init_queue() argument
2214 queue = &ctrl->queues[idx]; in nvme_fc_init_queue()
2216 queue->ctrl = ctrl; in nvme_fc_init_queue()
2219 queue->dev = ctrl->dev; in nvme_fc_init_queue()
2222 queue->cmnd_capsule_len = ctrl->ctrl.ioccsz * 16; in nvme_fc_init_queue()
2264 __nvme_fc_delete_hw_queue(struct nvme_fc_ctrl *ctrl, in __nvme_fc_delete_hw_queue() argument
2267 if (ctrl->lport->ops->delete_queue) in __nvme_fc_delete_hw_queue()
2268 ctrl->lport->ops->delete_queue(&ctrl->lport->localport, qidx, in __nvme_fc_delete_hw_queue()
2274 nvme_fc_free_io_queues(struct nvme_fc_ctrl *ctrl) in nvme_fc_free_io_queues() argument
2278 for (i = 1; i < ctrl->ctrl.queue_count; i++) in nvme_fc_free_io_queues()
2279 nvme_fc_free_queue(&ctrl->queues[i]); in nvme_fc_free_io_queues()
2283 __nvme_fc_create_hw_queue(struct nvme_fc_ctrl *ctrl, in __nvme_fc_create_hw_queue() argument
2289 if (ctrl->lport->ops->create_queue) in __nvme_fc_create_hw_queue()
2290 ret = ctrl->lport->ops->create_queue(&ctrl->lport->localport, in __nvme_fc_create_hw_queue()
2297 nvme_fc_delete_hw_io_queues(struct nvme_fc_ctrl *ctrl) in nvme_fc_delete_hw_io_queues() argument
2299 struct nvme_fc_queue *queue = &ctrl->queues[ctrl->ctrl.queue_count - 1]; in nvme_fc_delete_hw_io_queues()
2302 for (i = ctrl->ctrl.queue_count - 1; i >= 1; i--, queue--) in nvme_fc_delete_hw_io_queues()
2303 __nvme_fc_delete_hw_queue(ctrl, queue, i); in nvme_fc_delete_hw_io_queues()
2307 nvme_fc_create_hw_io_queues(struct nvme_fc_ctrl *ctrl, u16 qsize) in nvme_fc_create_hw_io_queues() argument
2309 struct nvme_fc_queue *queue = &ctrl->queues[1]; in nvme_fc_create_hw_io_queues()
2312 for (i = 1; i < ctrl->ctrl.queue_count; i++, queue++) { in nvme_fc_create_hw_io_queues()
2313 ret = __nvme_fc_create_hw_queue(ctrl, queue, i, qsize); in nvme_fc_create_hw_io_queues()
2322 __nvme_fc_delete_hw_queue(ctrl, &ctrl->queues[i], i); in nvme_fc_create_hw_io_queues()
2327 nvme_fc_connect_io_queues(struct nvme_fc_ctrl *ctrl, u16 qsize) in nvme_fc_connect_io_queues() argument
2331 for (i = 1; i < ctrl->ctrl.queue_count; i++) { in nvme_fc_connect_io_queues()
2332 ret = nvme_fc_connect_queue(ctrl, &ctrl->queues[i], qsize, in nvme_fc_connect_io_queues()
2336 ret = nvmf_connect_io_queue(&ctrl->ctrl, i); in nvme_fc_connect_io_queues()
2340 set_bit(NVME_FC_Q_LIVE, &ctrl->queues[i].flags); in nvme_fc_connect_io_queues()
2347 nvme_fc_init_io_queues(struct nvme_fc_ctrl *ctrl) in nvme_fc_init_io_queues() argument
2351 for (i = 1; i < ctrl->ctrl.queue_count; i++) in nvme_fc_init_io_queues()
2352 nvme_fc_init_queue(ctrl, i); in nvme_fc_init_io_queues()
2358 struct nvme_fc_ctrl *ctrl = in nvme_fc_ctrl_free() local
2363 spin_lock_irqsave(&ctrl->rport->lock, flags); in nvme_fc_ctrl_free()
2364 list_del(&ctrl->ctrl_list); in nvme_fc_ctrl_free()
2365 spin_unlock_irqrestore(&ctrl->rport->lock, flags); in nvme_fc_ctrl_free()
2367 kfree(ctrl->queues); in nvme_fc_ctrl_free()
2369 put_device(ctrl->dev); in nvme_fc_ctrl_free()
2370 nvme_fc_rport_put(ctrl->rport); in nvme_fc_ctrl_free()
2372 ida_free(&nvme_fc_ctrl_cnt, ctrl->cnum); in nvme_fc_ctrl_free()
2373 if (ctrl->ctrl.opts) in nvme_fc_ctrl_free()
2374 nvmf_free_options(ctrl->ctrl.opts); in nvme_fc_ctrl_free()
2375 kfree(ctrl); in nvme_fc_ctrl_free()
2379 nvme_fc_ctrl_put(struct nvme_fc_ctrl *ctrl) in nvme_fc_ctrl_put() argument
2381 kref_put(&ctrl->ref, nvme_fc_ctrl_free); in nvme_fc_ctrl_put()
2385 nvme_fc_ctrl_get(struct nvme_fc_ctrl *ctrl) in nvme_fc_ctrl_get() argument
2387 return kref_get_unless_zero(&ctrl->ref); in nvme_fc_ctrl_get()
2397 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl); in nvme_fc_free_ctrl() local
2399 WARN_ON(nctrl != &ctrl->ctrl); in nvme_fc_free_ctrl()
2401 nvme_fc_ctrl_put(ctrl); in nvme_fc_free_ctrl()
2420 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl); in nvme_fc_terminate_exchange() local
2424 __nvme_fc_abort_op(ctrl, op); in nvme_fc_terminate_exchange()
2438 __nvme_fc_abort_outstanding_ios(struct nvme_fc_ctrl *ctrl, bool start_queues) in __nvme_fc_abort_outstanding_ios() argument
2446 if (ctrl->ctrl.queue_count > 1) { in __nvme_fc_abort_outstanding_ios()
2447 for (q = 1; q < ctrl->ctrl.queue_count; q++) in __nvme_fc_abort_outstanding_ios()
2448 clear_bit(NVME_FC_Q_LIVE, &ctrl->queues[q].flags); in __nvme_fc_abort_outstanding_ios()
2450 clear_bit(NVME_FC_Q_LIVE, &ctrl->queues[0].flags); in __nvme_fc_abort_outstanding_ios()
2464 if (ctrl->ctrl.queue_count > 1) { in __nvme_fc_abort_outstanding_ios()
2465 nvme_quiesce_io_queues(&ctrl->ctrl); in __nvme_fc_abort_outstanding_ios()
2466 nvme_sync_io_queues(&ctrl->ctrl); in __nvme_fc_abort_outstanding_ios()
2467 blk_mq_tagset_busy_iter(&ctrl->tag_set, in __nvme_fc_abort_outstanding_ios()
2468 nvme_fc_terminate_exchange, &ctrl->ctrl); in __nvme_fc_abort_outstanding_ios()
2469 blk_mq_tagset_wait_completed_request(&ctrl->tag_set); in __nvme_fc_abort_outstanding_ios()
2471 nvme_unquiesce_io_queues(&ctrl->ctrl); in __nvme_fc_abort_outstanding_ios()
2489 nvme_quiesce_admin_queue(&ctrl->ctrl); in __nvme_fc_abort_outstanding_ios()
2490 blk_sync_queue(ctrl->ctrl.admin_q); in __nvme_fc_abort_outstanding_ios()
2491 blk_mq_tagset_busy_iter(&ctrl->admin_tag_set, in __nvme_fc_abort_outstanding_ios()
2492 nvme_fc_terminate_exchange, &ctrl->ctrl); in __nvme_fc_abort_outstanding_ios()
2493 blk_mq_tagset_wait_completed_request(&ctrl->admin_tag_set); in __nvme_fc_abort_outstanding_ios()
2495 nvme_unquiesce_admin_queue(&ctrl->ctrl); in __nvme_fc_abort_outstanding_ios()
2499 nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl, char *errmsg) in nvme_fc_error_recovery() argument
2501 enum nvme_ctrl_state state = nvme_ctrl_state(&ctrl->ctrl); in nvme_fc_error_recovery()
2511 __nvme_fc_abort_outstanding_ios(ctrl, true); in nvme_fc_error_recovery()
2512 dev_warn(ctrl->ctrl.device, in nvme_fc_error_recovery()
2514 ctrl->cnum); in nvme_fc_error_recovery()
2522 dev_warn(ctrl->ctrl.device, in nvme_fc_error_recovery()
2524 ctrl->cnum, errmsg); in nvme_fc_error_recovery()
2525 dev_warn(ctrl->ctrl.device, in nvme_fc_error_recovery()
2526 "NVME-FC{%d}: resetting controller\n", ctrl->cnum); in nvme_fc_error_recovery()
2528 nvme_reset_ctrl(&ctrl->ctrl); in nvme_fc_error_recovery()
2534 struct nvme_fc_ctrl *ctrl = op->ctrl; in nvme_fc_timeout() local
2543 dev_info(ctrl->ctrl.device, in nvme_fc_timeout()
2546 ctrl->cnum, qnum, sqe->common.opcode, sqe->fabrics.fctype, in nvme_fc_timeout()
2549 if (__nvme_fc_abort_op(ctrl, op)) in nvme_fc_timeout()
2550 nvme_fc_error_recovery(ctrl, "io timeout abort failed"); in nvme_fc_timeout()
2561 nvme_fc_map_data(struct nvme_fc_ctrl *ctrl, struct request *rq, in nvme_fc_map_data() argument
2581 freq->sg_cnt = fc_dma_map_sg(ctrl->lport->dev, freq->sg_table.sgl, in nvme_fc_map_data()
2596 nvme_fc_unmap_data(struct nvme_fc_ctrl *ctrl, struct request *rq, in nvme_fc_unmap_data() argument
2604 fc_dma_unmap_sg(ctrl->lport->dev, freq->sg_table.sgl, op->nents, in nvme_fc_unmap_data()
2636 nvme_fc_start_fcp_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue, in nvme_fc_start_fcp_op() argument
2648 if (ctrl->rport->remoteport.port_state != FC_OBJSTATE_ONLINE) in nvme_fc_start_fcp_op()
2651 if (!nvme_fc_ctrl_get(ctrl)) in nvme_fc_start_fcp_op()
2695 ret = nvme_fc_map_data(ctrl, op->rq, op); in nvme_fc_start_fcp_op()
2698 nvme_fc_ctrl_put(ctrl); in nvme_fc_start_fcp_op()
2705 fc_dma_sync_single_for_device(ctrl->lport->dev, op->fcp_req.cmddma, in nvme_fc_start_fcp_op()
2714 ret = ctrl->lport->ops->fcp_io(&ctrl->lport->localport, in nvme_fc_start_fcp_op()
2715 &ctrl->rport->remoteport, in nvme_fc_start_fcp_op()
2732 __nvme_fc_fcpop_chk_teardowns(ctrl, op, opstate); in nvme_fc_start_fcp_op()
2735 nvme_fc_unmap_data(ctrl, op->rq, op); in nvme_fc_start_fcp_op()
2739 nvme_fc_ctrl_put(ctrl); in nvme_fc_start_fcp_op()
2741 if (ctrl->rport->remoteport.port_state == FC_OBJSTATE_ONLINE && in nvme_fc_start_fcp_op()
2757 struct nvme_fc_ctrl *ctrl = queue->ctrl; in nvme_fc_queue_rq() local
2765 if (ctrl->rport->remoteport.port_state != FC_OBJSTATE_ONLINE || in nvme_fc_queue_rq()
2766 !nvme_check_ready(&queue->ctrl->ctrl, rq, queue_ready)) in nvme_fc_queue_rq()
2767 return nvme_fail_nonready_command(&queue->ctrl->ctrl, rq); in nvme_fc_queue_rq()
2791 return nvme_fc_start_fcp_op(ctrl, queue, op, data_len, io_dir); in nvme_fc_queue_rq()
2797 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(arg); in nvme_fc_submit_async_event() local
2801 if (test_bit(FCCTRL_TERMIO, &ctrl->flags)) in nvme_fc_submit_async_event()
2804 aen_op = &ctrl->aen_ops[0]; in nvme_fc_submit_async_event()
2806 ret = nvme_fc_start_fcp_op(ctrl, aen_op->queue, aen_op, 0, in nvme_fc_submit_async_event()
2809 dev_err(ctrl->ctrl.device, in nvme_fc_submit_async_event()
2817 struct nvme_fc_ctrl *ctrl = op->ctrl; in nvme_fc_complete_rq() local
2822 nvme_fc_unmap_data(ctrl, rq, op); in nvme_fc_complete_rq()
2824 nvme_fc_ctrl_put(ctrl); in nvme_fc_complete_rq()
2829 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(set->driver_data); in nvme_fc_map_queues() local
2841 if (ctrl->lport->ops->map_queues) in nvme_fc_map_queues()
2842 ctrl->lport->ops->map_queues(&ctrl->lport->localport, in nvme_fc_map_queues()
2860 nvme_fc_create_io_queues(struct nvme_fc_ctrl *ctrl) in nvme_fc_create_io_queues() argument
2862 struct nvmf_ctrl_options *opts = ctrl->ctrl.opts; in nvme_fc_create_io_queues()
2867 ctrl->lport->ops->max_hw_queues); in nvme_fc_create_io_queues()
2868 ret = nvme_set_queue_count(&ctrl->ctrl, &nr_io_queues); in nvme_fc_create_io_queues()
2870 dev_info(ctrl->ctrl.device, in nvme_fc_create_io_queues()
2875 ctrl->ctrl.queue_count = nr_io_queues + 1; in nvme_fc_create_io_queues()
2879 nvme_fc_init_io_queues(ctrl); in nvme_fc_create_io_queues()
2881 ret = nvme_alloc_io_tag_set(&ctrl->ctrl, &ctrl->tag_set, in nvme_fc_create_io_queues()
2884 ctrl->lport->ops->fcprqst_priv_sz)); in nvme_fc_create_io_queues()
2888 ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize + 1); in nvme_fc_create_io_queues()
2892 ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize + 1); in nvme_fc_create_io_queues()
2896 ctrl->ioq_live = true; in nvme_fc_create_io_queues()
2901 nvme_fc_delete_hw_io_queues(ctrl); in nvme_fc_create_io_queues()
2903 nvme_remove_io_tag_set(&ctrl->ctrl); in nvme_fc_create_io_queues()
2904 nvme_fc_free_io_queues(ctrl); in nvme_fc_create_io_queues()
2907 ctrl->ctrl.tagset = NULL; in nvme_fc_create_io_queues()
2913 nvme_fc_recreate_io_queues(struct nvme_fc_ctrl *ctrl) in nvme_fc_recreate_io_queues() argument
2915 struct nvmf_ctrl_options *opts = ctrl->ctrl.opts; in nvme_fc_recreate_io_queues()
2916 u32 prior_ioq_cnt = ctrl->ctrl.queue_count - 1; in nvme_fc_recreate_io_queues()
2921 ctrl->lport->ops->max_hw_queues); in nvme_fc_recreate_io_queues()
2922 ret = nvme_set_queue_count(&ctrl->ctrl, &nr_io_queues); in nvme_fc_recreate_io_queues()
2924 dev_info(ctrl->ctrl.device, in nvme_fc_recreate_io_queues()
2930 dev_info(ctrl->ctrl.device, in nvme_fc_recreate_io_queues()
2936 ctrl->ctrl.queue_count = nr_io_queues + 1; in nvme_fc_recreate_io_queues()
2938 if (ctrl->ctrl.queue_count == 1) in nvme_fc_recreate_io_queues()
2942 dev_info(ctrl->ctrl.device, in nvme_fc_recreate_io_queues()
2945 blk_mq_update_nr_hw_queues(&ctrl->tag_set, nr_io_queues); in nvme_fc_recreate_io_queues()
2948 ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize + 1); in nvme_fc_recreate_io_queues()
2952 ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize + 1); in nvme_fc_recreate_io_queues()
2959 nvme_fc_delete_hw_io_queues(ctrl); in nvme_fc_recreate_io_queues()
2961 nvme_fc_free_io_queues(ctrl); in nvme_fc_recreate_io_queues()
2985 nvme_fc_ctlr_active_on_rport(struct nvme_fc_ctrl *ctrl) in nvme_fc_ctlr_active_on_rport() argument
2987 struct nvme_fc_rport *rport = ctrl->rport; in nvme_fc_ctlr_active_on_rport()
2990 if (test_and_set_bit(ASSOC_ACTIVE, &ctrl->flags)) in nvme_fc_ctlr_active_on_rport()
3001 nvme_fc_ctlr_inactive_on_rport(struct nvme_fc_ctrl *ctrl) in nvme_fc_ctlr_inactive_on_rport() argument
3003 struct nvme_fc_rport *rport = ctrl->rport; in nvme_fc_ctlr_inactive_on_rport()
3007 /* clearing of ctrl->flags ASSOC_ACTIVE bit is in association delete */ in nvme_fc_ctlr_inactive_on_rport()
3024 nvme_fc_create_association(struct nvme_fc_ctrl *ctrl) in nvme_fc_create_association() argument
3026 struct nvmf_ctrl_options *opts = ctrl->ctrl.opts; in nvme_fc_create_association()
3031 ++ctrl->ctrl.nr_reconnects; in nvme_fc_create_association()
3033 spin_lock_irqsave(&ctrl->rport->lock, flags); in nvme_fc_create_association()
3034 if (ctrl->rport->remoteport.port_state != FC_OBJSTATE_ONLINE) { in nvme_fc_create_association()
3035 spin_unlock_irqrestore(&ctrl->rport->lock, flags); in nvme_fc_create_association()
3039 if (nvme_fc_ctlr_active_on_rport(ctrl)) { in nvme_fc_create_association()
3040 spin_unlock_irqrestore(&ctrl->rport->lock, flags); in nvme_fc_create_association()
3043 spin_unlock_irqrestore(&ctrl->rport->lock, flags); in nvme_fc_create_association()
3045 dev_info(ctrl->ctrl.device, in nvme_fc_create_association()
3048 ctrl->cnum, ctrl->lport->localport.port_name, in nvme_fc_create_association()
3049 ctrl->rport->remoteport.port_name, ctrl->ctrl.opts->subsysnqn); in nvme_fc_create_association()
3051 clear_bit(ASSOC_FAILED, &ctrl->flags); in nvme_fc_create_association()
3057 ret = __nvme_fc_create_hw_queue(ctrl, &ctrl->queues[0], 0, in nvme_fc_create_association()
3062 ret = nvme_fc_connect_admin_queue(ctrl, &ctrl->queues[0], in nvme_fc_create_association()
3067 ret = nvmf_connect_admin_queue(&ctrl->ctrl); in nvme_fc_create_association()
3071 set_bit(NVME_FC_Q_LIVE, &ctrl->queues[0].flags); in nvme_fc_create_association()
3076 * todo:- add code to check if ctrl attributes changed from in nvme_fc_create_association()
3080 ret = nvme_enable_ctrl(&ctrl->ctrl); in nvme_fc_create_association()
3081 if (!ret && test_bit(ASSOC_FAILED, &ctrl->flags)) in nvme_fc_create_association()
3086 ctrl->ctrl.max_segments = ctrl->lport->ops->max_sgl_segments; in nvme_fc_create_association()
3087 ctrl->ctrl.max_hw_sectors = ctrl->ctrl.max_segments << in nvme_fc_create_association()
3090 nvme_unquiesce_admin_queue(&ctrl->ctrl); in nvme_fc_create_association()
3092 ret = nvme_init_ctrl_finish(&ctrl->ctrl, false); in nvme_fc_create_association()
3095 if (test_bit(ASSOC_FAILED, &ctrl->flags)) { in nvme_fc_create_association()
3102 if (ctrl->ctrl.icdoff) { in nvme_fc_create_association()
3103 dev_err(ctrl->ctrl.device, "icdoff %d is not supported!\n", in nvme_fc_create_association()
3104 ctrl->ctrl.icdoff); in nvme_fc_create_association()
3110 if (!nvme_ctrl_sgl_supported(&ctrl->ctrl)) { in nvme_fc_create_association()
3111 dev_err(ctrl->ctrl.device, in nvme_fc_create_association()
3117 if (opts->queue_size > ctrl->ctrl.maxcmd) { in nvme_fc_create_association()
3119 dev_warn(ctrl->ctrl.device, in nvme_fc_create_association()
3120 "queue_size %zu > ctrl maxcmd %u, reducing " in nvme_fc_create_association()
3122 opts->queue_size, ctrl->ctrl.maxcmd); in nvme_fc_create_association()
3123 opts->queue_size = ctrl->ctrl.maxcmd; in nvme_fc_create_association()
3124 ctrl->ctrl.sqsize = opts->queue_size - 1; in nvme_fc_create_association()
3127 ret = nvme_fc_init_aen_ops(ctrl); in nvme_fc_create_association()
3135 if (ctrl->ctrl.queue_count > 1) { in nvme_fc_create_association()
3136 if (!ctrl->ioq_live) in nvme_fc_create_association()
3137 ret = nvme_fc_create_io_queues(ctrl); in nvme_fc_create_association()
3139 ret = nvme_fc_recreate_io_queues(ctrl); in nvme_fc_create_association()
3141 if (!ret && test_bit(ASSOC_FAILED, &ctrl->flags)) in nvme_fc_create_association()
3146 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE)) { in nvme_fc_create_association()
3151 ctrl->ctrl.nr_reconnects = 0; in nvme_fc_create_association()
3152 nvme_start_ctrl(&ctrl->ctrl); in nvme_fc_create_association()
3157 nvme_fc_term_aen_ops(ctrl); in nvme_fc_create_association()
3159 nvme_stop_keep_alive(&ctrl->ctrl); in nvme_fc_create_association()
3161 dev_warn(ctrl->ctrl.device, in nvme_fc_create_association()
3163 ctrl->cnum, ctrl->association_id, ret); in nvme_fc_create_association()
3165 nvme_fc_xmt_disconnect_assoc(ctrl); in nvme_fc_create_association()
3166 spin_lock_irqsave(&ctrl->lock, flags); in nvme_fc_create_association()
3167 ctrl->association_id = 0; in nvme_fc_create_association()
3168 disls = ctrl->rcv_disconn; in nvme_fc_create_association()
3169 ctrl->rcv_disconn = NULL; in nvme_fc_create_association()
3170 spin_unlock_irqrestore(&ctrl->lock, flags); in nvme_fc_create_association()
3174 __nvme_fc_delete_hw_queue(ctrl, &ctrl->queues[0], 0); in nvme_fc_create_association()
3176 nvme_fc_free_queue(&ctrl->queues[0]); in nvme_fc_create_association()
3177 clear_bit(ASSOC_ACTIVE, &ctrl->flags); in nvme_fc_create_association()
3178 nvme_fc_ctlr_inactive_on_rport(ctrl); in nvme_fc_create_association()
3191 nvme_fc_delete_association(struct nvme_fc_ctrl *ctrl) in nvme_fc_delete_association() argument
3196 if (!test_and_clear_bit(ASSOC_ACTIVE, &ctrl->flags)) in nvme_fc_delete_association()
3199 spin_lock_irqsave(&ctrl->lock, flags); in nvme_fc_delete_association()
3200 set_bit(FCCTRL_TERMIO, &ctrl->flags); in nvme_fc_delete_association()
3201 ctrl->iocnt = 0; in nvme_fc_delete_association()
3202 spin_unlock_irqrestore(&ctrl->lock, flags); in nvme_fc_delete_association()
3204 __nvme_fc_abort_outstanding_ios(ctrl, false); in nvme_fc_delete_association()
3207 nvme_fc_abort_aen_ops(ctrl); in nvme_fc_delete_association()
3210 spin_lock_irq(&ctrl->lock); in nvme_fc_delete_association()
3211 wait_event_lock_irq(ctrl->ioabort_wait, ctrl->iocnt == 0, ctrl->lock); in nvme_fc_delete_association()
3212 clear_bit(FCCTRL_TERMIO, &ctrl->flags); in nvme_fc_delete_association()
3213 spin_unlock_irq(&ctrl->lock); in nvme_fc_delete_association()
3215 nvme_fc_term_aen_ops(ctrl); in nvme_fc_delete_association()
3223 if (ctrl->association_id) in nvme_fc_delete_association()
3224 nvme_fc_xmt_disconnect_assoc(ctrl); in nvme_fc_delete_association()
3226 spin_lock_irqsave(&ctrl->lock, flags); in nvme_fc_delete_association()
3227 ctrl->association_id = 0; in nvme_fc_delete_association()
3228 disls = ctrl->rcv_disconn; in nvme_fc_delete_association()
3229 ctrl->rcv_disconn = NULL; in nvme_fc_delete_association()
3230 spin_unlock_irqrestore(&ctrl->lock, flags); in nvme_fc_delete_association()
3238 if (ctrl->ctrl.tagset) { in nvme_fc_delete_association()
3239 nvme_fc_delete_hw_io_queues(ctrl); in nvme_fc_delete_association()
3240 nvme_fc_free_io_queues(ctrl); in nvme_fc_delete_association()
3243 __nvme_fc_delete_hw_queue(ctrl, &ctrl->queues[0], 0); in nvme_fc_delete_association()
3244 nvme_fc_free_queue(&ctrl->queues[0]); in nvme_fc_delete_association()
3247 nvme_unquiesce_admin_queue(&ctrl->ctrl); in nvme_fc_delete_association()
3250 nvme_unquiesce_io_queues(&ctrl->ctrl); in nvme_fc_delete_association()
3252 nvme_fc_ctlr_inactive_on_rport(ctrl); in nvme_fc_delete_association()
3258 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl); in nvme_fc_delete_ctrl() local
3260 cancel_delayed_work_sync(&ctrl->connect_work); in nvme_fc_delete_ctrl()
3266 nvme_fc_delete_association(ctrl); in nvme_fc_delete_ctrl()
3267 cancel_work_sync(&ctrl->ioerr_work); in nvme_fc_delete_ctrl()
3269 if (ctrl->ctrl.tagset) in nvme_fc_delete_ctrl()
3270 nvme_remove_io_tag_set(&ctrl->ctrl); in nvme_fc_delete_ctrl()
3272 nvme_unquiesce_admin_queue(&ctrl->ctrl); in nvme_fc_delete_ctrl()
3273 nvme_remove_admin_tag_set(&ctrl->ctrl); in nvme_fc_delete_ctrl()
3277 nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status) in nvme_fc_reconnect_or_delete() argument
3279 struct nvme_fc_rport *rport = ctrl->rport; in nvme_fc_reconnect_or_delete()
3281 unsigned long recon_delay = ctrl->ctrl.opts->reconnect_delay * HZ; in nvme_fc_reconnect_or_delete()
3284 if (nvme_ctrl_state(&ctrl->ctrl) != NVME_CTRL_CONNECTING) in nvme_fc_reconnect_or_delete()
3288 dev_info(ctrl->ctrl.device, in nvme_fc_reconnect_or_delete()
3290 ctrl->cnum, status); in nvme_fc_reconnect_or_delete()
3294 if (recon && nvmf_should_reconnect(&ctrl->ctrl, status)) { in nvme_fc_reconnect_or_delete()
3296 dev_info(ctrl->ctrl.device, in nvme_fc_reconnect_or_delete()
3299 ctrl->cnum, recon_delay / HZ); in nvme_fc_reconnect_or_delete()
3303 queue_delayed_work(nvme_wq, &ctrl->connect_work, recon_delay); in nvme_fc_reconnect_or_delete()
3307 dev_warn(ctrl->ctrl.device, in nvme_fc_reconnect_or_delete()
3309 ctrl->cnum); in nvme_fc_reconnect_or_delete()
3311 dev_warn(ctrl->ctrl.device, in nvme_fc_reconnect_or_delete()
3314 ctrl->cnum, ctrl->ctrl.nr_reconnects); in nvme_fc_reconnect_or_delete()
3316 dev_warn(ctrl->ctrl.device, in nvme_fc_reconnect_or_delete()
3319 ctrl->cnum, min_t(int, portptr->dev_loss_tmo, in nvme_fc_reconnect_or_delete()
3320 (ctrl->ctrl.opts->max_reconnects * in nvme_fc_reconnect_or_delete()
3321 ctrl->ctrl.opts->reconnect_delay))); in nvme_fc_reconnect_or_delete()
3322 WARN_ON(nvme_delete_ctrl(&ctrl->ctrl)); in nvme_fc_reconnect_or_delete()
3329 struct nvme_fc_ctrl *ctrl = in nvme_fc_reset_ctrl_work() local
3330 container_of(work, struct nvme_fc_ctrl, ctrl.reset_work); in nvme_fc_reset_ctrl_work()
3332 nvme_stop_ctrl(&ctrl->ctrl); in nvme_fc_reset_ctrl_work()
3335 nvme_fc_delete_association(ctrl); in nvme_fc_reset_ctrl_work()
3337 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) in nvme_fc_reset_ctrl_work()
3338 dev_err(ctrl->ctrl.device, in nvme_fc_reset_ctrl_work()
3340 "to CONNECTING\n", ctrl->cnum); in nvme_fc_reset_ctrl_work()
3342 if (ctrl->rport->remoteport.port_state == FC_OBJSTATE_ONLINE) { in nvme_fc_reset_ctrl_work()
3343 if (!queue_delayed_work(nvme_wq, &ctrl->connect_work, 0)) { in nvme_fc_reset_ctrl_work()
3344 dev_err(ctrl->ctrl.device, in nvme_fc_reset_ctrl_work()
3346 "after reset\n", ctrl->cnum); in nvme_fc_reset_ctrl_work()
3348 flush_delayed_work(&ctrl->connect_work); in nvme_fc_reset_ctrl_work()
3351 nvme_fc_reconnect_or_delete(ctrl, -ENOTCONN); in nvme_fc_reset_ctrl_work()
3376 struct nvme_fc_ctrl *ctrl = in nvme_fc_connect_ctrl_work() local
3380 ret = nvme_fc_create_association(ctrl); in nvme_fc_connect_ctrl_work()
3382 nvme_fc_reconnect_or_delete(ctrl, ret); in nvme_fc_connect_ctrl_work()
3384 dev_info(ctrl->ctrl.device, in nvme_fc_connect_ctrl_work()
3386 ctrl->cnum); in nvme_fc_connect_ctrl_work()
3412 struct nvme_fc_ctrl *ctrl; in nvme_fc_existing_controller() local
3417 list_for_each_entry(ctrl, &rport->ctrl_list, ctrl_list) { in nvme_fc_existing_controller()
3418 found = nvmf_ctlr_matches_baseopts(&ctrl->ctrl, opts); in nvme_fc_existing_controller()
3431 struct nvme_fc_ctrl *ctrl; in nvme_fc_alloc_ctrl() local
3446 ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); in nvme_fc_alloc_ctrl()
3447 if (!ctrl) { in nvme_fc_alloc_ctrl()
3471 ctrl->ctrl.opts = opts; in nvme_fc_alloc_ctrl()
3472 ctrl->ctrl.nr_reconnects = 0; in nvme_fc_alloc_ctrl()
3473 INIT_LIST_HEAD(&ctrl->ctrl_list); in nvme_fc_alloc_ctrl()
3474 ctrl->lport = lport; in nvme_fc_alloc_ctrl()
3475 ctrl->rport = rport; in nvme_fc_alloc_ctrl()
3476 ctrl->dev = lport->dev; in nvme_fc_alloc_ctrl()
3477 ctrl->cnum = idx; in nvme_fc_alloc_ctrl()
3478 ctrl->ioq_live = false; in nvme_fc_alloc_ctrl()
3479 init_waitqueue_head(&ctrl->ioabort_wait); in nvme_fc_alloc_ctrl()
3481 get_device(ctrl->dev); in nvme_fc_alloc_ctrl()
3482 kref_init(&ctrl->ref); in nvme_fc_alloc_ctrl()
3484 INIT_WORK(&ctrl->ctrl.reset_work, nvme_fc_reset_ctrl_work); in nvme_fc_alloc_ctrl()
3485 INIT_DELAYED_WORK(&ctrl->connect_work, nvme_fc_connect_ctrl_work); in nvme_fc_alloc_ctrl()
3486 INIT_WORK(&ctrl->ioerr_work, nvme_fc_ctrl_ioerr_work); in nvme_fc_alloc_ctrl()
3487 spin_lock_init(&ctrl->lock); in nvme_fc_alloc_ctrl()
3490 ctrl->ctrl.queue_count = min_t(unsigned int, in nvme_fc_alloc_ctrl()
3493 ctrl->ctrl.queue_count++; /* +1 for admin queue */ in nvme_fc_alloc_ctrl()
3495 ctrl->ctrl.sqsize = opts->queue_size - 1; in nvme_fc_alloc_ctrl()
3496 ctrl->ctrl.kato = opts->kato; in nvme_fc_alloc_ctrl()
3497 ctrl->ctrl.cntlid = 0xffff; in nvme_fc_alloc_ctrl()
3500 ctrl->queues = kcalloc(ctrl->ctrl.queue_count, in nvme_fc_alloc_ctrl()
3502 if (!ctrl->queues) in nvme_fc_alloc_ctrl()
3505 nvme_fc_init_queue(ctrl, 0); in nvme_fc_alloc_ctrl()
3514 ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_fc_ctrl_ops, 0); in nvme_fc_alloc_ctrl()
3518 ctrl->ctrl.numa_node = dev_to_node(lport->dev); in nvme_fc_alloc_ctrl()
3520 return ctrl; in nvme_fc_alloc_ctrl()
3523 kfree(ctrl->queues); in nvme_fc_alloc_ctrl()
3525 put_device(ctrl->dev); in nvme_fc_alloc_ctrl()
3526 ida_free(&nvme_fc_ctrl_cnt, ctrl->cnum); in nvme_fc_alloc_ctrl()
3528 kfree(ctrl); in nvme_fc_alloc_ctrl()
3538 struct nvme_fc_ctrl *ctrl; in nvme_fc_init_ctrl() local
3542 ctrl = nvme_fc_alloc_ctrl(dev, opts, lport, rport); in nvme_fc_init_ctrl()
3543 if (IS_ERR(ctrl)) in nvme_fc_init_ctrl()
3544 return ERR_CAST(ctrl); in nvme_fc_init_ctrl()
3546 ret = nvme_add_ctrl(&ctrl->ctrl); in nvme_fc_init_ctrl()
3550 ret = nvme_alloc_admin_tag_set(&ctrl->ctrl, &ctrl->admin_tag_set, in nvme_fc_init_ctrl()
3553 ctrl->lport->ops->fcprqst_priv_sz)); in nvme_fc_init_ctrl()
3558 list_add_tail(&ctrl->ctrl_list, &rport->ctrl_list); in nvme_fc_init_ctrl()
3561 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) { in nvme_fc_init_ctrl()
3562 dev_err(ctrl->ctrl.device, in nvme_fc_init_ctrl()
3563 "NVME-FC{%d}: failed to init ctrl state\n", ctrl->cnum); in nvme_fc_init_ctrl()
3567 if (!queue_delayed_work(nvme_wq, &ctrl->connect_work, 0)) { in nvme_fc_init_ctrl()
3568 dev_err(ctrl->ctrl.device, in nvme_fc_init_ctrl()
3570 ctrl->cnum); in nvme_fc_init_ctrl()
3574 flush_delayed_work(&ctrl->connect_work); in nvme_fc_init_ctrl()
3576 dev_info(ctrl->ctrl.device, in nvme_fc_init_ctrl()
3577 "NVME-FC{%d}: new ctrl: NQN \"%s\", hostnqn: %s\n", in nvme_fc_init_ctrl()
3578 ctrl->cnum, nvmf_ctrl_subsysnqn(&ctrl->ctrl), opts->host->nqn); in nvme_fc_init_ctrl()
3580 return &ctrl->ctrl; in nvme_fc_init_ctrl()
3583 nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_DELETING); in nvme_fc_init_ctrl()
3584 cancel_work_sync(&ctrl->ioerr_work); in nvme_fc_init_ctrl()
3585 cancel_work_sync(&ctrl->ctrl.reset_work); in nvme_fc_init_ctrl()
3586 cancel_delayed_work_sync(&ctrl->connect_work); in nvme_fc_init_ctrl()
3588 ctrl->ctrl.opts = NULL; in nvme_fc_init_ctrl()
3590 /* initiate nvme ctrl ref counting teardown */ in nvme_fc_init_ctrl()
3591 nvme_uninit_ctrl(&ctrl->ctrl); in nvme_fc_init_ctrl()
3594 /* Remove core ctrl ref. */ in nvme_fc_init_ctrl()
3595 nvme_put_ctrl(&ctrl->ctrl); in nvme_fc_init_ctrl()
3679 struct nvme_ctrl *ctrl; in nvme_fc_create_ctrl() local
3713 ctrl = nvme_fc_init_ctrl(dev, opts, lport, rport); in nvme_fc_create_ctrl()
3714 if (IS_ERR(ctrl)) in nvme_fc_create_ctrl()
3716 return ctrl; in nvme_fc_create_ctrl()
3933 struct nvme_fc_ctrl *ctrl; in nvme_fc_delete_controllers() local
3936 list_for_each_entry(ctrl, &rport->ctrl_list, ctrl_list) { in nvme_fc_delete_controllers()
3937 dev_warn(ctrl->ctrl.device, in nvme_fc_delete_controllers()
3938 "NVME-FC{%d}: transport unloading: deleting ctrl\n", in nvme_fc_delete_controllers()
3939 ctrl->cnum); in nvme_fc_delete_controllers()
3940 nvme_delete_ctrl(&ctrl->ctrl); in nvme_fc_delete_controllers()