Lines Matching full:ctrl
35 struct nvme_fc_ctrl *ctrl; member
99 struct nvme_fc_ctrl *ctrl; member
178 struct nvme_ctrl ctrl; member
182 to_fc_ctrl(struct nvme_ctrl *ctrl) in to_fc_ctrl() argument
184 return container_of(ctrl, struct nvme_fc_ctrl, ctrl); in to_fc_ctrl()
556 nvme_fc_resume_controller(struct nvme_fc_ctrl *ctrl) in nvme_fc_resume_controller() argument
558 switch (ctrl->ctrl.state) { in nvme_fc_resume_controller()
565 dev_info(ctrl->ctrl.device, in nvme_fc_resume_controller()
567 "Attempting reconnect\n", ctrl->cnum); in nvme_fc_resume_controller()
569 queue_delayed_work(nvme_wq, &ctrl->connect_work, 0); in nvme_fc_resume_controller()
591 struct nvme_fc_ctrl *ctrl; in nvme_fc_attach_to_suspended_rport() local
627 list_for_each_entry(ctrl, &rport->ctrl_list, ctrl_list) in nvme_fc_attach_to_suspended_rport()
628 nvme_fc_resume_controller(ctrl); in nvme_fc_attach_to_suspended_rport()
788 nvme_fc_ctrl_connectivity_loss(struct nvme_fc_ctrl *ctrl) in nvme_fc_ctrl_connectivity_loss() argument
790 dev_info(ctrl->ctrl.device, in nvme_fc_ctrl_connectivity_loss()
792 "Reconnect", ctrl->cnum); in nvme_fc_ctrl_connectivity_loss()
794 switch (ctrl->ctrl.state) { in nvme_fc_ctrl_connectivity_loss()
804 if (nvme_reset_ctrl(&ctrl->ctrl)) { in nvme_fc_ctrl_connectivity_loss()
805 dev_warn(ctrl->ctrl.device, in nvme_fc_ctrl_connectivity_loss()
807 ctrl->cnum); in nvme_fc_ctrl_connectivity_loss()
808 nvme_delete_ctrl(&ctrl->ctrl); in nvme_fc_ctrl_connectivity_loss()
854 struct nvme_fc_ctrl *ctrl; in nvme_fc_unregister_remoteport() local
870 list_for_each_entry(ctrl, &rport->ctrl_list, ctrl_list) { in nvme_fc_unregister_remoteport()
873 dev_warn(ctrl->ctrl.device, in nvme_fc_unregister_remoteport()
875 ctrl->cnum); in nvme_fc_unregister_remoteport()
876 nvme_delete_ctrl(&ctrl->ctrl); in nvme_fc_unregister_remoteport()
878 nvme_fc_ctrl_connectivity_loss(ctrl); in nvme_fc_unregister_remoteport()
1033 static void nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl, char *errmsg);
1175 nvme_fc_connect_admin_queue(struct nvme_fc_ctrl *ctrl, in nvme_fc_connect_admin_queue() argument
1187 ctrl->lport->ops->lsrqst_priv_sz), GFP_KERNEL); in nvme_fc_connect_admin_queue()
1189 dev_info(ctrl->ctrl.device, in nvme_fc_connect_admin_queue()
1191 ctrl->cnum); in nvme_fc_connect_admin_queue()
1199 if (ctrl->lport->ops->lsrqst_priv_sz) in nvme_fc_connect_admin_queue()
1218 uuid_copy(&assoc_rqst->assoc_cmd.hostid, &ctrl->ctrl.opts->host->id); in nvme_fc_connect_admin_queue()
1219 strncpy(assoc_rqst->assoc_cmd.hostnqn, ctrl->ctrl.opts->host->nqn, in nvme_fc_connect_admin_queue()
1221 strncpy(assoc_rqst->assoc_cmd.subnqn, ctrl->ctrl.opts->subsysnqn, in nvme_fc_connect_admin_queue()
1231 ret = nvme_fc_send_ls_req(ctrl->rport, lsop); in nvme_fc_connect_admin_queue()
1268 dev_err(ctrl->dev, in nvme_fc_connect_admin_queue()
1272 spin_lock_irqsave(&ctrl->lock, flags); in nvme_fc_connect_admin_queue()
1273 ctrl->association_id = in nvme_fc_connect_admin_queue()
1278 spin_unlock_irqrestore(&ctrl->lock, flags); in nvme_fc_connect_admin_queue()
1285 dev_err(ctrl->dev, in nvme_fc_connect_admin_queue()
1292 nvme_fc_connect_queue(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue, in nvme_fc_connect_queue() argument
1303 ctrl->lport->ops->lsrqst_priv_sz), GFP_KERNEL); in nvme_fc_connect_queue()
1305 dev_info(ctrl->ctrl.device, in nvme_fc_connect_queue()
1307 ctrl->cnum); in nvme_fc_connect_queue()
1315 if (ctrl->lport->ops->lsrqst_priv_sz) in nvme_fc_connect_queue()
1329 conn_rqst->associd.association_id = cpu_to_be64(ctrl->association_id); in nvme_fc_connect_queue()
1346 ret = nvme_fc_send_ls_req(ctrl->rport, lsop); in nvme_fc_connect_queue()
1374 dev_err(ctrl->dev, in nvme_fc_connect_queue()
1387 dev_err(ctrl->dev, in nvme_fc_connect_queue()
1423 nvme_fc_xmt_disconnect_assoc(struct nvme_fc_ctrl *ctrl) in nvme_fc_xmt_disconnect_assoc() argument
1433 ctrl->lport->ops->lsrqst_priv_sz), GFP_KERNEL); in nvme_fc_xmt_disconnect_assoc()
1435 dev_info(ctrl->ctrl.device, in nvme_fc_xmt_disconnect_assoc()
1438 ctrl->cnum); in nvme_fc_xmt_disconnect_assoc()
1445 if (ctrl->lport->ops->lsrqst_priv_sz) in nvme_fc_xmt_disconnect_assoc()
1451 ctrl->association_id); in nvme_fc_xmt_disconnect_assoc()
1453 ret = nvme_fc_send_ls_req_async(ctrl->rport, lsop, in nvme_fc_xmt_disconnect_assoc()
1509 struct nvme_fc_ctrl *ctrl, *ret = NULL; in nvme_fc_match_disconn_ls() local
1516 list_for_each_entry(ctrl, &rport->ctrl_list, ctrl_list) { in nvme_fc_match_disconn_ls()
1517 if (!nvme_fc_ctrl_get(ctrl)) in nvme_fc_match_disconn_ls()
1519 spin_lock(&ctrl->lock); in nvme_fc_match_disconn_ls()
1520 if (association_id == ctrl->association_id) { in nvme_fc_match_disconn_ls()
1521 oldls = ctrl->rcv_disconn; in nvme_fc_match_disconn_ls()
1522 ctrl->rcv_disconn = lsop; in nvme_fc_match_disconn_ls()
1523 ret = ctrl; in nvme_fc_match_disconn_ls()
1525 spin_unlock(&ctrl->lock); in nvme_fc_match_disconn_ls()
1527 /* leave the ctrl get reference */ in nvme_fc_match_disconn_ls()
1529 nvme_fc_ctrl_put(ctrl); in nvme_fc_match_disconn_ls()
1538 "LS's received\n", ctrl->cnum); in nvme_fc_match_disconn_ls()
1564 struct nvme_fc_ctrl *ctrl = NULL; in nvme_fc_ls_disconnect_assoc() local
1572 ctrl = nvme_fc_match_disconn_ls(rport, lsop); in nvme_fc_ls_disconnect_assoc()
1573 if (!ctrl) in nvme_fc_ls_disconnect_assoc()
1606 nvme_fc_error_recovery(ctrl, "Disconnect Association LS received"); in nvme_fc_ls_disconnect_assoc()
1609 nvme_fc_ctrl_put(ctrl); in nvme_fc_ls_disconnect_assoc()
1810 /* *********************** NVME Ctrl Routines **************************** */
1813 __nvme_fc_exit_request(struct nvme_fc_ctrl *ctrl, in __nvme_fc_exit_request() argument
1816 fc_dma_unmap_single(ctrl->lport->dev, op->fcp_req.rspdma, in __nvme_fc_exit_request()
1818 fc_dma_unmap_single(ctrl->lport->dev, op->fcp_req.cmddma, in __nvme_fc_exit_request()
1834 __nvme_fc_abort_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_fcp_op *op) in __nvme_fc_abort_op() argument
1839 spin_lock_irqsave(&ctrl->lock, flags); in __nvme_fc_abort_op()
1843 else if (test_bit(FCCTRL_TERMIO, &ctrl->flags)) { in __nvme_fc_abort_op()
1845 ctrl->iocnt++; in __nvme_fc_abort_op()
1847 spin_unlock_irqrestore(&ctrl->lock, flags); in __nvme_fc_abort_op()
1852 ctrl->lport->ops->fcp_abort(&ctrl->lport->localport, in __nvme_fc_abort_op()
1853 &ctrl->rport->remoteport, in __nvme_fc_abort_op()
1861 nvme_fc_abort_aen_ops(struct nvme_fc_ctrl *ctrl) in nvme_fc_abort_aen_ops() argument
1863 struct nvme_fc_fcp_op *aen_op = ctrl->aen_ops; in nvme_fc_abort_aen_ops()
1871 __nvme_fc_abort_op(ctrl, aen_op); in nvme_fc_abort_aen_ops()
1875 __nvme_fc_fcpop_chk_teardowns(struct nvme_fc_ctrl *ctrl, in __nvme_fc_fcpop_chk_teardowns() argument
1881 spin_lock_irqsave(&ctrl->lock, flags); in __nvme_fc_fcpop_chk_teardowns()
1882 if (test_bit(FCCTRL_TERMIO, &ctrl->flags) && in __nvme_fc_fcpop_chk_teardowns()
1884 if (!--ctrl->iocnt) in __nvme_fc_fcpop_chk_teardowns()
1885 wake_up(&ctrl->ioabort_wait); in __nvme_fc_fcpop_chk_teardowns()
1887 spin_unlock_irqrestore(&ctrl->lock, flags); in __nvme_fc_fcpop_chk_teardowns()
1897 struct nvme_fc_ctrl *ctrl = op->ctrl; in nvme_fc_fcpio_done() local
1945 fc_dma_sync_single_for_cpu(ctrl->lport->dev, op->fcp_req.rspdma, in nvme_fc_fcpio_done()
1952 dev_info(ctrl->ctrl.device, in nvme_fc_fcpio_done()
1954 ctrl->cnum, freq->status); in nvme_fc_fcpio_done()
1984 dev_info(ctrl->ctrl.device, in nvme_fc_fcpio_done()
1987 ctrl->cnum, freq->transferred_length, in nvme_fc_fcpio_done()
2006 dev_info(ctrl->ctrl.device, in nvme_fc_fcpio_done()
2010 ctrl->cnum, be16_to_cpu(op->rsp_iu.iu_len), in nvme_fc_fcpio_done()
2024 dev_info(ctrl->ctrl.device, in nvme_fc_fcpio_done()
2027 ctrl->cnum, freq->rcv_rsplen); in nvme_fc_fcpio_done()
2035 nvme_complete_async_event(&queue->ctrl->ctrl, status, &result); in nvme_fc_fcpio_done()
2036 __nvme_fc_fcpop_chk_teardowns(ctrl, op, opstate); in nvme_fc_fcpio_done()
2039 nvme_fc_ctrl_put(ctrl); in nvme_fc_fcpio_done()
2043 __nvme_fc_fcpop_chk_teardowns(ctrl, op, opstate); in nvme_fc_fcpio_done()
2049 nvme_fc_error_recovery(ctrl, "transport detected io error"); in nvme_fc_fcpio_done()
2053 __nvme_fc_init_request(struct nvme_fc_ctrl *ctrl, in __nvme_fc_init_request() argument
2068 op->ctrl = ctrl; in __nvme_fc_init_request()
2082 op->fcp_req.cmddma = fc_dma_map_single(ctrl->lport->dev, in __nvme_fc_init_request()
2084 if (fc_dma_mapping_error(ctrl->lport->dev, op->fcp_req.cmddma)) { in __nvme_fc_init_request()
2085 dev_err(ctrl->dev, in __nvme_fc_init_request()
2091 op->fcp_req.rspdma = fc_dma_map_single(ctrl->lport->dev, in __nvme_fc_init_request()
2094 if (fc_dma_mapping_error(ctrl->lport->dev, op->fcp_req.rspdma)) { in __nvme_fc_init_request()
2095 dev_err(ctrl->dev, in __nvme_fc_init_request()
2109 struct nvme_fc_ctrl *ctrl = set->driver_data; in nvme_fc_init_request() local
2111 int queue_idx = (set == &ctrl->tag_set) ? hctx_idx + 1 : 0; in nvme_fc_init_request()
2112 struct nvme_fc_queue *queue = &ctrl->queues[queue_idx]; in nvme_fc_init_request()
2115 res = __nvme_fc_init_request(ctrl, queue, &op->op, rq, queue->rqcnt++); in nvme_fc_init_request()
2120 nvme_req(rq)->ctrl = &ctrl->ctrl; in nvme_fc_init_request()
2125 nvme_fc_init_aen_ops(struct nvme_fc_ctrl *ctrl) in nvme_fc_init_aen_ops() argument
2133 aen_op = ctrl->aen_ops; in nvme_fc_init_aen_ops()
2135 if (ctrl->lport->ops->fcprqst_priv_sz) { in nvme_fc_init_aen_ops()
2136 private = kzalloc(ctrl->lport->ops->fcprqst_priv_sz, in nvme_fc_init_aen_ops()
2144 ret = __nvme_fc_init_request(ctrl, &ctrl->queues[0], in nvme_fc_init_aen_ops()
2164 nvme_fc_term_aen_ops(struct nvme_fc_ctrl *ctrl) in nvme_fc_term_aen_ops() argument
2169 cancel_work_sync(&ctrl->ctrl.async_event_work); in nvme_fc_term_aen_ops()
2170 aen_op = ctrl->aen_ops; in nvme_fc_term_aen_ops()
2172 __nvme_fc_exit_request(ctrl, aen_op); in nvme_fc_term_aen_ops()
2180 __nvme_fc_init_hctx(struct blk_mq_hw_ctx *hctx, struct nvme_fc_ctrl *ctrl, in __nvme_fc_init_hctx() argument
2183 struct nvme_fc_queue *queue = &ctrl->queues[qidx]; in __nvme_fc_init_hctx()
2193 struct nvme_fc_ctrl *ctrl = data; in nvme_fc_init_hctx() local
2195 __nvme_fc_init_hctx(hctx, ctrl, hctx_idx + 1); in nvme_fc_init_hctx()
2204 struct nvme_fc_ctrl *ctrl = data; in nvme_fc_init_admin_hctx() local
2206 __nvme_fc_init_hctx(hctx, ctrl, hctx_idx); in nvme_fc_init_admin_hctx()
2212 nvme_fc_init_queue(struct nvme_fc_ctrl *ctrl, int idx) in nvme_fc_init_queue() argument
2216 queue = &ctrl->queues[idx]; in nvme_fc_init_queue()
2218 queue->ctrl = ctrl; in nvme_fc_init_queue()
2221 queue->dev = ctrl->dev; in nvme_fc_init_queue()
2224 queue->cmnd_capsule_len = ctrl->ctrl.ioccsz * 16; in nvme_fc_init_queue()
2266 __nvme_fc_delete_hw_queue(struct nvme_fc_ctrl *ctrl, in __nvme_fc_delete_hw_queue() argument
2269 if (ctrl->lport->ops->delete_queue) in __nvme_fc_delete_hw_queue()
2270 ctrl->lport->ops->delete_queue(&ctrl->lport->localport, qidx, in __nvme_fc_delete_hw_queue()
2276 nvme_fc_free_io_queues(struct nvme_fc_ctrl *ctrl) in nvme_fc_free_io_queues() argument
2280 for (i = 1; i < ctrl->ctrl.queue_count; i++) in nvme_fc_free_io_queues()
2281 nvme_fc_free_queue(&ctrl->queues[i]); in nvme_fc_free_io_queues()
2285 __nvme_fc_create_hw_queue(struct nvme_fc_ctrl *ctrl, in __nvme_fc_create_hw_queue() argument
2291 if (ctrl->lport->ops->create_queue) in __nvme_fc_create_hw_queue()
2292 ret = ctrl->lport->ops->create_queue(&ctrl->lport->localport, in __nvme_fc_create_hw_queue()
2299 nvme_fc_delete_hw_io_queues(struct nvme_fc_ctrl *ctrl) in nvme_fc_delete_hw_io_queues() argument
2301 struct nvme_fc_queue *queue = &ctrl->queues[ctrl->ctrl.queue_count - 1]; in nvme_fc_delete_hw_io_queues()
2304 for (i = ctrl->ctrl.queue_count - 1; i >= 1; i--, queue--) in nvme_fc_delete_hw_io_queues()
2305 __nvme_fc_delete_hw_queue(ctrl, queue, i); in nvme_fc_delete_hw_io_queues()
2309 nvme_fc_create_hw_io_queues(struct nvme_fc_ctrl *ctrl, u16 qsize) in nvme_fc_create_hw_io_queues() argument
2311 struct nvme_fc_queue *queue = &ctrl->queues[1]; in nvme_fc_create_hw_io_queues()
2314 for (i = 1; i < ctrl->ctrl.queue_count; i++, queue++) { in nvme_fc_create_hw_io_queues()
2315 ret = __nvme_fc_create_hw_queue(ctrl, queue, i, qsize); in nvme_fc_create_hw_io_queues()
2324 __nvme_fc_delete_hw_queue(ctrl, &ctrl->queues[i], i); in nvme_fc_create_hw_io_queues()
2329 nvme_fc_connect_io_queues(struct nvme_fc_ctrl *ctrl, u16 qsize) in nvme_fc_connect_io_queues() argument
2333 for (i = 1; i < ctrl->ctrl.queue_count; i++) { in nvme_fc_connect_io_queues()
2334 ret = nvme_fc_connect_queue(ctrl, &ctrl->queues[i], qsize, in nvme_fc_connect_io_queues()
2338 ret = nvmf_connect_io_queue(&ctrl->ctrl, i, false); in nvme_fc_connect_io_queues()
2342 set_bit(NVME_FC_Q_LIVE, &ctrl->queues[i].flags); in nvme_fc_connect_io_queues()
2349 nvme_fc_init_io_queues(struct nvme_fc_ctrl *ctrl) in nvme_fc_init_io_queues() argument
2353 for (i = 1; i < ctrl->ctrl.queue_count; i++) in nvme_fc_init_io_queues()
2354 nvme_fc_init_queue(ctrl, i); in nvme_fc_init_io_queues()
2360 struct nvme_fc_ctrl *ctrl = in nvme_fc_ctrl_free() local
2364 if (ctrl->ctrl.tagset) { in nvme_fc_ctrl_free()
2365 blk_cleanup_queue(ctrl->ctrl.connect_q); in nvme_fc_ctrl_free()
2366 blk_mq_free_tag_set(&ctrl->tag_set); in nvme_fc_ctrl_free()
2370 spin_lock_irqsave(&ctrl->rport->lock, flags); in nvme_fc_ctrl_free()
2371 list_del(&ctrl->ctrl_list); in nvme_fc_ctrl_free()
2372 spin_unlock_irqrestore(&ctrl->rport->lock, flags); in nvme_fc_ctrl_free()
2374 blk_mq_unquiesce_queue(ctrl->ctrl.admin_q); in nvme_fc_ctrl_free()
2375 blk_cleanup_queue(ctrl->ctrl.admin_q); in nvme_fc_ctrl_free()
2376 blk_cleanup_queue(ctrl->ctrl.fabrics_q); in nvme_fc_ctrl_free()
2377 blk_mq_free_tag_set(&ctrl->admin_tag_set); in nvme_fc_ctrl_free()
2379 kfree(ctrl->queues); in nvme_fc_ctrl_free()
2381 put_device(ctrl->dev); in nvme_fc_ctrl_free()
2382 nvme_fc_rport_put(ctrl->rport); in nvme_fc_ctrl_free()
2384 ida_simple_remove(&nvme_fc_ctrl_cnt, ctrl->cnum); in nvme_fc_ctrl_free()
2385 if (ctrl->ctrl.opts) in nvme_fc_ctrl_free()
2386 nvmf_free_options(ctrl->ctrl.opts); in nvme_fc_ctrl_free()
2387 kfree(ctrl); in nvme_fc_ctrl_free()
2391 nvme_fc_ctrl_put(struct nvme_fc_ctrl *ctrl) in nvme_fc_ctrl_put() argument
2393 kref_put(&ctrl->ref, nvme_fc_ctrl_free); in nvme_fc_ctrl_put()
2397 nvme_fc_ctrl_get(struct nvme_fc_ctrl *ctrl) in nvme_fc_ctrl_get() argument
2399 return kref_get_unless_zero(&ctrl->ref); in nvme_fc_ctrl_get()
2409 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl); in nvme_fc_nvme_ctrl_freed() local
2411 WARN_ON(nctrl != &ctrl->ctrl); in nvme_fc_nvme_ctrl_freed()
2413 nvme_fc_ctrl_put(ctrl); in nvme_fc_nvme_ctrl_freed()
2433 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl); in nvme_fc_terminate_exchange() local
2436 __nvme_fc_abort_op(ctrl, op); in nvme_fc_terminate_exchange()
2450 __nvme_fc_abort_outstanding_ios(struct nvme_fc_ctrl *ctrl, bool start_queues) in __nvme_fc_abort_outstanding_ios() argument
2464 if (ctrl->ctrl.queue_count > 1) { in __nvme_fc_abort_outstanding_ios()
2465 nvme_stop_queues(&ctrl->ctrl); in __nvme_fc_abort_outstanding_ios()
2466 blk_mq_tagset_busy_iter(&ctrl->tag_set, in __nvme_fc_abort_outstanding_ios()
2467 nvme_fc_terminate_exchange, &ctrl->ctrl); in __nvme_fc_abort_outstanding_ios()
2468 blk_mq_tagset_wait_completed_request(&ctrl->tag_set); in __nvme_fc_abort_outstanding_ios()
2470 nvme_start_queues(&ctrl->ctrl); in __nvme_fc_abort_outstanding_ios()
2488 blk_mq_quiesce_queue(ctrl->ctrl.admin_q); in __nvme_fc_abort_outstanding_ios()
2489 blk_mq_tagset_busy_iter(&ctrl->admin_tag_set, in __nvme_fc_abort_outstanding_ios()
2490 nvme_fc_terminate_exchange, &ctrl->ctrl); in __nvme_fc_abort_outstanding_ios()
2491 blk_mq_tagset_wait_completed_request(&ctrl->admin_tag_set); in __nvme_fc_abort_outstanding_ios()
2495 nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl, char *errmsg) in nvme_fc_error_recovery() argument
2504 if (ctrl->ctrl.state == NVME_CTRL_CONNECTING) { in nvme_fc_error_recovery()
2505 __nvme_fc_abort_outstanding_ios(ctrl, true); in nvme_fc_error_recovery()
2506 set_bit(ASSOC_FAILED, &ctrl->flags); in nvme_fc_error_recovery()
2511 if (ctrl->ctrl.state != NVME_CTRL_LIVE) in nvme_fc_error_recovery()
2514 dev_warn(ctrl->ctrl.device, in nvme_fc_error_recovery()
2516 ctrl->cnum, errmsg); in nvme_fc_error_recovery()
2517 dev_warn(ctrl->ctrl.device, in nvme_fc_error_recovery()
2518 "NVME-FC{%d}: resetting controller\n", ctrl->cnum); in nvme_fc_error_recovery()
2520 nvme_reset_ctrl(&ctrl->ctrl); in nvme_fc_error_recovery()
2527 struct nvme_fc_ctrl *ctrl = op->ctrl; in nvme_fc_timeout() local
2535 dev_info(ctrl->ctrl.device, in nvme_fc_timeout()
2538 ctrl->cnum, op->queue->qnum, sqe->common.opcode, in nvme_fc_timeout()
2540 if (__nvme_fc_abort_op(ctrl, op)) in nvme_fc_timeout()
2541 nvme_fc_error_recovery(ctrl, "io timeout abort failed"); in nvme_fc_timeout()
2552 nvme_fc_map_data(struct nvme_fc_ctrl *ctrl, struct request *rq, in nvme_fc_map_data() argument
2572 freq->sg_cnt = fc_dma_map_sg(ctrl->lport->dev, freq->sg_table.sgl, in nvme_fc_map_data()
2587 nvme_fc_unmap_data(struct nvme_fc_ctrl *ctrl, struct request *rq, in nvme_fc_unmap_data() argument
2595 fc_dma_unmap_sg(ctrl->lport->dev, freq->sg_table.sgl, op->nents, in nvme_fc_unmap_data()
2627 nvme_fc_start_fcp_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue, in nvme_fc_start_fcp_op() argument
2639 if (ctrl->rport->remoteport.port_state != FC_OBJSTATE_ONLINE) in nvme_fc_start_fcp_op()
2642 if (!nvme_fc_ctrl_get(ctrl)) in nvme_fc_start_fcp_op()
2686 ret = nvme_fc_map_data(ctrl, op->rq, op); in nvme_fc_start_fcp_op()
2689 nvme_fc_ctrl_put(ctrl); in nvme_fc_start_fcp_op()
2696 fc_dma_sync_single_for_device(ctrl->lport->dev, op->fcp_req.cmddma, in nvme_fc_start_fcp_op()
2705 ret = ctrl->lport->ops->fcp_io(&ctrl->lport->localport, in nvme_fc_start_fcp_op()
2706 &ctrl->rport->remoteport, in nvme_fc_start_fcp_op()
2723 __nvme_fc_fcpop_chk_teardowns(ctrl, op, opstate); in nvme_fc_start_fcp_op()
2726 nvme_fc_unmap_data(ctrl, op->rq, op); in nvme_fc_start_fcp_op()
2730 nvme_fc_ctrl_put(ctrl); in nvme_fc_start_fcp_op()
2732 if (ctrl->rport->remoteport.port_state == FC_OBJSTATE_ONLINE && in nvme_fc_start_fcp_op()
2748 struct nvme_fc_ctrl *ctrl = queue->ctrl; in nvme_fc_queue_rq() local
2758 if (ctrl->rport->remoteport.port_state != FC_OBJSTATE_ONLINE || in nvme_fc_queue_rq()
2759 !nvmf_check_ready(&queue->ctrl->ctrl, rq, queue_ready)) in nvme_fc_queue_rq()
2760 return nvmf_fail_nonready_command(&queue->ctrl->ctrl, rq); in nvme_fc_queue_rq()
2784 return nvme_fc_start_fcp_op(ctrl, queue, op, data_len, io_dir); in nvme_fc_queue_rq()
2790 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(arg); in nvme_fc_submit_async_event() local
2794 if (test_bit(FCCTRL_TERMIO, &ctrl->flags)) in nvme_fc_submit_async_event()
2797 aen_op = &ctrl->aen_ops[0]; in nvme_fc_submit_async_event()
2799 ret = nvme_fc_start_fcp_op(ctrl, aen_op->queue, aen_op, 0, in nvme_fc_submit_async_event()
2802 dev_err(ctrl->ctrl.device, in nvme_fc_submit_async_event()
2810 struct nvme_fc_ctrl *ctrl = op->ctrl; in nvme_fc_complete_rq() local
2815 nvme_fc_unmap_data(ctrl, rq, op); in nvme_fc_complete_rq()
2817 nvme_fc_ctrl_put(ctrl); in nvme_fc_complete_rq()
2831 nvme_fc_create_io_queues(struct nvme_fc_ctrl *ctrl) in nvme_fc_create_io_queues() argument
2833 struct nvmf_ctrl_options *opts = ctrl->ctrl.opts; in nvme_fc_create_io_queues()
2838 ctrl->lport->ops->max_hw_queues); in nvme_fc_create_io_queues()
2839 ret = nvme_set_queue_count(&ctrl->ctrl, &nr_io_queues); in nvme_fc_create_io_queues()
2841 dev_info(ctrl->ctrl.device, in nvme_fc_create_io_queues()
2846 ctrl->ctrl.queue_count = nr_io_queues + 1; in nvme_fc_create_io_queues()
2850 nvme_fc_init_io_queues(ctrl); in nvme_fc_create_io_queues()
2852 memset(&ctrl->tag_set, 0, sizeof(ctrl->tag_set)); in nvme_fc_create_io_queues()
2853 ctrl->tag_set.ops = &nvme_fc_mq_ops; in nvme_fc_create_io_queues()
2854 ctrl->tag_set.queue_depth = ctrl->ctrl.opts->queue_size; in nvme_fc_create_io_queues()
2855 ctrl->tag_set.reserved_tags = 1; /* fabric connect */ in nvme_fc_create_io_queues()
2856 ctrl->tag_set.numa_node = ctrl->ctrl.numa_node; in nvme_fc_create_io_queues()
2857 ctrl->tag_set.flags = BLK_MQ_F_SHOULD_MERGE; in nvme_fc_create_io_queues()
2858 ctrl->tag_set.cmd_size = in nvme_fc_create_io_queues()
2860 ctrl->lport->ops->fcprqst_priv_sz); in nvme_fc_create_io_queues()
2861 ctrl->tag_set.driver_data = ctrl; in nvme_fc_create_io_queues()
2862 ctrl->tag_set.nr_hw_queues = ctrl->ctrl.queue_count - 1; in nvme_fc_create_io_queues()
2863 ctrl->tag_set.timeout = NVME_IO_TIMEOUT; in nvme_fc_create_io_queues()
2865 ret = blk_mq_alloc_tag_set(&ctrl->tag_set); in nvme_fc_create_io_queues()
2869 ctrl->ctrl.tagset = &ctrl->tag_set; in nvme_fc_create_io_queues()
2871 ctrl->ctrl.connect_q = blk_mq_init_queue(&ctrl->tag_set); in nvme_fc_create_io_queues()
2872 if (IS_ERR(ctrl->ctrl.connect_q)) { in nvme_fc_create_io_queues()
2873 ret = PTR_ERR(ctrl->ctrl.connect_q); in nvme_fc_create_io_queues()
2877 ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize + 1); in nvme_fc_create_io_queues()
2881 ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize + 1); in nvme_fc_create_io_queues()
2885 ctrl->ioq_live = true; in nvme_fc_create_io_queues()
2890 nvme_fc_delete_hw_io_queues(ctrl); in nvme_fc_create_io_queues()
2892 blk_cleanup_queue(ctrl->ctrl.connect_q); in nvme_fc_create_io_queues()
2894 blk_mq_free_tag_set(&ctrl->tag_set); in nvme_fc_create_io_queues()
2895 nvme_fc_free_io_queues(ctrl); in nvme_fc_create_io_queues()
2898 ctrl->ctrl.tagset = NULL; in nvme_fc_create_io_queues()
2904 nvme_fc_recreate_io_queues(struct nvme_fc_ctrl *ctrl) in nvme_fc_recreate_io_queues() argument
2906 struct nvmf_ctrl_options *opts = ctrl->ctrl.opts; in nvme_fc_recreate_io_queues()
2907 u32 prior_ioq_cnt = ctrl->ctrl.queue_count - 1; in nvme_fc_recreate_io_queues()
2912 ctrl->lport->ops->max_hw_queues); in nvme_fc_recreate_io_queues()
2913 ret = nvme_set_queue_count(&ctrl->ctrl, &nr_io_queues); in nvme_fc_recreate_io_queues()
2915 dev_info(ctrl->ctrl.device, in nvme_fc_recreate_io_queues()
2921 dev_info(ctrl->ctrl.device, in nvme_fc_recreate_io_queues()
2927 ctrl->ctrl.queue_count = nr_io_queues + 1; in nvme_fc_recreate_io_queues()
2929 if (ctrl->ctrl.queue_count == 1) in nvme_fc_recreate_io_queues()
2932 ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize + 1); in nvme_fc_recreate_io_queues()
2936 ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize + 1); in nvme_fc_recreate_io_queues()
2941 dev_info(ctrl->ctrl.device, in nvme_fc_recreate_io_queues()
2944 nvme_wait_freeze(&ctrl->ctrl); 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()
2946 nvme_unfreeze(&ctrl->ctrl); in nvme_fc_recreate_io_queues()
2952 nvme_fc_delete_hw_io_queues(ctrl); in nvme_fc_recreate_io_queues()
2954 nvme_fc_free_io_queues(ctrl); in nvme_fc_recreate_io_queues()
2978 nvme_fc_ctlr_active_on_rport(struct nvme_fc_ctrl *ctrl) in nvme_fc_ctlr_active_on_rport() argument
2980 struct nvme_fc_rport *rport = ctrl->rport; in nvme_fc_ctlr_active_on_rport()
2983 if (test_and_set_bit(ASSOC_ACTIVE, &ctrl->flags)) in nvme_fc_ctlr_active_on_rport()
2994 nvme_fc_ctlr_inactive_on_rport(struct nvme_fc_ctrl *ctrl) in nvme_fc_ctlr_inactive_on_rport() argument
2996 struct nvme_fc_rport *rport = ctrl->rport; in nvme_fc_ctlr_inactive_on_rport()
3000 /* clearing of ctrl->flags ASSOC_ACTIVE bit is in association delete */ in nvme_fc_ctlr_inactive_on_rport()
3017 nvme_fc_create_association(struct nvme_fc_ctrl *ctrl) in nvme_fc_create_association() argument
3019 struct nvmf_ctrl_options *opts = ctrl->ctrl.opts; in nvme_fc_create_association()
3025 ++ctrl->ctrl.nr_reconnects; in nvme_fc_create_association()
3027 if (ctrl->rport->remoteport.port_state != FC_OBJSTATE_ONLINE) in nvme_fc_create_association()
3030 if (nvme_fc_ctlr_active_on_rport(ctrl)) in nvme_fc_create_association()
3033 dev_info(ctrl->ctrl.device, in nvme_fc_create_association()
3036 ctrl->cnum, ctrl->lport->localport.port_name, in nvme_fc_create_association()
3037 ctrl->rport->remoteport.port_name, ctrl->ctrl.opts->subsysnqn); in nvme_fc_create_association()
3039 clear_bit(ASSOC_FAILED, &ctrl->flags); in nvme_fc_create_association()
3045 ret = __nvme_fc_create_hw_queue(ctrl, &ctrl->queues[0], 0, in nvme_fc_create_association()
3050 ret = nvme_fc_connect_admin_queue(ctrl, &ctrl->queues[0], in nvme_fc_create_association()
3055 ret = nvmf_connect_admin_queue(&ctrl->ctrl); in nvme_fc_create_association()
3059 set_bit(NVME_FC_Q_LIVE, &ctrl->queues[0].flags); in nvme_fc_create_association()
3064 * todo:- add code to check if ctrl attributes changed from in nvme_fc_create_association()
3068 ret = nvme_enable_ctrl(&ctrl->ctrl); in nvme_fc_create_association()
3069 if (ret || test_bit(ASSOC_FAILED, &ctrl->flags)) in nvme_fc_create_association()
3072 ctrl->ctrl.max_segments = ctrl->lport->ops->max_sgl_segments; in nvme_fc_create_association()
3073 ctrl->ctrl.max_hw_sectors = ctrl->ctrl.max_segments << in nvme_fc_create_association()
3076 blk_mq_unquiesce_queue(ctrl->ctrl.admin_q); in nvme_fc_create_association()
3078 ret = nvme_init_identify(&ctrl->ctrl); in nvme_fc_create_association()
3079 if (ret || test_bit(ASSOC_FAILED, &ctrl->flags)) in nvme_fc_create_association()
3085 if (ctrl->ctrl.icdoff) { in nvme_fc_create_association()
3086 dev_err(ctrl->ctrl.device, "icdoff %d is not supported!\n", in nvme_fc_create_association()
3087 ctrl->ctrl.icdoff); in nvme_fc_create_association()
3093 if (opts->queue_size > ctrl->ctrl.maxcmd) { in nvme_fc_create_association()
3095 dev_warn(ctrl->ctrl.device, in nvme_fc_create_association()
3096 "queue_size %zu > ctrl maxcmd %u, reducing " in nvme_fc_create_association()
3098 opts->queue_size, ctrl->ctrl.maxcmd); in nvme_fc_create_association()
3099 opts->queue_size = ctrl->ctrl.maxcmd; in nvme_fc_create_association()
3102 if (opts->queue_size > ctrl->ctrl.sqsize + 1) { in nvme_fc_create_association()
3104 dev_warn(ctrl->ctrl.device, in nvme_fc_create_association()
3105 "queue_size %zu > ctrl sqsize %u, reducing " in nvme_fc_create_association()
3107 opts->queue_size, ctrl->ctrl.sqsize + 1); in nvme_fc_create_association()
3108 opts->queue_size = ctrl->ctrl.sqsize + 1; in nvme_fc_create_association()
3111 ret = nvme_fc_init_aen_ops(ctrl); in nvme_fc_create_association()
3119 if (ctrl->ctrl.queue_count > 1) { in nvme_fc_create_association()
3120 if (!ctrl->ioq_live) in nvme_fc_create_association()
3121 ret = nvme_fc_create_io_queues(ctrl); in nvme_fc_create_association()
3123 ret = nvme_fc_recreate_io_queues(ctrl); in nvme_fc_create_association()
3125 if (ret || test_bit(ASSOC_FAILED, &ctrl->flags)) in nvme_fc_create_association()
3128 changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE); in nvme_fc_create_association()
3130 ctrl->ctrl.nr_reconnects = 0; in nvme_fc_create_association()
3133 nvme_start_ctrl(&ctrl->ctrl); in nvme_fc_create_association()
3138 nvme_fc_term_aen_ops(ctrl); in nvme_fc_create_association()
3141 nvme_fc_xmt_disconnect_assoc(ctrl); in nvme_fc_create_association()
3142 spin_lock_irqsave(&ctrl->lock, flags); in nvme_fc_create_association()
3143 ctrl->association_id = 0; in nvme_fc_create_association()
3144 disls = ctrl->rcv_disconn; in nvme_fc_create_association()
3145 ctrl->rcv_disconn = NULL; in nvme_fc_create_association()
3146 spin_unlock_irqrestore(&ctrl->lock, flags); in nvme_fc_create_association()
3150 __nvme_fc_delete_hw_queue(ctrl, &ctrl->queues[0], 0); in nvme_fc_create_association()
3152 nvme_fc_free_queue(&ctrl->queues[0]); in nvme_fc_create_association()
3153 clear_bit(ASSOC_ACTIVE, &ctrl->flags); in nvme_fc_create_association()
3154 nvme_fc_ctlr_inactive_on_rport(ctrl); in nvme_fc_create_association()
3167 nvme_fc_delete_association(struct nvme_fc_ctrl *ctrl) in nvme_fc_delete_association() argument
3172 if (!test_and_clear_bit(ASSOC_ACTIVE, &ctrl->flags)) in nvme_fc_delete_association()
3175 spin_lock_irqsave(&ctrl->lock, flags); in nvme_fc_delete_association()
3176 set_bit(FCCTRL_TERMIO, &ctrl->flags); in nvme_fc_delete_association()
3177 ctrl->iocnt = 0; in nvme_fc_delete_association()
3178 spin_unlock_irqrestore(&ctrl->lock, flags); in nvme_fc_delete_association()
3180 __nvme_fc_abort_outstanding_ios(ctrl, false); in nvme_fc_delete_association()
3183 nvme_fc_abort_aen_ops(ctrl); in nvme_fc_delete_association()
3186 spin_lock_irq(&ctrl->lock); in nvme_fc_delete_association()
3187 wait_event_lock_irq(ctrl->ioabort_wait, ctrl->iocnt == 0, ctrl->lock); in nvme_fc_delete_association()
3188 clear_bit(FCCTRL_TERMIO, &ctrl->flags); in nvme_fc_delete_association()
3189 spin_unlock_irq(&ctrl->lock); in nvme_fc_delete_association()
3191 nvme_fc_term_aen_ops(ctrl); in nvme_fc_delete_association()
3199 if (ctrl->association_id) in nvme_fc_delete_association()
3200 nvme_fc_xmt_disconnect_assoc(ctrl); in nvme_fc_delete_association()
3202 spin_lock_irqsave(&ctrl->lock, flags); in nvme_fc_delete_association()
3203 ctrl->association_id = 0; in nvme_fc_delete_association()
3204 disls = ctrl->rcv_disconn; in nvme_fc_delete_association()
3205 ctrl->rcv_disconn = NULL; in nvme_fc_delete_association()
3206 spin_unlock_irqrestore(&ctrl->lock, flags); in nvme_fc_delete_association()
3214 if (ctrl->ctrl.tagset) { in nvme_fc_delete_association()
3215 nvme_fc_delete_hw_io_queues(ctrl); in nvme_fc_delete_association()
3216 nvme_fc_free_io_queues(ctrl); in nvme_fc_delete_association()
3219 __nvme_fc_delete_hw_queue(ctrl, &ctrl->queues[0], 0); in nvme_fc_delete_association()
3220 nvme_fc_free_queue(&ctrl->queues[0]); in nvme_fc_delete_association()
3223 blk_mq_unquiesce_queue(ctrl->ctrl.admin_q); in nvme_fc_delete_association()
3226 nvme_start_queues(&ctrl->ctrl); in nvme_fc_delete_association()
3228 nvme_fc_ctlr_inactive_on_rport(ctrl); in nvme_fc_delete_association()
3234 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl); in nvme_fc_delete_ctrl() local
3236 cancel_delayed_work_sync(&ctrl->connect_work); in nvme_fc_delete_ctrl()
3241 nvme_fc_delete_association(ctrl); in nvme_fc_delete_ctrl()
3245 nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status) in nvme_fc_reconnect_or_delete() argument
3247 struct nvme_fc_rport *rport = ctrl->rport; in nvme_fc_reconnect_or_delete()
3249 unsigned long recon_delay = ctrl->ctrl.opts->reconnect_delay * HZ; in nvme_fc_reconnect_or_delete()
3252 if (ctrl->ctrl.state != NVME_CTRL_CONNECTING) in nvme_fc_reconnect_or_delete()
3256 dev_info(ctrl->ctrl.device, in nvme_fc_reconnect_or_delete()
3258 ctrl->cnum, status); in nvme_fc_reconnect_or_delete()
3262 if (recon && nvmf_should_reconnect(&ctrl->ctrl)) { in nvme_fc_reconnect_or_delete()
3264 dev_info(ctrl->ctrl.device, in nvme_fc_reconnect_or_delete()
3267 ctrl->cnum, recon_delay / HZ); in nvme_fc_reconnect_or_delete()
3271 queue_delayed_work(nvme_wq, &ctrl->connect_work, recon_delay); in nvme_fc_reconnect_or_delete()
3274 dev_warn(ctrl->ctrl.device, in nvme_fc_reconnect_or_delete()
3277 ctrl->cnum, ctrl->ctrl.nr_reconnects); in nvme_fc_reconnect_or_delete()
3279 dev_warn(ctrl->ctrl.device, in nvme_fc_reconnect_or_delete()
3282 ctrl->cnum, min_t(int, portptr->dev_loss_tmo, in nvme_fc_reconnect_or_delete()
3283 (ctrl->ctrl.opts->max_reconnects * in nvme_fc_reconnect_or_delete()
3284 ctrl->ctrl.opts->reconnect_delay))); in nvme_fc_reconnect_or_delete()
3285 WARN_ON(nvme_delete_ctrl(&ctrl->ctrl)); in nvme_fc_reconnect_or_delete()
3292 struct nvme_fc_ctrl *ctrl = in nvme_fc_reset_ctrl_work() local
3293 container_of(work, struct nvme_fc_ctrl, ctrl.reset_work); in nvme_fc_reset_ctrl_work()
3295 nvme_stop_ctrl(&ctrl->ctrl); in nvme_fc_reset_ctrl_work()
3298 nvme_fc_delete_association(ctrl); in nvme_fc_reset_ctrl_work()
3300 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) in nvme_fc_reset_ctrl_work()
3301 dev_err(ctrl->ctrl.device, in nvme_fc_reset_ctrl_work()
3303 "to CONNECTING\n", ctrl->cnum); in nvme_fc_reset_ctrl_work()
3305 if (ctrl->rport->remoteport.port_state == FC_OBJSTATE_ONLINE) { in nvme_fc_reset_ctrl_work()
3306 if (!queue_delayed_work(nvme_wq, &ctrl->connect_work, 0)) { in nvme_fc_reset_ctrl_work()
3307 dev_err(ctrl->ctrl.device, in nvme_fc_reset_ctrl_work()
3309 "after reset\n", ctrl->cnum); in nvme_fc_reset_ctrl_work()
3311 flush_delayed_work(&ctrl->connect_work); in nvme_fc_reset_ctrl_work()
3314 nvme_fc_reconnect_or_delete(ctrl, -ENOTCONN); in nvme_fc_reset_ctrl_work()
3337 struct nvme_fc_ctrl *ctrl = in nvme_fc_connect_ctrl_work() local
3341 ret = nvme_fc_create_association(ctrl); in nvme_fc_connect_ctrl_work()
3343 nvme_fc_reconnect_or_delete(ctrl, ret); in nvme_fc_connect_ctrl_work()
3345 dev_info(ctrl->ctrl.device, in nvme_fc_connect_ctrl_work()
3347 ctrl->cnum); in nvme_fc_connect_ctrl_work()
3373 struct nvme_fc_ctrl *ctrl; in nvme_fc_existing_controller() local
3378 list_for_each_entry(ctrl, &rport->ctrl_list, ctrl_list) { in nvme_fc_existing_controller()
3379 found = nvmf_ctlr_matches_baseopts(&ctrl->ctrl, opts); in nvme_fc_existing_controller()
3392 struct nvme_fc_ctrl *ctrl; in nvme_fc_init_ctrl() local
3408 ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); in nvme_fc_init_ctrl()
3409 if (!ctrl) { in nvme_fc_init_ctrl()
3433 ctrl->ctrl.opts = opts; in nvme_fc_init_ctrl()
3434 ctrl->ctrl.nr_reconnects = 0; in nvme_fc_init_ctrl()
3436 ctrl->ctrl.numa_node = dev_to_node(lport->dev); in nvme_fc_init_ctrl()
3438 ctrl->ctrl.numa_node = NUMA_NO_NODE; in nvme_fc_init_ctrl()
3439 INIT_LIST_HEAD(&ctrl->ctrl_list); in nvme_fc_init_ctrl()
3440 ctrl->lport = lport; in nvme_fc_init_ctrl()
3441 ctrl->rport = rport; in nvme_fc_init_ctrl()
3442 ctrl->dev = lport->dev; in nvme_fc_init_ctrl()
3443 ctrl->cnum = idx; in nvme_fc_init_ctrl()
3444 ctrl->ioq_live = false; in nvme_fc_init_ctrl()
3445 init_waitqueue_head(&ctrl->ioabort_wait); in nvme_fc_init_ctrl()
3447 get_device(ctrl->dev); in nvme_fc_init_ctrl()
3448 kref_init(&ctrl->ref); in nvme_fc_init_ctrl()
3450 INIT_WORK(&ctrl->ctrl.reset_work, nvme_fc_reset_ctrl_work); in nvme_fc_init_ctrl()
3451 INIT_DELAYED_WORK(&ctrl->connect_work, nvme_fc_connect_ctrl_work); in nvme_fc_init_ctrl()
3452 spin_lock_init(&ctrl->lock); in nvme_fc_init_ctrl()
3455 ctrl->ctrl.queue_count = min_t(unsigned int, in nvme_fc_init_ctrl()
3458 ctrl->ctrl.queue_count++; /* +1 for admin queue */ in nvme_fc_init_ctrl()
3460 ctrl->ctrl.sqsize = opts->queue_size - 1; in nvme_fc_init_ctrl()
3461 ctrl->ctrl.kato = opts->kato; in nvme_fc_init_ctrl()
3462 ctrl->ctrl.cntlid = 0xffff; in nvme_fc_init_ctrl()
3465 ctrl->queues = kcalloc(ctrl->ctrl.queue_count, in nvme_fc_init_ctrl()
3467 if (!ctrl->queues) in nvme_fc_init_ctrl()
3470 nvme_fc_init_queue(ctrl, 0); in nvme_fc_init_ctrl()
3472 memset(&ctrl->admin_tag_set, 0, sizeof(ctrl->admin_tag_set)); in nvme_fc_init_ctrl()
3473 ctrl->admin_tag_set.ops = &nvme_fc_admin_mq_ops; in nvme_fc_init_ctrl()
3474 ctrl->admin_tag_set.queue_depth = NVME_AQ_MQ_TAG_DEPTH; in nvme_fc_init_ctrl()
3475 ctrl->admin_tag_set.reserved_tags = 2; /* fabric connect + Keep-Alive */ in nvme_fc_init_ctrl()
3476 ctrl->admin_tag_set.numa_node = ctrl->ctrl.numa_node; in nvme_fc_init_ctrl()
3477 ctrl->admin_tag_set.cmd_size = in nvme_fc_init_ctrl()
3479 ctrl->lport->ops->fcprqst_priv_sz); in nvme_fc_init_ctrl()
3480 ctrl->admin_tag_set.driver_data = ctrl; in nvme_fc_init_ctrl()
3481 ctrl->admin_tag_set.nr_hw_queues = 1; in nvme_fc_init_ctrl()
3482 ctrl->admin_tag_set.timeout = ADMIN_TIMEOUT; in nvme_fc_init_ctrl()
3483 ctrl->admin_tag_set.flags = BLK_MQ_F_NO_SCHED; in nvme_fc_init_ctrl()
3485 ret = blk_mq_alloc_tag_set(&ctrl->admin_tag_set); in nvme_fc_init_ctrl()
3488 ctrl->ctrl.admin_tagset = &ctrl->admin_tag_set; in nvme_fc_init_ctrl()
3490 ctrl->ctrl.fabrics_q = blk_mq_init_queue(&ctrl->admin_tag_set); in nvme_fc_init_ctrl()
3491 if (IS_ERR(ctrl->ctrl.fabrics_q)) { in nvme_fc_init_ctrl()
3492 ret = PTR_ERR(ctrl->ctrl.fabrics_q); in nvme_fc_init_ctrl()
3496 ctrl->ctrl.admin_q = blk_mq_init_queue(&ctrl->admin_tag_set); in nvme_fc_init_ctrl()
3497 if (IS_ERR(ctrl->ctrl.admin_q)) { in nvme_fc_init_ctrl()
3498 ret = PTR_ERR(ctrl->ctrl.admin_q); in nvme_fc_init_ctrl()
3509 ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_fc_ctrl_ops, 0); in nvme_fc_init_ctrl()
3513 /* at this point, teardown path changes to ref counting on nvme ctrl */ in nvme_fc_init_ctrl()
3516 list_add_tail(&ctrl->ctrl_list, &rport->ctrl_list); in nvme_fc_init_ctrl()
3519 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RESETTING) || in nvme_fc_init_ctrl()
3520 !nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) { in nvme_fc_init_ctrl()
3521 dev_err(ctrl->ctrl.device, in nvme_fc_init_ctrl()
3522 "NVME-FC{%d}: failed to init ctrl state\n", ctrl->cnum); in nvme_fc_init_ctrl()
3526 if (!queue_delayed_work(nvme_wq, &ctrl->connect_work, 0)) { in nvme_fc_init_ctrl()
3527 dev_err(ctrl->ctrl.device, in nvme_fc_init_ctrl()
3529 ctrl->cnum); in nvme_fc_init_ctrl()
3533 flush_delayed_work(&ctrl->connect_work); in nvme_fc_init_ctrl()
3535 dev_info(ctrl->ctrl.device, in nvme_fc_init_ctrl()
3536 "NVME-FC{%d}: new ctrl: NQN \"%s\"\n", in nvme_fc_init_ctrl()
3537 ctrl->cnum, ctrl->ctrl.opts->subsysnqn); in nvme_fc_init_ctrl()
3539 return &ctrl->ctrl; in nvme_fc_init_ctrl()
3542 nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_DELETING); in nvme_fc_init_ctrl()
3543 cancel_work_sync(&ctrl->ctrl.reset_work); in nvme_fc_init_ctrl()
3544 cancel_delayed_work_sync(&ctrl->connect_work); in nvme_fc_init_ctrl()
3546 ctrl->ctrl.opts = NULL; in nvme_fc_init_ctrl()
3548 /* initiate nvme ctrl ref counting teardown */ in nvme_fc_init_ctrl()
3549 nvme_uninit_ctrl(&ctrl->ctrl); in nvme_fc_init_ctrl()
3551 /* Remove core ctrl ref. */ in nvme_fc_init_ctrl()
3552 nvme_put_ctrl(&ctrl->ctrl); in nvme_fc_init_ctrl()
3566 blk_cleanup_queue(ctrl->ctrl.admin_q); in nvme_fc_init_ctrl()
3568 blk_cleanup_queue(ctrl->ctrl.fabrics_q); in nvme_fc_init_ctrl()
3570 blk_mq_free_tag_set(&ctrl->admin_tag_set); in nvme_fc_init_ctrl()
3572 kfree(ctrl->queues); in nvme_fc_init_ctrl()
3574 put_device(ctrl->dev); in nvme_fc_init_ctrl()
3575 ida_simple_remove(&nvme_fc_ctrl_cnt, ctrl->cnum); in nvme_fc_init_ctrl()
3577 kfree(ctrl); in nvme_fc_init_ctrl()
3654 struct nvme_ctrl *ctrl; in nvme_fc_create_ctrl() local
3688 ctrl = nvme_fc_init_ctrl(dev, opts, lport, rport); in nvme_fc_create_ctrl()
3689 if (IS_ERR(ctrl)) in nvme_fc_create_ctrl()
3691 return ctrl; in nvme_fc_create_ctrl()
3852 struct nvme_fc_ctrl *ctrl; in nvme_fc_delete_controllers() local
3855 list_for_each_entry(ctrl, &rport->ctrl_list, ctrl_list) { in nvme_fc_delete_controllers()
3856 dev_warn(ctrl->ctrl.device, in nvme_fc_delete_controllers()
3857 "NVME-FC{%d}: transport unloading: deleting ctrl\n", in nvme_fc_delete_controllers()
3858 ctrl->cnum); in nvme_fc_delete_controllers()
3859 nvme_delete_ctrl(&ctrl->ctrl); in nvme_fc_delete_controllers()
3892 pr_info("%s: ctrl deletes complete\n", __func__); in nvme_fc_exit_module()