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()
495 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_verify_hdgst()
505 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_verify_hdgst()
524 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_check_ddgst()
546 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(set->driver_data); in nvme_tcp_init_request() local
549 int queue_idx = (set == &ctrl->tag_set) ? hctx_idx + 1 : 0; in nvme_tcp_init_request()
550 struct nvme_tcp_queue *queue = &ctrl->queues[queue_idx]; in nvme_tcp_init_request()
561 nvme_req(rq)->ctrl = &ctrl->ctrl; in nvme_tcp_init_request()
570 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(data); in nvme_tcp_init_hctx() local
571 struct nvme_tcp_queue *queue = &ctrl->queues[hctx_idx + 1]; in nvme_tcp_init_hctx()
580 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(data); in nvme_tcp_init_admin_hctx() local
581 struct nvme_tcp_queue *queue = &ctrl->queues[0]; in nvme_tcp_init_admin_hctx()
604 static void nvme_tcp_error_recovery(struct nvme_ctrl *ctrl) in nvme_tcp_error_recovery() argument
606 if (!nvme_change_ctrl_state(ctrl, NVME_CTRL_RESETTING)) in nvme_tcp_error_recovery()
609 dev_warn(ctrl->device, "starting error recovery\n"); in nvme_tcp_error_recovery()
610 queue_work(nvme_reset_wq, &to_tcp_ctrl(ctrl)->err_work); in nvme_tcp_error_recovery()
621 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_process_nvme_cqe()
624 nvme_tcp_error_recovery(&queue->ctrl->ctrl); in nvme_tcp_process_nvme_cqe()
646 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_c2h_data()
653 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_c2h_data()
663 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_c2h_data()
666 nvme_tcp_error_recovery(&queue->ctrl->ctrl); in nvme_tcp_handle_c2h_data()
687 nvme_complete_async_event(&queue->ctrl->ctrl, cqe->status, in nvme_tcp_handle_comp()
739 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_r2t()
747 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_r2t()
754 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_r2t()
761 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_r2t()
796 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_c2h_term()
808 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_handle_c2h_term()
837 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_recv_pdu()
879 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_recv_pdu()
915 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_recv_data()
935 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_recv_data()
989 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_recv_ddgst()
1033 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_recv_skb()
1036 nvme_tcp_error_recovery(&queue->ctrl->ctrl); in nvme_tcp_recv_skb()
1086 nvme_tcp_error_recovery(&queue->ctrl->ctrl); in nvme_tcp_state_change()
1089 dev_info(queue->ctrl->ctrl.device, in nvme_tcp_state_change()
1109 nvme_complete_async_event(&req->queue->ctrl->ctrl, in nvme_tcp_fail_request()
1328 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_try_send()
1422 static void nvme_tcp_free_async_req(struct nvme_tcp_ctrl *ctrl) in nvme_tcp_free_async_req() argument
1424 struct nvme_tcp_request *async = &ctrl->async_req; in nvme_tcp_free_async_req()
1429 static int nvme_tcp_alloc_async_req(struct nvme_tcp_ctrl *ctrl) in nvme_tcp_alloc_async_req() argument
1431 struct nvme_tcp_queue *queue = &ctrl->queues[0]; in nvme_tcp_alloc_async_req()
1432 struct nvme_tcp_request *async = &ctrl->async_req; in nvme_tcp_alloc_async_req()
1441 async->queue = &ctrl->queues[0]; in nvme_tcp_alloc_async_req()
1447 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl); in nvme_tcp_free_queue() local
1448 struct nvme_tcp_queue *queue = &ctrl->queues[qid]; in nvme_tcp_free_queue()
1562 pr_err("queue %d: data digest mismatch host: %s ctrl: %s\n", in nvme_tcp_init_connection()
1572 pr_err("queue %d: header digest mismatch host: %s ctrl: %s\n", in nvme_tcp_init_connection()
1608 struct nvme_tcp_ctrl *ctrl = queue->ctrl; in nvme_tcp_default_queue() local
1612 qid < 1 + ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_tcp_default_queue()
1617 struct nvme_tcp_ctrl *ctrl = queue->ctrl; in nvme_tcp_read_queue() local
1622 qid < 1 + ctrl->io_queues[HCTX_TYPE_DEFAULT] + in nvme_tcp_read_queue()
1623 ctrl->io_queues[HCTX_TYPE_READ]; in nvme_tcp_read_queue()
1628 struct nvme_tcp_ctrl *ctrl = queue->ctrl; in nvme_tcp_poll_queue() local
1634 qid < 1 + ctrl->io_queues[HCTX_TYPE_DEFAULT] + in nvme_tcp_poll_queue()
1635 ctrl->io_queues[HCTX_TYPE_READ] + in nvme_tcp_poll_queue()
1636 ctrl->io_queues[HCTX_TYPE_POLL]; in nvme_tcp_poll_queue()
1650 struct nvme_tcp_ctrl *ctrl = queue->ctrl; in nvme_tcp_set_queue_io_cpu() local
1651 struct blk_mq_tag_set *set = &ctrl->tag_set; in nvme_tcp_set_queue_io_cpu()
1687 dev_dbg(ctrl->ctrl.device, "queue %d: using cpu %d\n", in nvme_tcp_set_queue_io_cpu()
1694 struct nvme_tcp_ctrl *ctrl = queue->ctrl; in nvme_tcp_tls_done() local
1698 dev_dbg(ctrl->ctrl.device, "queue %d: TLS handshake done, key %x, status %d\n", in nvme_tcp_tls_done()
1708 dev_warn(ctrl->ctrl.device, "queue %d: Invalid key %x\n", in nvme_tcp_tls_done()
1714 ctrl->ctrl.tls_pskid = key_serial(tls_key); in nvme_tcp_tls_done()
1774 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl); in nvme_tcp_alloc_queue() local
1775 struct nvme_tcp_queue *queue = &ctrl->queues[qid]; in nvme_tcp_alloc_queue()
1780 queue->ctrl = ctrl; in nvme_tcp_alloc_queue()
1793 ctrl->addr.ss_family, SOCK_STREAM, in nvme_tcp_alloc_queue()
1844 ret = kernel_bind(queue->sock, (struct sockaddr *)&ctrl->src_addr, in nvme_tcp_alloc_queue()
1845 sizeof(ctrl->src_addr)); in nvme_tcp_alloc_queue()
1890 ret = kernel_connect(queue->sock, (struct sockaddr *)&ctrl->addr, in nvme_tcp_alloc_queue()
1891 sizeof(ctrl->addr), 0); in nvme_tcp_alloc_queue()
1951 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl); in nvme_tcp_stop_queue_nowait() local
1952 struct nvme_tcp_queue *queue = &ctrl->queues[qid]; in nvme_tcp_stop_queue_nowait()
1970 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl); in nvme_tcp_wait_queue() local
1971 struct nvme_tcp_queue *queue = &ctrl->queues[qid]; in nvme_tcp_wait_queue()
2011 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl); in nvme_tcp_start_queue() local
2012 struct nvme_tcp_queue *queue = &ctrl->queues[idx]; in nvme_tcp_start_queue()
2036 static void nvme_tcp_free_admin_queue(struct nvme_ctrl *ctrl) in nvme_tcp_free_admin_queue() argument
2038 if (to_tcp_ctrl(ctrl)->async_req.pdu) { in nvme_tcp_free_admin_queue()
2039 cancel_work_sync(&ctrl->async_event_work); in nvme_tcp_free_admin_queue()
2040 nvme_tcp_free_async_req(to_tcp_ctrl(ctrl)); in nvme_tcp_free_admin_queue()
2041 to_tcp_ctrl(ctrl)->async_req.pdu = NULL; in nvme_tcp_free_admin_queue()
2044 nvme_tcp_free_queue(ctrl, 0); in nvme_tcp_free_admin_queue()
2047 static void nvme_tcp_free_io_queues(struct nvme_ctrl *ctrl) in nvme_tcp_free_io_queues() argument
2051 for (i = 1; i < ctrl->queue_count; i++) in nvme_tcp_free_io_queues()
2052 nvme_tcp_free_queue(ctrl, i); in nvme_tcp_free_io_queues()
2055 static void nvme_tcp_stop_io_queues(struct nvme_ctrl *ctrl) in nvme_tcp_stop_io_queues() argument
2059 for (i = 1; i < ctrl->queue_count; i++) in nvme_tcp_stop_io_queues()
2060 nvme_tcp_stop_queue_nowait(ctrl, i); in nvme_tcp_stop_io_queues()
2061 for (i = 1; i < ctrl->queue_count; i++) in nvme_tcp_stop_io_queues()
2062 nvme_tcp_wait_queue(ctrl, i); in nvme_tcp_stop_io_queues()
2065 static int nvme_tcp_start_io_queues(struct nvme_ctrl *ctrl, in nvme_tcp_start_io_queues() argument
2071 ret = nvme_tcp_start_queue(ctrl, i); in nvme_tcp_start_io_queues()
2080 nvme_tcp_stop_queue(ctrl, i); in nvme_tcp_start_io_queues()
2084 static int nvme_tcp_alloc_admin_queue(struct nvme_ctrl *ctrl) in nvme_tcp_alloc_admin_queue() argument
2089 if (nvme_tcp_tls_configured(ctrl)) { in nvme_tcp_alloc_admin_queue()
2090 if (ctrl->opts->tls_key) in nvme_tcp_alloc_admin_queue()
2091 pskid = key_serial(ctrl->opts->tls_key); in nvme_tcp_alloc_admin_queue()
2092 else if (ctrl->opts->tls) { in nvme_tcp_alloc_admin_queue()
2093 pskid = nvme_tls_psk_default(ctrl->opts->keyring, in nvme_tcp_alloc_admin_queue()
2094 ctrl->opts->host->nqn, in nvme_tcp_alloc_admin_queue()
2095 ctrl->opts->subsysnqn); in nvme_tcp_alloc_admin_queue()
2097 dev_err(ctrl->device, "no valid PSK found\n"); in nvme_tcp_alloc_admin_queue()
2103 ret = nvme_tcp_alloc_queue(ctrl, 0, pskid); in nvme_tcp_alloc_admin_queue()
2107 ret = nvme_tcp_alloc_async_req(to_tcp_ctrl(ctrl)); in nvme_tcp_alloc_admin_queue()
2114 nvme_tcp_free_queue(ctrl, 0); in nvme_tcp_alloc_admin_queue()
2118 static int __nvme_tcp_alloc_io_queues(struct nvme_ctrl *ctrl) in __nvme_tcp_alloc_io_queues() argument
2122 if (nvme_tcp_tls_configured(ctrl)) { in __nvme_tcp_alloc_io_queues()
2123 if (ctrl->opts->concat) { in __nvme_tcp_alloc_io_queues()
2128 if (!ctrl->opts->tls_key) { in __nvme_tcp_alloc_io_queues()
2129 dev_err(ctrl->device, "no PSK generated\n"); in __nvme_tcp_alloc_io_queues()
2132 if (ctrl->tls_pskid && in __nvme_tcp_alloc_io_queues()
2133 ctrl->tls_pskid != key_serial(ctrl->opts->tls_key)) { in __nvme_tcp_alloc_io_queues()
2134 dev_err(ctrl->device, "Stale PSK id %08x\n", ctrl->tls_pskid); in __nvme_tcp_alloc_io_queues()
2135 ctrl->tls_pskid = 0; in __nvme_tcp_alloc_io_queues()
2137 } else if (!ctrl->tls_pskid) { in __nvme_tcp_alloc_io_queues()
2138 dev_err(ctrl->device, "no PSK negotiated\n"); in __nvme_tcp_alloc_io_queues()
2143 for (i = 1; i < ctrl->queue_count; i++) { in __nvme_tcp_alloc_io_queues()
2144 ret = nvme_tcp_alloc_queue(ctrl, i, in __nvme_tcp_alloc_io_queues()
2145 ctrl->tls_pskid); in __nvme_tcp_alloc_io_queues()
2154 nvme_tcp_free_queue(ctrl, i); in __nvme_tcp_alloc_io_queues()
2159 static int nvme_tcp_alloc_io_queues(struct nvme_ctrl *ctrl) in nvme_tcp_alloc_io_queues() argument
2164 nr_io_queues = nvmf_nr_io_queues(ctrl->opts); in nvme_tcp_alloc_io_queues()
2165 ret = nvme_set_queue_count(ctrl, &nr_io_queues); in nvme_tcp_alloc_io_queues()
2170 dev_err(ctrl->device, in nvme_tcp_alloc_io_queues()
2175 ctrl->queue_count = nr_io_queues + 1; in nvme_tcp_alloc_io_queues()
2176 dev_info(ctrl->device, in nvme_tcp_alloc_io_queues()
2179 nvmf_set_io_queues(ctrl->opts, nr_io_queues, in nvme_tcp_alloc_io_queues()
2180 to_tcp_ctrl(ctrl)->io_queues); in nvme_tcp_alloc_io_queues()
2181 return __nvme_tcp_alloc_io_queues(ctrl); in nvme_tcp_alloc_io_queues()
2184 static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new) in nvme_tcp_configure_io_queues() argument
2188 ret = nvme_tcp_alloc_io_queues(ctrl); in nvme_tcp_configure_io_queues()
2193 ret = nvme_alloc_io_tag_set(ctrl, &to_tcp_ctrl(ctrl)->tag_set, in nvme_tcp_configure_io_queues()
2195 ctrl->opts->nr_poll_queues ? HCTX_MAX_TYPES : 2, in nvme_tcp_configure_io_queues()
2206 nr_queues = min(ctrl->tagset->nr_hw_queues + 1, ctrl->queue_count); in nvme_tcp_configure_io_queues()
2207 ret = nvme_tcp_start_io_queues(ctrl, 1, nr_queues); in nvme_tcp_configure_io_queues()
2212 nvme_start_freeze(ctrl); in nvme_tcp_configure_io_queues()
2213 nvme_unquiesce_io_queues(ctrl); in nvme_tcp_configure_io_queues()
2214 if (!nvme_wait_freeze_timeout(ctrl, NVME_IO_TIMEOUT)) { in nvme_tcp_configure_io_queues()
2221 nvme_unfreeze(ctrl); in nvme_tcp_configure_io_queues()
2224 blk_mq_update_nr_hw_queues(ctrl->tagset, in nvme_tcp_configure_io_queues()
2225 ctrl->queue_count - 1); in nvme_tcp_configure_io_queues()
2226 nvme_unfreeze(ctrl); in nvme_tcp_configure_io_queues()
2233 ret = nvme_tcp_start_io_queues(ctrl, nr_queues, in nvme_tcp_configure_io_queues()
2234 ctrl->tagset->nr_hw_queues + 1); in nvme_tcp_configure_io_queues()
2241 nvme_quiesce_io_queues(ctrl); in nvme_tcp_configure_io_queues()
2242 nvme_sync_io_queues(ctrl); in nvme_tcp_configure_io_queues()
2243 nvme_tcp_stop_io_queues(ctrl); in nvme_tcp_configure_io_queues()
2245 nvme_cancel_tagset(ctrl); in nvme_tcp_configure_io_queues()
2247 nvme_remove_io_tag_set(ctrl); in nvme_tcp_configure_io_queues()
2249 nvme_tcp_free_io_queues(ctrl); in nvme_tcp_configure_io_queues()
2253 static int nvme_tcp_configure_admin_queue(struct nvme_ctrl *ctrl, bool new) in nvme_tcp_configure_admin_queue() argument
2257 error = nvme_tcp_alloc_admin_queue(ctrl); in nvme_tcp_configure_admin_queue()
2262 error = nvme_alloc_admin_tag_set(ctrl, in nvme_tcp_configure_admin_queue()
2263 &to_tcp_ctrl(ctrl)->admin_tag_set, in nvme_tcp_configure_admin_queue()
2270 error = nvme_tcp_start_queue(ctrl, 0); in nvme_tcp_configure_admin_queue()
2274 error = nvme_enable_ctrl(ctrl); in nvme_tcp_configure_admin_queue()
2278 nvme_unquiesce_admin_queue(ctrl); in nvme_tcp_configure_admin_queue()
2280 error = nvme_init_ctrl_finish(ctrl, false); in nvme_tcp_configure_admin_queue()
2287 nvme_quiesce_admin_queue(ctrl); in nvme_tcp_configure_admin_queue()
2288 blk_sync_queue(ctrl->admin_q); in nvme_tcp_configure_admin_queue()
2290 nvme_tcp_stop_queue(ctrl, 0); in nvme_tcp_configure_admin_queue()
2291 nvme_cancel_admin_tagset(ctrl); in nvme_tcp_configure_admin_queue()
2294 nvme_remove_admin_tag_set(ctrl); in nvme_tcp_configure_admin_queue()
2296 nvme_tcp_free_admin_queue(ctrl); in nvme_tcp_configure_admin_queue()
2300 static void nvme_tcp_teardown_admin_queue(struct nvme_ctrl *ctrl, in nvme_tcp_teardown_admin_queue() argument
2303 nvme_quiesce_admin_queue(ctrl); in nvme_tcp_teardown_admin_queue()
2304 blk_sync_queue(ctrl->admin_q); in nvme_tcp_teardown_admin_queue()
2305 nvme_tcp_stop_queue(ctrl, 0); in nvme_tcp_teardown_admin_queue()
2306 nvme_cancel_admin_tagset(ctrl); in nvme_tcp_teardown_admin_queue()
2308 nvme_unquiesce_admin_queue(ctrl); in nvme_tcp_teardown_admin_queue()
2309 nvme_remove_admin_tag_set(ctrl); in nvme_tcp_teardown_admin_queue()
2311 nvme_tcp_free_admin_queue(ctrl); in nvme_tcp_teardown_admin_queue()
2312 if (ctrl->tls_pskid) { in nvme_tcp_teardown_admin_queue()
2313 dev_dbg(ctrl->device, "Wipe negotiated TLS_PSK %08x\n", in nvme_tcp_teardown_admin_queue()
2314 ctrl->tls_pskid); in nvme_tcp_teardown_admin_queue()
2315 ctrl->tls_pskid = 0; in nvme_tcp_teardown_admin_queue()
2319 static void nvme_tcp_teardown_io_queues(struct nvme_ctrl *ctrl, in nvme_tcp_teardown_io_queues() argument
2322 if (ctrl->queue_count <= 1) in nvme_tcp_teardown_io_queues()
2324 nvme_quiesce_io_queues(ctrl); in nvme_tcp_teardown_io_queues()
2325 nvme_sync_io_queues(ctrl); in nvme_tcp_teardown_io_queues()
2326 nvme_tcp_stop_io_queues(ctrl); in nvme_tcp_teardown_io_queues()
2327 nvme_cancel_tagset(ctrl); in nvme_tcp_teardown_io_queues()
2329 nvme_unquiesce_io_queues(ctrl); in nvme_tcp_teardown_io_queues()
2330 nvme_remove_io_tag_set(ctrl); in nvme_tcp_teardown_io_queues()
2332 nvme_tcp_free_io_queues(ctrl); in nvme_tcp_teardown_io_queues()
2335 static void nvme_tcp_reconnect_or_remove(struct nvme_ctrl *ctrl, in nvme_tcp_reconnect_or_remove() argument
2338 enum nvme_ctrl_state state = nvme_ctrl_state(ctrl); in nvme_tcp_reconnect_or_remove()
2346 if (nvmf_should_reconnect(ctrl, status)) { in nvme_tcp_reconnect_or_remove()
2347 dev_info(ctrl->device, "Reconnecting in %d seconds...\n", in nvme_tcp_reconnect_or_remove()
2348 ctrl->opts->reconnect_delay); in nvme_tcp_reconnect_or_remove()
2349 queue_delayed_work(nvme_wq, &to_tcp_ctrl(ctrl)->connect_work, in nvme_tcp_reconnect_or_remove()
2350 ctrl->opts->reconnect_delay * HZ); in nvme_tcp_reconnect_or_remove()
2352 dev_info(ctrl->device, "Removing controller (%d)...\n", in nvme_tcp_reconnect_or_remove()
2354 nvme_delete_ctrl(ctrl); in nvme_tcp_reconnect_or_remove()
2363 * - the generated key is present in ctrl->tls_key (otherwise there's nothing
2366 * - a valid PSK key ID has been set in ctrl->tls_pskid (otherwise TLS
2374 static bool nvme_tcp_key_revoke_needed(struct nvme_ctrl *ctrl) in nvme_tcp_key_revoke_needed() argument
2376 return ctrl->opts->concat && ctrl->opts->tls_key && ctrl->tls_pskid; in nvme_tcp_key_revoke_needed()
2379 static int nvme_tcp_setup_ctrl(struct nvme_ctrl *ctrl, bool new) in nvme_tcp_setup_ctrl() argument
2381 struct nvmf_ctrl_options *opts = ctrl->opts; in nvme_tcp_setup_ctrl()
2384 ret = nvme_tcp_configure_admin_queue(ctrl, new); in nvme_tcp_setup_ctrl()
2388 if (ctrl->opts && ctrl->opts->concat && !ctrl->tls_pskid) { in nvme_tcp_setup_ctrl()
2390 dev_dbg(ctrl->device, "restart admin queue for secure concatenation\n"); in nvme_tcp_setup_ctrl()
2391 nvme_stop_keep_alive(ctrl); in nvme_tcp_setup_ctrl()
2392 nvme_tcp_teardown_admin_queue(ctrl, false); in nvme_tcp_setup_ctrl()
2393 ret = nvme_tcp_configure_admin_queue(ctrl, false); in nvme_tcp_setup_ctrl()
2398 if (ctrl->icdoff) { in nvme_tcp_setup_ctrl()
2400 dev_err(ctrl->device, "icdoff is not supported!\n"); in nvme_tcp_setup_ctrl()
2404 if (!nvme_ctrl_sgl_supported(ctrl)) { in nvme_tcp_setup_ctrl()
2406 dev_err(ctrl->device, "Mandatory sgls are not supported!\n"); in nvme_tcp_setup_ctrl()
2410 if (opts->queue_size > ctrl->sqsize + 1) in nvme_tcp_setup_ctrl()
2411 dev_warn(ctrl->device, in nvme_tcp_setup_ctrl()
2412 "queue_size %zu > ctrl sqsize %u, clamping down\n", in nvme_tcp_setup_ctrl()
2413 opts->queue_size, ctrl->sqsize + 1); in nvme_tcp_setup_ctrl()
2415 if (ctrl->sqsize + 1 > ctrl->maxcmd) { in nvme_tcp_setup_ctrl()
2416 dev_warn(ctrl->device, in nvme_tcp_setup_ctrl()
2417 "sqsize %u > ctrl maxcmd %u, clamping down\n", in nvme_tcp_setup_ctrl()
2418 ctrl->sqsize + 1, ctrl->maxcmd); in nvme_tcp_setup_ctrl()
2419 ctrl->sqsize = ctrl->maxcmd - 1; in nvme_tcp_setup_ctrl()
2422 if (ctrl->queue_count > 1) { in nvme_tcp_setup_ctrl()
2423 ret = nvme_tcp_configure_io_queues(ctrl, new); in nvme_tcp_setup_ctrl()
2428 if (!nvme_change_ctrl_state(ctrl, NVME_CTRL_LIVE)) { in nvme_tcp_setup_ctrl()
2430 * state change failure is ok if we started ctrl delete, in nvme_tcp_setup_ctrl()
2434 enum nvme_ctrl_state state = nvme_ctrl_state(ctrl); in nvme_tcp_setup_ctrl()
2443 nvme_start_ctrl(ctrl); in nvme_tcp_setup_ctrl()
2447 if (ctrl->queue_count > 1) { in nvme_tcp_setup_ctrl()
2448 nvme_quiesce_io_queues(ctrl); in nvme_tcp_setup_ctrl()
2449 nvme_sync_io_queues(ctrl); in nvme_tcp_setup_ctrl()
2450 nvme_tcp_stop_io_queues(ctrl); in nvme_tcp_setup_ctrl()
2451 nvme_cancel_tagset(ctrl); in nvme_tcp_setup_ctrl()
2453 nvme_remove_io_tag_set(ctrl); in nvme_tcp_setup_ctrl()
2454 nvme_tcp_free_io_queues(ctrl); in nvme_tcp_setup_ctrl()
2457 nvme_stop_keep_alive(ctrl); in nvme_tcp_setup_ctrl()
2458 nvme_tcp_teardown_admin_queue(ctrl, new); in nvme_tcp_setup_ctrl()
2466 struct nvme_ctrl *ctrl = &tcp_ctrl->ctrl; in nvme_tcp_reconnect_ctrl_work() local
2469 ++ctrl->nr_reconnects; in nvme_tcp_reconnect_ctrl_work()
2471 ret = nvme_tcp_setup_ctrl(ctrl, false); in nvme_tcp_reconnect_ctrl_work()
2475 dev_info(ctrl->device, "Successfully reconnected (attempt %d/%d)\n", in nvme_tcp_reconnect_ctrl_work()
2476 ctrl->nr_reconnects, ctrl->opts->max_reconnects); in nvme_tcp_reconnect_ctrl_work()
2478 ctrl->nr_reconnects = 0; in nvme_tcp_reconnect_ctrl_work()
2483 dev_info(ctrl->device, "Failed reconnect attempt %d/%d\n", in nvme_tcp_reconnect_ctrl_work()
2484 ctrl->nr_reconnects, ctrl->opts->max_reconnects); in nvme_tcp_reconnect_ctrl_work()
2485 nvme_tcp_reconnect_or_remove(ctrl, ret); in nvme_tcp_reconnect_ctrl_work()
2492 struct nvme_ctrl *ctrl = &tcp_ctrl->ctrl; in nvme_tcp_error_recovery_work() local
2494 if (nvme_tcp_key_revoke_needed(ctrl)) in nvme_tcp_error_recovery_work()
2495 nvme_auth_revoke_tls_key(ctrl); in nvme_tcp_error_recovery_work()
2496 nvme_stop_keep_alive(ctrl); in nvme_tcp_error_recovery_work()
2497 flush_work(&ctrl->async_event_work); in nvme_tcp_error_recovery_work()
2498 nvme_tcp_teardown_io_queues(ctrl, false); in nvme_tcp_error_recovery_work()
2500 nvme_unquiesce_io_queues(ctrl); in nvme_tcp_error_recovery_work()
2501 nvme_tcp_teardown_admin_queue(ctrl, false); in nvme_tcp_error_recovery_work()
2502 nvme_unquiesce_admin_queue(ctrl); in nvme_tcp_error_recovery_work()
2503 nvme_auth_stop(ctrl); in nvme_tcp_error_recovery_work()
2505 if (!nvme_change_ctrl_state(ctrl, NVME_CTRL_CONNECTING)) { in nvme_tcp_error_recovery_work()
2506 /* state change failure is ok if we started ctrl delete */ in nvme_tcp_error_recovery_work()
2507 enum nvme_ctrl_state state = nvme_ctrl_state(ctrl); in nvme_tcp_error_recovery_work()
2514 nvme_tcp_reconnect_or_remove(ctrl, 0); in nvme_tcp_error_recovery_work()
2517 static void nvme_tcp_teardown_ctrl(struct nvme_ctrl *ctrl, bool shutdown) in nvme_tcp_teardown_ctrl() argument
2519 nvme_tcp_teardown_io_queues(ctrl, shutdown); in nvme_tcp_teardown_ctrl()
2520 nvme_quiesce_admin_queue(ctrl); in nvme_tcp_teardown_ctrl()
2521 nvme_disable_ctrl(ctrl, shutdown); in nvme_tcp_teardown_ctrl()
2522 nvme_tcp_teardown_admin_queue(ctrl, shutdown); in nvme_tcp_teardown_ctrl()
2525 static void nvme_tcp_delete_ctrl(struct nvme_ctrl *ctrl) in nvme_tcp_delete_ctrl() argument
2527 nvme_tcp_teardown_ctrl(ctrl, true); in nvme_tcp_delete_ctrl()
2532 struct nvme_ctrl *ctrl = in nvme_reset_ctrl_work() local
2536 if (nvme_tcp_key_revoke_needed(ctrl)) in nvme_reset_ctrl_work()
2537 nvme_auth_revoke_tls_key(ctrl); in nvme_reset_ctrl_work()
2538 nvme_stop_ctrl(ctrl); in nvme_reset_ctrl_work()
2539 nvme_tcp_teardown_ctrl(ctrl, false); in nvme_reset_ctrl_work()
2541 if (!nvme_change_ctrl_state(ctrl, NVME_CTRL_CONNECTING)) { in nvme_reset_ctrl_work()
2542 /* state change failure is ok if we started ctrl delete */ in nvme_reset_ctrl_work()
2543 enum nvme_ctrl_state state = nvme_ctrl_state(ctrl); in nvme_reset_ctrl_work()
2550 ret = nvme_tcp_setup_ctrl(ctrl, false); in nvme_reset_ctrl_work()
2557 ++ctrl->nr_reconnects; in nvme_reset_ctrl_work()
2558 nvme_tcp_reconnect_or_remove(ctrl, ret); in nvme_reset_ctrl_work()
2561 static void nvme_tcp_stop_ctrl(struct nvme_ctrl *ctrl) in nvme_tcp_stop_ctrl() argument
2563 flush_work(&to_tcp_ctrl(ctrl)->err_work); in nvme_tcp_stop_ctrl()
2564 cancel_delayed_work_sync(&to_tcp_ctrl(ctrl)->connect_work); in nvme_tcp_stop_ctrl()
2569 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl); in nvme_tcp_free_ctrl() local
2571 if (list_empty(&ctrl->list)) in nvme_tcp_free_ctrl()
2575 list_del(&ctrl->list); in nvme_tcp_free_ctrl()
2580 kfree(ctrl->queues); in nvme_tcp_free_ctrl()
2581 kfree(ctrl); in nvme_tcp_free_ctrl()
2599 sg->addr = cpu_to_le64(queue->ctrl->ctrl.icdoff); in nvme_tcp_set_sg_inline()
2617 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(arg); in nvme_tcp_submit_async_event() local
2618 struct nvme_tcp_queue *queue = &ctrl->queues[0]; in nvme_tcp_submit_async_event()
2619 struct nvme_tcp_cmd_pdu *pdu = ctrl->async_req.pdu; in nvme_tcp_submit_async_event()
2635 ctrl->async_req.state = NVME_TCP_SEND_CMD_PDU; in nvme_tcp_submit_async_event()
2636 ctrl->async_req.offset = 0; in nvme_tcp_submit_async_event()
2637 ctrl->async_req.curr_bio = NULL; in nvme_tcp_submit_async_event()
2638 ctrl->async_req.data_len = 0; in nvme_tcp_submit_async_event()
2640 nvme_tcp_queue_request(&ctrl->async_req, true, true); in nvme_tcp_submit_async_event()
2646 struct nvme_ctrl *ctrl = &req->queue->ctrl->ctrl; in nvme_tcp_complete_timed_out() local
2648 nvme_tcp_stop_queue(ctrl, nvme_tcp_queue_id(req->queue)); in nvme_tcp_complete_timed_out()
2655 struct nvme_ctrl *ctrl = &req->queue->ctrl->ctrl; in nvme_tcp_timeout() local
2660 dev_warn(ctrl->device, in nvme_tcp_timeout()
2665 if (nvme_ctrl_state(ctrl) != NVME_CTRL_LIVE) { in nvme_tcp_timeout()
2670 * - ctrl disable/shutdown fabrics requests in nvme_tcp_timeout()
2687 nvme_tcp_error_recovery(ctrl); in nvme_tcp_timeout()
2757 dev_err(queue->ctrl->ctrl.device, in nvme_tcp_setup_cmd_pdu()
2783 if (!nvme_check_ready(&queue->ctrl->ctrl, rq, queue_ready)) in nvme_tcp_queue_rq()
2784 return nvme_fail_nonready_command(&queue->ctrl->ctrl, rq); in nvme_tcp_queue_rq()
2799 struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(set->driver_data); in nvme_tcp_map_queues() local
2801 nvmf_map_queues(set, &ctrl->ctrl, ctrl->io_queues); in nvme_tcp_map_queues()
2821 static int nvme_tcp_get_address(struct nvme_ctrl *ctrl, char *buf, int size) in nvme_tcp_get_address() argument
2823 struct nvme_tcp_queue *queue = &to_tcp_ctrl(ctrl)->queues[0]; in nvme_tcp_get_address()
2827 len = nvmf_get_address(ctrl, buf, size); in nvme_tcp_get_address()
2886 struct nvme_tcp_ctrl *ctrl; in nvme_tcp_existing_controller() local
2890 list_for_each_entry(ctrl, &nvme_tcp_ctrl_list, list) { in nvme_tcp_existing_controller()
2891 found = nvmf_ip_options_match(&ctrl->ctrl, opts); in nvme_tcp_existing_controller()
2903 struct nvme_tcp_ctrl *ctrl; in nvme_tcp_alloc_ctrl() local
2906 ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); in nvme_tcp_alloc_ctrl()
2907 if (!ctrl) in nvme_tcp_alloc_ctrl()
2910 INIT_LIST_HEAD(&ctrl->list); in nvme_tcp_alloc_ctrl()
2911 ctrl->ctrl.opts = opts; in nvme_tcp_alloc_ctrl()
2912 ctrl->ctrl.queue_count = opts->nr_io_queues + opts->nr_write_queues + in nvme_tcp_alloc_ctrl()
2914 ctrl->ctrl.sqsize = opts->queue_size - 1; in nvme_tcp_alloc_ctrl()
2915 ctrl->ctrl.kato = opts->kato; in nvme_tcp_alloc_ctrl()
2917 INIT_DELAYED_WORK(&ctrl->connect_work, in nvme_tcp_alloc_ctrl()
2919 INIT_WORK(&ctrl->err_work, nvme_tcp_error_recovery_work); in nvme_tcp_alloc_ctrl()
2920 INIT_WORK(&ctrl->ctrl.reset_work, nvme_reset_ctrl_work); in nvme_tcp_alloc_ctrl()
2933 opts->traddr, opts->trsvcid, &ctrl->addr); in nvme_tcp_alloc_ctrl()
2942 opts->host_traddr, NULL, &ctrl->src_addr); in nvme_tcp_alloc_ctrl()
2964 ctrl->queues = kcalloc(ctrl->ctrl.queue_count, sizeof(*ctrl->queues), in nvme_tcp_alloc_ctrl()
2966 if (!ctrl->queues) { in nvme_tcp_alloc_ctrl()
2971 ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_tcp_ctrl_ops, 0); in nvme_tcp_alloc_ctrl()
2975 return ctrl; in nvme_tcp_alloc_ctrl()
2977 kfree(ctrl->queues); in nvme_tcp_alloc_ctrl()
2979 kfree(ctrl); in nvme_tcp_alloc_ctrl()
2986 struct nvme_tcp_ctrl *ctrl; in nvme_tcp_create_ctrl() local
2989 ctrl = nvme_tcp_alloc_ctrl(dev, opts); in nvme_tcp_create_ctrl()
2990 if (IS_ERR(ctrl)) in nvme_tcp_create_ctrl()
2991 return ERR_CAST(ctrl); in nvme_tcp_create_ctrl()
2993 ret = nvme_add_ctrl(&ctrl->ctrl); in nvme_tcp_create_ctrl()
2997 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) { in nvme_tcp_create_ctrl()
3003 ret = nvme_tcp_setup_ctrl(&ctrl->ctrl, true); in nvme_tcp_create_ctrl()
3007 dev_info(ctrl->ctrl.device, "new ctrl: NQN \"%s\", addr %pISp, hostnqn: %s\n", in nvme_tcp_create_ctrl()
3008 nvmf_ctrl_subsysnqn(&ctrl->ctrl), &ctrl->addr, opts->host->nqn); in nvme_tcp_create_ctrl()
3011 list_add_tail(&ctrl->list, &nvme_tcp_ctrl_list); in nvme_tcp_create_ctrl()
3014 return &ctrl->ctrl; in nvme_tcp_create_ctrl()
3017 nvme_uninit_ctrl(&ctrl->ctrl); in nvme_tcp_create_ctrl()
3019 nvme_put_ctrl(&ctrl->ctrl); in nvme_tcp_create_ctrl()
3068 struct nvme_tcp_ctrl *ctrl; in nvme_tcp_cleanup_module() local
3073 list_for_each_entry(ctrl, &nvme_tcp_ctrl_list, list) in nvme_tcp_cleanup_module()
3074 nvme_delete_ctrl(&ctrl->ctrl); in nvme_tcp_cleanup_module()