Lines Matching refs:ctrl

41 	struct nvme_fc_ctrl	*ctrl;  member
94 struct nvme_fc_ctrl *ctrl; member
163 struct nvme_ctrl ctrl; member
167 to_fc_ctrl(struct nvme_ctrl *ctrl) in to_fc_ctrl() argument
169 return container_of(ctrl, struct nvme_fc_ctrl, ctrl); in to_fc_ctrl()
530 nvme_fc_resume_controller(struct nvme_fc_ctrl *ctrl) in nvme_fc_resume_controller() argument
532 switch (ctrl->ctrl.state) { in nvme_fc_resume_controller()
539 dev_info(ctrl->ctrl.device, in nvme_fc_resume_controller()
541 "Attempting reconnect\n", ctrl->cnum); in nvme_fc_resume_controller()
543 queue_delayed_work(nvme_wq, &ctrl->connect_work, 0); in nvme_fc_resume_controller()
565 struct nvme_fc_ctrl *ctrl; in nvme_fc_attach_to_suspended_rport() local
601 list_for_each_entry(ctrl, &rport->ctrl_list, ctrl_list) in nvme_fc_attach_to_suspended_rport()
602 nvme_fc_resume_controller(ctrl); in nvme_fc_attach_to_suspended_rport()
756 nvme_fc_ctrl_connectivity_loss(struct nvme_fc_ctrl *ctrl) in nvme_fc_ctrl_connectivity_loss() argument
758 dev_info(ctrl->ctrl.device, in nvme_fc_ctrl_connectivity_loss()
760 "Reconnect", ctrl->cnum); in nvme_fc_ctrl_connectivity_loss()
762 switch (ctrl->ctrl.state) { in nvme_fc_ctrl_connectivity_loss()
772 if (nvme_reset_ctrl(&ctrl->ctrl)) { in nvme_fc_ctrl_connectivity_loss()
773 dev_warn(ctrl->ctrl.device, in nvme_fc_ctrl_connectivity_loss()
775 ctrl->cnum); in nvme_fc_ctrl_connectivity_loss()
776 nvme_delete_ctrl(&ctrl->ctrl); in nvme_fc_ctrl_connectivity_loss()
821 struct nvme_fc_ctrl *ctrl; in nvme_fc_unregister_remoteport() local
837 list_for_each_entry(ctrl, &rport->ctrl_list, ctrl_list) { in nvme_fc_unregister_remoteport()
840 dev_warn(ctrl->ctrl.device, in nvme_fc_unregister_remoteport()
842 ctrl->cnum); in nvme_fc_unregister_remoteport()
843 nvme_delete_ctrl(&ctrl->ctrl); in nvme_fc_unregister_remoteport()
845 nvme_fc_ctrl_connectivity_loss(ctrl); in nvme_fc_unregister_remoteport()
1176 nvme_fc_connect_admin_queue(struct nvme_fc_ctrl *ctrl, in nvme_fc_connect_admin_queue() argument
1186 ctrl->lport->ops->lsrqst_priv_sz + in nvme_fc_connect_admin_queue()
1196 (lsreq->private + ctrl->lport->ops->lsrqst_priv_sz); in nvme_fc_connect_admin_queue()
1213 uuid_copy(&assoc_rqst->assoc_cmd.hostid, &ctrl->ctrl.opts->host->id); in nvme_fc_connect_admin_queue()
1214 strncpy(assoc_rqst->assoc_cmd.hostnqn, ctrl->ctrl.opts->host->nqn, in nvme_fc_connect_admin_queue()
1216 strncpy(assoc_rqst->assoc_cmd.subnqn, ctrl->ctrl.opts->subsysnqn, in nvme_fc_connect_admin_queue()
1226 ret = nvme_fc_send_ls_req(ctrl->rport, lsop); in nvme_fc_connect_admin_queue()
1263 dev_err(ctrl->dev, in nvme_fc_connect_admin_queue()
1267 ctrl->association_id = in nvme_fc_connect_admin_queue()
1278 dev_err(ctrl->dev, in nvme_fc_connect_admin_queue()
1285 nvme_fc_connect_queue(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue, in nvme_fc_connect_queue() argument
1295 ctrl->lport->ops->lsrqst_priv_sz + in nvme_fc_connect_queue()
1305 (lsreq->private + ctrl->lport->ops->lsrqst_priv_sz); in nvme_fc_connect_queue()
1317 conn_rqst->associd.association_id = cpu_to_be64(ctrl->association_id); in nvme_fc_connect_queue()
1334 ret = nvme_fc_send_ls_req(ctrl->rport, lsop); in nvme_fc_connect_queue()
1362 dev_err(ctrl->dev, in nvme_fc_connect_queue()
1375 dev_err(ctrl->dev, in nvme_fc_connect_queue()
1411 nvme_fc_xmt_disconnect_assoc(struct nvme_fc_ctrl *ctrl) in nvme_fc_xmt_disconnect_assoc() argument
1420 ctrl->lport->ops->lsrqst_priv_sz + in nvme_fc_xmt_disconnect_assoc()
1431 (lsreq->private + ctrl->lport->ops->lsrqst_priv_sz); in nvme_fc_xmt_disconnect_assoc()
1444 discon_rqst->associd.association_id = cpu_to_be64(ctrl->association_id); in nvme_fc_xmt_disconnect_assoc()
1452 discon_rqst->discon_cmd.id = cpu_to_be64(ctrl->association_id); in nvme_fc_xmt_disconnect_assoc()
1460 ret = nvme_fc_send_ls_req_async(ctrl->rport, lsop, in nvme_fc_xmt_disconnect_assoc()
1466 ctrl->association_id = 0; in nvme_fc_xmt_disconnect_assoc()
1472 static void nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl, char *errmsg);
1475 __nvme_fc_exit_request(struct nvme_fc_ctrl *ctrl, in __nvme_fc_exit_request() argument
1478 fc_dma_unmap_single(ctrl->lport->dev, op->fcp_req.rspdma, in __nvme_fc_exit_request()
1480 fc_dma_unmap_single(ctrl->lport->dev, op->fcp_req.cmddma, in __nvme_fc_exit_request()
1496 __nvme_fc_abort_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_fcp_op *op) in __nvme_fc_abort_op() argument
1501 spin_lock_irqsave(&ctrl->lock, flags); in __nvme_fc_abort_op()
1505 else if (ctrl->flags & FCCTRL_TERMIO) in __nvme_fc_abort_op()
1506 ctrl->iocnt++; in __nvme_fc_abort_op()
1507 spin_unlock_irqrestore(&ctrl->lock, flags); in __nvme_fc_abort_op()
1512 ctrl->lport->ops->fcp_abort(&ctrl->lport->localport, in __nvme_fc_abort_op()
1513 &ctrl->rport->remoteport, in __nvme_fc_abort_op()
1521 nvme_fc_abort_aen_ops(struct nvme_fc_ctrl *ctrl) in nvme_fc_abort_aen_ops() argument
1523 struct nvme_fc_fcp_op *aen_op = ctrl->aen_ops; in nvme_fc_abort_aen_ops()
1527 __nvme_fc_abort_op(ctrl, aen_op); in nvme_fc_abort_aen_ops()
1531 __nvme_fc_fcpop_chk_teardowns(struct nvme_fc_ctrl *ctrl, in __nvme_fc_fcpop_chk_teardowns() argument
1537 spin_lock_irqsave(&ctrl->lock, flags); in __nvme_fc_fcpop_chk_teardowns()
1538 if (ctrl->flags & FCCTRL_TERMIO) { in __nvme_fc_fcpop_chk_teardowns()
1539 if (!--ctrl->iocnt) in __nvme_fc_fcpop_chk_teardowns()
1540 wake_up(&ctrl->ioabort_wait); in __nvme_fc_fcpop_chk_teardowns()
1542 spin_unlock_irqrestore(&ctrl->lock, flags); in __nvme_fc_fcpop_chk_teardowns()
1552 struct nvme_fc_ctrl *ctrl = op->ctrl; in nvme_fc_fcpio_done() local
1600 fc_dma_sync_single_for_cpu(ctrl->lport->dev, op->fcp_req.rspdma, in nvme_fc_fcpio_done()
1667 nvme_complete_async_event(&queue->ctrl->ctrl, status, &result); in nvme_fc_fcpio_done()
1668 __nvme_fc_fcpop_chk_teardowns(ctrl, op, opstate); in nvme_fc_fcpio_done()
1671 nvme_fc_ctrl_put(ctrl); in nvme_fc_fcpio_done()
1675 __nvme_fc_fcpop_chk_teardowns(ctrl, op, opstate); in nvme_fc_fcpio_done()
1680 nvme_fc_error_recovery(ctrl, "transport detected io error"); in nvme_fc_fcpio_done()
1684 __nvme_fc_init_request(struct nvme_fc_ctrl *ctrl, in __nvme_fc_init_request() argument
1699 op->ctrl = ctrl; in __nvme_fc_init_request()
1708 op->fcp_req.cmddma = fc_dma_map_single(ctrl->lport->dev, in __nvme_fc_init_request()
1710 if (fc_dma_mapping_error(ctrl->lport->dev, op->fcp_req.cmddma)) { in __nvme_fc_init_request()
1711 dev_err(ctrl->dev, in __nvme_fc_init_request()
1717 op->fcp_req.rspdma = fc_dma_map_single(ctrl->lport->dev, in __nvme_fc_init_request()
1720 if (fc_dma_mapping_error(ctrl->lport->dev, op->fcp_req.rspdma)) { in __nvme_fc_init_request()
1721 dev_err(ctrl->dev, in __nvme_fc_init_request()
1735 struct nvme_fc_ctrl *ctrl = set->driver_data; in nvme_fc_init_request() local
1737 int queue_idx = (set == &ctrl->tag_set) ? hctx_idx + 1 : 0; in nvme_fc_init_request()
1738 struct nvme_fc_queue *queue = &ctrl->queues[queue_idx]; in nvme_fc_init_request()
1740 nvme_req(rq)->ctrl = &ctrl->ctrl; in nvme_fc_init_request()
1741 return __nvme_fc_init_request(ctrl, queue, op, rq, queue->rqcnt++); in nvme_fc_init_request()
1745 nvme_fc_init_aen_ops(struct nvme_fc_ctrl *ctrl) in nvme_fc_init_aen_ops() argument
1753 aen_op = ctrl->aen_ops; in nvme_fc_init_aen_ops()
1755 private = kzalloc(ctrl->lport->ops->fcprqst_priv_sz, in nvme_fc_init_aen_ops()
1762 ret = __nvme_fc_init_request(ctrl, &ctrl->queues[0], in nvme_fc_init_aen_ops()
1783 nvme_fc_term_aen_ops(struct nvme_fc_ctrl *ctrl) in nvme_fc_term_aen_ops() argument
1788 aen_op = ctrl->aen_ops; in nvme_fc_term_aen_ops()
1793 __nvme_fc_exit_request(ctrl, aen_op); in nvme_fc_term_aen_ops()
1801 __nvme_fc_init_hctx(struct blk_mq_hw_ctx *hctx, struct nvme_fc_ctrl *ctrl, in __nvme_fc_init_hctx() argument
1804 struct nvme_fc_queue *queue = &ctrl->queues[qidx]; in __nvme_fc_init_hctx()
1814 struct nvme_fc_ctrl *ctrl = data; in nvme_fc_init_hctx() local
1816 __nvme_fc_init_hctx(hctx, ctrl, hctx_idx + 1); in nvme_fc_init_hctx()
1825 struct nvme_fc_ctrl *ctrl = data; in nvme_fc_init_admin_hctx() local
1827 __nvme_fc_init_hctx(hctx, ctrl, hctx_idx); in nvme_fc_init_admin_hctx()
1833 nvme_fc_init_queue(struct nvme_fc_ctrl *ctrl, int idx) in nvme_fc_init_queue() argument
1837 queue = &ctrl->queues[idx]; in nvme_fc_init_queue()
1839 queue->ctrl = ctrl; in nvme_fc_init_queue()
1842 queue->dev = ctrl->dev; in nvme_fc_init_queue()
1845 queue->cmnd_capsule_len = ctrl->ctrl.ioccsz * 16; in nvme_fc_init_queue()
1887 __nvme_fc_delete_hw_queue(struct nvme_fc_ctrl *ctrl, in __nvme_fc_delete_hw_queue() argument
1890 if (ctrl->lport->ops->delete_queue) in __nvme_fc_delete_hw_queue()
1891 ctrl->lport->ops->delete_queue(&ctrl->lport->localport, qidx, in __nvme_fc_delete_hw_queue()
1897 nvme_fc_free_io_queues(struct nvme_fc_ctrl *ctrl) in nvme_fc_free_io_queues() argument
1901 for (i = 1; i < ctrl->ctrl.queue_count; i++) in nvme_fc_free_io_queues()
1902 nvme_fc_free_queue(&ctrl->queues[i]); in nvme_fc_free_io_queues()
1906 __nvme_fc_create_hw_queue(struct nvme_fc_ctrl *ctrl, in __nvme_fc_create_hw_queue() argument
1912 if (ctrl->lport->ops->create_queue) in __nvme_fc_create_hw_queue()
1913 ret = ctrl->lport->ops->create_queue(&ctrl->lport->localport, in __nvme_fc_create_hw_queue()
1920 nvme_fc_delete_hw_io_queues(struct nvme_fc_ctrl *ctrl) in nvme_fc_delete_hw_io_queues() argument
1922 struct nvme_fc_queue *queue = &ctrl->queues[ctrl->ctrl.queue_count - 1]; in nvme_fc_delete_hw_io_queues()
1925 for (i = ctrl->ctrl.queue_count - 1; i >= 1; i--, queue--) in nvme_fc_delete_hw_io_queues()
1926 __nvme_fc_delete_hw_queue(ctrl, queue, i); in nvme_fc_delete_hw_io_queues()
1930 nvme_fc_create_hw_io_queues(struct nvme_fc_ctrl *ctrl, u16 qsize) in nvme_fc_create_hw_io_queues() argument
1932 struct nvme_fc_queue *queue = &ctrl->queues[1]; in nvme_fc_create_hw_io_queues()
1935 for (i = 1; i < ctrl->ctrl.queue_count; i++, queue++) { in nvme_fc_create_hw_io_queues()
1936 ret = __nvme_fc_create_hw_queue(ctrl, queue, i, qsize); in nvme_fc_create_hw_io_queues()
1945 __nvme_fc_delete_hw_queue(ctrl, &ctrl->queues[i], i); in nvme_fc_create_hw_io_queues()
1950 nvme_fc_connect_io_queues(struct nvme_fc_ctrl *ctrl, u16 qsize) in nvme_fc_connect_io_queues() argument
1954 for (i = 1; i < ctrl->ctrl.queue_count; i++) { in nvme_fc_connect_io_queues()
1955 ret = nvme_fc_connect_queue(ctrl, &ctrl->queues[i], qsize, in nvme_fc_connect_io_queues()
1959 ret = nvmf_connect_io_queue(&ctrl->ctrl, i); in nvme_fc_connect_io_queues()
1963 set_bit(NVME_FC_Q_LIVE, &ctrl->queues[i].flags); in nvme_fc_connect_io_queues()
1970 nvme_fc_init_io_queues(struct nvme_fc_ctrl *ctrl) in nvme_fc_init_io_queues() argument
1974 for (i = 1; i < ctrl->ctrl.queue_count; i++) in nvme_fc_init_io_queues()
1975 nvme_fc_init_queue(ctrl, i); in nvme_fc_init_io_queues()
1981 struct nvme_fc_ctrl *ctrl = in nvme_fc_ctrl_free() local
1985 if (ctrl->ctrl.tagset) { in nvme_fc_ctrl_free()
1986 blk_cleanup_queue(ctrl->ctrl.connect_q); in nvme_fc_ctrl_free()
1987 blk_mq_free_tag_set(&ctrl->tag_set); in nvme_fc_ctrl_free()
1991 spin_lock_irqsave(&ctrl->rport->lock, flags); in nvme_fc_ctrl_free()
1992 list_del(&ctrl->ctrl_list); in nvme_fc_ctrl_free()
1993 spin_unlock_irqrestore(&ctrl->rport->lock, flags); in nvme_fc_ctrl_free()
1995 blk_mq_unquiesce_queue(ctrl->ctrl.admin_q); in nvme_fc_ctrl_free()
1996 blk_cleanup_queue(ctrl->ctrl.admin_q); in nvme_fc_ctrl_free()
1997 blk_mq_free_tag_set(&ctrl->admin_tag_set); in nvme_fc_ctrl_free()
1999 kfree(ctrl->queues); in nvme_fc_ctrl_free()
2001 put_device(ctrl->dev); in nvme_fc_ctrl_free()
2002 nvme_fc_rport_put(ctrl->rport); in nvme_fc_ctrl_free()
2004 ida_simple_remove(&nvme_fc_ctrl_cnt, ctrl->cnum); in nvme_fc_ctrl_free()
2005 if (ctrl->ctrl.opts) in nvme_fc_ctrl_free()
2006 nvmf_free_options(ctrl->ctrl.opts); in nvme_fc_ctrl_free()
2007 kfree(ctrl); in nvme_fc_ctrl_free()
2011 nvme_fc_ctrl_put(struct nvme_fc_ctrl *ctrl) in nvme_fc_ctrl_put() argument
2013 kref_put(&ctrl->ref, nvme_fc_ctrl_free); in nvme_fc_ctrl_put()
2017 nvme_fc_ctrl_get(struct nvme_fc_ctrl *ctrl) in nvme_fc_ctrl_get() argument
2019 return kref_get_unless_zero(&ctrl->ref); in nvme_fc_ctrl_get()
2029 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl); in nvme_fc_nvme_ctrl_freed() local
2031 WARN_ON(nctrl != &ctrl->ctrl); in nvme_fc_nvme_ctrl_freed()
2033 nvme_fc_ctrl_put(ctrl); in nvme_fc_nvme_ctrl_freed()
2037 nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl, char *errmsg) in nvme_fc_error_recovery() argument
2040 if (ctrl->ctrl.state != NVME_CTRL_LIVE) in nvme_fc_error_recovery()
2043 dev_warn(ctrl->ctrl.device, in nvme_fc_error_recovery()
2045 ctrl->cnum, errmsg); in nvme_fc_error_recovery()
2046 dev_warn(ctrl->ctrl.device, in nvme_fc_error_recovery()
2047 "NVME-FC{%d}: resetting controller\n", ctrl->cnum); in nvme_fc_error_recovery()
2049 nvme_reset_ctrl(&ctrl->ctrl); in nvme_fc_error_recovery()
2056 struct nvme_fc_ctrl *ctrl = op->ctrl; in nvme_fc_timeout() local
2065 nvme_fc_error_recovery(ctrl, "io timeout error"); in nvme_fc_timeout()
2076 nvme_fc_map_data(struct nvme_fc_ctrl *ctrl, struct request *rq, in nvme_fc_map_data() argument
2097 freq->sg_cnt = fc_dma_map_sg(ctrl->lport->dev, freq->sg_table.sgl, in nvme_fc_map_data()
2112 nvme_fc_unmap_data(struct nvme_fc_ctrl *ctrl, struct request *rq, in nvme_fc_unmap_data() argument
2120 fc_dma_unmap_sg(ctrl->lport->dev, freq->sg_table.sgl, op->nents, in nvme_fc_unmap_data()
2155 nvme_fc_start_fcp_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue, in nvme_fc_start_fcp_op() argument
2168 if (ctrl->rport->remoteport.port_state != FC_OBJSTATE_ONLINE) in nvme_fc_start_fcp_op()
2171 if (!nvme_fc_ctrl_get(ctrl)) in nvme_fc_start_fcp_op()
2217 ret = nvme_fc_map_data(ctrl, op->rq, op); in nvme_fc_start_fcp_op()
2220 nvme_fc_ctrl_put(ctrl); in nvme_fc_start_fcp_op()
2227 fc_dma_sync_single_for_device(ctrl->lport->dev, op->fcp_req.cmddma, in nvme_fc_start_fcp_op()
2235 ret = ctrl->lport->ops->fcp_io(&ctrl->lport->localport, in nvme_fc_start_fcp_op()
2236 &ctrl->rport->remoteport, in nvme_fc_start_fcp_op()
2241 __nvme_fc_fcpop_chk_teardowns(ctrl, op, opstate); in nvme_fc_start_fcp_op()
2244 nvme_fc_unmap_data(ctrl, op->rq, op); in nvme_fc_start_fcp_op()
2246 nvme_fc_ctrl_put(ctrl); in nvme_fc_start_fcp_op()
2248 if (ctrl->rport->remoteport.port_state == FC_OBJSTATE_ONLINE && in nvme_fc_start_fcp_op()
2264 struct nvme_fc_ctrl *ctrl = queue->ctrl; in nvme_fc_queue_rq() local
2274 if (ctrl->rport->remoteport.port_state != FC_OBJSTATE_ONLINE || in nvme_fc_queue_rq()
2275 !nvmf_check_ready(&queue->ctrl->ctrl, rq, queue_ready)) in nvme_fc_queue_rq()
2276 return nvmf_fail_nonready_command(&queue->ctrl->ctrl, rq); in nvme_fc_queue_rq()
2289 return nvme_fc_start_fcp_op(ctrl, queue, op, data_len, io_dir); in nvme_fc_queue_rq()
2296 return queue->ctrl->admin_tag_set.tags[queue->qnum]; in nvme_fc_tagset()
2298 return queue->ctrl->tag_set.tags[queue->qnum - 1]; in nvme_fc_tagset()
2306 struct nvme_fc_ctrl *ctrl = queue->ctrl; in nvme_fc_poll() local
2317 (ctrl->lport->ops->poll_queue)) in nvme_fc_poll()
2318 ctrl->lport->ops->poll_queue(&ctrl->lport->localport, in nvme_fc_poll()
2327 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(arg); in nvme_fc_submit_async_event() local
2333 spin_lock_irqsave(&ctrl->lock, flags); in nvme_fc_submit_async_event()
2334 if (ctrl->flags & FCCTRL_TERMIO) in nvme_fc_submit_async_event()
2336 spin_unlock_irqrestore(&ctrl->lock, flags); in nvme_fc_submit_async_event()
2341 aen_op = &ctrl->aen_ops[0]; in nvme_fc_submit_async_event()
2343 ret = nvme_fc_start_fcp_op(ctrl, aen_op->queue, aen_op, 0, in nvme_fc_submit_async_event()
2346 dev_err(ctrl->ctrl.device, in nvme_fc_submit_async_event()
2354 struct nvme_fc_ctrl *ctrl = op->ctrl; in nvme_fc_complete_rq() local
2358 nvme_fc_unmap_data(ctrl, rq, op); in nvme_fc_complete_rq()
2360 nvme_fc_ctrl_put(ctrl); in nvme_fc_complete_rq()
2380 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl); in nvme_fc_terminate_exchange() local
2383 __nvme_fc_abort_op(ctrl, op); in nvme_fc_terminate_exchange()
2398 nvme_fc_create_io_queues(struct nvme_fc_ctrl *ctrl) in nvme_fc_create_io_queues() argument
2400 struct nvmf_ctrl_options *opts = ctrl->ctrl.opts; in nvme_fc_create_io_queues()
2405 ctrl->lport->ops->max_hw_queues); in nvme_fc_create_io_queues()
2406 ret = nvme_set_queue_count(&ctrl->ctrl, &nr_io_queues); in nvme_fc_create_io_queues()
2408 dev_info(ctrl->ctrl.device, in nvme_fc_create_io_queues()
2413 ctrl->ctrl.queue_count = nr_io_queues + 1; in nvme_fc_create_io_queues()
2417 nvme_fc_init_io_queues(ctrl); in nvme_fc_create_io_queues()
2419 memset(&ctrl->tag_set, 0, sizeof(ctrl->tag_set)); in nvme_fc_create_io_queues()
2420 ctrl->tag_set.ops = &nvme_fc_mq_ops; in nvme_fc_create_io_queues()
2421 ctrl->tag_set.queue_depth = ctrl->ctrl.opts->queue_size; in nvme_fc_create_io_queues()
2422 ctrl->tag_set.reserved_tags = 1; /* fabric connect */ in nvme_fc_create_io_queues()
2423 ctrl->tag_set.numa_node = NUMA_NO_NODE; in nvme_fc_create_io_queues()
2424 ctrl->tag_set.flags = BLK_MQ_F_SHOULD_MERGE; in nvme_fc_create_io_queues()
2425 ctrl->tag_set.cmd_size = sizeof(struct nvme_fc_fcp_op) + in nvme_fc_create_io_queues()
2428 ctrl->lport->ops->fcprqst_priv_sz; in nvme_fc_create_io_queues()
2429 ctrl->tag_set.driver_data = ctrl; in nvme_fc_create_io_queues()
2430 ctrl->tag_set.nr_hw_queues = ctrl->ctrl.queue_count - 1; in nvme_fc_create_io_queues()
2431 ctrl->tag_set.timeout = NVME_IO_TIMEOUT; in nvme_fc_create_io_queues()
2433 ret = blk_mq_alloc_tag_set(&ctrl->tag_set); in nvme_fc_create_io_queues()
2437 ctrl->ctrl.tagset = &ctrl->tag_set; in nvme_fc_create_io_queues()
2439 ctrl->ctrl.connect_q = blk_mq_init_queue(&ctrl->tag_set); in nvme_fc_create_io_queues()
2440 if (IS_ERR(ctrl->ctrl.connect_q)) { in nvme_fc_create_io_queues()
2441 ret = PTR_ERR(ctrl->ctrl.connect_q); in nvme_fc_create_io_queues()
2445 ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize + 1); in nvme_fc_create_io_queues()
2449 ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize + 1); in nvme_fc_create_io_queues()
2453 ctrl->ioq_live = true; in nvme_fc_create_io_queues()
2458 nvme_fc_delete_hw_io_queues(ctrl); in nvme_fc_create_io_queues()
2460 blk_cleanup_queue(ctrl->ctrl.connect_q); in nvme_fc_create_io_queues()
2462 blk_mq_free_tag_set(&ctrl->tag_set); in nvme_fc_create_io_queues()
2463 nvme_fc_free_io_queues(ctrl); in nvme_fc_create_io_queues()
2466 ctrl->ctrl.tagset = NULL; in nvme_fc_create_io_queues()
2472 nvme_fc_recreate_io_queues(struct nvme_fc_ctrl *ctrl) in nvme_fc_recreate_io_queues() argument
2474 struct nvmf_ctrl_options *opts = ctrl->ctrl.opts; in nvme_fc_recreate_io_queues()
2479 ctrl->lport->ops->max_hw_queues); in nvme_fc_recreate_io_queues()
2480 ret = nvme_set_queue_count(&ctrl->ctrl, &nr_io_queues); in nvme_fc_recreate_io_queues()
2482 dev_info(ctrl->ctrl.device, in nvme_fc_recreate_io_queues()
2487 ctrl->ctrl.queue_count = nr_io_queues + 1; in nvme_fc_recreate_io_queues()
2489 if (ctrl->ctrl.queue_count == 1) in nvme_fc_recreate_io_queues()
2492 ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize + 1); in nvme_fc_recreate_io_queues()
2496 ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize + 1); in nvme_fc_recreate_io_queues()
2500 blk_mq_update_nr_hw_queues(&ctrl->tag_set, nr_io_queues); in nvme_fc_recreate_io_queues()
2505 nvme_fc_delete_hw_io_queues(ctrl); in nvme_fc_recreate_io_queues()
2507 nvme_fc_free_io_queues(ctrl); in nvme_fc_recreate_io_queues()
2531 nvme_fc_ctlr_active_on_rport(struct nvme_fc_ctrl *ctrl) in nvme_fc_ctlr_active_on_rport() argument
2533 struct nvme_fc_rport *rport = ctrl->rport; in nvme_fc_ctlr_active_on_rport()
2536 if (ctrl->assoc_active) in nvme_fc_ctlr_active_on_rport()
2539 ctrl->assoc_active = true; in nvme_fc_ctlr_active_on_rport()
2548 nvme_fc_ctlr_inactive_on_rport(struct nvme_fc_ctrl *ctrl) in nvme_fc_ctlr_inactive_on_rport() argument
2550 struct nvme_fc_rport *rport = ctrl->rport; in nvme_fc_ctlr_inactive_on_rport()
2571 nvme_fc_create_association(struct nvme_fc_ctrl *ctrl) in nvme_fc_create_association() argument
2573 struct nvmf_ctrl_options *opts = ctrl->ctrl.opts; in nvme_fc_create_association()
2577 ++ctrl->ctrl.nr_reconnects; in nvme_fc_create_association()
2579 if (ctrl->rport->remoteport.port_state != FC_OBJSTATE_ONLINE) in nvme_fc_create_association()
2582 if (nvme_fc_ctlr_active_on_rport(ctrl)) in nvme_fc_create_association()
2589 ret = __nvme_fc_create_hw_queue(ctrl, &ctrl->queues[0], 0, in nvme_fc_create_association()
2594 ret = nvme_fc_connect_admin_queue(ctrl, &ctrl->queues[0], in nvme_fc_create_association()
2599 blk_mq_unquiesce_queue(ctrl->ctrl.admin_q); in nvme_fc_create_association()
2601 ret = nvmf_connect_admin_queue(&ctrl->ctrl); in nvme_fc_create_association()
2605 set_bit(NVME_FC_Q_LIVE, &ctrl->queues[0].flags); in nvme_fc_create_association()
2614 ret = nvmf_reg_read64(&ctrl->ctrl, NVME_REG_CAP, &ctrl->ctrl.cap); in nvme_fc_create_association()
2616 dev_err(ctrl->ctrl.device, in nvme_fc_create_association()
2621 ctrl->ctrl.sqsize = in nvme_fc_create_association()
2622 min_t(int, NVME_CAP_MQES(ctrl->ctrl.cap), ctrl->ctrl.sqsize); in nvme_fc_create_association()
2624 ret = nvme_enable_ctrl(&ctrl->ctrl, ctrl->ctrl.cap); in nvme_fc_create_association()
2628 ctrl->ctrl.max_hw_sectors = in nvme_fc_create_association()
2629 (ctrl->lport->ops->max_sgl_segments - 1) << (PAGE_SHIFT - 9); in nvme_fc_create_association()
2631 ret = nvme_init_identify(&ctrl->ctrl); in nvme_fc_create_association()
2638 if (ctrl->ctrl.icdoff) { in nvme_fc_create_association()
2639 dev_err(ctrl->ctrl.device, "icdoff %d is not supported!\n", in nvme_fc_create_association()
2640 ctrl->ctrl.icdoff); in nvme_fc_create_association()
2646 if (opts->queue_size > ctrl->ctrl.maxcmd) { in nvme_fc_create_association()
2648 dev_warn(ctrl->ctrl.device, in nvme_fc_create_association()
2651 opts->queue_size, ctrl->ctrl.maxcmd); in nvme_fc_create_association()
2652 opts->queue_size = ctrl->ctrl.maxcmd; in nvme_fc_create_association()
2655 if (opts->queue_size > ctrl->ctrl.sqsize + 1) { in nvme_fc_create_association()
2657 dev_warn(ctrl->ctrl.device, in nvme_fc_create_association()
2659 opts->queue_size, ctrl->ctrl.sqsize + 1); in nvme_fc_create_association()
2660 opts->queue_size = ctrl->ctrl.sqsize + 1; in nvme_fc_create_association()
2663 ret = nvme_fc_init_aen_ops(ctrl); in nvme_fc_create_association()
2671 if (ctrl->ctrl.queue_count > 1) { in nvme_fc_create_association()
2672 if (!ctrl->ioq_live) in nvme_fc_create_association()
2673 ret = nvme_fc_create_io_queues(ctrl); in nvme_fc_create_association()
2675 ret = nvme_fc_recreate_io_queues(ctrl); in nvme_fc_create_association()
2680 changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE); in nvme_fc_create_association()
2682 ctrl->ctrl.nr_reconnects = 0; in nvme_fc_create_association()
2685 nvme_start_ctrl(&ctrl->ctrl); in nvme_fc_create_association()
2690 nvme_fc_term_aen_ops(ctrl); in nvme_fc_create_association()
2693 nvme_fc_xmt_disconnect_assoc(ctrl); in nvme_fc_create_association()
2695 __nvme_fc_delete_hw_queue(ctrl, &ctrl->queues[0], 0); in nvme_fc_create_association()
2697 nvme_fc_free_queue(&ctrl->queues[0]); in nvme_fc_create_association()
2698 ctrl->assoc_active = false; in nvme_fc_create_association()
2699 nvme_fc_ctlr_inactive_on_rport(ctrl); in nvme_fc_create_association()
2711 nvme_fc_delete_association(struct nvme_fc_ctrl *ctrl) in nvme_fc_delete_association() argument
2715 if (!ctrl->assoc_active) in nvme_fc_delete_association()
2717 ctrl->assoc_active = false; in nvme_fc_delete_association()
2719 spin_lock_irqsave(&ctrl->lock, flags); in nvme_fc_delete_association()
2720 ctrl->flags |= FCCTRL_TERMIO; in nvme_fc_delete_association()
2721 ctrl->iocnt = 0; in nvme_fc_delete_association()
2722 spin_unlock_irqrestore(&ctrl->lock, flags); in nvme_fc_delete_association()
2736 if (ctrl->ctrl.queue_count > 1) { in nvme_fc_delete_association()
2737 nvme_stop_queues(&ctrl->ctrl); in nvme_fc_delete_association()
2738 blk_mq_tagset_busy_iter(&ctrl->tag_set, in nvme_fc_delete_association()
2739 nvme_fc_terminate_exchange, &ctrl->ctrl); in nvme_fc_delete_association()
2759 blk_mq_quiesce_queue(ctrl->ctrl.admin_q); in nvme_fc_delete_association()
2760 blk_mq_tagset_busy_iter(&ctrl->admin_tag_set, in nvme_fc_delete_association()
2761 nvme_fc_terminate_exchange, &ctrl->ctrl); in nvme_fc_delete_association()
2764 nvme_fc_abort_aen_ops(ctrl); in nvme_fc_delete_association()
2767 spin_lock_irq(&ctrl->lock); in nvme_fc_delete_association()
2768 wait_event_lock_irq(ctrl->ioabort_wait, ctrl->iocnt == 0, ctrl->lock); in nvme_fc_delete_association()
2769 ctrl->flags &= ~FCCTRL_TERMIO; in nvme_fc_delete_association()
2770 spin_unlock_irq(&ctrl->lock); in nvme_fc_delete_association()
2772 nvme_fc_term_aen_ops(ctrl); in nvme_fc_delete_association()
2780 if (ctrl->association_id) in nvme_fc_delete_association()
2781 nvme_fc_xmt_disconnect_assoc(ctrl); in nvme_fc_delete_association()
2783 if (ctrl->ctrl.tagset) { in nvme_fc_delete_association()
2784 nvme_fc_delete_hw_io_queues(ctrl); in nvme_fc_delete_association()
2785 nvme_fc_free_io_queues(ctrl); in nvme_fc_delete_association()
2788 __nvme_fc_delete_hw_queue(ctrl, &ctrl->queues[0], 0); in nvme_fc_delete_association()
2789 nvme_fc_free_queue(&ctrl->queues[0]); in nvme_fc_delete_association()
2792 blk_mq_unquiesce_queue(ctrl->ctrl.admin_q); in nvme_fc_delete_association()
2795 nvme_start_queues(&ctrl->ctrl); in nvme_fc_delete_association()
2797 nvme_fc_ctlr_inactive_on_rport(ctrl); in nvme_fc_delete_association()
2803 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl); in nvme_fc_delete_ctrl() local
2805 cancel_delayed_work_sync(&ctrl->connect_work); in nvme_fc_delete_ctrl()
2810 nvme_fc_delete_association(ctrl); in nvme_fc_delete_ctrl()
2814 nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status) in nvme_fc_reconnect_or_delete() argument
2816 struct nvme_fc_rport *rport = ctrl->rport; in nvme_fc_reconnect_or_delete()
2818 unsigned long recon_delay = ctrl->ctrl.opts->reconnect_delay * HZ; in nvme_fc_reconnect_or_delete()
2821 if (ctrl->ctrl.state != NVME_CTRL_CONNECTING) in nvme_fc_reconnect_or_delete()
2825 dev_info(ctrl->ctrl.device, in nvme_fc_reconnect_or_delete()
2827 ctrl->cnum, status); in nvme_fc_reconnect_or_delete()
2831 if (recon && nvmf_should_reconnect(&ctrl->ctrl)) { in nvme_fc_reconnect_or_delete()
2833 dev_info(ctrl->ctrl.device, in nvme_fc_reconnect_or_delete()
2836 ctrl->cnum, recon_delay / HZ); in nvme_fc_reconnect_or_delete()
2840 queue_delayed_work(nvme_wq, &ctrl->connect_work, recon_delay); in nvme_fc_reconnect_or_delete()
2843 dev_warn(ctrl->ctrl.device, in nvme_fc_reconnect_or_delete()
2846 ctrl->cnum, ctrl->ctrl.nr_reconnects); in nvme_fc_reconnect_or_delete()
2848 dev_warn(ctrl->ctrl.device, in nvme_fc_reconnect_or_delete()
2851 ctrl->cnum, portptr->dev_loss_tmo); in nvme_fc_reconnect_or_delete()
2852 WARN_ON(nvme_delete_ctrl(&ctrl->ctrl)); in nvme_fc_reconnect_or_delete()
2859 struct nvme_fc_ctrl *ctrl = in nvme_fc_reset_ctrl_work() local
2860 container_of(work, struct nvme_fc_ctrl, ctrl.reset_work); in nvme_fc_reset_ctrl_work()
2863 nvme_stop_ctrl(&ctrl->ctrl); in nvme_fc_reset_ctrl_work()
2866 nvme_fc_delete_association(ctrl); in nvme_fc_reset_ctrl_work()
2868 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) { in nvme_fc_reset_ctrl_work()
2869 dev_err(ctrl->ctrl.device, in nvme_fc_reset_ctrl_work()
2871 "to CONNECTING\n", ctrl->cnum); in nvme_fc_reset_ctrl_work()
2875 if (ctrl->rport->remoteport.port_state == FC_OBJSTATE_ONLINE) in nvme_fc_reset_ctrl_work()
2876 ret = nvme_fc_create_association(ctrl); in nvme_fc_reset_ctrl_work()
2881 nvme_fc_reconnect_or_delete(ctrl, ret); in nvme_fc_reset_ctrl_work()
2883 dev_info(ctrl->ctrl.device, in nvme_fc_reset_ctrl_work()
2885 ctrl->cnum); in nvme_fc_reset_ctrl_work()
2906 struct nvme_fc_ctrl *ctrl = in nvme_fc_connect_ctrl_work() local
2910 ret = nvme_fc_create_association(ctrl); in nvme_fc_connect_ctrl_work()
2912 nvme_fc_reconnect_or_delete(ctrl, ret); in nvme_fc_connect_ctrl_work()
2914 dev_info(ctrl->ctrl.device, in nvme_fc_connect_ctrl_work()
2916 ctrl->cnum); in nvme_fc_connect_ctrl_work()
2942 struct nvme_fc_ctrl *ctrl; in nvme_fc_existing_controller() local
2947 list_for_each_entry(ctrl, &rport->ctrl_list, ctrl_list) { in nvme_fc_existing_controller()
2948 found = nvmf_ctlr_matches_baseopts(&ctrl->ctrl, opts); in nvme_fc_existing_controller()
2961 struct nvme_fc_ctrl *ctrl; in nvme_fc_init_ctrl() local
2977 ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); in nvme_fc_init_ctrl()
2978 if (!ctrl) { in nvme_fc_init_ctrl()
2989 ctrl->ctrl.opts = opts; in nvme_fc_init_ctrl()
2990 ctrl->ctrl.nr_reconnects = 0; in nvme_fc_init_ctrl()
2991 INIT_LIST_HEAD(&ctrl->ctrl_list); in nvme_fc_init_ctrl()
2992 ctrl->lport = lport; in nvme_fc_init_ctrl()
2993 ctrl->rport = rport; in nvme_fc_init_ctrl()
2994 ctrl->dev = lport->dev; in nvme_fc_init_ctrl()
2995 ctrl->cnum = idx; in nvme_fc_init_ctrl()
2996 ctrl->ioq_live = false; in nvme_fc_init_ctrl()
2997 ctrl->assoc_active = false; in nvme_fc_init_ctrl()
2998 init_waitqueue_head(&ctrl->ioabort_wait); in nvme_fc_init_ctrl()
3000 get_device(ctrl->dev); in nvme_fc_init_ctrl()
3001 kref_init(&ctrl->ref); in nvme_fc_init_ctrl()
3003 INIT_WORK(&ctrl->ctrl.reset_work, nvme_fc_reset_ctrl_work); in nvme_fc_init_ctrl()
3004 INIT_DELAYED_WORK(&ctrl->connect_work, nvme_fc_connect_ctrl_work); in nvme_fc_init_ctrl()
3005 spin_lock_init(&ctrl->lock); in nvme_fc_init_ctrl()
3008 ctrl->ctrl.queue_count = min_t(unsigned int, in nvme_fc_init_ctrl()
3011 ctrl->ctrl.queue_count++; /* +1 for admin queue */ in nvme_fc_init_ctrl()
3013 ctrl->ctrl.sqsize = opts->queue_size - 1; in nvme_fc_init_ctrl()
3014 ctrl->ctrl.kato = opts->kato; in nvme_fc_init_ctrl()
3015 ctrl->ctrl.cntlid = 0xffff; in nvme_fc_init_ctrl()
3018 ctrl->queues = kcalloc(ctrl->ctrl.queue_count, in nvme_fc_init_ctrl()
3020 if (!ctrl->queues) in nvme_fc_init_ctrl()
3023 nvme_fc_init_queue(ctrl, 0); in nvme_fc_init_ctrl()
3025 memset(&ctrl->admin_tag_set, 0, sizeof(ctrl->admin_tag_set)); in nvme_fc_init_ctrl()
3026 ctrl->admin_tag_set.ops = &nvme_fc_admin_mq_ops; in nvme_fc_init_ctrl()
3027 ctrl->admin_tag_set.queue_depth = NVME_AQ_MQ_TAG_DEPTH; in nvme_fc_init_ctrl()
3028 ctrl->admin_tag_set.reserved_tags = 2; /* fabric connect + Keep-Alive */ in nvme_fc_init_ctrl()
3029 ctrl->admin_tag_set.numa_node = NUMA_NO_NODE; in nvme_fc_init_ctrl()
3030 ctrl->admin_tag_set.cmd_size = sizeof(struct nvme_fc_fcp_op) + in nvme_fc_init_ctrl()
3033 ctrl->lport->ops->fcprqst_priv_sz; in nvme_fc_init_ctrl()
3034 ctrl->admin_tag_set.driver_data = ctrl; in nvme_fc_init_ctrl()
3035 ctrl->admin_tag_set.nr_hw_queues = 1; in nvme_fc_init_ctrl()
3036 ctrl->admin_tag_set.timeout = ADMIN_TIMEOUT; in nvme_fc_init_ctrl()
3037 ctrl->admin_tag_set.flags = BLK_MQ_F_NO_SCHED; in nvme_fc_init_ctrl()
3039 ret = blk_mq_alloc_tag_set(&ctrl->admin_tag_set); in nvme_fc_init_ctrl()
3042 ctrl->ctrl.admin_tagset = &ctrl->admin_tag_set; in nvme_fc_init_ctrl()
3044 ctrl->ctrl.admin_q = blk_mq_init_queue(&ctrl->admin_tag_set); in nvme_fc_init_ctrl()
3045 if (IS_ERR(ctrl->ctrl.admin_q)) { in nvme_fc_init_ctrl()
3046 ret = PTR_ERR(ctrl->ctrl.admin_q); in nvme_fc_init_ctrl()
3057 ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_fc_ctrl_ops, 0); in nvme_fc_init_ctrl()
3064 list_add_tail(&ctrl->ctrl_list, &rport->ctrl_list); in nvme_fc_init_ctrl()
3067 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RESETTING) || in nvme_fc_init_ctrl()
3068 !nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) { in nvme_fc_init_ctrl()
3069 dev_err(ctrl->ctrl.device, in nvme_fc_init_ctrl()
3070 "NVME-FC{%d}: failed to init ctrl state\n", ctrl->cnum); in nvme_fc_init_ctrl()
3074 nvme_get_ctrl(&ctrl->ctrl); in nvme_fc_init_ctrl()
3076 if (!queue_delayed_work(nvme_wq, &ctrl->connect_work, 0)) { in nvme_fc_init_ctrl()
3077 nvme_put_ctrl(&ctrl->ctrl); in nvme_fc_init_ctrl()
3078 dev_err(ctrl->ctrl.device, in nvme_fc_init_ctrl()
3080 ctrl->cnum); in nvme_fc_init_ctrl()
3084 flush_delayed_work(&ctrl->connect_work); in nvme_fc_init_ctrl()
3086 dev_info(ctrl->ctrl.device, in nvme_fc_init_ctrl()
3088 ctrl->cnum, ctrl->ctrl.opts->subsysnqn); in nvme_fc_init_ctrl()
3090 return &ctrl->ctrl; in nvme_fc_init_ctrl()
3093 nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_DELETING); in nvme_fc_init_ctrl()
3094 cancel_work_sync(&ctrl->ctrl.reset_work); in nvme_fc_init_ctrl()
3095 cancel_delayed_work_sync(&ctrl->connect_work); in nvme_fc_init_ctrl()
3097 ctrl->ctrl.opts = NULL; in nvme_fc_init_ctrl()
3100 nvme_uninit_ctrl(&ctrl->ctrl); in nvme_fc_init_ctrl()
3103 nvme_put_ctrl(&ctrl->ctrl); in nvme_fc_init_ctrl()
3117 blk_cleanup_queue(ctrl->ctrl.admin_q); in nvme_fc_init_ctrl()
3119 blk_mq_free_tag_set(&ctrl->admin_tag_set); in nvme_fc_init_ctrl()
3121 kfree(ctrl->queues); in nvme_fc_init_ctrl()
3123 put_device(ctrl->dev); in nvme_fc_init_ctrl()
3124 ida_simple_remove(&nvme_fc_ctrl_cnt, ctrl->cnum); in nvme_fc_init_ctrl()
3126 kfree(ctrl); in nvme_fc_init_ctrl()
3203 struct nvme_ctrl *ctrl; in nvme_fc_create_ctrl() local
3235 ctrl = nvme_fc_init_ctrl(dev, opts, lport, rport); in nvme_fc_create_ctrl()
3236 if (IS_ERR(ctrl)) in nvme_fc_create_ctrl()
3238 return ctrl; in nvme_fc_create_ctrl()