Lines Matching full:ctrl
164 struct nvme_tcp_ctrl *ctrl; member
194 struct nvme_ctrl ctrl; member
209 static inline struct nvme_tcp_ctrl *to_tcp_ctrl(struct nvme_ctrl *ctrl) in to_tcp_ctrl() argument
211 return container_of(ctrl, struct nvme_tcp_ctrl, ctrl); in to_tcp_ctrl()
216 return queue - queue->ctrl->queues; in nvme_tcp_queue_id()
246 static inline bool nvme_tcp_tls_configured(struct nvme_ctrl *ctrl) in nvme_tcp_tls_configured() argument
251 return ctrl->opts->tls || ctrl->opts->concat; in nvme_tcp_tls_configured()
259 return queue->ctrl->admin_tag_set.tags[queue_idx]; in nvme_tcp_tagset()
260 return queue->ctrl->tag_set.tags[queue_idx - 1]; in nvme_tcp_tagset()
294 return req == &req->queue->ctrl->async_req; in nvme_tcp_async_req()
502 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_verify_hdgst()
511 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_verify_hdgst()
530 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_check_ddgst()
552 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(set->driver_data); in nvme_tcp_init_request() local
555 int queue_idx = (set == &ctrl->tag_set) ? hctx_idx + 1 : 0; in nvme_tcp_init_request()
556 struct nvme_tcp_queue *queue = &ctrl->queues[queue_idx]; in nvme_tcp_init_request()
567 nvme_req(rq)->ctrl = &ctrl->ctrl; in nvme_tcp_init_request()
578 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(data); in nvme_tcp_init_hctx() local
579 struct nvme_tcp_queue *queue = &ctrl->queues[hctx_idx + 1]; in nvme_tcp_init_hctx()
588 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(data); in nvme_tcp_init_admin_hctx() local
589 struct nvme_tcp_queue *queue = &ctrl->queues[0]; in nvme_tcp_init_admin_hctx()
612 static void nvme_tcp_error_recovery(struct nvme_ctrl *ctrl) in nvme_tcp_error_recovery() argument
614 if (!nvme_change_ctrl_state(ctrl, NVME_CTRL_RESETTING)) in nvme_tcp_error_recovery()
617 dev_warn(ctrl->device, "starting error recovery\n"); in nvme_tcp_error_recovery()
618 queue_work(nvme_reset_wq, &to_tcp_ctrl(ctrl)->err_work); in nvme_tcp_error_recovery()
629 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_process_nvme_cqe()
632 nvme_tcp_error_recovery(&queue->ctrl->ctrl); in nvme_tcp_process_nvme_cqe()
654 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_c2h_data()
661 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_c2h_data()
671 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_c2h_data()
674 nvme_tcp_error_recovery(&queue->ctrl->ctrl); in nvme_tcp_handle_c2h_data()
695 nvme_complete_async_event(&queue->ctrl->ctrl, cqe->status, in nvme_tcp_handle_comp()
747 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_r2t()
755 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_r2t()
762 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_r2t()
769 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_r2t()
777 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_r2t()
814 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_c2h_term()
826 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_c2h_term()
855 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_recv_pdu()
897 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_recv_pdu()
933 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_recv_data()
953 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_recv_data()
1007 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_recv_ddgst()
1051 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_recv_skb()
1054 nvme_tcp_error_recovery(&queue->ctrl->ctrl); in nvme_tcp_recv_skb()
1107 nvme_tcp_error_recovery(&queue->ctrl->ctrl); in nvme_tcp_state_change()
1110 dev_info(queue->ctrl->ctrl.device, in nvme_tcp_state_change()
1130 nvme_complete_async_event(&req->queue->ctrl->ctrl, in nvme_tcp_fail_request()
1349 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_try_send()
1413 static void nvme_tcp_free_async_req(struct nvme_tcp_ctrl *ctrl) in nvme_tcp_free_async_req() argument
1415 struct nvme_tcp_request *async = &ctrl->async_req; in nvme_tcp_free_async_req()
1420 static int nvme_tcp_alloc_async_req(struct nvme_tcp_ctrl *ctrl) in nvme_tcp_alloc_async_req() argument
1422 struct nvme_tcp_queue *queue = &ctrl->queues[0]; in nvme_tcp_alloc_async_req()
1423 struct nvme_tcp_request *async = &ctrl->async_req; in nvme_tcp_alloc_async_req()
1432 async->queue = &ctrl->queues[0]; in nvme_tcp_alloc_async_req()
1438 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl); in nvme_tcp_free_queue() local
1439 struct nvme_tcp_queue *queue = &ctrl->queues[qid]; in nvme_tcp_free_queue()
1550 pr_err("queue %d: data digest mismatch host: %s ctrl: %s\n", in nvme_tcp_init_connection()
1560 pr_err("queue %d: header digest mismatch host: %s ctrl: %s\n", in nvme_tcp_init_connection()
1596 struct nvme_tcp_ctrl *ctrl = queue->ctrl; in nvme_tcp_default_queue() local
1600 qid < 1 + ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_tcp_default_queue()
1605 struct nvme_tcp_ctrl *ctrl = queue->ctrl; in nvme_tcp_read_queue() local
1610 qid < 1 + ctrl->io_queues[HCTX_TYPE_DEFAULT] + in nvme_tcp_read_queue()
1611 ctrl->io_queues[HCTX_TYPE_READ]; in nvme_tcp_read_queue()
1616 struct nvme_tcp_ctrl *ctrl = queue->ctrl; in nvme_tcp_poll_queue() local
1622 qid < 1 + ctrl->io_queues[HCTX_TYPE_DEFAULT] + in nvme_tcp_poll_queue()
1623 ctrl->io_queues[HCTX_TYPE_READ] + in nvme_tcp_poll_queue()
1624 ctrl->io_queues[HCTX_TYPE_POLL]; in nvme_tcp_poll_queue()
1638 struct nvme_tcp_ctrl *ctrl = queue->ctrl; in nvme_tcp_set_queue_io_cpu() local
1639 struct blk_mq_tag_set *set = &ctrl->tag_set; in nvme_tcp_set_queue_io_cpu()
1675 dev_dbg(ctrl->ctrl.device, "queue %d: using cpu %d\n", in nvme_tcp_set_queue_io_cpu()
1682 struct nvme_tcp_ctrl *ctrl = queue->ctrl; in nvme_tcp_tls_done() local
1686 dev_dbg(ctrl->ctrl.device, "queue %d: TLS handshake done, key %x, status %d\n", in nvme_tcp_tls_done()
1696 dev_warn(ctrl->ctrl.device, "queue %d: Invalid key %x\n", in nvme_tcp_tls_done()
1702 ctrl->ctrl.tls_pskid = key_serial(tls_key); in nvme_tcp_tls_done()
1767 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl); in nvme_tcp_alloc_queue() local
1768 struct nvme_tcp_queue *queue = &ctrl->queues[qid]; in nvme_tcp_alloc_queue()
1773 queue->ctrl = ctrl; in nvme_tcp_alloc_queue()
1786 ctrl->addr.ss_family, SOCK_STREAM, in nvme_tcp_alloc_queue()
1837 ret = kernel_bind(queue->sock, (struct sockaddr_unsized *)&ctrl->src_addr, in nvme_tcp_alloc_queue()
1838 sizeof(ctrl->src_addr)); in nvme_tcp_alloc_queue()
1875 ret = kernel_connect(queue->sock, (struct sockaddr_unsized *)&ctrl->addr, in nvme_tcp_alloc_queue()
1876 sizeof(ctrl->addr), 0); in nvme_tcp_alloc_queue()
1933 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl); in nvme_tcp_stop_queue_nowait() local
1934 struct nvme_tcp_queue *queue = &ctrl->queues[qid]; in nvme_tcp_stop_queue_nowait()
1952 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl); in nvme_tcp_wait_queue() local
1953 struct nvme_tcp_queue *queue = &ctrl->queues[qid]; in nvme_tcp_wait_queue()
1993 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl); in nvme_tcp_start_queue() local
1994 struct nvme_tcp_queue *queue = &ctrl->queues[idx]; in nvme_tcp_start_queue()
2018 static void nvme_tcp_free_admin_queue(struct nvme_ctrl *ctrl) in nvme_tcp_free_admin_queue() argument
2020 if (to_tcp_ctrl(ctrl)->async_req.pdu) { in nvme_tcp_free_admin_queue()
2021 cancel_work_sync(&ctrl->async_event_work); in nvme_tcp_free_admin_queue()
2022 nvme_tcp_free_async_req(to_tcp_ctrl(ctrl)); in nvme_tcp_free_admin_queue()
2023 to_tcp_ctrl(ctrl)->async_req.pdu = NULL; in nvme_tcp_free_admin_queue()
2026 nvme_tcp_free_queue(ctrl, 0); in nvme_tcp_free_admin_queue()
2029 static void nvme_tcp_free_io_queues(struct nvme_ctrl *ctrl) in nvme_tcp_free_io_queues() argument
2033 for (i = 1; i < ctrl->queue_count; i++) in nvme_tcp_free_io_queues()
2034 nvme_tcp_free_queue(ctrl, i); in nvme_tcp_free_io_queues()
2037 static void nvme_tcp_stop_io_queues(struct nvme_ctrl *ctrl) in nvme_tcp_stop_io_queues() argument
2041 for (i = 1; i < ctrl->queue_count; i++) in nvme_tcp_stop_io_queues()
2042 nvme_tcp_stop_queue_nowait(ctrl, i); in nvme_tcp_stop_io_queues()
2043 for (i = 1; i < ctrl->queue_count; i++) in nvme_tcp_stop_io_queues()
2044 nvme_tcp_wait_queue(ctrl, i); in nvme_tcp_stop_io_queues()
2047 static int nvme_tcp_start_io_queues(struct nvme_ctrl *ctrl, in nvme_tcp_start_io_queues() argument
2053 ret = nvme_tcp_start_queue(ctrl, i); in nvme_tcp_start_io_queues()
2062 nvme_tcp_stop_queue(ctrl, i); in nvme_tcp_start_io_queues()
2066 static int nvme_tcp_alloc_admin_queue(struct nvme_ctrl *ctrl) in nvme_tcp_alloc_admin_queue() argument
2071 if (nvme_tcp_tls_configured(ctrl)) { in nvme_tcp_alloc_admin_queue()
2072 if (ctrl->opts->tls_key) in nvme_tcp_alloc_admin_queue()
2073 pskid = key_serial(ctrl->opts->tls_key); in nvme_tcp_alloc_admin_queue()
2074 else if (ctrl->opts->tls) { in nvme_tcp_alloc_admin_queue()
2075 pskid = nvme_tls_psk_default(ctrl->opts->keyring, in nvme_tcp_alloc_admin_queue()
2076 ctrl->opts->host->nqn, in nvme_tcp_alloc_admin_queue()
2077 ctrl->opts->subsysnqn); in nvme_tcp_alloc_admin_queue()
2079 dev_err(ctrl->device, "no valid PSK found\n"); in nvme_tcp_alloc_admin_queue()
2085 ret = nvme_tcp_alloc_queue(ctrl, 0, pskid); in nvme_tcp_alloc_admin_queue()
2089 ret = nvme_tcp_alloc_async_req(to_tcp_ctrl(ctrl)); in nvme_tcp_alloc_admin_queue()
2096 nvme_tcp_free_queue(ctrl, 0); in nvme_tcp_alloc_admin_queue()
2100 static int __nvme_tcp_alloc_io_queues(struct nvme_ctrl *ctrl) in __nvme_tcp_alloc_io_queues() argument
2104 if (nvme_tcp_tls_configured(ctrl)) { in __nvme_tcp_alloc_io_queues()
2105 if (ctrl->opts->concat) { in __nvme_tcp_alloc_io_queues()
2110 if (!ctrl->opts->tls_key) { in __nvme_tcp_alloc_io_queues()
2111 dev_err(ctrl->device, "no PSK generated\n"); in __nvme_tcp_alloc_io_queues()
2114 if (ctrl->tls_pskid && in __nvme_tcp_alloc_io_queues()
2115 ctrl->tls_pskid != key_serial(ctrl->opts->tls_key)) { in __nvme_tcp_alloc_io_queues()
2116 dev_err(ctrl->device, "Stale PSK id %08x\n", ctrl->tls_pskid); in __nvme_tcp_alloc_io_queues()
2117 ctrl->tls_pskid = 0; in __nvme_tcp_alloc_io_queues()
2119 } else if (!ctrl->tls_pskid) { in __nvme_tcp_alloc_io_queues()
2120 dev_err(ctrl->device, "no PSK negotiated\n"); in __nvme_tcp_alloc_io_queues()
2125 for (i = 1; i < ctrl->queue_count; i++) { in __nvme_tcp_alloc_io_queues()
2126 ret = nvme_tcp_alloc_queue(ctrl, i, in __nvme_tcp_alloc_io_queues()
2127 ctrl->tls_pskid); in __nvme_tcp_alloc_io_queues()
2136 nvme_tcp_free_queue(ctrl, i); in __nvme_tcp_alloc_io_queues()
2141 static int nvme_tcp_alloc_io_queues(struct nvme_ctrl *ctrl) in nvme_tcp_alloc_io_queues() argument
2146 nr_io_queues = nvmf_nr_io_queues(ctrl->opts); in nvme_tcp_alloc_io_queues()
2147 ret = nvme_set_queue_count(ctrl, &nr_io_queues); in nvme_tcp_alloc_io_queues()
2152 dev_err(ctrl->device, in nvme_tcp_alloc_io_queues()
2157 ctrl->queue_count = nr_io_queues + 1; in nvme_tcp_alloc_io_queues()
2158 dev_info(ctrl->device, in nvme_tcp_alloc_io_queues()
2161 nvmf_set_io_queues(ctrl->opts, nr_io_queues, in nvme_tcp_alloc_io_queues()
2162 to_tcp_ctrl(ctrl)->io_queues); in nvme_tcp_alloc_io_queues()
2163 return __nvme_tcp_alloc_io_queues(ctrl); in nvme_tcp_alloc_io_queues()
2166 static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new) in nvme_tcp_configure_io_queues() argument
2170 ret = nvme_tcp_alloc_io_queues(ctrl); in nvme_tcp_configure_io_queues()
2175 ret = nvme_alloc_io_tag_set(ctrl, &to_tcp_ctrl(ctrl)->tag_set, in nvme_tcp_configure_io_queues()
2177 ctrl->opts->nr_poll_queues ? HCTX_MAX_TYPES : 2, in nvme_tcp_configure_io_queues()
2188 nr_queues = min(ctrl->tagset->nr_hw_queues + 1, ctrl->queue_count); in nvme_tcp_configure_io_queues()
2189 ret = nvme_tcp_start_io_queues(ctrl, 1, nr_queues); in nvme_tcp_configure_io_queues()
2194 nvme_start_freeze(ctrl); in nvme_tcp_configure_io_queues()
2195 nvme_unquiesce_io_queues(ctrl); in nvme_tcp_configure_io_queues()
2196 if (!nvme_wait_freeze_timeout(ctrl, NVME_IO_TIMEOUT)) { in nvme_tcp_configure_io_queues()
2203 nvme_unfreeze(ctrl); in nvme_tcp_configure_io_queues()
2206 blk_mq_update_nr_hw_queues(ctrl->tagset, in nvme_tcp_configure_io_queues()
2207 ctrl->queue_count - 1); in nvme_tcp_configure_io_queues()
2208 nvme_unfreeze(ctrl); in nvme_tcp_configure_io_queues()
2215 ret = nvme_tcp_start_io_queues(ctrl, nr_queues, in nvme_tcp_configure_io_queues()
2216 ctrl->tagset->nr_hw_queues + 1); in nvme_tcp_configure_io_queues()
2223 nvme_quiesce_io_queues(ctrl); in nvme_tcp_configure_io_queues()
2224 nvme_sync_io_queues(ctrl); in nvme_tcp_configure_io_queues()
2225 nvme_tcp_stop_io_queues(ctrl); in nvme_tcp_configure_io_queues()
2227 nvme_cancel_tagset(ctrl); in nvme_tcp_configure_io_queues()
2229 nvme_remove_io_tag_set(ctrl); in nvme_tcp_configure_io_queues()
2231 nvme_tcp_free_io_queues(ctrl); in nvme_tcp_configure_io_queues()
2235 static int nvme_tcp_configure_admin_queue(struct nvme_ctrl *ctrl, bool new) in nvme_tcp_configure_admin_queue() argument
2239 error = nvme_tcp_alloc_admin_queue(ctrl); in nvme_tcp_configure_admin_queue()
2244 error = nvme_alloc_admin_tag_set(ctrl, in nvme_tcp_configure_admin_queue()
2245 &to_tcp_ctrl(ctrl)->admin_tag_set, in nvme_tcp_configure_admin_queue()
2252 error = nvme_tcp_start_queue(ctrl, 0); in nvme_tcp_configure_admin_queue()
2256 if (ctrl->opts->concat && !ctrl->tls_pskid) in nvme_tcp_configure_admin_queue()
2259 error = nvme_enable_ctrl(ctrl); in nvme_tcp_configure_admin_queue()
2263 nvme_unquiesce_admin_queue(ctrl); in nvme_tcp_configure_admin_queue()
2265 error = nvme_init_ctrl_finish(ctrl, false); in nvme_tcp_configure_admin_queue()
2272 nvme_quiesce_admin_queue(ctrl); in nvme_tcp_configure_admin_queue()
2273 blk_sync_queue(ctrl->admin_q); in nvme_tcp_configure_admin_queue()
2275 nvme_tcp_stop_queue(ctrl, 0); in nvme_tcp_configure_admin_queue()
2276 nvme_cancel_admin_tagset(ctrl); in nvme_tcp_configure_admin_queue()
2279 nvme_remove_admin_tag_set(ctrl); in nvme_tcp_configure_admin_queue()
2281 nvme_tcp_free_admin_queue(ctrl); in nvme_tcp_configure_admin_queue()
2285 static void nvme_tcp_teardown_admin_queue(struct nvme_ctrl *ctrl, in nvme_tcp_teardown_admin_queue() argument
2288 nvme_quiesce_admin_queue(ctrl); in nvme_tcp_teardown_admin_queue()
2289 blk_sync_queue(ctrl->admin_q); in nvme_tcp_teardown_admin_queue()
2290 nvme_tcp_stop_queue(ctrl, 0); in nvme_tcp_teardown_admin_queue()
2291 nvme_cancel_admin_tagset(ctrl); in nvme_tcp_teardown_admin_queue()
2293 nvme_unquiesce_admin_queue(ctrl); in nvme_tcp_teardown_admin_queue()
2294 nvme_remove_admin_tag_set(ctrl); in nvme_tcp_teardown_admin_queue()
2296 nvme_tcp_free_admin_queue(ctrl); in nvme_tcp_teardown_admin_queue()
2297 if (ctrl->tls_pskid) { in nvme_tcp_teardown_admin_queue()
2298 dev_dbg(ctrl->device, "Wipe negotiated TLS_PSK %08x\n", in nvme_tcp_teardown_admin_queue()
2299 ctrl->tls_pskid); in nvme_tcp_teardown_admin_queue()
2300 ctrl->tls_pskid = 0; in nvme_tcp_teardown_admin_queue()
2304 static void nvme_tcp_teardown_io_queues(struct nvme_ctrl *ctrl, in nvme_tcp_teardown_io_queues() argument
2307 if (ctrl->queue_count <= 1) in nvme_tcp_teardown_io_queues()
2309 nvme_quiesce_io_queues(ctrl); in nvme_tcp_teardown_io_queues()
2310 nvme_sync_io_queues(ctrl); in nvme_tcp_teardown_io_queues()
2311 nvme_tcp_stop_io_queues(ctrl); in nvme_tcp_teardown_io_queues()
2312 nvme_cancel_tagset(ctrl); in nvme_tcp_teardown_io_queues()
2314 nvme_unquiesce_io_queues(ctrl); in nvme_tcp_teardown_io_queues()
2315 nvme_remove_io_tag_set(ctrl); in nvme_tcp_teardown_io_queues()
2317 nvme_tcp_free_io_queues(ctrl); in nvme_tcp_teardown_io_queues()
2320 static void nvme_tcp_reconnect_or_remove(struct nvme_ctrl *ctrl, in nvme_tcp_reconnect_or_remove() argument
2323 enum nvme_ctrl_state state = nvme_ctrl_state(ctrl); in nvme_tcp_reconnect_or_remove()
2331 if (nvmf_should_reconnect(ctrl, status)) { in nvme_tcp_reconnect_or_remove()
2332 dev_info(ctrl->device, "Reconnecting in %d seconds...\n", in nvme_tcp_reconnect_or_remove()
2333 ctrl->opts->reconnect_delay); in nvme_tcp_reconnect_or_remove()
2334 queue_delayed_work(nvme_wq, &to_tcp_ctrl(ctrl)->connect_work, in nvme_tcp_reconnect_or_remove()
2335 ctrl->opts->reconnect_delay * HZ); in nvme_tcp_reconnect_or_remove()
2337 dev_info(ctrl->device, "Removing controller (%d)...\n", in nvme_tcp_reconnect_or_remove()
2339 nvme_delete_ctrl(ctrl); in nvme_tcp_reconnect_or_remove()
2348 * - the generated key is present in ctrl->tls_key (otherwise there's nothing
2351 * - a valid PSK key ID has been set in ctrl->tls_pskid (otherwise TLS
2359 static bool nvme_tcp_key_revoke_needed(struct nvme_ctrl *ctrl) in nvme_tcp_key_revoke_needed() argument
2361 return ctrl->opts->concat && ctrl->opts->tls_key && ctrl->tls_pskid; in nvme_tcp_key_revoke_needed()
2364 static int nvme_tcp_setup_ctrl(struct nvme_ctrl *ctrl, bool new) in nvme_tcp_setup_ctrl() argument
2366 struct nvmf_ctrl_options *opts = ctrl->opts; in nvme_tcp_setup_ctrl()
2369 ret = nvme_tcp_configure_admin_queue(ctrl, new); in nvme_tcp_setup_ctrl()
2373 if (ctrl->opts->concat && !ctrl->tls_pskid) { in nvme_tcp_setup_ctrl()
2375 dev_dbg(ctrl->device, "restart admin queue for secure concatenation\n"); in nvme_tcp_setup_ctrl()
2376 nvme_stop_keep_alive(ctrl); in nvme_tcp_setup_ctrl()
2377 nvme_tcp_teardown_admin_queue(ctrl, false); in nvme_tcp_setup_ctrl()
2378 ret = nvme_tcp_configure_admin_queue(ctrl, false); in nvme_tcp_setup_ctrl()
2383 if (ctrl->icdoff) { in nvme_tcp_setup_ctrl()
2385 dev_err(ctrl->device, "icdoff is not supported!\n"); in nvme_tcp_setup_ctrl()
2389 if (!nvme_ctrl_sgl_supported(ctrl)) { in nvme_tcp_setup_ctrl()
2391 dev_err(ctrl->device, "Mandatory sgls are not supported!\n"); in nvme_tcp_setup_ctrl()
2395 if (opts->queue_size > ctrl->sqsize + 1) in nvme_tcp_setup_ctrl()
2396 dev_warn(ctrl->device, in nvme_tcp_setup_ctrl()
2397 "queue_size %zu > ctrl sqsize %u, clamping down\n", in nvme_tcp_setup_ctrl()
2398 opts->queue_size, ctrl->sqsize + 1); in nvme_tcp_setup_ctrl()
2400 if (ctrl->sqsize + 1 > ctrl->maxcmd) { in nvme_tcp_setup_ctrl()
2401 dev_warn(ctrl->device, in nvme_tcp_setup_ctrl()
2402 "sqsize %u > ctrl maxcmd %u, clamping down\n", in nvme_tcp_setup_ctrl()
2403 ctrl->sqsize + 1, ctrl->maxcmd); in nvme_tcp_setup_ctrl()
2404 ctrl->sqsize = ctrl->maxcmd - 1; in nvme_tcp_setup_ctrl()
2407 if (ctrl->queue_count > 1) { in nvme_tcp_setup_ctrl()
2408 ret = nvme_tcp_configure_io_queues(ctrl, new); in nvme_tcp_setup_ctrl()
2413 if (!nvme_change_ctrl_state(ctrl, NVME_CTRL_LIVE)) { in nvme_tcp_setup_ctrl()
2415 * state change failure is ok if we started ctrl delete, in nvme_tcp_setup_ctrl()
2419 enum nvme_ctrl_state state = nvme_ctrl_state(ctrl); in nvme_tcp_setup_ctrl()
2428 nvme_start_ctrl(ctrl); in nvme_tcp_setup_ctrl()
2432 if (ctrl->queue_count > 1) { in nvme_tcp_setup_ctrl()
2433 nvme_quiesce_io_queues(ctrl); in nvme_tcp_setup_ctrl()
2434 nvme_sync_io_queues(ctrl); in nvme_tcp_setup_ctrl()
2435 nvme_tcp_stop_io_queues(ctrl); in nvme_tcp_setup_ctrl()
2436 nvme_cancel_tagset(ctrl); in nvme_tcp_setup_ctrl()
2438 nvme_remove_io_tag_set(ctrl); in nvme_tcp_setup_ctrl()
2439 nvme_tcp_free_io_queues(ctrl); in nvme_tcp_setup_ctrl()
2442 nvme_stop_keep_alive(ctrl); in nvme_tcp_setup_ctrl()
2443 nvme_tcp_teardown_admin_queue(ctrl, new); in nvme_tcp_setup_ctrl()
2451 struct nvme_ctrl *ctrl = &tcp_ctrl->ctrl; in nvme_tcp_reconnect_ctrl_work() local
2454 ++ctrl->nr_reconnects; in nvme_tcp_reconnect_ctrl_work()
2456 ret = nvme_tcp_setup_ctrl(ctrl, false); in nvme_tcp_reconnect_ctrl_work()
2460 dev_info(ctrl->device, "Successfully reconnected (attempt %d/%d)\n", in nvme_tcp_reconnect_ctrl_work()
2461 ctrl->nr_reconnects, ctrl->opts->max_reconnects); in nvme_tcp_reconnect_ctrl_work()
2463 ctrl->nr_reconnects = 0; in nvme_tcp_reconnect_ctrl_work()
2468 dev_info(ctrl->device, "Failed reconnect attempt %d/%d\n", in nvme_tcp_reconnect_ctrl_work()
2469 ctrl->nr_reconnects, ctrl->opts->max_reconnects); in nvme_tcp_reconnect_ctrl_work()
2470 nvme_tcp_reconnect_or_remove(ctrl, ret); in nvme_tcp_reconnect_ctrl_work()
2477 struct nvme_ctrl *ctrl = &tcp_ctrl->ctrl; in nvme_tcp_error_recovery_work() local
2479 if (nvme_tcp_key_revoke_needed(ctrl)) in nvme_tcp_error_recovery_work()
2480 nvme_auth_revoke_tls_key(ctrl); in nvme_tcp_error_recovery_work()
2481 nvme_stop_keep_alive(ctrl); in nvme_tcp_error_recovery_work()
2482 flush_work(&ctrl->async_event_work); in nvme_tcp_error_recovery_work()
2483 nvme_tcp_teardown_io_queues(ctrl, false); in nvme_tcp_error_recovery_work()
2485 nvme_unquiesce_io_queues(ctrl); in nvme_tcp_error_recovery_work()
2486 nvme_tcp_teardown_admin_queue(ctrl, false); in nvme_tcp_error_recovery_work()
2487 nvme_unquiesce_admin_queue(ctrl); in nvme_tcp_error_recovery_work()
2488 nvme_auth_stop(ctrl); in nvme_tcp_error_recovery_work()
2490 if (!nvme_change_ctrl_state(ctrl, NVME_CTRL_CONNECTING)) { in nvme_tcp_error_recovery_work()
2491 /* state change failure is ok if we started ctrl delete */ in nvme_tcp_error_recovery_work()
2492 enum nvme_ctrl_state state = nvme_ctrl_state(ctrl); in nvme_tcp_error_recovery_work()
2499 nvme_tcp_reconnect_or_remove(ctrl, 0); in nvme_tcp_error_recovery_work()
2502 static void nvme_tcp_teardown_ctrl(struct nvme_ctrl *ctrl, bool shutdown) in nvme_tcp_teardown_ctrl() argument
2504 nvme_tcp_teardown_io_queues(ctrl, shutdown); in nvme_tcp_teardown_ctrl()
2505 nvme_quiesce_admin_queue(ctrl); in nvme_tcp_teardown_ctrl()
2506 nvme_disable_ctrl(ctrl, shutdown); in nvme_tcp_teardown_ctrl()
2507 nvme_tcp_teardown_admin_queue(ctrl, shutdown); in nvme_tcp_teardown_ctrl()
2510 static void nvme_tcp_delete_ctrl(struct nvme_ctrl *ctrl) in nvme_tcp_delete_ctrl() argument
2512 nvme_tcp_teardown_ctrl(ctrl, true); in nvme_tcp_delete_ctrl()
2517 struct nvme_ctrl *ctrl = in nvme_reset_ctrl_work() local
2521 if (nvme_tcp_key_revoke_needed(ctrl)) in nvme_reset_ctrl_work()
2522 nvme_auth_revoke_tls_key(ctrl); in nvme_reset_ctrl_work()
2523 nvme_stop_ctrl(ctrl); in nvme_reset_ctrl_work()
2524 nvme_tcp_teardown_ctrl(ctrl, false); in nvme_reset_ctrl_work()
2526 if (!nvme_change_ctrl_state(ctrl, NVME_CTRL_CONNECTING)) { in nvme_reset_ctrl_work()
2527 /* state change failure is ok if we started ctrl delete */ in nvme_reset_ctrl_work()
2528 enum nvme_ctrl_state state = nvme_ctrl_state(ctrl); in nvme_reset_ctrl_work()
2535 ret = nvme_tcp_setup_ctrl(ctrl, false); in nvme_reset_ctrl_work()
2542 ++ctrl->nr_reconnects; in nvme_reset_ctrl_work()
2543 nvme_tcp_reconnect_or_remove(ctrl, ret); in nvme_reset_ctrl_work()
2546 static void nvme_tcp_stop_ctrl(struct nvme_ctrl *ctrl) in nvme_tcp_stop_ctrl() argument
2548 flush_work(&to_tcp_ctrl(ctrl)->err_work); in nvme_tcp_stop_ctrl()
2549 cancel_delayed_work_sync(&to_tcp_ctrl(ctrl)->connect_work); in nvme_tcp_stop_ctrl()
2554 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl); in nvme_tcp_free_ctrl() local
2556 if (list_empty(&ctrl->list)) in nvme_tcp_free_ctrl()
2560 list_del(&ctrl->list); in nvme_tcp_free_ctrl()
2565 kfree(ctrl->queues); in nvme_tcp_free_ctrl()
2566 kfree(ctrl); in nvme_tcp_free_ctrl()
2584 sg->addr = cpu_to_le64(queue->ctrl->ctrl.icdoff); in nvme_tcp_set_sg_inline()
2602 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(arg); in nvme_tcp_submit_async_event() local
2603 struct nvme_tcp_queue *queue = &ctrl->queues[0]; in nvme_tcp_submit_async_event()
2604 struct nvme_tcp_cmd_pdu *pdu = ctrl->async_req.pdu; in nvme_tcp_submit_async_event()
2620 ctrl->async_req.state = NVME_TCP_SEND_CMD_PDU; in nvme_tcp_submit_async_event()
2621 ctrl->async_req.offset = 0; in nvme_tcp_submit_async_event()
2622 ctrl->async_req.curr_bio = NULL; in nvme_tcp_submit_async_event()
2623 ctrl->async_req.data_len = 0; in nvme_tcp_submit_async_event()
2624 init_llist_node(&ctrl->async_req.lentry); in nvme_tcp_submit_async_event()
2625 INIT_LIST_HEAD(&ctrl->async_req.entry); in nvme_tcp_submit_async_event()
2627 nvme_tcp_queue_request(&ctrl->async_req, true); in nvme_tcp_submit_async_event()
2633 struct nvme_ctrl *ctrl = &req->queue->ctrl->ctrl; in nvme_tcp_complete_timed_out() local
2635 nvme_tcp_stop_queue(ctrl, nvme_tcp_queue_id(req->queue)); in nvme_tcp_complete_timed_out()
2642 struct nvme_ctrl *ctrl = &req->queue->ctrl->ctrl; in nvme_tcp_timeout() local
2647 dev_warn(ctrl->device, in nvme_tcp_timeout()
2652 if (nvme_ctrl_state(ctrl) != NVME_CTRL_LIVE) { in nvme_tcp_timeout()
2657 * - ctrl disable/shutdown fabrics requests in nvme_tcp_timeout()
2674 nvme_tcp_error_recovery(ctrl); in nvme_tcp_timeout()
2744 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_setup_cmd_pdu()
2770 if (!nvme_check_ready(&queue->ctrl->ctrl, rq, queue_ready)) in nvme_tcp_queue_rq()
2771 return nvme_fail_nonready_command(&queue->ctrl->ctrl, rq); in nvme_tcp_queue_rq()
2786 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(set->driver_data); in nvme_tcp_map_queues() local
2788 nvmf_map_queues(set, &ctrl->ctrl, ctrl->io_queues); in nvme_tcp_map_queues()
2808 static int nvme_tcp_get_address(struct nvme_ctrl *ctrl, char *buf, int size) in nvme_tcp_get_address() argument
2810 struct nvme_tcp_queue *queue = &to_tcp_ctrl(ctrl)->queues[0]; in nvme_tcp_get_address()
2814 len = nvmf_get_address(ctrl, buf, size); in nvme_tcp_get_address()
2874 struct nvme_tcp_ctrl *ctrl; in nvme_tcp_existing_controller() local
2878 list_for_each_entry(ctrl, &nvme_tcp_ctrl_list, list) { in nvme_tcp_existing_controller()
2879 found = nvmf_ip_options_match(&ctrl->ctrl, opts); in nvme_tcp_existing_controller()
2891 struct nvme_tcp_ctrl *ctrl; in nvme_tcp_alloc_ctrl() local
2894 ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); in nvme_tcp_alloc_ctrl()
2895 if (!ctrl) in nvme_tcp_alloc_ctrl()
2898 INIT_LIST_HEAD(&ctrl->list); in nvme_tcp_alloc_ctrl()
2899 ctrl->ctrl.opts = opts; in nvme_tcp_alloc_ctrl()
2900 ctrl->ctrl.queue_count = opts->nr_io_queues + opts->nr_write_queues + in nvme_tcp_alloc_ctrl()
2902 ctrl->ctrl.sqsize = opts->queue_size - 1; in nvme_tcp_alloc_ctrl()
2903 ctrl->ctrl.kato = opts->kato; in nvme_tcp_alloc_ctrl()
2905 INIT_DELAYED_WORK(&ctrl->connect_work, in nvme_tcp_alloc_ctrl()
2907 INIT_WORK(&ctrl->err_work, nvme_tcp_error_recovery_work); in nvme_tcp_alloc_ctrl()
2908 INIT_WORK(&ctrl->ctrl.reset_work, nvme_reset_ctrl_work); in nvme_tcp_alloc_ctrl()
2921 opts->traddr, opts->trsvcid, &ctrl->addr); in nvme_tcp_alloc_ctrl()
2930 opts->host_traddr, NULL, &ctrl->src_addr); in nvme_tcp_alloc_ctrl()
2952 ctrl->queues = kcalloc(ctrl->ctrl.queue_count, sizeof(*ctrl->queues), in nvme_tcp_alloc_ctrl()
2954 if (!ctrl->queues) { in nvme_tcp_alloc_ctrl()
2959 ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_tcp_ctrl_ops, 0); in nvme_tcp_alloc_ctrl()
2963 return ctrl; in nvme_tcp_alloc_ctrl()
2965 kfree(ctrl->queues); in nvme_tcp_alloc_ctrl()
2967 kfree(ctrl); in nvme_tcp_alloc_ctrl()
2974 struct nvme_tcp_ctrl *ctrl; in nvme_tcp_create_ctrl() local
2977 ctrl = nvme_tcp_alloc_ctrl(dev, opts); in nvme_tcp_create_ctrl()
2978 if (IS_ERR(ctrl)) in nvme_tcp_create_ctrl()
2979 return ERR_CAST(ctrl); in nvme_tcp_create_ctrl()
2981 ret = nvme_add_ctrl(&ctrl->ctrl); in nvme_tcp_create_ctrl()
2985 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) { in nvme_tcp_create_ctrl()
2991 ret = nvme_tcp_setup_ctrl(&ctrl->ctrl, true); in nvme_tcp_create_ctrl()
2995 dev_info(ctrl->ctrl.device, "new ctrl: NQN \"%s\", addr %pISp, hostnqn: %s\n", in nvme_tcp_create_ctrl()
2996 nvmf_ctrl_subsysnqn(&ctrl->ctrl), &ctrl->addr, opts->host->nqn); in nvme_tcp_create_ctrl()
2999 list_add_tail(&ctrl->list, &nvme_tcp_ctrl_list); in nvme_tcp_create_ctrl()
3002 return &ctrl->ctrl; in nvme_tcp_create_ctrl()
3005 nvme_uninit_ctrl(&ctrl->ctrl); in nvme_tcp_create_ctrl()
3007 nvme_put_ctrl(&ctrl->ctrl); in nvme_tcp_create_ctrl()
3056 struct nvme_tcp_ctrl *ctrl; in nvme_tcp_cleanup_module() local
3061 list_for_each_entry(ctrl, &nvme_tcp_ctrl_list, list) in nvme_tcp_cleanup_module()
3062 nvme_delete_ctrl(&ctrl->ctrl); in nvme_tcp_cleanup_module()