Lines Matching full:ctrl

138 	struct nvme_tcp_ctrl	*ctrl;  member
166 struct nvme_ctrl ctrl; member
181 static inline struct nvme_tcp_ctrl *to_tcp_ctrl(struct nvme_ctrl *ctrl) in to_tcp_ctrl() argument
183 return container_of(ctrl, struct nvme_tcp_ctrl, ctrl); in to_tcp_ctrl()
188 return queue - queue->ctrl->queues; in nvme_tcp_queue_id()
196 return queue->ctrl->admin_tag_set.tags[queue_idx]; in nvme_tcp_tagset()
197 return queue->ctrl->tag_set.tags[queue_idx - 1]; in nvme_tcp_tagset()
219 return req == &req->queue->ctrl->async_req; in nvme_tcp_async_req()
414 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_verify_hdgst()
424 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_verify_hdgst()
443 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_check_ddgst()
465 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(set->driver_data); in nvme_tcp_init_request() local
468 int queue_idx = (set == &ctrl->tag_set) ? hctx_idx + 1 : 0; in nvme_tcp_init_request()
469 struct nvme_tcp_queue *queue = &ctrl->queues[queue_idx]; in nvme_tcp_init_request()
480 nvme_req(rq)->ctrl = &ctrl->ctrl; in nvme_tcp_init_request()
489 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(data); in nvme_tcp_init_hctx() local
490 struct nvme_tcp_queue *queue = &ctrl->queues[hctx_idx + 1]; in nvme_tcp_init_hctx()
499 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(data); in nvme_tcp_init_admin_hctx() local
500 struct nvme_tcp_queue *queue = &ctrl->queues[0]; in nvme_tcp_init_admin_hctx()
523 static void nvme_tcp_error_recovery(struct nvme_ctrl *ctrl) in nvme_tcp_error_recovery() argument
525 if (!nvme_change_ctrl_state(ctrl, NVME_CTRL_RESETTING)) in nvme_tcp_error_recovery()
528 dev_warn(ctrl->device, "starting error recovery\n"); in nvme_tcp_error_recovery()
529 queue_work(nvme_reset_wq, &to_tcp_ctrl(ctrl)->err_work); in nvme_tcp_error_recovery()
540 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_process_nvme_cqe()
543 nvme_tcp_error_recovery(&queue->ctrl->ctrl); in nvme_tcp_process_nvme_cqe()
565 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_c2h_data()
572 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_c2h_data()
582 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_c2h_data()
585 nvme_tcp_error_recovery(&queue->ctrl->ctrl); in nvme_tcp_handle_c2h_data()
606 nvme_complete_async_event(&queue->ctrl->ctrl, cqe->status, in nvme_tcp_handle_comp()
658 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_r2t()
666 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_r2t()
673 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_r2t()
680 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_r2t()
741 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_recv_pdu()
778 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_recv_data()
798 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_recv_data()
852 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_recv_ddgst()
893 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_recv_skb()
896 nvme_tcp_error_recovery(&queue->ctrl->ctrl); in nvme_tcp_recv_skb()
944 nvme_tcp_error_recovery(&queue->ctrl->ctrl); in nvme_tcp_state_change()
947 dev_info(queue->ctrl->ctrl.device, in nvme_tcp_state_change()
967 nvme_complete_async_event(&req->queue->ctrl->ctrl, in nvme_tcp_fail_request()
1181 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_try_send()
1275 static void nvme_tcp_free_async_req(struct nvme_tcp_ctrl *ctrl) in nvme_tcp_free_async_req() argument
1277 struct nvme_tcp_request *async = &ctrl->async_req; in nvme_tcp_free_async_req()
1282 static int nvme_tcp_alloc_async_req(struct nvme_tcp_ctrl *ctrl) in nvme_tcp_alloc_async_req() argument
1284 struct nvme_tcp_queue *queue = &ctrl->queues[0]; in nvme_tcp_alloc_async_req()
1285 struct nvme_tcp_request *async = &ctrl->async_req; in nvme_tcp_alloc_async_req()
1294 async->queue = &ctrl->queues[0]; in nvme_tcp_alloc_async_req()
1301 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl); in nvme_tcp_free_queue() local
1302 struct nvme_tcp_queue *queue = &ctrl->queues[qid]; in nvme_tcp_free_queue()
1394 pr_err("queue %d: data digest mismatch host: %s ctrl: %s\n", in nvme_tcp_init_connection()
1404 pr_err("queue %d: header digest mismatch host: %s ctrl: %s\n", in nvme_tcp_init_connection()
1440 struct nvme_tcp_ctrl *ctrl = queue->ctrl; in nvme_tcp_default_queue() local
1444 qid < 1 + ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_tcp_default_queue()
1449 struct nvme_tcp_ctrl *ctrl = queue->ctrl; in nvme_tcp_read_queue() local
1454 qid < 1 + ctrl->io_queues[HCTX_TYPE_DEFAULT] + in nvme_tcp_read_queue()
1455 ctrl->io_queues[HCTX_TYPE_READ]; in nvme_tcp_read_queue()
1460 struct nvme_tcp_ctrl *ctrl = queue->ctrl; in nvme_tcp_poll_queue() local
1466 qid < 1 + ctrl->io_queues[HCTX_TYPE_DEFAULT] + in nvme_tcp_poll_queue()
1467 ctrl->io_queues[HCTX_TYPE_READ] + in nvme_tcp_poll_queue()
1468 ctrl->io_queues[HCTX_TYPE_POLL]; in nvme_tcp_poll_queue()
1473 struct nvme_tcp_ctrl *ctrl = queue->ctrl; in nvme_tcp_set_queue_io_cpu() local
1480 n = qid - ctrl->io_queues[HCTX_TYPE_DEFAULT] - 1; in nvme_tcp_set_queue_io_cpu()
1482 n = qid - ctrl->io_queues[HCTX_TYPE_DEFAULT] - in nvme_tcp_set_queue_io_cpu()
1483 ctrl->io_queues[HCTX_TYPE_READ] - 1; in nvme_tcp_set_queue_io_cpu()
1489 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl); in nvme_tcp_alloc_queue() local
1490 struct nvme_tcp_queue *queue = &ctrl->queues[qid]; in nvme_tcp_alloc_queue()
1494 queue->ctrl = ctrl; in nvme_tcp_alloc_queue()
1506 ret = sock_create(ctrl->addr.ss_family, SOCK_STREAM, in nvme_tcp_alloc_queue()
1549 ret = kernel_bind(queue->sock, (struct sockaddr *)&ctrl->src_addr, in nvme_tcp_alloc_queue()
1550 sizeof(ctrl->src_addr)); in nvme_tcp_alloc_queue()
1595 ret = kernel_connect(queue->sock, (struct sockaddr *)&ctrl->addr, in nvme_tcp_alloc_queue()
1596 sizeof(ctrl->addr), 0); in nvme_tcp_alloc_queue()
1663 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl); in nvme_tcp_stop_queue() local
1664 struct nvme_tcp_queue *queue = &ctrl->queues[qid]; in nvme_tcp_stop_queue()
1677 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl); in nvme_tcp_start_queue() local
1686 set_bit(NVME_TCP_Q_LIVE, &ctrl->queues[idx].flags); in nvme_tcp_start_queue()
1688 if (test_bit(NVME_TCP_Q_ALLOCATED, &ctrl->queues[idx].flags)) in nvme_tcp_start_queue()
1689 __nvme_tcp_stop_queue(&ctrl->queues[idx]); in nvme_tcp_start_queue()
1696 static void nvme_tcp_free_admin_queue(struct nvme_ctrl *ctrl) in nvme_tcp_free_admin_queue() argument
1698 if (to_tcp_ctrl(ctrl)->async_req.pdu) { in nvme_tcp_free_admin_queue()
1699 cancel_work_sync(&ctrl->async_event_work); in nvme_tcp_free_admin_queue()
1700 nvme_tcp_free_async_req(to_tcp_ctrl(ctrl)); in nvme_tcp_free_admin_queue()
1701 to_tcp_ctrl(ctrl)->async_req.pdu = NULL; in nvme_tcp_free_admin_queue()
1704 nvme_tcp_free_queue(ctrl, 0); in nvme_tcp_free_admin_queue()
1707 static void nvme_tcp_free_io_queues(struct nvme_ctrl *ctrl) in nvme_tcp_free_io_queues() argument
1711 for (i = 1; i < ctrl->queue_count; i++) in nvme_tcp_free_io_queues()
1712 nvme_tcp_free_queue(ctrl, i); in nvme_tcp_free_io_queues()
1715 static void nvme_tcp_stop_io_queues(struct nvme_ctrl *ctrl) in nvme_tcp_stop_io_queues() argument
1719 for (i = 1; i < ctrl->queue_count; i++) in nvme_tcp_stop_io_queues()
1720 nvme_tcp_stop_queue(ctrl, i); in nvme_tcp_stop_io_queues()
1723 static int nvme_tcp_start_io_queues(struct nvme_ctrl *ctrl, in nvme_tcp_start_io_queues() argument
1729 ret = nvme_tcp_start_queue(ctrl, i); in nvme_tcp_start_io_queues()
1738 nvme_tcp_stop_queue(ctrl, i); in nvme_tcp_start_io_queues()
1742 static int nvme_tcp_alloc_admin_queue(struct nvme_ctrl *ctrl) in nvme_tcp_alloc_admin_queue() argument
1746 ret = nvme_tcp_alloc_queue(ctrl, 0); in nvme_tcp_alloc_admin_queue()
1750 ret = nvme_tcp_alloc_async_req(to_tcp_ctrl(ctrl)); in nvme_tcp_alloc_admin_queue()
1757 nvme_tcp_free_queue(ctrl, 0); in nvme_tcp_alloc_admin_queue()
1761 static int __nvme_tcp_alloc_io_queues(struct nvme_ctrl *ctrl) in __nvme_tcp_alloc_io_queues() argument
1765 for (i = 1; i < ctrl->queue_count; i++) { in __nvme_tcp_alloc_io_queues()
1766 ret = nvme_tcp_alloc_queue(ctrl, i); in __nvme_tcp_alloc_io_queues()
1775 nvme_tcp_free_queue(ctrl, i); in __nvme_tcp_alloc_io_queues()
1780 static unsigned int nvme_tcp_nr_io_queues(struct nvme_ctrl *ctrl) in nvme_tcp_nr_io_queues() argument
1784 nr_io_queues = min(ctrl->opts->nr_io_queues, num_online_cpus()); in nvme_tcp_nr_io_queues()
1785 nr_io_queues += min(ctrl->opts->nr_write_queues, num_online_cpus()); in nvme_tcp_nr_io_queues()
1786 nr_io_queues += min(ctrl->opts->nr_poll_queues, num_online_cpus()); in nvme_tcp_nr_io_queues()
1794 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl); in nvme_tcp_set_io_queues() local
1803 ctrl->io_queues[HCTX_TYPE_READ] = opts->nr_io_queues; in nvme_tcp_set_io_queues()
1804 nr_io_queues -= ctrl->io_queues[HCTX_TYPE_READ]; in nvme_tcp_set_io_queues()
1805 ctrl->io_queues[HCTX_TYPE_DEFAULT] = in nvme_tcp_set_io_queues()
1807 nr_io_queues -= ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_tcp_set_io_queues()
1814 ctrl->io_queues[HCTX_TYPE_DEFAULT] = in nvme_tcp_set_io_queues()
1816 nr_io_queues -= ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_tcp_set_io_queues()
1821 ctrl->io_queues[HCTX_TYPE_POLL] = in nvme_tcp_set_io_queues()
1826 static int nvme_tcp_alloc_io_queues(struct nvme_ctrl *ctrl) in nvme_tcp_alloc_io_queues() argument
1831 nr_io_queues = nvme_tcp_nr_io_queues(ctrl); in nvme_tcp_alloc_io_queues()
1832 ret = nvme_set_queue_count(ctrl, &nr_io_queues); in nvme_tcp_alloc_io_queues()
1837 dev_err(ctrl->device, in nvme_tcp_alloc_io_queues()
1842 ctrl->queue_count = nr_io_queues + 1; in nvme_tcp_alloc_io_queues()
1843 dev_info(ctrl->device, in nvme_tcp_alloc_io_queues()
1846 nvme_tcp_set_io_queues(ctrl, nr_io_queues); in nvme_tcp_alloc_io_queues()
1848 return __nvme_tcp_alloc_io_queues(ctrl); in nvme_tcp_alloc_io_queues()
1851 static void nvme_tcp_destroy_io_queues(struct nvme_ctrl *ctrl, bool remove) in nvme_tcp_destroy_io_queues() argument
1853 nvme_tcp_stop_io_queues(ctrl); in nvme_tcp_destroy_io_queues()
1855 nvme_remove_io_tag_set(ctrl); in nvme_tcp_destroy_io_queues()
1856 nvme_tcp_free_io_queues(ctrl); in nvme_tcp_destroy_io_queues()
1859 static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new) in nvme_tcp_configure_io_queues() argument
1863 ret = nvme_tcp_alloc_io_queues(ctrl); in nvme_tcp_configure_io_queues()
1868 ret = nvme_alloc_io_tag_set(ctrl, &to_tcp_ctrl(ctrl)->tag_set, in nvme_tcp_configure_io_queues()
1881 nr_queues = min(ctrl->tagset->nr_hw_queues + 1, ctrl->queue_count); in nvme_tcp_configure_io_queues()
1882 ret = nvme_tcp_start_io_queues(ctrl, 1, nr_queues); in nvme_tcp_configure_io_queues()
1887 nvme_start_queues(ctrl); in nvme_tcp_configure_io_queues()
1888 if (!nvme_wait_freeze_timeout(ctrl, NVME_IO_TIMEOUT)) { in nvme_tcp_configure_io_queues()
1897 blk_mq_update_nr_hw_queues(ctrl->tagset, in nvme_tcp_configure_io_queues()
1898 ctrl->queue_count - 1); in nvme_tcp_configure_io_queues()
1899 nvme_unfreeze(ctrl); in nvme_tcp_configure_io_queues()
1906 ret = nvme_tcp_start_io_queues(ctrl, nr_queues, in nvme_tcp_configure_io_queues()
1907 ctrl->tagset->nr_hw_queues + 1); in nvme_tcp_configure_io_queues()
1914 nvme_stop_queues(ctrl); in nvme_tcp_configure_io_queues()
1915 nvme_sync_io_queues(ctrl); in nvme_tcp_configure_io_queues()
1916 nvme_tcp_stop_io_queues(ctrl); in nvme_tcp_configure_io_queues()
1918 nvme_cancel_tagset(ctrl); in nvme_tcp_configure_io_queues()
1920 nvme_remove_io_tag_set(ctrl); in nvme_tcp_configure_io_queues()
1922 nvme_tcp_free_io_queues(ctrl); in nvme_tcp_configure_io_queues()
1926 static void nvme_tcp_destroy_admin_queue(struct nvme_ctrl *ctrl, bool remove) in nvme_tcp_destroy_admin_queue() argument
1928 nvme_tcp_stop_queue(ctrl, 0); in nvme_tcp_destroy_admin_queue()
1930 nvme_remove_admin_tag_set(ctrl); in nvme_tcp_destroy_admin_queue()
1931 nvme_tcp_free_admin_queue(ctrl); in nvme_tcp_destroy_admin_queue()
1934 static int nvme_tcp_configure_admin_queue(struct nvme_ctrl *ctrl, bool new) in nvme_tcp_configure_admin_queue() argument
1938 error = nvme_tcp_alloc_admin_queue(ctrl); in nvme_tcp_configure_admin_queue()
1943 error = nvme_alloc_admin_tag_set(ctrl, in nvme_tcp_configure_admin_queue()
1944 &to_tcp_ctrl(ctrl)->admin_tag_set, in nvme_tcp_configure_admin_queue()
1951 error = nvme_tcp_start_queue(ctrl, 0); in nvme_tcp_configure_admin_queue()
1955 error = nvme_enable_ctrl(ctrl); in nvme_tcp_configure_admin_queue()
1959 nvme_start_admin_queue(ctrl); in nvme_tcp_configure_admin_queue()
1961 error = nvme_init_ctrl_finish(ctrl); in nvme_tcp_configure_admin_queue()
1968 nvme_stop_admin_queue(ctrl); in nvme_tcp_configure_admin_queue()
1969 blk_sync_queue(ctrl->admin_q); in nvme_tcp_configure_admin_queue()
1971 nvme_tcp_stop_queue(ctrl, 0); in nvme_tcp_configure_admin_queue()
1972 nvme_cancel_admin_tagset(ctrl); in nvme_tcp_configure_admin_queue()
1975 nvme_remove_admin_tag_set(ctrl); in nvme_tcp_configure_admin_queue()
1977 nvme_tcp_free_admin_queue(ctrl); in nvme_tcp_configure_admin_queue()
1981 static void nvme_tcp_teardown_admin_queue(struct nvme_ctrl *ctrl, in nvme_tcp_teardown_admin_queue() argument
1984 nvme_stop_admin_queue(ctrl); in nvme_tcp_teardown_admin_queue()
1985 blk_sync_queue(ctrl->admin_q); in nvme_tcp_teardown_admin_queue()
1986 nvme_tcp_stop_queue(ctrl, 0); in nvme_tcp_teardown_admin_queue()
1987 nvme_cancel_admin_tagset(ctrl); in nvme_tcp_teardown_admin_queue()
1989 nvme_start_admin_queue(ctrl); in nvme_tcp_teardown_admin_queue()
1990 nvme_tcp_destroy_admin_queue(ctrl, remove); in nvme_tcp_teardown_admin_queue()
1993 static void nvme_tcp_teardown_io_queues(struct nvme_ctrl *ctrl, in nvme_tcp_teardown_io_queues() argument
1996 if (ctrl->queue_count <= 1) in nvme_tcp_teardown_io_queues()
1998 nvme_stop_admin_queue(ctrl); in nvme_tcp_teardown_io_queues()
1999 nvme_start_freeze(ctrl); in nvme_tcp_teardown_io_queues()
2000 nvme_stop_queues(ctrl); in nvme_tcp_teardown_io_queues()
2001 nvme_sync_io_queues(ctrl); in nvme_tcp_teardown_io_queues()
2002 nvme_tcp_stop_io_queues(ctrl); in nvme_tcp_teardown_io_queues()
2003 nvme_cancel_tagset(ctrl); in nvme_tcp_teardown_io_queues()
2005 nvme_start_queues(ctrl); in nvme_tcp_teardown_io_queues()
2006 nvme_tcp_destroy_io_queues(ctrl, remove); in nvme_tcp_teardown_io_queues()
2009 static void nvme_tcp_reconnect_or_remove(struct nvme_ctrl *ctrl) in nvme_tcp_reconnect_or_remove() argument
2012 if (ctrl->state != NVME_CTRL_CONNECTING) { in nvme_tcp_reconnect_or_remove()
2013 WARN_ON_ONCE(ctrl->state == NVME_CTRL_NEW || in nvme_tcp_reconnect_or_remove()
2014 ctrl->state == NVME_CTRL_LIVE); in nvme_tcp_reconnect_or_remove()
2018 if (nvmf_should_reconnect(ctrl)) { in nvme_tcp_reconnect_or_remove()
2019 dev_info(ctrl->device, "Reconnecting in %d seconds...\n", in nvme_tcp_reconnect_or_remove()
2020 ctrl->opts->reconnect_delay); in nvme_tcp_reconnect_or_remove()
2021 queue_delayed_work(nvme_wq, &to_tcp_ctrl(ctrl)->connect_work, in nvme_tcp_reconnect_or_remove()
2022 ctrl->opts->reconnect_delay * HZ); in nvme_tcp_reconnect_or_remove()
2024 dev_info(ctrl->device, "Removing controller...\n"); in nvme_tcp_reconnect_or_remove()
2025 nvme_delete_ctrl(ctrl); in nvme_tcp_reconnect_or_remove()
2029 static int nvme_tcp_setup_ctrl(struct nvme_ctrl *ctrl, bool new) in nvme_tcp_setup_ctrl() argument
2031 struct nvmf_ctrl_options *opts = ctrl->opts; in nvme_tcp_setup_ctrl()
2034 ret = nvme_tcp_configure_admin_queue(ctrl, new); in nvme_tcp_setup_ctrl()
2038 if (ctrl->icdoff) { in nvme_tcp_setup_ctrl()
2040 dev_err(ctrl->device, "icdoff is not supported!\n"); in nvme_tcp_setup_ctrl()
2044 if (!nvme_ctrl_sgl_supported(ctrl)) { in nvme_tcp_setup_ctrl()
2046 dev_err(ctrl->device, "Mandatory sgls are not supported!\n"); in nvme_tcp_setup_ctrl()
2050 if (opts->queue_size > ctrl->sqsize + 1) in nvme_tcp_setup_ctrl()
2051 dev_warn(ctrl->device, in nvme_tcp_setup_ctrl()
2052 "queue_size %zu > ctrl sqsize %u, clamping down\n", in nvme_tcp_setup_ctrl()
2053 opts->queue_size, ctrl->sqsize + 1); in nvme_tcp_setup_ctrl()
2055 if (ctrl->sqsize + 1 > ctrl->maxcmd) { in nvme_tcp_setup_ctrl()
2056 dev_warn(ctrl->device, in nvme_tcp_setup_ctrl()
2057 "sqsize %u > ctrl maxcmd %u, clamping down\n", in nvme_tcp_setup_ctrl()
2058 ctrl->sqsize + 1, ctrl->maxcmd); in nvme_tcp_setup_ctrl()
2059 ctrl->sqsize = ctrl->maxcmd - 1; in nvme_tcp_setup_ctrl()
2062 if (ctrl->queue_count > 1) { in nvme_tcp_setup_ctrl()
2063 ret = nvme_tcp_configure_io_queues(ctrl, new); in nvme_tcp_setup_ctrl()
2068 if (!nvme_change_ctrl_state(ctrl, NVME_CTRL_LIVE)) { in nvme_tcp_setup_ctrl()
2070 * state change failure is ok if we started ctrl delete, in nvme_tcp_setup_ctrl()
2074 WARN_ON_ONCE(ctrl->state != NVME_CTRL_DELETING && in nvme_tcp_setup_ctrl()
2075 ctrl->state != NVME_CTRL_DELETING_NOIO); in nvme_tcp_setup_ctrl()
2081 nvme_start_ctrl(ctrl); in nvme_tcp_setup_ctrl()
2085 if (ctrl->queue_count > 1) { in nvme_tcp_setup_ctrl()
2086 nvme_stop_queues(ctrl); in nvme_tcp_setup_ctrl()
2087 nvme_sync_io_queues(ctrl); in nvme_tcp_setup_ctrl()
2088 nvme_tcp_stop_io_queues(ctrl); in nvme_tcp_setup_ctrl()
2089 nvme_cancel_tagset(ctrl); in nvme_tcp_setup_ctrl()
2090 nvme_tcp_destroy_io_queues(ctrl, new); in nvme_tcp_setup_ctrl()
2093 nvme_stop_admin_queue(ctrl); in nvme_tcp_setup_ctrl()
2094 blk_sync_queue(ctrl->admin_q); in nvme_tcp_setup_ctrl()
2095 nvme_tcp_stop_queue(ctrl, 0); in nvme_tcp_setup_ctrl()
2096 nvme_cancel_admin_tagset(ctrl); in nvme_tcp_setup_ctrl()
2097 nvme_tcp_destroy_admin_queue(ctrl, new); in nvme_tcp_setup_ctrl()
2105 struct nvme_ctrl *ctrl = &tcp_ctrl->ctrl; in nvme_tcp_reconnect_ctrl_work() local
2107 ++ctrl->nr_reconnects; in nvme_tcp_reconnect_ctrl_work()
2109 if (nvme_tcp_setup_ctrl(ctrl, false)) in nvme_tcp_reconnect_ctrl_work()
2112 dev_info(ctrl->device, "Successfully reconnected (%d attempt)\n", in nvme_tcp_reconnect_ctrl_work()
2113 ctrl->nr_reconnects); in nvme_tcp_reconnect_ctrl_work()
2115 ctrl->nr_reconnects = 0; in nvme_tcp_reconnect_ctrl_work()
2120 dev_info(ctrl->device, "Failed reconnect attempt %d\n", in nvme_tcp_reconnect_ctrl_work()
2121 ctrl->nr_reconnects); in nvme_tcp_reconnect_ctrl_work()
2122 nvme_tcp_reconnect_or_remove(ctrl); in nvme_tcp_reconnect_ctrl_work()
2129 struct nvme_ctrl *ctrl = &tcp_ctrl->ctrl; in nvme_tcp_error_recovery_work() local
2131 nvme_auth_stop(ctrl); in nvme_tcp_error_recovery_work()
2132 nvme_stop_keep_alive(ctrl); in nvme_tcp_error_recovery_work()
2133 flush_work(&ctrl->async_event_work); in nvme_tcp_error_recovery_work()
2134 nvme_tcp_teardown_io_queues(ctrl, false); in nvme_tcp_error_recovery_work()
2136 nvme_start_queues(ctrl); in nvme_tcp_error_recovery_work()
2137 nvme_tcp_teardown_admin_queue(ctrl, false); in nvme_tcp_error_recovery_work()
2138 nvme_start_admin_queue(ctrl); in nvme_tcp_error_recovery_work()
2140 if (!nvme_change_ctrl_state(ctrl, NVME_CTRL_CONNECTING)) { in nvme_tcp_error_recovery_work()
2141 /* state change failure is ok if we started ctrl delete */ in nvme_tcp_error_recovery_work()
2142 WARN_ON_ONCE(ctrl->state != NVME_CTRL_DELETING && in nvme_tcp_error_recovery_work()
2143 ctrl->state != NVME_CTRL_DELETING_NOIO); in nvme_tcp_error_recovery_work()
2147 nvme_tcp_reconnect_or_remove(ctrl); in nvme_tcp_error_recovery_work()
2150 static void nvme_tcp_teardown_ctrl(struct nvme_ctrl *ctrl, bool shutdown) in nvme_tcp_teardown_ctrl() argument
2152 nvme_tcp_teardown_io_queues(ctrl, shutdown); in nvme_tcp_teardown_ctrl()
2153 nvme_stop_admin_queue(ctrl); in nvme_tcp_teardown_ctrl()
2155 nvme_shutdown_ctrl(ctrl); in nvme_tcp_teardown_ctrl()
2157 nvme_disable_ctrl(ctrl); in nvme_tcp_teardown_ctrl()
2158 nvme_tcp_teardown_admin_queue(ctrl, shutdown); in nvme_tcp_teardown_ctrl()
2161 static void nvme_tcp_delete_ctrl(struct nvme_ctrl *ctrl) in nvme_tcp_delete_ctrl() argument
2163 nvme_tcp_teardown_ctrl(ctrl, true); in nvme_tcp_delete_ctrl()
2168 struct nvme_ctrl *ctrl = in nvme_reset_ctrl_work() local
2171 nvme_stop_ctrl(ctrl); in nvme_reset_ctrl_work()
2172 nvme_tcp_teardown_ctrl(ctrl, false); in nvme_reset_ctrl_work()
2174 if (!nvme_change_ctrl_state(ctrl, NVME_CTRL_CONNECTING)) { in nvme_reset_ctrl_work()
2175 /* state change failure is ok if we started ctrl delete */ in nvme_reset_ctrl_work()
2176 WARN_ON_ONCE(ctrl->state != NVME_CTRL_DELETING && in nvme_reset_ctrl_work()
2177 ctrl->state != NVME_CTRL_DELETING_NOIO); in nvme_reset_ctrl_work()
2181 if (nvme_tcp_setup_ctrl(ctrl, false)) in nvme_reset_ctrl_work()
2187 ++ctrl->nr_reconnects; in nvme_reset_ctrl_work()
2188 nvme_tcp_reconnect_or_remove(ctrl); in nvme_reset_ctrl_work()
2191 static void nvme_tcp_stop_ctrl(struct nvme_ctrl *ctrl) in nvme_tcp_stop_ctrl() argument
2193 flush_work(&to_tcp_ctrl(ctrl)->err_work); in nvme_tcp_stop_ctrl()
2194 cancel_delayed_work_sync(&to_tcp_ctrl(ctrl)->connect_work); in nvme_tcp_stop_ctrl()
2199 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl); in nvme_tcp_free_ctrl() local
2201 if (list_empty(&ctrl->list)) in nvme_tcp_free_ctrl()
2205 list_del(&ctrl->list); in nvme_tcp_free_ctrl()
2210 kfree(ctrl->queues); in nvme_tcp_free_ctrl()
2211 kfree(ctrl); in nvme_tcp_free_ctrl()
2229 sg->addr = cpu_to_le64(queue->ctrl->ctrl.icdoff); in nvme_tcp_set_sg_inline()
2247 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(arg); in nvme_tcp_submit_async_event() local
2248 struct nvme_tcp_queue *queue = &ctrl->queues[0]; in nvme_tcp_submit_async_event()
2249 struct nvme_tcp_cmd_pdu *pdu = ctrl->async_req.pdu; in nvme_tcp_submit_async_event()
2265 ctrl->async_req.state = NVME_TCP_SEND_CMD_PDU; in nvme_tcp_submit_async_event()
2266 ctrl->async_req.offset = 0; in nvme_tcp_submit_async_event()
2267 ctrl->async_req.curr_bio = NULL; in nvme_tcp_submit_async_event()
2268 ctrl->async_req.data_len = 0; in nvme_tcp_submit_async_event()
2270 nvme_tcp_queue_request(&ctrl->async_req, true, true); in nvme_tcp_submit_async_event()
2276 struct nvme_ctrl *ctrl = &req->queue->ctrl->ctrl; in nvme_tcp_complete_timed_out() local
2278 nvme_tcp_stop_queue(ctrl, nvme_tcp_queue_id(req->queue)); in nvme_tcp_complete_timed_out()
2285 struct nvme_ctrl *ctrl = &req->queue->ctrl->ctrl; in nvme_tcp_timeout() local
2288 dev_warn(ctrl->device, in nvme_tcp_timeout()
2292 if (ctrl->state != NVME_CTRL_LIVE) { in nvme_tcp_timeout()
2297 * - ctrl disable/shutdown fabrics requests in nvme_tcp_timeout()
2314 nvme_tcp_error_recovery(ctrl); in nvme_tcp_timeout()
2384 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_setup_cmd_pdu()
2410 if (!nvme_check_ready(&queue->ctrl->ctrl, rq, queue_ready)) in nvme_tcp_queue_rq()
2411 return nvme_fail_nonready_command(&queue->ctrl->ctrl, rq); in nvme_tcp_queue_rq()
2426 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(set->driver_data); in nvme_tcp_map_queues() local
2427 struct nvmf_ctrl_options *opts = ctrl->ctrl.opts; in nvme_tcp_map_queues()
2429 if (opts->nr_write_queues && ctrl->io_queues[HCTX_TYPE_READ]) { in nvme_tcp_map_queues()
2432 ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_tcp_map_queues()
2435 ctrl->io_queues[HCTX_TYPE_READ]; in nvme_tcp_map_queues()
2437 ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_tcp_map_queues()
2441 ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_tcp_map_queues()
2444 ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_tcp_map_queues()
2450 if (opts->nr_poll_queues && ctrl->io_queues[HCTX_TYPE_POLL]) { in nvme_tcp_map_queues()
2453 ctrl->io_queues[HCTX_TYPE_POLL]; in nvme_tcp_map_queues()
2455 ctrl->io_queues[HCTX_TYPE_DEFAULT] + in nvme_tcp_map_queues()
2456 ctrl->io_queues[HCTX_TYPE_READ]; in nvme_tcp_map_queues()
2460 dev_info(ctrl->ctrl.device, in nvme_tcp_map_queues()
2462 ctrl->io_queues[HCTX_TYPE_DEFAULT], in nvme_tcp_map_queues()
2463 ctrl->io_queues[HCTX_TYPE_READ], in nvme_tcp_map_queues()
2464 ctrl->io_queues[HCTX_TYPE_POLL]); in nvme_tcp_map_queues()
2483 static int nvme_tcp_get_address(struct nvme_ctrl *ctrl, char *buf, int size) in nvme_tcp_get_address() argument
2485 struct nvme_tcp_queue *queue = &to_tcp_ctrl(ctrl)->queues[0]; in nvme_tcp_get_address()
2489 len = nvmf_get_address(ctrl, buf, size); in nvme_tcp_get_address()
2540 struct nvme_tcp_ctrl *ctrl; in nvme_tcp_existing_controller() local
2544 list_for_each_entry(ctrl, &nvme_tcp_ctrl_list, list) { in nvme_tcp_existing_controller()
2545 found = nvmf_ip_options_match(&ctrl->ctrl, opts); in nvme_tcp_existing_controller()
2557 struct nvme_tcp_ctrl *ctrl; in nvme_tcp_create_ctrl() local
2560 ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); in nvme_tcp_create_ctrl()
2561 if (!ctrl) in nvme_tcp_create_ctrl()
2564 INIT_LIST_HEAD(&ctrl->list); in nvme_tcp_create_ctrl()
2565 ctrl->ctrl.opts = opts; in nvme_tcp_create_ctrl()
2566 ctrl->ctrl.queue_count = opts->nr_io_queues + opts->nr_write_queues + in nvme_tcp_create_ctrl()
2568 ctrl->ctrl.sqsize = opts->queue_size - 1; in nvme_tcp_create_ctrl()
2569 ctrl->ctrl.kato = opts->kato; in nvme_tcp_create_ctrl()
2571 INIT_DELAYED_WORK(&ctrl->connect_work, in nvme_tcp_create_ctrl()
2573 INIT_WORK(&ctrl->err_work, nvme_tcp_error_recovery_work); in nvme_tcp_create_ctrl()
2574 INIT_WORK(&ctrl->ctrl.reset_work, nvme_reset_ctrl_work); in nvme_tcp_create_ctrl()
2587 opts->traddr, opts->trsvcid, &ctrl->addr); in nvme_tcp_create_ctrl()
2596 opts->host_traddr, NULL, &ctrl->src_addr); in nvme_tcp_create_ctrl()
2618 ctrl->queues = kcalloc(ctrl->ctrl.queue_count, sizeof(*ctrl->queues), in nvme_tcp_create_ctrl()
2620 if (!ctrl->queues) { in nvme_tcp_create_ctrl()
2625 ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_tcp_ctrl_ops, 0); in nvme_tcp_create_ctrl()
2629 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) { in nvme_tcp_create_ctrl()
2635 ret = nvme_tcp_setup_ctrl(&ctrl->ctrl, true); in nvme_tcp_create_ctrl()
2639 dev_info(ctrl->ctrl.device, "new ctrl: NQN \"%s\", addr %pISp\n", in nvme_tcp_create_ctrl()
2640 nvmf_ctrl_subsysnqn(&ctrl->ctrl), &ctrl->addr); in nvme_tcp_create_ctrl()
2643 list_add_tail(&ctrl->list, &nvme_tcp_ctrl_list); in nvme_tcp_create_ctrl()
2646 return &ctrl->ctrl; in nvme_tcp_create_ctrl()
2649 nvme_uninit_ctrl(&ctrl->ctrl); in nvme_tcp_create_ctrl()
2650 nvme_put_ctrl(&ctrl->ctrl); in nvme_tcp_create_ctrl()
2655 kfree(ctrl->queues); in nvme_tcp_create_ctrl()
2657 kfree(ctrl); in nvme_tcp_create_ctrl()
2686 struct nvme_tcp_ctrl *ctrl; in nvme_tcp_cleanup_module() local
2691 list_for_each_entry(ctrl, &nvme_tcp_ctrl_list, list) in nvme_tcp_cleanup_module()
2692 nvme_delete_ctrl(&ctrl->ctrl); in nvme_tcp_cleanup_module()