Lines Matching full:ctrl
162 struct nvme_tcp_ctrl *ctrl; member
192 struct nvme_ctrl ctrl; member
207 static inline struct nvme_tcp_ctrl *to_tcp_ctrl(struct nvme_ctrl *ctrl) in to_tcp_ctrl() argument
209 return container_of(ctrl, struct nvme_tcp_ctrl, ctrl); in to_tcp_ctrl()
214 return queue - queue->ctrl->queues; in nvme_tcp_queue_id()
231 static inline bool nvme_tcp_tls_configured(struct nvme_ctrl *ctrl) in nvme_tcp_tls_configured() argument
236 return ctrl->opts->tls; in nvme_tcp_tls_configured()
244 return queue->ctrl->admin_tag_set.tags[queue_idx]; in nvme_tcp_tagset()
245 return queue->ctrl->tag_set.tags[queue_idx - 1]; in nvme_tcp_tagset()
279 return req == &req->queue->ctrl->async_req; in nvme_tcp_async_req()
480 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_verify_hdgst()
490 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_verify_hdgst()
509 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_check_ddgst()
531 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(set->driver_data); in nvme_tcp_init_request() local
534 int queue_idx = (set == &ctrl->tag_set) ? hctx_idx + 1 : 0; in nvme_tcp_init_request()
535 struct nvme_tcp_queue *queue = &ctrl->queues[queue_idx]; in nvme_tcp_init_request()
546 nvme_req(rq)->ctrl = &ctrl->ctrl; in nvme_tcp_init_request()
555 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(data); in nvme_tcp_init_hctx() local
556 struct nvme_tcp_queue *queue = &ctrl->queues[hctx_idx + 1]; in nvme_tcp_init_hctx()
565 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(data); in nvme_tcp_init_admin_hctx() local
566 struct nvme_tcp_queue *queue = &ctrl->queues[0]; in nvme_tcp_init_admin_hctx()
589 static void nvme_tcp_error_recovery(struct nvme_ctrl *ctrl) in nvme_tcp_error_recovery() argument
591 if (!nvme_change_ctrl_state(ctrl, NVME_CTRL_RESETTING)) in nvme_tcp_error_recovery()
594 dev_warn(ctrl->device, "starting error recovery\n"); in nvme_tcp_error_recovery()
595 queue_work(nvme_reset_wq, &to_tcp_ctrl(ctrl)->err_work); in nvme_tcp_error_recovery()
606 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_process_nvme_cqe()
609 nvme_tcp_error_recovery(&queue->ctrl->ctrl); in nvme_tcp_process_nvme_cqe()
631 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_c2h_data()
638 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_c2h_data()
648 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_c2h_data()
651 nvme_tcp_error_recovery(&queue->ctrl->ctrl); in nvme_tcp_handle_c2h_data()
672 nvme_complete_async_event(&queue->ctrl->ctrl, cqe->status, in nvme_tcp_handle_comp()
724 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_r2t()
732 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_r2t()
739 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_r2t()
746 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_r2t()
807 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_recv_pdu()
844 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_recv_data()
864 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_recv_data()
918 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_recv_ddgst()
962 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_recv_skb()
965 nvme_tcp_error_recovery(&queue->ctrl->ctrl); in nvme_tcp_recv_skb()
1015 nvme_tcp_error_recovery(&queue->ctrl->ctrl); in nvme_tcp_state_change()
1018 dev_info(queue->ctrl->ctrl.device, in nvme_tcp_state_change()
1038 nvme_complete_async_event(&req->queue->ctrl->ctrl, in nvme_tcp_fail_request()
1257 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_try_send()
1351 static void nvme_tcp_free_async_req(struct nvme_tcp_ctrl *ctrl) in nvme_tcp_free_async_req() argument
1353 struct nvme_tcp_request *async = &ctrl->async_req; in nvme_tcp_free_async_req()
1358 static int nvme_tcp_alloc_async_req(struct nvme_tcp_ctrl *ctrl) in nvme_tcp_alloc_async_req() argument
1360 struct nvme_tcp_queue *queue = &ctrl->queues[0]; in nvme_tcp_alloc_async_req()
1361 struct nvme_tcp_request *async = &ctrl->async_req; in nvme_tcp_alloc_async_req()
1370 async->queue = &ctrl->queues[0]; in nvme_tcp_alloc_async_req()
1376 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl); in nvme_tcp_free_queue() local
1377 struct nvme_tcp_queue *queue = &ctrl->queues[qid]; in nvme_tcp_free_queue()
1488 pr_err("queue %d: data digest mismatch host: %s ctrl: %s\n", in nvme_tcp_init_connection()
1498 pr_err("queue %d: header digest mismatch host: %s ctrl: %s\n", in nvme_tcp_init_connection()
1534 struct nvme_tcp_ctrl *ctrl = queue->ctrl; in nvme_tcp_default_queue() local
1538 qid < 1 + ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_tcp_default_queue()
1543 struct nvme_tcp_ctrl *ctrl = queue->ctrl; in nvme_tcp_read_queue() local
1548 qid < 1 + ctrl->io_queues[HCTX_TYPE_DEFAULT] + in nvme_tcp_read_queue()
1549 ctrl->io_queues[HCTX_TYPE_READ]; in nvme_tcp_read_queue()
1554 struct nvme_tcp_ctrl *ctrl = queue->ctrl; in nvme_tcp_poll_queue() local
1560 qid < 1 + ctrl->io_queues[HCTX_TYPE_DEFAULT] + in nvme_tcp_poll_queue()
1561 ctrl->io_queues[HCTX_TYPE_READ] + in nvme_tcp_poll_queue()
1562 ctrl->io_queues[HCTX_TYPE_POLL]; in nvme_tcp_poll_queue()
1567 struct nvme_tcp_ctrl *ctrl = queue->ctrl; in nvme_tcp_set_queue_io_cpu() local
1574 n = qid - ctrl->io_queues[HCTX_TYPE_DEFAULT] - 1; in nvme_tcp_set_queue_io_cpu()
1576 n = qid - ctrl->io_queues[HCTX_TYPE_DEFAULT] - in nvme_tcp_set_queue_io_cpu()
1577 ctrl->io_queues[HCTX_TYPE_READ] - 1; in nvme_tcp_set_queue_io_cpu()
1587 struct nvme_tcp_ctrl *ctrl = queue->ctrl; in nvme_tcp_tls_done() local
1591 dev_dbg(ctrl->ctrl.device, "queue %d: TLS handshake done, key %x, status %d\n", in nvme_tcp_tls_done()
1601 dev_warn(ctrl->ctrl.device, "queue %d: Invalid key %x\n", in nvme_tcp_tls_done()
1607 ctrl->ctrl.tls_pskid = key_serial(tls_key); in nvme_tcp_tls_done()
1667 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl); in nvme_tcp_alloc_queue() local
1668 struct nvme_tcp_queue *queue = &ctrl->queues[qid]; in nvme_tcp_alloc_queue()
1673 queue->ctrl = ctrl; in nvme_tcp_alloc_queue()
1685 ret = sock_create(ctrl->addr.ss_family, SOCK_STREAM, in nvme_tcp_alloc_queue()
1734 ret = kernel_bind(queue->sock, (struct sockaddr *)&ctrl->src_addr, in nvme_tcp_alloc_queue()
1735 sizeof(ctrl->src_addr)); in nvme_tcp_alloc_queue()
1780 ret = kernel_connect(queue->sock, (struct sockaddr *)&ctrl->addr, in nvme_tcp_alloc_queue()
1781 sizeof(ctrl->addr), 0); in nvme_tcp_alloc_queue()
1841 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl); in nvme_tcp_stop_queue() local
1842 struct nvme_tcp_queue *queue = &ctrl->queues[qid]; in nvme_tcp_stop_queue()
1873 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl); in nvme_tcp_start_queue() local
1874 struct nvme_tcp_queue *queue = &ctrl->queues[idx]; in nvme_tcp_start_queue()
1897 static void nvme_tcp_free_admin_queue(struct nvme_ctrl *ctrl) in nvme_tcp_free_admin_queue() argument
1899 if (to_tcp_ctrl(ctrl)->async_req.pdu) { in nvme_tcp_free_admin_queue()
1900 cancel_work_sync(&ctrl->async_event_work); in nvme_tcp_free_admin_queue()
1901 nvme_tcp_free_async_req(to_tcp_ctrl(ctrl)); in nvme_tcp_free_admin_queue()
1902 to_tcp_ctrl(ctrl)->async_req.pdu = NULL; in nvme_tcp_free_admin_queue()
1905 nvme_tcp_free_queue(ctrl, 0); in nvme_tcp_free_admin_queue()
1908 static void nvme_tcp_free_io_queues(struct nvme_ctrl *ctrl) in nvme_tcp_free_io_queues() argument
1912 for (i = 1; i < ctrl->queue_count; i++) in nvme_tcp_free_io_queues()
1913 nvme_tcp_free_queue(ctrl, i); in nvme_tcp_free_io_queues()
1916 static void nvme_tcp_stop_io_queues(struct nvme_ctrl *ctrl) in nvme_tcp_stop_io_queues() argument
1920 for (i = 1; i < ctrl->queue_count; i++) in nvme_tcp_stop_io_queues()
1921 nvme_tcp_stop_queue(ctrl, i); in nvme_tcp_stop_io_queues()
1924 static int nvme_tcp_start_io_queues(struct nvme_ctrl *ctrl, in nvme_tcp_start_io_queues() argument
1930 ret = nvme_tcp_start_queue(ctrl, i); in nvme_tcp_start_io_queues()
1939 nvme_tcp_stop_queue(ctrl, i); in nvme_tcp_start_io_queues()
1943 static int nvme_tcp_alloc_admin_queue(struct nvme_ctrl *ctrl) in nvme_tcp_alloc_admin_queue() argument
1948 if (nvme_tcp_tls_configured(ctrl)) { in nvme_tcp_alloc_admin_queue()
1949 if (ctrl->opts->tls_key) in nvme_tcp_alloc_admin_queue()
1950 pskid = key_serial(ctrl->opts->tls_key); in nvme_tcp_alloc_admin_queue()
1952 pskid = nvme_tls_psk_default(ctrl->opts->keyring, in nvme_tcp_alloc_admin_queue()
1953 ctrl->opts->host->nqn, in nvme_tcp_alloc_admin_queue()
1954 ctrl->opts->subsysnqn); in nvme_tcp_alloc_admin_queue()
1956 dev_err(ctrl->device, "no valid PSK found\n"); in nvme_tcp_alloc_admin_queue()
1962 ret = nvme_tcp_alloc_queue(ctrl, 0, pskid); in nvme_tcp_alloc_admin_queue()
1966 ret = nvme_tcp_alloc_async_req(to_tcp_ctrl(ctrl)); in nvme_tcp_alloc_admin_queue()
1973 nvme_tcp_free_queue(ctrl, 0); in nvme_tcp_alloc_admin_queue()
1977 static int __nvme_tcp_alloc_io_queues(struct nvme_ctrl *ctrl) in __nvme_tcp_alloc_io_queues() argument
1981 if (nvme_tcp_tls_configured(ctrl) && !ctrl->tls_pskid) { in __nvme_tcp_alloc_io_queues()
1982 dev_err(ctrl->device, "no PSK negotiated\n"); in __nvme_tcp_alloc_io_queues()
1986 for (i = 1; i < ctrl->queue_count; i++) { in __nvme_tcp_alloc_io_queues()
1987 ret = nvme_tcp_alloc_queue(ctrl, i, in __nvme_tcp_alloc_io_queues()
1988 ctrl->tls_pskid); in __nvme_tcp_alloc_io_queues()
1997 nvme_tcp_free_queue(ctrl, i); in __nvme_tcp_alloc_io_queues()
2002 static int nvme_tcp_alloc_io_queues(struct nvme_ctrl *ctrl) in nvme_tcp_alloc_io_queues() argument
2007 nr_io_queues = nvmf_nr_io_queues(ctrl->opts); in nvme_tcp_alloc_io_queues()
2008 ret = nvme_set_queue_count(ctrl, &nr_io_queues); in nvme_tcp_alloc_io_queues()
2013 dev_err(ctrl->device, in nvme_tcp_alloc_io_queues()
2018 ctrl->queue_count = nr_io_queues + 1; in nvme_tcp_alloc_io_queues()
2019 dev_info(ctrl->device, in nvme_tcp_alloc_io_queues()
2022 nvmf_set_io_queues(ctrl->opts, nr_io_queues, in nvme_tcp_alloc_io_queues()
2023 to_tcp_ctrl(ctrl)->io_queues); in nvme_tcp_alloc_io_queues()
2024 return __nvme_tcp_alloc_io_queues(ctrl); in nvme_tcp_alloc_io_queues()
2027 static void nvme_tcp_destroy_io_queues(struct nvme_ctrl *ctrl, bool remove) in nvme_tcp_destroy_io_queues() argument
2029 nvme_tcp_stop_io_queues(ctrl); in nvme_tcp_destroy_io_queues()
2031 nvme_remove_io_tag_set(ctrl); in nvme_tcp_destroy_io_queues()
2032 nvme_tcp_free_io_queues(ctrl); in nvme_tcp_destroy_io_queues()
2035 static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new) in nvme_tcp_configure_io_queues() argument
2039 ret = nvme_tcp_alloc_io_queues(ctrl); in nvme_tcp_configure_io_queues()
2044 ret = nvme_alloc_io_tag_set(ctrl, &to_tcp_ctrl(ctrl)->tag_set, in nvme_tcp_configure_io_queues()
2046 ctrl->opts->nr_poll_queues ? HCTX_MAX_TYPES : 2, in nvme_tcp_configure_io_queues()
2057 nr_queues = min(ctrl->tagset->nr_hw_queues + 1, ctrl->queue_count); in nvme_tcp_configure_io_queues()
2058 ret = nvme_tcp_start_io_queues(ctrl, 1, nr_queues); in nvme_tcp_configure_io_queues()
2063 nvme_start_freeze(ctrl); in nvme_tcp_configure_io_queues()
2064 nvme_unquiesce_io_queues(ctrl); in nvme_tcp_configure_io_queues()
2065 if (!nvme_wait_freeze_timeout(ctrl, NVME_IO_TIMEOUT)) { in nvme_tcp_configure_io_queues()
2072 nvme_unfreeze(ctrl); in nvme_tcp_configure_io_queues()
2075 blk_mq_update_nr_hw_queues(ctrl->tagset, in nvme_tcp_configure_io_queues()
2076 ctrl->queue_count - 1); in nvme_tcp_configure_io_queues()
2077 nvme_unfreeze(ctrl); in nvme_tcp_configure_io_queues()
2084 ret = nvme_tcp_start_io_queues(ctrl, nr_queues, in nvme_tcp_configure_io_queues()
2085 ctrl->tagset->nr_hw_queues + 1); in nvme_tcp_configure_io_queues()
2092 nvme_quiesce_io_queues(ctrl); in nvme_tcp_configure_io_queues()
2093 nvme_sync_io_queues(ctrl); in nvme_tcp_configure_io_queues()
2094 nvme_tcp_stop_io_queues(ctrl); in nvme_tcp_configure_io_queues()
2096 nvme_cancel_tagset(ctrl); in nvme_tcp_configure_io_queues()
2098 nvme_remove_io_tag_set(ctrl); in nvme_tcp_configure_io_queues()
2100 nvme_tcp_free_io_queues(ctrl); in nvme_tcp_configure_io_queues()
2104 static void nvme_tcp_destroy_admin_queue(struct nvme_ctrl *ctrl, bool remove) in nvme_tcp_destroy_admin_queue() argument
2106 nvme_tcp_stop_queue(ctrl, 0); in nvme_tcp_destroy_admin_queue()
2108 nvme_remove_admin_tag_set(ctrl); in nvme_tcp_destroy_admin_queue()
2109 nvme_tcp_free_admin_queue(ctrl); in nvme_tcp_destroy_admin_queue()
2112 static int nvme_tcp_configure_admin_queue(struct nvme_ctrl *ctrl, bool new) in nvme_tcp_configure_admin_queue() argument
2116 error = nvme_tcp_alloc_admin_queue(ctrl); in nvme_tcp_configure_admin_queue()
2121 error = nvme_alloc_admin_tag_set(ctrl, in nvme_tcp_configure_admin_queue()
2122 &to_tcp_ctrl(ctrl)->admin_tag_set, in nvme_tcp_configure_admin_queue()
2129 error = nvme_tcp_start_queue(ctrl, 0); in nvme_tcp_configure_admin_queue()
2133 error = nvme_enable_ctrl(ctrl); in nvme_tcp_configure_admin_queue()
2137 nvme_unquiesce_admin_queue(ctrl); in nvme_tcp_configure_admin_queue()
2139 error = nvme_init_ctrl_finish(ctrl, false); in nvme_tcp_configure_admin_queue()
2146 nvme_quiesce_admin_queue(ctrl); in nvme_tcp_configure_admin_queue()
2147 blk_sync_queue(ctrl->admin_q); in nvme_tcp_configure_admin_queue()
2149 nvme_tcp_stop_queue(ctrl, 0); in nvme_tcp_configure_admin_queue()
2150 nvme_cancel_admin_tagset(ctrl); in nvme_tcp_configure_admin_queue()
2153 nvme_remove_admin_tag_set(ctrl); in nvme_tcp_configure_admin_queue()
2155 nvme_tcp_free_admin_queue(ctrl); in nvme_tcp_configure_admin_queue()
2159 static void nvme_tcp_teardown_admin_queue(struct nvme_ctrl *ctrl, in nvme_tcp_teardown_admin_queue() argument
2162 nvme_quiesce_admin_queue(ctrl); in nvme_tcp_teardown_admin_queue()
2163 blk_sync_queue(ctrl->admin_q); in nvme_tcp_teardown_admin_queue()
2164 nvme_tcp_stop_queue(ctrl, 0); in nvme_tcp_teardown_admin_queue()
2165 nvme_cancel_admin_tagset(ctrl); in nvme_tcp_teardown_admin_queue()
2167 nvme_unquiesce_admin_queue(ctrl); in nvme_tcp_teardown_admin_queue()
2168 nvme_tcp_destroy_admin_queue(ctrl, remove); in nvme_tcp_teardown_admin_queue()
2169 if (ctrl->tls_pskid) { in nvme_tcp_teardown_admin_queue()
2170 dev_dbg(ctrl->device, "Wipe negotiated TLS_PSK %08x\n", in nvme_tcp_teardown_admin_queue()
2171 ctrl->tls_pskid); in nvme_tcp_teardown_admin_queue()
2172 ctrl->tls_pskid = 0; in nvme_tcp_teardown_admin_queue()
2176 static void nvme_tcp_teardown_io_queues(struct nvme_ctrl *ctrl, in nvme_tcp_teardown_io_queues() argument
2179 if (ctrl->queue_count <= 1) in nvme_tcp_teardown_io_queues()
2181 nvme_quiesce_admin_queue(ctrl); in nvme_tcp_teardown_io_queues()
2182 nvme_quiesce_io_queues(ctrl); in nvme_tcp_teardown_io_queues()
2183 nvme_sync_io_queues(ctrl); in nvme_tcp_teardown_io_queues()
2184 nvme_tcp_stop_io_queues(ctrl); in nvme_tcp_teardown_io_queues()
2185 nvme_cancel_tagset(ctrl); in nvme_tcp_teardown_io_queues()
2187 nvme_unquiesce_io_queues(ctrl); in nvme_tcp_teardown_io_queues()
2188 nvme_tcp_destroy_io_queues(ctrl, remove); in nvme_tcp_teardown_io_queues()
2191 static void nvme_tcp_reconnect_or_remove(struct nvme_ctrl *ctrl, in nvme_tcp_reconnect_or_remove() argument
2194 enum nvme_ctrl_state state = nvme_ctrl_state(ctrl); in nvme_tcp_reconnect_or_remove()
2202 if (nvmf_should_reconnect(ctrl, status)) { in nvme_tcp_reconnect_or_remove()
2203 dev_info(ctrl->device, "Reconnecting in %d seconds...\n", in nvme_tcp_reconnect_or_remove()
2204 ctrl->opts->reconnect_delay); in nvme_tcp_reconnect_or_remove()
2205 queue_delayed_work(nvme_wq, &to_tcp_ctrl(ctrl)->connect_work, in nvme_tcp_reconnect_or_remove()
2206 ctrl->opts->reconnect_delay * HZ); in nvme_tcp_reconnect_or_remove()
2208 dev_info(ctrl->device, "Removing controller (%d)...\n", in nvme_tcp_reconnect_or_remove()
2210 nvme_delete_ctrl(ctrl); in nvme_tcp_reconnect_or_remove()
2214 static int nvme_tcp_setup_ctrl(struct nvme_ctrl *ctrl, bool new) in nvme_tcp_setup_ctrl() argument
2216 struct nvmf_ctrl_options *opts = ctrl->opts; in nvme_tcp_setup_ctrl()
2219 ret = nvme_tcp_configure_admin_queue(ctrl, new); in nvme_tcp_setup_ctrl()
2223 if (ctrl->icdoff) { in nvme_tcp_setup_ctrl()
2225 dev_err(ctrl->device, "icdoff is not supported!\n"); in nvme_tcp_setup_ctrl()
2229 if (!nvme_ctrl_sgl_supported(ctrl)) { in nvme_tcp_setup_ctrl()
2231 dev_err(ctrl->device, "Mandatory sgls are not supported!\n"); in nvme_tcp_setup_ctrl()
2235 if (opts->queue_size > ctrl->sqsize + 1) in nvme_tcp_setup_ctrl()
2236 dev_warn(ctrl->device, in nvme_tcp_setup_ctrl()
2237 "queue_size %zu > ctrl sqsize %u, clamping down\n", in nvme_tcp_setup_ctrl()
2238 opts->queue_size, ctrl->sqsize + 1); in nvme_tcp_setup_ctrl()
2240 if (ctrl->sqsize + 1 > ctrl->maxcmd) { in nvme_tcp_setup_ctrl()
2241 dev_warn(ctrl->device, in nvme_tcp_setup_ctrl()
2242 "sqsize %u > ctrl maxcmd %u, clamping down\n", in nvme_tcp_setup_ctrl()
2243 ctrl->sqsize + 1, ctrl->maxcmd); in nvme_tcp_setup_ctrl()
2244 ctrl->sqsize = ctrl->maxcmd - 1; in nvme_tcp_setup_ctrl()
2247 if (ctrl->queue_count > 1) { in nvme_tcp_setup_ctrl()
2248 ret = nvme_tcp_configure_io_queues(ctrl, new); in nvme_tcp_setup_ctrl()
2253 if (!nvme_change_ctrl_state(ctrl, NVME_CTRL_LIVE)) { in nvme_tcp_setup_ctrl()
2255 * state change failure is ok if we started ctrl delete, in nvme_tcp_setup_ctrl()
2259 enum nvme_ctrl_state state = nvme_ctrl_state(ctrl); in nvme_tcp_setup_ctrl()
2268 nvme_start_ctrl(ctrl); in nvme_tcp_setup_ctrl()
2272 if (ctrl->queue_count > 1) { in nvme_tcp_setup_ctrl()
2273 nvme_quiesce_io_queues(ctrl); in nvme_tcp_setup_ctrl()
2274 nvme_sync_io_queues(ctrl); in nvme_tcp_setup_ctrl()
2275 nvme_tcp_stop_io_queues(ctrl); in nvme_tcp_setup_ctrl()
2276 nvme_cancel_tagset(ctrl); in nvme_tcp_setup_ctrl()
2277 nvme_tcp_destroy_io_queues(ctrl, new); in nvme_tcp_setup_ctrl()
2280 nvme_stop_keep_alive(ctrl); in nvme_tcp_setup_ctrl()
2281 nvme_tcp_teardown_admin_queue(ctrl, false); in nvme_tcp_setup_ctrl()
2289 struct nvme_ctrl *ctrl = &tcp_ctrl->ctrl; in nvme_tcp_reconnect_ctrl_work() local
2292 ++ctrl->nr_reconnects; in nvme_tcp_reconnect_ctrl_work()
2294 ret = nvme_tcp_setup_ctrl(ctrl, false); in nvme_tcp_reconnect_ctrl_work()
2298 dev_info(ctrl->device, "Successfully reconnected (attempt %d/%d)\n", in nvme_tcp_reconnect_ctrl_work()
2299 ctrl->nr_reconnects, ctrl->opts->max_reconnects); in nvme_tcp_reconnect_ctrl_work()
2301 ctrl->nr_reconnects = 0; in nvme_tcp_reconnect_ctrl_work()
2306 dev_info(ctrl->device, "Failed reconnect attempt %d/%d\n", in nvme_tcp_reconnect_ctrl_work()
2307 ctrl->nr_reconnects, ctrl->opts->max_reconnects); in nvme_tcp_reconnect_ctrl_work()
2308 nvme_tcp_reconnect_or_remove(ctrl, ret); in nvme_tcp_reconnect_ctrl_work()
2315 struct nvme_ctrl *ctrl = &tcp_ctrl->ctrl; in nvme_tcp_error_recovery_work() local
2317 nvme_stop_keep_alive(ctrl); in nvme_tcp_error_recovery_work()
2318 flush_work(&ctrl->async_event_work); in nvme_tcp_error_recovery_work()
2319 nvme_tcp_teardown_io_queues(ctrl, false); in nvme_tcp_error_recovery_work()
2321 nvme_unquiesce_io_queues(ctrl); in nvme_tcp_error_recovery_work()
2322 nvme_tcp_teardown_admin_queue(ctrl, false); in nvme_tcp_error_recovery_work()
2323 nvme_unquiesce_admin_queue(ctrl); in nvme_tcp_error_recovery_work()
2324 nvme_auth_stop(ctrl); in nvme_tcp_error_recovery_work()
2326 if (!nvme_change_ctrl_state(ctrl, NVME_CTRL_CONNECTING)) { in nvme_tcp_error_recovery_work()
2327 /* state change failure is ok if we started ctrl delete */ in nvme_tcp_error_recovery_work()
2328 enum nvme_ctrl_state state = nvme_ctrl_state(ctrl); in nvme_tcp_error_recovery_work()
2335 nvme_tcp_reconnect_or_remove(ctrl, 0); in nvme_tcp_error_recovery_work()
2338 static void nvme_tcp_teardown_ctrl(struct nvme_ctrl *ctrl, bool shutdown) in nvme_tcp_teardown_ctrl() argument
2340 nvme_tcp_teardown_io_queues(ctrl, shutdown); in nvme_tcp_teardown_ctrl()
2341 nvme_quiesce_admin_queue(ctrl); in nvme_tcp_teardown_ctrl()
2342 nvme_disable_ctrl(ctrl, shutdown); in nvme_tcp_teardown_ctrl()
2343 nvme_tcp_teardown_admin_queue(ctrl, shutdown); in nvme_tcp_teardown_ctrl()
2346 static void nvme_tcp_delete_ctrl(struct nvme_ctrl *ctrl) in nvme_tcp_delete_ctrl() argument
2348 nvme_tcp_teardown_ctrl(ctrl, true); in nvme_tcp_delete_ctrl()
2353 struct nvme_ctrl *ctrl = in nvme_reset_ctrl_work() local
2357 nvme_stop_ctrl(ctrl); in nvme_reset_ctrl_work()
2358 nvme_tcp_teardown_ctrl(ctrl, false); in nvme_reset_ctrl_work()
2360 if (!nvme_change_ctrl_state(ctrl, NVME_CTRL_CONNECTING)) { in nvme_reset_ctrl_work()
2361 /* state change failure is ok if we started ctrl delete */ in nvme_reset_ctrl_work()
2362 enum nvme_ctrl_state state = nvme_ctrl_state(ctrl); in nvme_reset_ctrl_work()
2369 ret = nvme_tcp_setup_ctrl(ctrl, false); in nvme_reset_ctrl_work()
2376 ++ctrl->nr_reconnects; in nvme_reset_ctrl_work()
2377 nvme_tcp_reconnect_or_remove(ctrl, ret); in nvme_reset_ctrl_work()
2380 static void nvme_tcp_stop_ctrl(struct nvme_ctrl *ctrl) in nvme_tcp_stop_ctrl() argument
2382 flush_work(&to_tcp_ctrl(ctrl)->err_work); in nvme_tcp_stop_ctrl()
2383 cancel_delayed_work_sync(&to_tcp_ctrl(ctrl)->connect_work); in nvme_tcp_stop_ctrl()
2388 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl); in nvme_tcp_free_ctrl() local
2390 if (list_empty(&ctrl->list)) in nvme_tcp_free_ctrl()
2394 list_del(&ctrl->list); in nvme_tcp_free_ctrl()
2399 kfree(ctrl->queues); in nvme_tcp_free_ctrl()
2400 kfree(ctrl); in nvme_tcp_free_ctrl()
2418 sg->addr = cpu_to_le64(queue->ctrl->ctrl.icdoff); in nvme_tcp_set_sg_inline()
2436 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(arg); in nvme_tcp_submit_async_event() local
2437 struct nvme_tcp_queue *queue = &ctrl->queues[0]; in nvme_tcp_submit_async_event()
2438 struct nvme_tcp_cmd_pdu *pdu = ctrl->async_req.pdu; in nvme_tcp_submit_async_event()
2454 ctrl->async_req.state = NVME_TCP_SEND_CMD_PDU; in nvme_tcp_submit_async_event()
2455 ctrl->async_req.offset = 0; in nvme_tcp_submit_async_event()
2456 ctrl->async_req.curr_bio = NULL; in nvme_tcp_submit_async_event()
2457 ctrl->async_req.data_len = 0; in nvme_tcp_submit_async_event()
2459 nvme_tcp_queue_request(&ctrl->async_req, true, true); in nvme_tcp_submit_async_event()
2465 struct nvme_ctrl *ctrl = &req->queue->ctrl->ctrl; in nvme_tcp_complete_timed_out() local
2467 nvme_tcp_stop_queue(ctrl, nvme_tcp_queue_id(req->queue)); in nvme_tcp_complete_timed_out()
2474 struct nvme_ctrl *ctrl = &req->queue->ctrl->ctrl; in nvme_tcp_timeout() local
2479 dev_warn(ctrl->device, in nvme_tcp_timeout()
2484 if (nvme_ctrl_state(ctrl) != NVME_CTRL_LIVE) { in nvme_tcp_timeout()
2489 * - ctrl disable/shutdown fabrics requests in nvme_tcp_timeout()
2506 nvme_tcp_error_recovery(ctrl); in nvme_tcp_timeout()
2576 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_setup_cmd_pdu()
2602 if (!nvme_check_ready(&queue->ctrl->ctrl, rq, queue_ready)) in nvme_tcp_queue_rq()
2603 return nvme_fail_nonready_command(&queue->ctrl->ctrl, rq); in nvme_tcp_queue_rq()
2618 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(set->driver_data); in nvme_tcp_map_queues() local
2620 nvmf_map_queues(set, &ctrl->ctrl, ctrl->io_queues); in nvme_tcp_map_queues()
2639 static int nvme_tcp_get_address(struct nvme_ctrl *ctrl, char *buf, int size) in nvme_tcp_get_address() argument
2641 struct nvme_tcp_queue *queue = &to_tcp_ctrl(ctrl)->queues[0]; in nvme_tcp_get_address()
2645 len = nvmf_get_address(ctrl, buf, size); in nvme_tcp_get_address()
2704 struct nvme_tcp_ctrl *ctrl; in nvme_tcp_existing_controller() local
2708 list_for_each_entry(ctrl, &nvme_tcp_ctrl_list, list) { in nvme_tcp_existing_controller()
2709 found = nvmf_ip_options_match(&ctrl->ctrl, opts); in nvme_tcp_existing_controller()
2721 struct nvme_tcp_ctrl *ctrl; in nvme_tcp_alloc_ctrl() local
2724 ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); in nvme_tcp_alloc_ctrl()
2725 if (!ctrl) in nvme_tcp_alloc_ctrl()
2728 INIT_LIST_HEAD(&ctrl->list); in nvme_tcp_alloc_ctrl()
2729 ctrl->ctrl.opts = opts; in nvme_tcp_alloc_ctrl()
2730 ctrl->ctrl.queue_count = opts->nr_io_queues + opts->nr_write_queues + in nvme_tcp_alloc_ctrl()
2732 ctrl->ctrl.sqsize = opts->queue_size - 1; in nvme_tcp_alloc_ctrl()
2733 ctrl->ctrl.kato = opts->kato; in nvme_tcp_alloc_ctrl()
2735 INIT_DELAYED_WORK(&ctrl->connect_work, in nvme_tcp_alloc_ctrl()
2737 INIT_WORK(&ctrl->err_work, nvme_tcp_error_recovery_work); in nvme_tcp_alloc_ctrl()
2738 INIT_WORK(&ctrl->ctrl.reset_work, nvme_reset_ctrl_work); in nvme_tcp_alloc_ctrl()
2751 opts->traddr, opts->trsvcid, &ctrl->addr); in nvme_tcp_alloc_ctrl()
2760 opts->host_traddr, NULL, &ctrl->src_addr); in nvme_tcp_alloc_ctrl()
2782 ctrl->queues = kcalloc(ctrl->ctrl.queue_count, sizeof(*ctrl->queues), in nvme_tcp_alloc_ctrl()
2784 if (!ctrl->queues) { in nvme_tcp_alloc_ctrl()
2789 ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_tcp_ctrl_ops, 0); in nvme_tcp_alloc_ctrl()
2793 return ctrl; in nvme_tcp_alloc_ctrl()
2795 kfree(ctrl->queues); in nvme_tcp_alloc_ctrl()
2797 kfree(ctrl); in nvme_tcp_alloc_ctrl()
2804 struct nvme_tcp_ctrl *ctrl; in nvme_tcp_create_ctrl() local
2807 ctrl = nvme_tcp_alloc_ctrl(dev, opts); in nvme_tcp_create_ctrl()
2808 if (IS_ERR(ctrl)) in nvme_tcp_create_ctrl()
2809 return ERR_CAST(ctrl); in nvme_tcp_create_ctrl()
2811 ret = nvme_add_ctrl(&ctrl->ctrl); in nvme_tcp_create_ctrl()
2815 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) { in nvme_tcp_create_ctrl()
2821 ret = nvme_tcp_setup_ctrl(&ctrl->ctrl, true); in nvme_tcp_create_ctrl()
2825 dev_info(ctrl->ctrl.device, "new ctrl: NQN \"%s\", addr %pISp, hostnqn: %s\n", in nvme_tcp_create_ctrl()
2826 nvmf_ctrl_subsysnqn(&ctrl->ctrl), &ctrl->addr, opts->host->nqn); in nvme_tcp_create_ctrl()
2829 list_add_tail(&ctrl->list, &nvme_tcp_ctrl_list); in nvme_tcp_create_ctrl()
2832 return &ctrl->ctrl; in nvme_tcp_create_ctrl()
2835 nvme_uninit_ctrl(&ctrl->ctrl); in nvme_tcp_create_ctrl()
2837 nvme_put_ctrl(&ctrl->ctrl); in nvme_tcp_create_ctrl()
2882 struct nvme_tcp_ctrl *ctrl; in nvme_tcp_cleanup_module() local
2887 list_for_each_entry(ctrl, &nvme_tcp_ctrl_list, list) in nvme_tcp_cleanup_module()
2888 nvme_delete_ctrl(&ctrl->ctrl); in nvme_tcp_cleanup_module()