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()
557 nvme_fc_resume_controller(struct nvme_fc_ctrl *ctrl) in nvme_fc_resume_controller() argument
559 switch (ctrl->ctrl.state) { in nvme_fc_resume_controller()
566 dev_info(ctrl->ctrl.device, in nvme_fc_resume_controller()
568 "Attempting reconnect\n", ctrl->cnum); in nvme_fc_resume_controller()
570 queue_delayed_work(nvme_wq, &ctrl->connect_work, 0); in nvme_fc_resume_controller()
592 struct nvme_fc_ctrl *ctrl; in nvme_fc_attach_to_suspended_rport() local
628 list_for_each_entry(ctrl, &rport->ctrl_list, ctrl_list) in nvme_fc_attach_to_suspended_rport()
629 nvme_fc_resume_controller(ctrl); in nvme_fc_attach_to_suspended_rport()
789 nvme_fc_ctrl_connectivity_loss(struct nvme_fc_ctrl *ctrl) in nvme_fc_ctrl_connectivity_loss() argument
791 dev_info(ctrl->ctrl.device, in nvme_fc_ctrl_connectivity_loss()
793 "Reconnect", ctrl->cnum); in nvme_fc_ctrl_connectivity_loss()
795 switch (ctrl->ctrl.state) { in nvme_fc_ctrl_connectivity_loss()
805 if (nvme_reset_ctrl(&ctrl->ctrl)) { in nvme_fc_ctrl_connectivity_loss()
806 dev_warn(ctrl->ctrl.device, in nvme_fc_ctrl_connectivity_loss()
808 ctrl->cnum); in nvme_fc_ctrl_connectivity_loss()
809 nvme_delete_ctrl(&ctrl->ctrl); in nvme_fc_ctrl_connectivity_loss()
855 struct nvme_fc_ctrl *ctrl; in nvme_fc_unregister_remoteport() local
871 list_for_each_entry(ctrl, &rport->ctrl_list, ctrl_list) { in nvme_fc_unregister_remoteport()
874 dev_warn(ctrl->ctrl.device, in nvme_fc_unregister_remoteport()
876 ctrl->cnum); in nvme_fc_unregister_remoteport()
877 nvme_delete_ctrl(&ctrl->ctrl); in nvme_fc_unregister_remoteport()
879 nvme_fc_ctrl_connectivity_loss(ctrl); in nvme_fc_unregister_remoteport()
1034 static void nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl, char *errmsg);
1176 nvme_fc_connect_admin_queue(struct nvme_fc_ctrl *ctrl, in nvme_fc_connect_admin_queue() argument
1188 ctrl->lport->ops->lsrqst_priv_sz), GFP_KERNEL); in nvme_fc_connect_admin_queue()
1190 dev_info(ctrl->ctrl.device, in nvme_fc_connect_admin_queue()
1192 ctrl->cnum); in nvme_fc_connect_admin_queue()
1200 if (ctrl->lport->ops->lsrqst_priv_sz) in nvme_fc_connect_admin_queue()
1219 uuid_copy(&assoc_rqst->assoc_cmd.hostid, &ctrl->ctrl.opts->host->id); in nvme_fc_connect_admin_queue()
1220 strncpy(assoc_rqst->assoc_cmd.hostnqn, ctrl->ctrl.opts->host->nqn, in nvme_fc_connect_admin_queue()
1222 strncpy(assoc_rqst->assoc_cmd.subnqn, ctrl->ctrl.opts->subsysnqn, in nvme_fc_connect_admin_queue()
1232 ret = nvme_fc_send_ls_req(ctrl->rport, lsop); in nvme_fc_connect_admin_queue()
1269 dev_err(ctrl->dev, in nvme_fc_connect_admin_queue()
1273 spin_lock_irqsave(&ctrl->lock, flags); in nvme_fc_connect_admin_queue()
1274 ctrl->association_id = in nvme_fc_connect_admin_queue()
1279 spin_unlock_irqrestore(&ctrl->lock, flags); in nvme_fc_connect_admin_queue()
1286 dev_err(ctrl->dev, in nvme_fc_connect_admin_queue()
1293 nvme_fc_connect_queue(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue, in nvme_fc_connect_queue() argument
1304 ctrl->lport->ops->lsrqst_priv_sz), GFP_KERNEL); in nvme_fc_connect_queue()
1306 dev_info(ctrl->ctrl.device, in nvme_fc_connect_queue()
1308 ctrl->cnum); in nvme_fc_connect_queue()
1316 if (ctrl->lport->ops->lsrqst_priv_sz) in nvme_fc_connect_queue()
1330 conn_rqst->associd.association_id = cpu_to_be64(ctrl->association_id); in nvme_fc_connect_queue()
1347 ret = nvme_fc_send_ls_req(ctrl->rport, lsop); in nvme_fc_connect_queue()
1375 dev_err(ctrl->dev, in nvme_fc_connect_queue()
1388 dev_err(ctrl->dev, in nvme_fc_connect_queue()
1424 nvme_fc_xmt_disconnect_assoc(struct nvme_fc_ctrl *ctrl) in nvme_fc_xmt_disconnect_assoc() argument
1434 ctrl->lport->ops->lsrqst_priv_sz), GFP_KERNEL); in nvme_fc_xmt_disconnect_assoc()
1436 dev_info(ctrl->ctrl.device, in nvme_fc_xmt_disconnect_assoc()
1439 ctrl->cnum); in nvme_fc_xmt_disconnect_assoc()
1446 if (ctrl->lport->ops->lsrqst_priv_sz) in nvme_fc_xmt_disconnect_assoc()
1452 ctrl->association_id); in nvme_fc_xmt_disconnect_assoc()
1454 ret = nvme_fc_send_ls_req_async(ctrl->rport, lsop, in nvme_fc_xmt_disconnect_assoc()
1510 struct nvme_fc_ctrl *ctrl, *ret = NULL; in nvme_fc_match_disconn_ls() local
1517 list_for_each_entry(ctrl, &rport->ctrl_list, ctrl_list) { in nvme_fc_match_disconn_ls()
1518 if (!nvme_fc_ctrl_get(ctrl)) in nvme_fc_match_disconn_ls()
1520 spin_lock(&ctrl->lock); in nvme_fc_match_disconn_ls()
1521 if (association_id == ctrl->association_id) { in nvme_fc_match_disconn_ls()
1522 oldls = ctrl->rcv_disconn; in nvme_fc_match_disconn_ls()
1523 ctrl->rcv_disconn = lsop; in nvme_fc_match_disconn_ls()
1524 ret = ctrl; in nvme_fc_match_disconn_ls()
1526 spin_unlock(&ctrl->lock); in nvme_fc_match_disconn_ls()
1528 /* leave the ctrl get reference */ in nvme_fc_match_disconn_ls()
1530 nvme_fc_ctrl_put(ctrl); in nvme_fc_match_disconn_ls()
1539 "LS's received\n", ctrl->cnum); in nvme_fc_match_disconn_ls()
1565 struct nvme_fc_ctrl *ctrl = NULL; in nvme_fc_ls_disconnect_assoc() local
1573 ctrl = nvme_fc_match_disconn_ls(rport, lsop); in nvme_fc_ls_disconnect_assoc()
1574 if (!ctrl) in nvme_fc_ls_disconnect_assoc()
1607 nvme_fc_error_recovery(ctrl, "Disconnect Association LS received"); in nvme_fc_ls_disconnect_assoc()
1610 nvme_fc_ctrl_put(ctrl); in nvme_fc_ls_disconnect_assoc()
1811 /* *********************** NVME Ctrl Routines **************************** */
1814 __nvme_fc_exit_request(struct nvme_fc_ctrl *ctrl, in __nvme_fc_exit_request() argument
1817 fc_dma_unmap_single(ctrl->lport->dev, op->fcp_req.rspdma, in __nvme_fc_exit_request()
1819 fc_dma_unmap_single(ctrl->lport->dev, op->fcp_req.cmddma, in __nvme_fc_exit_request()
1835 __nvme_fc_abort_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_fcp_op *op) in __nvme_fc_abort_op() argument
1840 spin_lock_irqsave(&ctrl->lock, flags); in __nvme_fc_abort_op()
1844 else if (test_bit(FCCTRL_TERMIO, &ctrl->flags)) { in __nvme_fc_abort_op()
1846 ctrl->iocnt++; in __nvme_fc_abort_op()
1848 spin_unlock_irqrestore(&ctrl->lock, flags); in __nvme_fc_abort_op()
1853 ctrl->lport->ops->fcp_abort(&ctrl->lport->localport, in __nvme_fc_abort_op()
1854 &ctrl->rport->remoteport, in __nvme_fc_abort_op()
1862 nvme_fc_abort_aen_ops(struct nvme_fc_ctrl *ctrl) in nvme_fc_abort_aen_ops() argument
1864 struct nvme_fc_fcp_op *aen_op = ctrl->aen_ops; in nvme_fc_abort_aen_ops()
1872 __nvme_fc_abort_op(ctrl, aen_op); in nvme_fc_abort_aen_ops()
1876 __nvme_fc_fcpop_chk_teardowns(struct nvme_fc_ctrl *ctrl, in __nvme_fc_fcpop_chk_teardowns() argument
1882 spin_lock_irqsave(&ctrl->lock, flags); in __nvme_fc_fcpop_chk_teardowns()
1883 if (test_bit(FCCTRL_TERMIO, &ctrl->flags) && in __nvme_fc_fcpop_chk_teardowns()
1885 if (!--ctrl->iocnt) in __nvme_fc_fcpop_chk_teardowns()
1886 wake_up(&ctrl->ioabort_wait); in __nvme_fc_fcpop_chk_teardowns()
1888 spin_unlock_irqrestore(&ctrl->lock, flags); in __nvme_fc_fcpop_chk_teardowns()
1895 struct nvme_fc_ctrl *ctrl = in nvme_fc_ctrl_ioerr_work() local
1898 nvme_fc_error_recovery(ctrl, "transport detected io error"); in nvme_fc_ctrl_ioerr_work()
1907 struct nvme_fc_ctrl *ctrl = op->ctrl; in nvme_fc_fcpio_done() local
1955 fc_dma_sync_single_for_cpu(ctrl->lport->dev, op->fcp_req.rspdma, in nvme_fc_fcpio_done()
1962 dev_info(ctrl->ctrl.device, in nvme_fc_fcpio_done()
1964 ctrl->cnum, freq->status); in nvme_fc_fcpio_done()
1994 dev_info(ctrl->ctrl.device, in nvme_fc_fcpio_done()
1997 ctrl->cnum, freq->transferred_length, in nvme_fc_fcpio_done()
2016 dev_info(ctrl->ctrl.device, in nvme_fc_fcpio_done()
2020 ctrl->cnum, be16_to_cpu(op->rsp_iu.iu_len), in nvme_fc_fcpio_done()
2034 dev_info(ctrl->ctrl.device, in nvme_fc_fcpio_done()
2037 ctrl->cnum, freq->rcv_rsplen); in nvme_fc_fcpio_done()
2045 nvme_complete_async_event(&queue->ctrl->ctrl, status, &result); in nvme_fc_fcpio_done()
2046 __nvme_fc_fcpop_chk_teardowns(ctrl, op, opstate); in nvme_fc_fcpio_done()
2049 nvme_fc_ctrl_put(ctrl); in nvme_fc_fcpio_done()
2053 __nvme_fc_fcpop_chk_teardowns(ctrl, op, opstate); in nvme_fc_fcpio_done()
2058 if (terminate_assoc && ctrl->ctrl.state != NVME_CTRL_RESETTING) in nvme_fc_fcpio_done()
2059 queue_work(nvme_reset_wq, &ctrl->ioerr_work); in nvme_fc_fcpio_done()
2063 __nvme_fc_init_request(struct nvme_fc_ctrl *ctrl, in __nvme_fc_init_request() argument
2078 op->ctrl = ctrl; in __nvme_fc_init_request()
2092 op->fcp_req.cmddma = fc_dma_map_single(ctrl->lport->dev, in __nvme_fc_init_request()
2094 if (fc_dma_mapping_error(ctrl->lport->dev, op->fcp_req.cmddma)) { in __nvme_fc_init_request()
2095 dev_err(ctrl->dev, in __nvme_fc_init_request()
2101 op->fcp_req.rspdma = fc_dma_map_single(ctrl->lport->dev, in __nvme_fc_init_request()
2104 if (fc_dma_mapping_error(ctrl->lport->dev, op->fcp_req.rspdma)) { in __nvme_fc_init_request()
2105 dev_err(ctrl->dev, in __nvme_fc_init_request()
2119 struct nvme_fc_ctrl *ctrl = set->driver_data; in nvme_fc_init_request() local
2121 int queue_idx = (set == &ctrl->tag_set) ? hctx_idx + 1 : 0; in nvme_fc_init_request()
2122 struct nvme_fc_queue *queue = &ctrl->queues[queue_idx]; in nvme_fc_init_request()
2125 res = __nvme_fc_init_request(ctrl, queue, &op->op, rq, queue->rqcnt++); in nvme_fc_init_request()
2130 nvme_req(rq)->ctrl = &ctrl->ctrl; in nvme_fc_init_request()
2136 nvme_fc_init_aen_ops(struct nvme_fc_ctrl *ctrl) in nvme_fc_init_aen_ops() argument
2144 aen_op = ctrl->aen_ops; in nvme_fc_init_aen_ops()
2146 if (ctrl->lport->ops->fcprqst_priv_sz) { in nvme_fc_init_aen_ops()
2147 private = kzalloc(ctrl->lport->ops->fcprqst_priv_sz, in nvme_fc_init_aen_ops()
2155 ret = __nvme_fc_init_request(ctrl, &ctrl->queues[0], in nvme_fc_init_aen_ops()
2175 nvme_fc_term_aen_ops(struct nvme_fc_ctrl *ctrl) in nvme_fc_term_aen_ops() argument
2180 cancel_work_sync(&ctrl->ctrl.async_event_work); in nvme_fc_term_aen_ops()
2181 aen_op = ctrl->aen_ops; in nvme_fc_term_aen_ops()
2183 __nvme_fc_exit_request(ctrl, aen_op); in nvme_fc_term_aen_ops()
2191 __nvme_fc_init_hctx(struct blk_mq_hw_ctx *hctx, struct nvme_fc_ctrl *ctrl, in __nvme_fc_init_hctx() argument
2194 struct nvme_fc_queue *queue = &ctrl->queues[qidx]; in __nvme_fc_init_hctx()
2204 struct nvme_fc_ctrl *ctrl = data; in nvme_fc_init_hctx() local
2206 __nvme_fc_init_hctx(hctx, ctrl, hctx_idx + 1); in nvme_fc_init_hctx()
2215 struct nvme_fc_ctrl *ctrl = data; in nvme_fc_init_admin_hctx() local
2217 __nvme_fc_init_hctx(hctx, ctrl, hctx_idx); in nvme_fc_init_admin_hctx()
2223 nvme_fc_init_queue(struct nvme_fc_ctrl *ctrl, int idx) in nvme_fc_init_queue() argument
2227 queue = &ctrl->queues[idx]; in nvme_fc_init_queue()
2229 queue->ctrl = ctrl; in nvme_fc_init_queue()
2232 queue->dev = ctrl->dev; in nvme_fc_init_queue()
2235 queue->cmnd_capsule_len = ctrl->ctrl.ioccsz * 16; in nvme_fc_init_queue()
2277 __nvme_fc_delete_hw_queue(struct nvme_fc_ctrl *ctrl, in __nvme_fc_delete_hw_queue() argument
2280 if (ctrl->lport->ops->delete_queue) in __nvme_fc_delete_hw_queue()
2281 ctrl->lport->ops->delete_queue(&ctrl->lport->localport, qidx, in __nvme_fc_delete_hw_queue()
2287 nvme_fc_free_io_queues(struct nvme_fc_ctrl *ctrl) in nvme_fc_free_io_queues() argument
2291 for (i = 1; i < ctrl->ctrl.queue_count; i++) in nvme_fc_free_io_queues()
2292 nvme_fc_free_queue(&ctrl->queues[i]); in nvme_fc_free_io_queues()
2296 __nvme_fc_create_hw_queue(struct nvme_fc_ctrl *ctrl, in __nvme_fc_create_hw_queue() argument
2302 if (ctrl->lport->ops->create_queue) in __nvme_fc_create_hw_queue()
2303 ret = ctrl->lport->ops->create_queue(&ctrl->lport->localport, in __nvme_fc_create_hw_queue()
2310 nvme_fc_delete_hw_io_queues(struct nvme_fc_ctrl *ctrl) in nvme_fc_delete_hw_io_queues() argument
2312 struct nvme_fc_queue *queue = &ctrl->queues[ctrl->ctrl.queue_count - 1]; in nvme_fc_delete_hw_io_queues()
2315 for (i = ctrl->ctrl.queue_count - 1; i >= 1; i--, queue--) in nvme_fc_delete_hw_io_queues()
2316 __nvme_fc_delete_hw_queue(ctrl, queue, i); in nvme_fc_delete_hw_io_queues()
2320 nvme_fc_create_hw_io_queues(struct nvme_fc_ctrl *ctrl, u16 qsize) in nvme_fc_create_hw_io_queues() argument
2322 struct nvme_fc_queue *queue = &ctrl->queues[1]; in nvme_fc_create_hw_io_queues()
2325 for (i = 1; i < ctrl->ctrl.queue_count; i++, queue++) { in nvme_fc_create_hw_io_queues()
2326 ret = __nvme_fc_create_hw_queue(ctrl, queue, i, qsize); in nvme_fc_create_hw_io_queues()
2335 __nvme_fc_delete_hw_queue(ctrl, &ctrl->queues[i], i); in nvme_fc_create_hw_io_queues()
2340 nvme_fc_connect_io_queues(struct nvme_fc_ctrl *ctrl, u16 qsize) in nvme_fc_connect_io_queues() argument
2344 for (i = 1; i < ctrl->ctrl.queue_count; i++) { in nvme_fc_connect_io_queues()
2345 ret = nvme_fc_connect_queue(ctrl, &ctrl->queues[i], qsize, in nvme_fc_connect_io_queues()
2349 ret = nvmf_connect_io_queue(&ctrl->ctrl, i); in nvme_fc_connect_io_queues()
2353 set_bit(NVME_FC_Q_LIVE, &ctrl->queues[i].flags); in nvme_fc_connect_io_queues()
2360 nvme_fc_init_io_queues(struct nvme_fc_ctrl *ctrl) in nvme_fc_init_io_queues() argument
2364 for (i = 1; i < ctrl->ctrl.queue_count; i++) in nvme_fc_init_io_queues()
2365 nvme_fc_init_queue(ctrl, i); in nvme_fc_init_io_queues()
2371 struct nvme_fc_ctrl *ctrl = in nvme_fc_ctrl_free() local
2375 if (ctrl->ctrl.tagset) { in nvme_fc_ctrl_free()
2376 blk_cleanup_queue(ctrl->ctrl.connect_q); in nvme_fc_ctrl_free()
2377 blk_mq_free_tag_set(&ctrl->tag_set); in nvme_fc_ctrl_free()
2381 spin_lock_irqsave(&ctrl->rport->lock, flags); in nvme_fc_ctrl_free()
2382 list_del(&ctrl->ctrl_list); in nvme_fc_ctrl_free()
2383 spin_unlock_irqrestore(&ctrl->rport->lock, flags); in nvme_fc_ctrl_free()
2385 blk_mq_unquiesce_queue(ctrl->ctrl.admin_q); in nvme_fc_ctrl_free()
2386 blk_cleanup_queue(ctrl->ctrl.admin_q); in nvme_fc_ctrl_free()
2387 blk_cleanup_queue(ctrl->ctrl.fabrics_q); in nvme_fc_ctrl_free()
2388 blk_mq_free_tag_set(&ctrl->admin_tag_set); in nvme_fc_ctrl_free()
2390 kfree(ctrl->queues); in nvme_fc_ctrl_free()
2392 put_device(ctrl->dev); in nvme_fc_ctrl_free()
2393 nvme_fc_rport_put(ctrl->rport); in nvme_fc_ctrl_free()
2395 ida_simple_remove(&nvme_fc_ctrl_cnt, ctrl->cnum); in nvme_fc_ctrl_free()
2396 if (ctrl->ctrl.opts) in nvme_fc_ctrl_free()
2397 nvmf_free_options(ctrl->ctrl.opts); in nvme_fc_ctrl_free()
2398 kfree(ctrl); in nvme_fc_ctrl_free()
2402 nvme_fc_ctrl_put(struct nvme_fc_ctrl *ctrl) in nvme_fc_ctrl_put() argument
2404 kref_put(&ctrl->ref, nvme_fc_ctrl_free); in nvme_fc_ctrl_put()
2408 nvme_fc_ctrl_get(struct nvme_fc_ctrl *ctrl) in nvme_fc_ctrl_get() argument
2410 return kref_get_unless_zero(&ctrl->ref); in nvme_fc_ctrl_get()
2420 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl); in nvme_fc_nvme_ctrl_freed() local
2422 WARN_ON(nctrl != &ctrl->ctrl); in nvme_fc_nvme_ctrl_freed()
2424 nvme_fc_ctrl_put(ctrl); in nvme_fc_nvme_ctrl_freed()
2444 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl); in nvme_fc_terminate_exchange() local
2448 __nvme_fc_abort_op(ctrl, op); in nvme_fc_terminate_exchange()
2462 __nvme_fc_abort_outstanding_ios(struct nvme_fc_ctrl *ctrl, bool start_queues) in __nvme_fc_abort_outstanding_ios() argument
2470 if (ctrl->ctrl.queue_count > 1) { in __nvme_fc_abort_outstanding_ios()
2471 for (q = 1; q < ctrl->ctrl.queue_count; q++) in __nvme_fc_abort_outstanding_ios()
2472 clear_bit(NVME_FC_Q_LIVE, &ctrl->queues[q].flags); in __nvme_fc_abort_outstanding_ios()
2474 clear_bit(NVME_FC_Q_LIVE, &ctrl->queues[0].flags); in __nvme_fc_abort_outstanding_ios()
2488 if (ctrl->ctrl.queue_count > 1) { in __nvme_fc_abort_outstanding_ios()
2489 nvme_stop_queues(&ctrl->ctrl); in __nvme_fc_abort_outstanding_ios()
2490 nvme_sync_io_queues(&ctrl->ctrl); in __nvme_fc_abort_outstanding_ios()
2491 blk_mq_tagset_busy_iter(&ctrl->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->tag_set); in __nvme_fc_abort_outstanding_ios()
2495 nvme_start_queues(&ctrl->ctrl); in __nvme_fc_abort_outstanding_ios()
2513 blk_mq_quiesce_queue(ctrl->ctrl.admin_q); in __nvme_fc_abort_outstanding_ios()
2514 blk_sync_queue(ctrl->ctrl.admin_q); in __nvme_fc_abort_outstanding_ios()
2515 blk_mq_tagset_busy_iter(&ctrl->admin_tag_set, in __nvme_fc_abort_outstanding_ios()
2516 nvme_fc_terminate_exchange, &ctrl->ctrl); in __nvme_fc_abort_outstanding_ios()
2517 blk_mq_tagset_wait_completed_request(&ctrl->admin_tag_set); in __nvme_fc_abort_outstanding_ios()
2521 nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl, char *errmsg) in nvme_fc_error_recovery() argument
2530 if (ctrl->ctrl.state == NVME_CTRL_CONNECTING) { in nvme_fc_error_recovery()
2531 __nvme_fc_abort_outstanding_ios(ctrl, true); in nvme_fc_error_recovery()
2532 set_bit(ASSOC_FAILED, &ctrl->flags); in nvme_fc_error_recovery()
2537 if (ctrl->ctrl.state != NVME_CTRL_LIVE) in nvme_fc_error_recovery()
2540 dev_warn(ctrl->ctrl.device, in nvme_fc_error_recovery()
2542 ctrl->cnum, errmsg); in nvme_fc_error_recovery()
2543 dev_warn(ctrl->ctrl.device, in nvme_fc_error_recovery()
2544 "NVME-FC{%d}: resetting controller\n", ctrl->cnum); in nvme_fc_error_recovery()
2546 nvme_reset_ctrl(&ctrl->ctrl); in nvme_fc_error_recovery()
2553 struct nvme_fc_ctrl *ctrl = op->ctrl; in nvme_fc_timeout() local
2561 dev_info(ctrl->ctrl.device, in nvme_fc_timeout()
2564 ctrl->cnum, op->queue->qnum, sqe->common.opcode, in nvme_fc_timeout()
2566 if (__nvme_fc_abort_op(ctrl, op)) in nvme_fc_timeout()
2567 nvme_fc_error_recovery(ctrl, "io timeout abort failed"); in nvme_fc_timeout()
2578 nvme_fc_map_data(struct nvme_fc_ctrl *ctrl, struct request *rq, in nvme_fc_map_data() argument
2598 freq->sg_cnt = fc_dma_map_sg(ctrl->lport->dev, freq->sg_table.sgl, in nvme_fc_map_data()
2613 nvme_fc_unmap_data(struct nvme_fc_ctrl *ctrl, struct request *rq, in nvme_fc_unmap_data() argument
2621 fc_dma_unmap_sg(ctrl->lport->dev, freq->sg_table.sgl, op->nents, in nvme_fc_unmap_data()
2653 nvme_fc_start_fcp_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue, in nvme_fc_start_fcp_op() argument
2665 if (ctrl->rport->remoteport.port_state != FC_OBJSTATE_ONLINE) in nvme_fc_start_fcp_op()
2668 if (!nvme_fc_ctrl_get(ctrl)) in nvme_fc_start_fcp_op()
2712 ret = nvme_fc_map_data(ctrl, op->rq, op); in nvme_fc_start_fcp_op()
2715 nvme_fc_ctrl_put(ctrl); in nvme_fc_start_fcp_op()
2722 fc_dma_sync_single_for_device(ctrl->lport->dev, op->fcp_req.cmddma, in nvme_fc_start_fcp_op()
2731 ret = ctrl->lport->ops->fcp_io(&ctrl->lport->localport, in nvme_fc_start_fcp_op()
2732 &ctrl->rport->remoteport, in nvme_fc_start_fcp_op()
2749 __nvme_fc_fcpop_chk_teardowns(ctrl, op, opstate); in nvme_fc_start_fcp_op()
2752 nvme_fc_unmap_data(ctrl, op->rq, op); in nvme_fc_start_fcp_op()
2756 nvme_fc_ctrl_put(ctrl); in nvme_fc_start_fcp_op()
2758 if (ctrl->rport->remoteport.port_state == FC_OBJSTATE_ONLINE && in nvme_fc_start_fcp_op()
2774 struct nvme_fc_ctrl *ctrl = queue->ctrl; in nvme_fc_queue_rq() local
2782 if (ctrl->rport->remoteport.port_state != FC_OBJSTATE_ONLINE || in nvme_fc_queue_rq()
2783 !nvme_check_ready(&queue->ctrl->ctrl, rq, queue_ready)) in nvme_fc_queue_rq()
2784 return nvme_fail_nonready_command(&queue->ctrl->ctrl, rq); in nvme_fc_queue_rq()
2808 return nvme_fc_start_fcp_op(ctrl, queue, op, data_len, io_dir); in nvme_fc_queue_rq()
2814 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(arg); in nvme_fc_submit_async_event() local
2818 if (test_bit(FCCTRL_TERMIO, &ctrl->flags)) in nvme_fc_submit_async_event()
2821 aen_op = &ctrl->aen_ops[0]; in nvme_fc_submit_async_event()
2823 ret = nvme_fc_start_fcp_op(ctrl, aen_op->queue, aen_op, 0, in nvme_fc_submit_async_event()
2826 dev_err(ctrl->ctrl.device, in nvme_fc_submit_async_event()
2834 struct nvme_fc_ctrl *ctrl = op->ctrl; in nvme_fc_complete_rq() local
2839 nvme_fc_unmap_data(ctrl, rq, op); in nvme_fc_complete_rq()
2841 nvme_fc_ctrl_put(ctrl); in nvme_fc_complete_rq()
2855 nvme_fc_create_io_queues(struct nvme_fc_ctrl *ctrl) in nvme_fc_create_io_queues() argument
2857 struct nvmf_ctrl_options *opts = ctrl->ctrl.opts; in nvme_fc_create_io_queues()
2862 ctrl->lport->ops->max_hw_queues); in nvme_fc_create_io_queues()
2863 ret = nvme_set_queue_count(&ctrl->ctrl, &nr_io_queues); in nvme_fc_create_io_queues()
2865 dev_info(ctrl->ctrl.device, in nvme_fc_create_io_queues()
2870 ctrl->ctrl.queue_count = nr_io_queues + 1; in nvme_fc_create_io_queues()
2874 nvme_fc_init_io_queues(ctrl); in nvme_fc_create_io_queues()
2876 memset(&ctrl->tag_set, 0, sizeof(ctrl->tag_set)); in nvme_fc_create_io_queues()
2877 ctrl->tag_set.ops = &nvme_fc_mq_ops; in nvme_fc_create_io_queues()
2878 ctrl->tag_set.queue_depth = ctrl->ctrl.opts->queue_size; in nvme_fc_create_io_queues()
2879 ctrl->tag_set.reserved_tags = NVMF_RESERVED_TAGS; in nvme_fc_create_io_queues()
2880 ctrl->tag_set.numa_node = ctrl->ctrl.numa_node; in nvme_fc_create_io_queues()
2881 ctrl->tag_set.flags = BLK_MQ_F_SHOULD_MERGE; in nvme_fc_create_io_queues()
2882 ctrl->tag_set.cmd_size = in nvme_fc_create_io_queues()
2884 ctrl->lport->ops->fcprqst_priv_sz); in nvme_fc_create_io_queues()
2885 ctrl->tag_set.driver_data = ctrl; in nvme_fc_create_io_queues()
2886 ctrl->tag_set.nr_hw_queues = ctrl->ctrl.queue_count - 1; in nvme_fc_create_io_queues()
2887 ctrl->tag_set.timeout = NVME_IO_TIMEOUT; in nvme_fc_create_io_queues()
2889 ret = blk_mq_alloc_tag_set(&ctrl->tag_set); in nvme_fc_create_io_queues()
2893 ctrl->ctrl.tagset = &ctrl->tag_set; in nvme_fc_create_io_queues()
2895 ctrl->ctrl.connect_q = blk_mq_init_queue(&ctrl->tag_set); in nvme_fc_create_io_queues()
2896 if (IS_ERR(ctrl->ctrl.connect_q)) { in nvme_fc_create_io_queues()
2897 ret = PTR_ERR(ctrl->ctrl.connect_q); in nvme_fc_create_io_queues()
2901 ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize + 1); in nvme_fc_create_io_queues()
2905 ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize + 1); in nvme_fc_create_io_queues()
2909 ctrl->ioq_live = true; in nvme_fc_create_io_queues()
2914 nvme_fc_delete_hw_io_queues(ctrl); in nvme_fc_create_io_queues()
2916 blk_cleanup_queue(ctrl->ctrl.connect_q); in nvme_fc_create_io_queues()
2918 blk_mq_free_tag_set(&ctrl->tag_set); in nvme_fc_create_io_queues()
2919 nvme_fc_free_io_queues(ctrl); in nvme_fc_create_io_queues()
2922 ctrl->ctrl.tagset = NULL; in nvme_fc_create_io_queues()
2928 nvme_fc_recreate_io_queues(struct nvme_fc_ctrl *ctrl) in nvme_fc_recreate_io_queues() argument
2930 struct nvmf_ctrl_options *opts = ctrl->ctrl.opts; in nvme_fc_recreate_io_queues()
2931 u32 prior_ioq_cnt = ctrl->ctrl.queue_count - 1; in nvme_fc_recreate_io_queues()
2936 ctrl->lport->ops->max_hw_queues); in nvme_fc_recreate_io_queues()
2937 ret = nvme_set_queue_count(&ctrl->ctrl, &nr_io_queues); in nvme_fc_recreate_io_queues()
2939 dev_info(ctrl->ctrl.device, in nvme_fc_recreate_io_queues()
2945 dev_info(ctrl->ctrl.device, in nvme_fc_recreate_io_queues()
2951 ctrl->ctrl.queue_count = nr_io_queues + 1; in nvme_fc_recreate_io_queues()
2953 if (ctrl->ctrl.queue_count == 1) in nvme_fc_recreate_io_queues()
2957 dev_info(ctrl->ctrl.device, in nvme_fc_recreate_io_queues()
2960 blk_mq_update_nr_hw_queues(&ctrl->tag_set, nr_io_queues); in nvme_fc_recreate_io_queues()
2963 ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize + 1); in nvme_fc_recreate_io_queues()
2967 ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize + 1); in nvme_fc_recreate_io_queues()
2974 nvme_fc_delete_hw_io_queues(ctrl); in nvme_fc_recreate_io_queues()
2976 nvme_fc_free_io_queues(ctrl); in nvme_fc_recreate_io_queues()
3000 nvme_fc_ctlr_active_on_rport(struct nvme_fc_ctrl *ctrl) in nvme_fc_ctlr_active_on_rport() argument
3002 struct nvme_fc_rport *rport = ctrl->rport; in nvme_fc_ctlr_active_on_rport()
3005 if (test_and_set_bit(ASSOC_ACTIVE, &ctrl->flags)) in nvme_fc_ctlr_active_on_rport()
3016 nvme_fc_ctlr_inactive_on_rport(struct nvme_fc_ctrl *ctrl) in nvme_fc_ctlr_inactive_on_rport() argument
3018 struct nvme_fc_rport *rport = ctrl->rport; in nvme_fc_ctlr_inactive_on_rport()
3022 /* clearing of ctrl->flags ASSOC_ACTIVE bit is in association delete */ in nvme_fc_ctlr_inactive_on_rport()
3039 nvme_fc_create_association(struct nvme_fc_ctrl *ctrl) in nvme_fc_create_association() argument
3041 struct nvmf_ctrl_options *opts = ctrl->ctrl.opts; in nvme_fc_create_association()
3047 ++ctrl->ctrl.nr_reconnects; in nvme_fc_create_association()
3049 if (ctrl->rport->remoteport.port_state != FC_OBJSTATE_ONLINE) in nvme_fc_create_association()
3052 if (nvme_fc_ctlr_active_on_rport(ctrl)) in nvme_fc_create_association()
3055 dev_info(ctrl->ctrl.device, in nvme_fc_create_association()
3058 ctrl->cnum, ctrl->lport->localport.port_name, in nvme_fc_create_association()
3059 ctrl->rport->remoteport.port_name, ctrl->ctrl.opts->subsysnqn); in nvme_fc_create_association()
3061 clear_bit(ASSOC_FAILED, &ctrl->flags); in nvme_fc_create_association()
3067 ret = __nvme_fc_create_hw_queue(ctrl, &ctrl->queues[0], 0, in nvme_fc_create_association()
3072 ret = nvme_fc_connect_admin_queue(ctrl, &ctrl->queues[0], in nvme_fc_create_association()
3077 ret = nvmf_connect_admin_queue(&ctrl->ctrl); in nvme_fc_create_association()
3081 set_bit(NVME_FC_Q_LIVE, &ctrl->queues[0].flags); in nvme_fc_create_association()
3086 * todo:- add code to check if ctrl attributes changed from in nvme_fc_create_association()
3090 ret = nvme_enable_ctrl(&ctrl->ctrl); in nvme_fc_create_association()
3091 if (ret || test_bit(ASSOC_FAILED, &ctrl->flags)) in nvme_fc_create_association()
3094 ctrl->ctrl.max_segments = ctrl->lport->ops->max_sgl_segments; in nvme_fc_create_association()
3095 ctrl->ctrl.max_hw_sectors = ctrl->ctrl.max_segments << in nvme_fc_create_association()
3098 blk_mq_unquiesce_queue(ctrl->ctrl.admin_q); in nvme_fc_create_association()
3100 ret = nvme_init_ctrl_finish(&ctrl->ctrl); in nvme_fc_create_association()
3101 if (ret || test_bit(ASSOC_FAILED, &ctrl->flags)) in nvme_fc_create_association()
3107 if (ctrl->ctrl.icdoff) { in nvme_fc_create_association()
3108 dev_err(ctrl->ctrl.device, "icdoff %d is not supported!\n", in nvme_fc_create_association()
3109 ctrl->ctrl.icdoff); in nvme_fc_create_association()
3115 if (!nvme_ctrl_sgl_supported(&ctrl->ctrl)) { in nvme_fc_create_association()
3116 dev_err(ctrl->ctrl.device, in nvme_fc_create_association()
3122 if (opts->queue_size > ctrl->ctrl.maxcmd) { in nvme_fc_create_association()
3124 dev_warn(ctrl->ctrl.device, in nvme_fc_create_association()
3125 "queue_size %zu > ctrl maxcmd %u, reducing " in nvme_fc_create_association()
3127 opts->queue_size, ctrl->ctrl.maxcmd); in nvme_fc_create_association()
3128 opts->queue_size = ctrl->ctrl.maxcmd; in nvme_fc_create_association()
3131 if (opts->queue_size > ctrl->ctrl.sqsize + 1) { in nvme_fc_create_association()
3133 dev_warn(ctrl->ctrl.device, in nvme_fc_create_association()
3134 "queue_size %zu > ctrl sqsize %u, reducing " in nvme_fc_create_association()
3136 opts->queue_size, ctrl->ctrl.sqsize + 1); in nvme_fc_create_association()
3137 opts->queue_size = ctrl->ctrl.sqsize + 1; in nvme_fc_create_association()
3140 ret = nvme_fc_init_aen_ops(ctrl); in nvme_fc_create_association()
3148 if (ctrl->ctrl.queue_count > 1) { in nvme_fc_create_association()
3149 if (!ctrl->ioq_live) in nvme_fc_create_association()
3150 ret = nvme_fc_create_io_queues(ctrl); in nvme_fc_create_association()
3152 ret = nvme_fc_recreate_io_queues(ctrl); in nvme_fc_create_association()
3154 if (ret || test_bit(ASSOC_FAILED, &ctrl->flags)) in nvme_fc_create_association()
3157 changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE); in nvme_fc_create_association()
3159 ctrl->ctrl.nr_reconnects = 0; in nvme_fc_create_association()
3162 nvme_start_ctrl(&ctrl->ctrl); in nvme_fc_create_association()
3167 nvme_fc_term_aen_ops(ctrl); in nvme_fc_create_association()
3170 nvme_fc_xmt_disconnect_assoc(ctrl); in nvme_fc_create_association()
3171 spin_lock_irqsave(&ctrl->lock, flags); in nvme_fc_create_association()
3172 ctrl->association_id = 0; in nvme_fc_create_association()
3173 disls = ctrl->rcv_disconn; in nvme_fc_create_association()
3174 ctrl->rcv_disconn = NULL; in nvme_fc_create_association()
3175 spin_unlock_irqrestore(&ctrl->lock, flags); in nvme_fc_create_association()
3179 __nvme_fc_delete_hw_queue(ctrl, &ctrl->queues[0], 0); in nvme_fc_create_association()
3181 nvme_fc_free_queue(&ctrl->queues[0]); in nvme_fc_create_association()
3182 clear_bit(ASSOC_ACTIVE, &ctrl->flags); in nvme_fc_create_association()
3183 nvme_fc_ctlr_inactive_on_rport(ctrl); in nvme_fc_create_association()
3196 nvme_fc_delete_association(struct nvme_fc_ctrl *ctrl) in nvme_fc_delete_association() argument
3201 if (!test_and_clear_bit(ASSOC_ACTIVE, &ctrl->flags)) in nvme_fc_delete_association()
3204 spin_lock_irqsave(&ctrl->lock, flags); in nvme_fc_delete_association()
3205 set_bit(FCCTRL_TERMIO, &ctrl->flags); in nvme_fc_delete_association()
3206 ctrl->iocnt = 0; in nvme_fc_delete_association()
3207 spin_unlock_irqrestore(&ctrl->lock, flags); in nvme_fc_delete_association()
3209 __nvme_fc_abort_outstanding_ios(ctrl, false); in nvme_fc_delete_association()
3212 nvme_fc_abort_aen_ops(ctrl); in nvme_fc_delete_association()
3215 spin_lock_irq(&ctrl->lock); in nvme_fc_delete_association()
3216 wait_event_lock_irq(ctrl->ioabort_wait, ctrl->iocnt == 0, ctrl->lock); in nvme_fc_delete_association()
3217 clear_bit(FCCTRL_TERMIO, &ctrl->flags); in nvme_fc_delete_association()
3218 spin_unlock_irq(&ctrl->lock); in nvme_fc_delete_association()
3220 nvme_fc_term_aen_ops(ctrl); in nvme_fc_delete_association()
3228 if (ctrl->association_id) in nvme_fc_delete_association()
3229 nvme_fc_xmt_disconnect_assoc(ctrl); in nvme_fc_delete_association()
3231 spin_lock_irqsave(&ctrl->lock, flags); in nvme_fc_delete_association()
3232 ctrl->association_id = 0; in nvme_fc_delete_association()
3233 disls = ctrl->rcv_disconn; in nvme_fc_delete_association()
3234 ctrl->rcv_disconn = NULL; in nvme_fc_delete_association()
3235 spin_unlock_irqrestore(&ctrl->lock, flags); in nvme_fc_delete_association()
3243 if (ctrl->ctrl.tagset) { in nvme_fc_delete_association()
3244 nvme_fc_delete_hw_io_queues(ctrl); in nvme_fc_delete_association()
3245 nvme_fc_free_io_queues(ctrl); in nvme_fc_delete_association()
3248 __nvme_fc_delete_hw_queue(ctrl, &ctrl->queues[0], 0); in nvme_fc_delete_association()
3249 nvme_fc_free_queue(&ctrl->queues[0]); in nvme_fc_delete_association()
3252 blk_mq_unquiesce_queue(ctrl->ctrl.admin_q); in nvme_fc_delete_association()
3255 nvme_start_queues(&ctrl->ctrl); in nvme_fc_delete_association()
3257 nvme_fc_ctlr_inactive_on_rport(ctrl); in nvme_fc_delete_association()
3263 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl); in nvme_fc_delete_ctrl() local
3265 cancel_work_sync(&ctrl->ioerr_work); in nvme_fc_delete_ctrl()
3266 cancel_delayed_work_sync(&ctrl->connect_work); in nvme_fc_delete_ctrl()
3271 nvme_fc_delete_association(ctrl); in nvme_fc_delete_ctrl()
3275 nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status) in nvme_fc_reconnect_or_delete() argument
3277 struct nvme_fc_rport *rport = ctrl->rport; in nvme_fc_reconnect_or_delete()
3279 unsigned long recon_delay = ctrl->ctrl.opts->reconnect_delay * HZ; in nvme_fc_reconnect_or_delete()
3282 if (ctrl->ctrl.state != NVME_CTRL_CONNECTING) in nvme_fc_reconnect_or_delete()
3286 dev_info(ctrl->ctrl.device, in nvme_fc_reconnect_or_delete()
3288 ctrl->cnum, status); in nvme_fc_reconnect_or_delete()
3294 if (recon && nvmf_should_reconnect(&ctrl->ctrl)) { 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()
3374 struct nvme_fc_ctrl *ctrl = in nvme_fc_connect_ctrl_work() local
3378 ret = nvme_fc_create_association(ctrl); in nvme_fc_connect_ctrl_work()
3380 nvme_fc_reconnect_or_delete(ctrl, ret); in nvme_fc_connect_ctrl_work()
3382 dev_info(ctrl->ctrl.device, in nvme_fc_connect_ctrl_work()
3384 ctrl->cnum); in nvme_fc_connect_ctrl_work()
3410 struct nvme_fc_ctrl *ctrl; in nvme_fc_existing_controller() local
3415 list_for_each_entry(ctrl, &rport->ctrl_list, ctrl_list) { in nvme_fc_existing_controller()
3416 found = nvmf_ctlr_matches_baseopts(&ctrl->ctrl, opts); in nvme_fc_existing_controller()
3429 struct nvme_fc_ctrl *ctrl; in nvme_fc_init_ctrl() local
3445 ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); in nvme_fc_init_ctrl()
3446 if (!ctrl) { in nvme_fc_init_ctrl()
3470 ctrl->ctrl.opts = opts; in nvme_fc_init_ctrl()
3471 ctrl->ctrl.nr_reconnects = 0; in nvme_fc_init_ctrl()
3473 ctrl->ctrl.numa_node = dev_to_node(lport->dev); in nvme_fc_init_ctrl()
3475 ctrl->ctrl.numa_node = NUMA_NO_NODE; in nvme_fc_init_ctrl()
3476 INIT_LIST_HEAD(&ctrl->ctrl_list); in nvme_fc_init_ctrl()
3477 ctrl->lport = lport; in nvme_fc_init_ctrl()
3478 ctrl->rport = rport; in nvme_fc_init_ctrl()
3479 ctrl->dev = lport->dev; in nvme_fc_init_ctrl()
3480 ctrl->cnum = idx; in nvme_fc_init_ctrl()
3481 ctrl->ioq_live = false; in nvme_fc_init_ctrl()
3482 init_waitqueue_head(&ctrl->ioabort_wait); in nvme_fc_init_ctrl()
3484 get_device(ctrl->dev); in nvme_fc_init_ctrl()
3485 kref_init(&ctrl->ref); in nvme_fc_init_ctrl()
3487 INIT_WORK(&ctrl->ctrl.reset_work, nvme_fc_reset_ctrl_work); in nvme_fc_init_ctrl()
3488 INIT_DELAYED_WORK(&ctrl->connect_work, nvme_fc_connect_ctrl_work); in nvme_fc_init_ctrl()
3489 INIT_WORK(&ctrl->ioerr_work, nvme_fc_ctrl_ioerr_work); in nvme_fc_init_ctrl()
3490 spin_lock_init(&ctrl->lock); in nvme_fc_init_ctrl()
3493 ctrl->ctrl.queue_count = min_t(unsigned int, in nvme_fc_init_ctrl()
3496 ctrl->ctrl.queue_count++; /* +1 for admin queue */ in nvme_fc_init_ctrl()
3498 ctrl->ctrl.sqsize = opts->queue_size - 1; in nvme_fc_init_ctrl()
3499 ctrl->ctrl.kato = opts->kato; in nvme_fc_init_ctrl()
3500 ctrl->ctrl.cntlid = 0xffff; in nvme_fc_init_ctrl()
3503 ctrl->queues = kcalloc(ctrl->ctrl.queue_count, in nvme_fc_init_ctrl()
3505 if (!ctrl->queues) in nvme_fc_init_ctrl()
3508 nvme_fc_init_queue(ctrl, 0); in nvme_fc_init_ctrl()
3510 memset(&ctrl->admin_tag_set, 0, sizeof(ctrl->admin_tag_set)); in nvme_fc_init_ctrl()
3511 ctrl->admin_tag_set.ops = &nvme_fc_admin_mq_ops; in nvme_fc_init_ctrl()
3512 ctrl->admin_tag_set.queue_depth = NVME_AQ_MQ_TAG_DEPTH; in nvme_fc_init_ctrl()
3513 ctrl->admin_tag_set.reserved_tags = NVMF_RESERVED_TAGS; in nvme_fc_init_ctrl()
3514 ctrl->admin_tag_set.numa_node = ctrl->ctrl.numa_node; in nvme_fc_init_ctrl()
3515 ctrl->admin_tag_set.cmd_size = in nvme_fc_init_ctrl()
3517 ctrl->lport->ops->fcprqst_priv_sz); in nvme_fc_init_ctrl()
3518 ctrl->admin_tag_set.driver_data = ctrl; in nvme_fc_init_ctrl()
3519 ctrl->admin_tag_set.nr_hw_queues = 1; in nvme_fc_init_ctrl()
3520 ctrl->admin_tag_set.timeout = NVME_ADMIN_TIMEOUT; in nvme_fc_init_ctrl()
3521 ctrl->admin_tag_set.flags = BLK_MQ_F_NO_SCHED; in nvme_fc_init_ctrl()
3523 ret = blk_mq_alloc_tag_set(&ctrl->admin_tag_set); in nvme_fc_init_ctrl()
3526 ctrl->ctrl.admin_tagset = &ctrl->admin_tag_set; in nvme_fc_init_ctrl()
3528 ctrl->ctrl.fabrics_q = blk_mq_init_queue(&ctrl->admin_tag_set); in nvme_fc_init_ctrl()
3529 if (IS_ERR(ctrl->ctrl.fabrics_q)) { in nvme_fc_init_ctrl()
3530 ret = PTR_ERR(ctrl->ctrl.fabrics_q); in nvme_fc_init_ctrl()
3534 ctrl->ctrl.admin_q = blk_mq_init_queue(&ctrl->admin_tag_set); in nvme_fc_init_ctrl()
3535 if (IS_ERR(ctrl->ctrl.admin_q)) { in nvme_fc_init_ctrl()
3536 ret = PTR_ERR(ctrl->ctrl.admin_q); in nvme_fc_init_ctrl()
3547 ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_fc_ctrl_ops, 0); in nvme_fc_init_ctrl()
3551 /* at this point, teardown path changes to ref counting on nvme ctrl */ in nvme_fc_init_ctrl()
3554 list_add_tail(&ctrl->ctrl_list, &rport->ctrl_list); in nvme_fc_init_ctrl()
3557 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RESETTING) || in nvme_fc_init_ctrl()
3558 !nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) { in nvme_fc_init_ctrl()
3559 dev_err(ctrl->ctrl.device, in nvme_fc_init_ctrl()
3560 "NVME-FC{%d}: failed to init ctrl state\n", ctrl->cnum); in nvme_fc_init_ctrl()
3564 if (!queue_delayed_work(nvme_wq, &ctrl->connect_work, 0)) { in nvme_fc_init_ctrl()
3565 dev_err(ctrl->ctrl.device, in nvme_fc_init_ctrl()
3567 ctrl->cnum); in nvme_fc_init_ctrl()
3571 flush_delayed_work(&ctrl->connect_work); in nvme_fc_init_ctrl()
3573 dev_info(ctrl->ctrl.device, in nvme_fc_init_ctrl()
3574 "NVME-FC{%d}: new ctrl: NQN \"%s\"\n", in nvme_fc_init_ctrl()
3575 ctrl->cnum, ctrl->ctrl.opts->subsysnqn); in nvme_fc_init_ctrl()
3577 return &ctrl->ctrl; in nvme_fc_init_ctrl()
3580 nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_DELETING); in nvme_fc_init_ctrl()
3581 cancel_work_sync(&ctrl->ioerr_work); in nvme_fc_init_ctrl()
3582 cancel_work_sync(&ctrl->ctrl.reset_work); in nvme_fc_init_ctrl()
3583 cancel_delayed_work_sync(&ctrl->connect_work); in nvme_fc_init_ctrl()
3585 ctrl->ctrl.opts = NULL; in nvme_fc_init_ctrl()
3587 /* initiate nvme ctrl ref counting teardown */ in nvme_fc_init_ctrl()
3588 nvme_uninit_ctrl(&ctrl->ctrl); in nvme_fc_init_ctrl()
3590 /* Remove core ctrl ref. */ in nvme_fc_init_ctrl()
3591 nvme_put_ctrl(&ctrl->ctrl); in nvme_fc_init_ctrl()
3605 blk_cleanup_queue(ctrl->ctrl.admin_q); in nvme_fc_init_ctrl()
3607 blk_cleanup_queue(ctrl->ctrl.fabrics_q); in nvme_fc_init_ctrl()
3609 blk_mq_free_tag_set(&ctrl->admin_tag_set); in nvme_fc_init_ctrl()
3611 kfree(ctrl->queues); in nvme_fc_init_ctrl()
3613 put_device(ctrl->dev); in nvme_fc_init_ctrl()
3614 ida_simple_remove(&nvme_fc_ctrl_cnt, ctrl->cnum); in nvme_fc_init_ctrl()
3616 kfree(ctrl); in nvme_fc_init_ctrl()
3693 struct nvme_ctrl *ctrl; in nvme_fc_create_ctrl() local
3727 ctrl = nvme_fc_init_ctrl(dev, opts, lport, rport); in nvme_fc_create_ctrl()
3728 if (IS_ERR(ctrl)) in nvme_fc_create_ctrl()
3730 return ctrl; in nvme_fc_create_ctrl()
3961 struct nvme_fc_ctrl *ctrl; in nvme_fc_delete_controllers() local
3964 list_for_each_entry(ctrl, &rport->ctrl_list, ctrl_list) { in nvme_fc_delete_controllers()
3965 dev_warn(ctrl->ctrl.device, in nvme_fc_delete_controllers()
3966 "NVME-FC{%d}: transport unloading: deleting ctrl\n", in nvme_fc_delete_controllers()
3967 ctrl->cnum); in nvme_fc_delete_controllers()
3968 nvme_delete_ctrl(&ctrl->ctrl); in nvme_fc_delete_controllers()
4001 pr_info("%s: ctrl deletes complete\n", __func__); in nvme_fc_exit_module()