Lines Matching refs:ctrl
79 struct nvme_rdma_ctrl *ctrl; member
112 struct nvme_ctrl ctrl; member
117 static inline struct nvme_rdma_ctrl *to_rdma_ctrl(struct nvme_ctrl *ctrl) in to_rdma_ctrl() argument
119 return container_of(ctrl, struct nvme_rdma_ctrl, ctrl); in to_rdma_ctrl()
155 return queue - queue->ctrl->queues; in nvme_rdma_queue_idx()
161 queue->ctrl->io_queues[HCTX_TYPE_DEFAULT] + in nvme_rdma_poll_queue()
162 queue->ctrl->io_queues[HCTX_TYPE_READ]; in nvme_rdma_poll_queue()
291 struct nvme_rdma_ctrl *ctrl = set->driver_data; in nvme_rdma_init_request() local
293 int queue_idx = (set == &ctrl->tag_set) ? hctx_idx + 1 : 0; in nvme_rdma_init_request()
294 struct nvme_rdma_queue *queue = &ctrl->queues[queue_idx]; in nvme_rdma_init_request()
296 nvme_req(rq)->ctrl = &ctrl->ctrl; in nvme_rdma_init_request()
309 struct nvme_rdma_ctrl *ctrl = data; in nvme_rdma_init_hctx() local
310 struct nvme_rdma_queue *queue = &ctrl->queues[hctx_idx + 1]; in nvme_rdma_init_hctx()
312 BUG_ON(hctx_idx >= ctrl->ctrl.queue_count); in nvme_rdma_init_hctx()
321 struct nvme_rdma_ctrl *ctrl = data; in nvme_rdma_init_admin_hctx() local
322 struct nvme_rdma_queue *queue = &ctrl->queues[0]; in nvme_rdma_init_admin_hctx()
493 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_create_queue_ib()
515 static int nvme_rdma_alloc_queue(struct nvme_rdma_ctrl *ctrl, in nvme_rdma_alloc_queue() argument
522 queue = &ctrl->queues[idx]; in nvme_rdma_alloc_queue()
523 queue->ctrl = ctrl; in nvme_rdma_alloc_queue()
527 queue->cmnd_capsule_len = ctrl->ctrl.ioccsz * 16; in nvme_rdma_alloc_queue()
536 dev_info(ctrl->ctrl.device, in nvme_rdma_alloc_queue()
541 if (ctrl->ctrl.opts->mask & NVMF_OPT_HOST_TRADDR) in nvme_rdma_alloc_queue()
542 src_addr = (struct sockaddr *)&ctrl->src_addr; in nvme_rdma_alloc_queue()
546 (struct sockaddr *)&ctrl->addr, in nvme_rdma_alloc_queue()
549 dev_info(ctrl->ctrl.device, in nvme_rdma_alloc_queue()
556 dev_info(ctrl->ctrl.device, in nvme_rdma_alloc_queue()
593 static void nvme_rdma_free_io_queues(struct nvme_rdma_ctrl *ctrl) in nvme_rdma_free_io_queues() argument
597 for (i = 1; i < ctrl->ctrl.queue_count; i++) in nvme_rdma_free_io_queues()
598 nvme_rdma_free_queue(&ctrl->queues[i]); in nvme_rdma_free_io_queues()
601 static void nvme_rdma_stop_io_queues(struct nvme_rdma_ctrl *ctrl) in nvme_rdma_stop_io_queues() argument
605 for (i = 1; i < ctrl->ctrl.queue_count; i++) in nvme_rdma_stop_io_queues()
606 nvme_rdma_stop_queue(&ctrl->queues[i]); in nvme_rdma_stop_io_queues()
609 static int nvme_rdma_start_queue(struct nvme_rdma_ctrl *ctrl, int idx) in nvme_rdma_start_queue() argument
611 struct nvme_rdma_queue *queue = &ctrl->queues[idx]; in nvme_rdma_start_queue()
616 ret = nvmf_connect_io_queue(&ctrl->ctrl, idx, poll); in nvme_rdma_start_queue()
618 ret = nvmf_connect_admin_queue(&ctrl->ctrl); in nvme_rdma_start_queue()
625 dev_info(ctrl->ctrl.device, in nvme_rdma_start_queue()
631 static int nvme_rdma_start_io_queues(struct nvme_rdma_ctrl *ctrl) in nvme_rdma_start_io_queues() argument
635 for (i = 1; i < ctrl->ctrl.queue_count; i++) { in nvme_rdma_start_io_queues()
636 ret = nvme_rdma_start_queue(ctrl, i); in nvme_rdma_start_io_queues()
645 nvme_rdma_stop_queue(&ctrl->queues[i]); in nvme_rdma_start_io_queues()
649 static int nvme_rdma_alloc_io_queues(struct nvme_rdma_ctrl *ctrl) in nvme_rdma_alloc_io_queues() argument
651 struct nvmf_ctrl_options *opts = ctrl->ctrl.opts; in nvme_rdma_alloc_io_queues()
652 struct ib_device *ibdev = ctrl->device->dev; in nvme_rdma_alloc_io_queues()
664 ret = nvme_set_queue_count(&ctrl->ctrl, &nr_io_queues); in nvme_rdma_alloc_io_queues()
668 ctrl->ctrl.queue_count = nr_io_queues + 1; in nvme_rdma_alloc_io_queues()
669 if (ctrl->ctrl.queue_count < 2) in nvme_rdma_alloc_io_queues()
672 dev_info(ctrl->ctrl.device, in nvme_rdma_alloc_io_queues()
681 ctrl->io_queues[HCTX_TYPE_READ] = nr_read_queues; in nvme_rdma_alloc_io_queues()
682 nr_io_queues -= ctrl->io_queues[HCTX_TYPE_READ]; in nvme_rdma_alloc_io_queues()
683 ctrl->io_queues[HCTX_TYPE_DEFAULT] = in nvme_rdma_alloc_io_queues()
685 nr_io_queues -= ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_rdma_alloc_io_queues()
692 ctrl->io_queues[HCTX_TYPE_DEFAULT] = in nvme_rdma_alloc_io_queues()
694 nr_io_queues -= ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_rdma_alloc_io_queues()
699 ctrl->io_queues[HCTX_TYPE_POLL] = in nvme_rdma_alloc_io_queues()
703 for (i = 1; i < ctrl->ctrl.queue_count; i++) { in nvme_rdma_alloc_io_queues()
704 ret = nvme_rdma_alloc_queue(ctrl, i, in nvme_rdma_alloc_io_queues()
705 ctrl->ctrl.sqsize + 1); in nvme_rdma_alloc_io_queues()
714 nvme_rdma_free_queue(&ctrl->queues[i]); in nvme_rdma_alloc_io_queues()
722 struct nvme_rdma_ctrl *ctrl = to_rdma_ctrl(nctrl); in nvme_rdma_alloc_tagset() local
727 set = &ctrl->admin_tag_set; in nvme_rdma_alloc_tagset()
735 set->driver_data = ctrl; in nvme_rdma_alloc_tagset()
740 set = &ctrl->tag_set; in nvme_rdma_alloc_tagset()
749 set->driver_data = ctrl; in nvme_rdma_alloc_tagset()
762 static void nvme_rdma_destroy_admin_queue(struct nvme_rdma_ctrl *ctrl, in nvme_rdma_destroy_admin_queue() argument
766 blk_cleanup_queue(ctrl->ctrl.admin_q); in nvme_rdma_destroy_admin_queue()
767 blk_cleanup_queue(ctrl->ctrl.fabrics_q); in nvme_rdma_destroy_admin_queue()
768 blk_mq_free_tag_set(ctrl->ctrl.admin_tagset); in nvme_rdma_destroy_admin_queue()
770 if (ctrl->async_event_sqe.data) { in nvme_rdma_destroy_admin_queue()
771 nvme_rdma_free_qe(ctrl->device->dev, &ctrl->async_event_sqe, in nvme_rdma_destroy_admin_queue()
773 ctrl->async_event_sqe.data = NULL; in nvme_rdma_destroy_admin_queue()
775 nvme_rdma_free_queue(&ctrl->queues[0]); in nvme_rdma_destroy_admin_queue()
778 static int nvme_rdma_configure_admin_queue(struct nvme_rdma_ctrl *ctrl, in nvme_rdma_configure_admin_queue() argument
783 error = nvme_rdma_alloc_queue(ctrl, 0, NVME_AQ_DEPTH); in nvme_rdma_configure_admin_queue()
787 ctrl->device = ctrl->queues[0].device; in nvme_rdma_configure_admin_queue()
788 ctrl->ctrl.numa_node = dev_to_node(ctrl->device->dev->dma_device); in nvme_rdma_configure_admin_queue()
790 ctrl->max_fr_pages = nvme_rdma_get_max_fr_pages(ctrl->device->dev); in nvme_rdma_configure_admin_queue()
797 error = nvme_rdma_alloc_qe(ctrl->device->dev, &ctrl->async_event_sqe, in nvme_rdma_configure_admin_queue()
803 ctrl->ctrl.admin_tagset = nvme_rdma_alloc_tagset(&ctrl->ctrl, true); in nvme_rdma_configure_admin_queue()
804 if (IS_ERR(ctrl->ctrl.admin_tagset)) { in nvme_rdma_configure_admin_queue()
805 error = PTR_ERR(ctrl->ctrl.admin_tagset); in nvme_rdma_configure_admin_queue()
809 ctrl->ctrl.fabrics_q = blk_mq_init_queue(&ctrl->admin_tag_set); in nvme_rdma_configure_admin_queue()
810 if (IS_ERR(ctrl->ctrl.fabrics_q)) { in nvme_rdma_configure_admin_queue()
811 error = PTR_ERR(ctrl->ctrl.fabrics_q); in nvme_rdma_configure_admin_queue()
815 ctrl->ctrl.admin_q = blk_mq_init_queue(&ctrl->admin_tag_set); in nvme_rdma_configure_admin_queue()
816 if (IS_ERR(ctrl->ctrl.admin_q)) { in nvme_rdma_configure_admin_queue()
817 error = PTR_ERR(ctrl->ctrl.admin_q); in nvme_rdma_configure_admin_queue()
822 error = nvme_rdma_start_queue(ctrl, 0); in nvme_rdma_configure_admin_queue()
826 error = nvme_enable_ctrl(&ctrl->ctrl); in nvme_rdma_configure_admin_queue()
830 ctrl->ctrl.max_segments = ctrl->max_fr_pages; in nvme_rdma_configure_admin_queue()
831 ctrl->ctrl.max_hw_sectors = ctrl->max_fr_pages << (ilog2(SZ_4K) - 9); in nvme_rdma_configure_admin_queue()
833 blk_mq_unquiesce_queue(ctrl->ctrl.admin_q); in nvme_rdma_configure_admin_queue()
835 error = nvme_init_identify(&ctrl->ctrl); in nvme_rdma_configure_admin_queue()
842 nvme_rdma_stop_queue(&ctrl->queues[0]); in nvme_rdma_configure_admin_queue()
845 blk_cleanup_queue(ctrl->ctrl.admin_q); in nvme_rdma_configure_admin_queue()
848 blk_cleanup_queue(ctrl->ctrl.fabrics_q); in nvme_rdma_configure_admin_queue()
851 blk_mq_free_tag_set(ctrl->ctrl.admin_tagset); in nvme_rdma_configure_admin_queue()
853 nvme_rdma_free_qe(ctrl->device->dev, &ctrl->async_event_sqe, in nvme_rdma_configure_admin_queue()
855 ctrl->async_event_sqe.data = NULL; in nvme_rdma_configure_admin_queue()
857 nvme_rdma_free_queue(&ctrl->queues[0]); in nvme_rdma_configure_admin_queue()
861 static void nvme_rdma_destroy_io_queues(struct nvme_rdma_ctrl *ctrl, in nvme_rdma_destroy_io_queues() argument
865 blk_cleanup_queue(ctrl->ctrl.connect_q); in nvme_rdma_destroy_io_queues()
866 blk_mq_free_tag_set(ctrl->ctrl.tagset); in nvme_rdma_destroy_io_queues()
868 nvme_rdma_free_io_queues(ctrl); in nvme_rdma_destroy_io_queues()
871 static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new) in nvme_rdma_configure_io_queues() argument
875 ret = nvme_rdma_alloc_io_queues(ctrl); in nvme_rdma_configure_io_queues()
880 ctrl->ctrl.tagset = nvme_rdma_alloc_tagset(&ctrl->ctrl, false); in nvme_rdma_configure_io_queues()
881 if (IS_ERR(ctrl->ctrl.tagset)) { in nvme_rdma_configure_io_queues()
882 ret = PTR_ERR(ctrl->ctrl.tagset); in nvme_rdma_configure_io_queues()
886 ctrl->ctrl.connect_q = blk_mq_init_queue(&ctrl->tag_set); in nvme_rdma_configure_io_queues()
887 if (IS_ERR(ctrl->ctrl.connect_q)) { in nvme_rdma_configure_io_queues()
888 ret = PTR_ERR(ctrl->ctrl.connect_q); in nvme_rdma_configure_io_queues()
892 blk_mq_update_nr_hw_queues(&ctrl->tag_set, in nvme_rdma_configure_io_queues()
893 ctrl->ctrl.queue_count - 1); in nvme_rdma_configure_io_queues()
896 ret = nvme_rdma_start_io_queues(ctrl); in nvme_rdma_configure_io_queues()
904 blk_cleanup_queue(ctrl->ctrl.connect_q); in nvme_rdma_configure_io_queues()
907 blk_mq_free_tag_set(ctrl->ctrl.tagset); in nvme_rdma_configure_io_queues()
909 nvme_rdma_free_io_queues(ctrl); in nvme_rdma_configure_io_queues()
913 static void nvme_rdma_teardown_admin_queue(struct nvme_rdma_ctrl *ctrl, in nvme_rdma_teardown_admin_queue() argument
916 blk_mq_quiesce_queue(ctrl->ctrl.admin_q); in nvme_rdma_teardown_admin_queue()
917 nvme_rdma_stop_queue(&ctrl->queues[0]); in nvme_rdma_teardown_admin_queue()
918 if (ctrl->ctrl.admin_tagset) { in nvme_rdma_teardown_admin_queue()
919 blk_mq_tagset_busy_iter(ctrl->ctrl.admin_tagset, in nvme_rdma_teardown_admin_queue()
920 nvme_cancel_request, &ctrl->ctrl); in nvme_rdma_teardown_admin_queue()
921 blk_mq_tagset_wait_completed_request(ctrl->ctrl.admin_tagset); in nvme_rdma_teardown_admin_queue()
924 blk_mq_unquiesce_queue(ctrl->ctrl.admin_q); in nvme_rdma_teardown_admin_queue()
925 nvme_rdma_destroy_admin_queue(ctrl, remove); in nvme_rdma_teardown_admin_queue()
928 static void nvme_rdma_teardown_io_queues(struct nvme_rdma_ctrl *ctrl, in nvme_rdma_teardown_io_queues() argument
931 if (ctrl->ctrl.queue_count > 1) { in nvme_rdma_teardown_io_queues()
932 nvme_stop_queues(&ctrl->ctrl); in nvme_rdma_teardown_io_queues()
933 nvme_rdma_stop_io_queues(ctrl); in nvme_rdma_teardown_io_queues()
934 if (ctrl->ctrl.tagset) { in nvme_rdma_teardown_io_queues()
935 blk_mq_tagset_busy_iter(ctrl->ctrl.tagset, in nvme_rdma_teardown_io_queues()
936 nvme_cancel_request, &ctrl->ctrl); in nvme_rdma_teardown_io_queues()
937 blk_mq_tagset_wait_completed_request(ctrl->ctrl.tagset); in nvme_rdma_teardown_io_queues()
940 nvme_start_queues(&ctrl->ctrl); in nvme_rdma_teardown_io_queues()
941 nvme_rdma_destroy_io_queues(ctrl, remove); in nvme_rdma_teardown_io_queues()
947 struct nvme_rdma_ctrl *ctrl = to_rdma_ctrl(nctrl); in nvme_rdma_free_ctrl() local
949 if (list_empty(&ctrl->list)) in nvme_rdma_free_ctrl()
953 list_del(&ctrl->list); in nvme_rdma_free_ctrl()
958 kfree(ctrl->queues); in nvme_rdma_free_ctrl()
959 kfree(ctrl); in nvme_rdma_free_ctrl()
962 static void nvme_rdma_reconnect_or_remove(struct nvme_rdma_ctrl *ctrl) in nvme_rdma_reconnect_or_remove() argument
965 if (ctrl->ctrl.state != NVME_CTRL_CONNECTING) { in nvme_rdma_reconnect_or_remove()
966 WARN_ON_ONCE(ctrl->ctrl.state == NVME_CTRL_NEW || in nvme_rdma_reconnect_or_remove()
967 ctrl->ctrl.state == NVME_CTRL_LIVE); in nvme_rdma_reconnect_or_remove()
971 if (nvmf_should_reconnect(&ctrl->ctrl)) { in nvme_rdma_reconnect_or_remove()
972 dev_info(ctrl->ctrl.device, "Reconnecting in %d seconds...\n", in nvme_rdma_reconnect_or_remove()
973 ctrl->ctrl.opts->reconnect_delay); in nvme_rdma_reconnect_or_remove()
974 queue_delayed_work(nvme_wq, &ctrl->reconnect_work, in nvme_rdma_reconnect_or_remove()
975 ctrl->ctrl.opts->reconnect_delay * HZ); in nvme_rdma_reconnect_or_remove()
977 nvme_delete_ctrl(&ctrl->ctrl); in nvme_rdma_reconnect_or_remove()
981 static int nvme_rdma_setup_ctrl(struct nvme_rdma_ctrl *ctrl, bool new) in nvme_rdma_setup_ctrl() argument
986 ret = nvme_rdma_configure_admin_queue(ctrl, new); in nvme_rdma_setup_ctrl()
990 if (ctrl->ctrl.icdoff) { in nvme_rdma_setup_ctrl()
991 dev_err(ctrl->ctrl.device, "icdoff is not supported!\n"); in nvme_rdma_setup_ctrl()
995 if (!(ctrl->ctrl.sgls & (1 << 2))) { in nvme_rdma_setup_ctrl()
996 dev_err(ctrl->ctrl.device, in nvme_rdma_setup_ctrl()
1001 if (ctrl->ctrl.opts->queue_size > ctrl->ctrl.sqsize + 1) { in nvme_rdma_setup_ctrl()
1002 dev_warn(ctrl->ctrl.device, in nvme_rdma_setup_ctrl()
1004 ctrl->ctrl.opts->queue_size, ctrl->ctrl.sqsize + 1); in nvme_rdma_setup_ctrl()
1007 if (ctrl->ctrl.sqsize + 1 > ctrl->ctrl.maxcmd) { in nvme_rdma_setup_ctrl()
1008 dev_warn(ctrl->ctrl.device, in nvme_rdma_setup_ctrl()
1010 ctrl->ctrl.sqsize + 1, ctrl->ctrl.maxcmd); in nvme_rdma_setup_ctrl()
1011 ctrl->ctrl.sqsize = ctrl->ctrl.maxcmd - 1; in nvme_rdma_setup_ctrl()
1014 if (ctrl->ctrl.sgls & (1 << 20)) in nvme_rdma_setup_ctrl()
1015 ctrl->use_inline_data = true; in nvme_rdma_setup_ctrl()
1017 if (ctrl->ctrl.queue_count > 1) { in nvme_rdma_setup_ctrl()
1018 ret = nvme_rdma_configure_io_queues(ctrl, new); in nvme_rdma_setup_ctrl()
1023 changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE); in nvme_rdma_setup_ctrl()
1026 WARN_ON_ONCE(ctrl->ctrl.state != NVME_CTRL_DELETING); in nvme_rdma_setup_ctrl()
1031 nvme_start_ctrl(&ctrl->ctrl); in nvme_rdma_setup_ctrl()
1035 if (ctrl->ctrl.queue_count > 1) in nvme_rdma_setup_ctrl()
1036 nvme_rdma_destroy_io_queues(ctrl, new); in nvme_rdma_setup_ctrl()
1038 nvme_rdma_stop_queue(&ctrl->queues[0]); in nvme_rdma_setup_ctrl()
1039 nvme_rdma_destroy_admin_queue(ctrl, new); in nvme_rdma_setup_ctrl()
1045 struct nvme_rdma_ctrl *ctrl = container_of(to_delayed_work(work), in nvme_rdma_reconnect_ctrl_work() local
1048 ++ctrl->ctrl.nr_reconnects; in nvme_rdma_reconnect_ctrl_work()
1050 if (nvme_rdma_setup_ctrl(ctrl, false)) in nvme_rdma_reconnect_ctrl_work()
1053 dev_info(ctrl->ctrl.device, "Successfully reconnected (%d attempts)\n", in nvme_rdma_reconnect_ctrl_work()
1054 ctrl->ctrl.nr_reconnects); in nvme_rdma_reconnect_ctrl_work()
1056 ctrl->ctrl.nr_reconnects = 0; in nvme_rdma_reconnect_ctrl_work()
1061 dev_info(ctrl->ctrl.device, "Failed reconnect attempt %d\n", in nvme_rdma_reconnect_ctrl_work()
1062 ctrl->ctrl.nr_reconnects); in nvme_rdma_reconnect_ctrl_work()
1063 nvme_rdma_reconnect_or_remove(ctrl); in nvme_rdma_reconnect_ctrl_work()
1068 struct nvme_rdma_ctrl *ctrl = container_of(work, in nvme_rdma_error_recovery_work() local
1071 nvme_stop_keep_alive(&ctrl->ctrl); in nvme_rdma_error_recovery_work()
1072 nvme_rdma_teardown_io_queues(ctrl, false); in nvme_rdma_error_recovery_work()
1073 nvme_start_queues(&ctrl->ctrl); in nvme_rdma_error_recovery_work()
1074 nvme_rdma_teardown_admin_queue(ctrl, false); in nvme_rdma_error_recovery_work()
1075 blk_mq_unquiesce_queue(ctrl->ctrl.admin_q); in nvme_rdma_error_recovery_work()
1077 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) { in nvme_rdma_error_recovery_work()
1079 WARN_ON_ONCE(ctrl->ctrl.state != NVME_CTRL_DELETING); in nvme_rdma_error_recovery_work()
1083 nvme_rdma_reconnect_or_remove(ctrl); in nvme_rdma_error_recovery_work()
1086 static void nvme_rdma_error_recovery(struct nvme_rdma_ctrl *ctrl) in nvme_rdma_error_recovery() argument
1088 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RESETTING)) in nvme_rdma_error_recovery()
1091 queue_work(nvme_wq, &ctrl->err_work); in nvme_rdma_error_recovery()
1098 struct nvme_rdma_ctrl *ctrl = queue->ctrl; in nvme_rdma_wr_error() local
1100 if (ctrl->ctrl.state == NVME_CTRL_LIVE) in nvme_rdma_wr_error()
1101 dev_info(ctrl->ctrl.device, in nvme_rdma_wr_error()
1105 nvme_rdma_error_recovery(ctrl); in nvme_rdma_wr_error()
1196 sg->addr = cpu_to_le64(queue->ctrl->ctrl.icdoff); in nvme_rdma_map_sg_inline()
1296 queue->ctrl->use_inline_data && in nvme_rdma_map_data()
1365 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_post_send()
1391 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_post_recv()
1402 return queue->ctrl->admin_tag_set.tags[queue_idx]; in nvme_rdma_tagset()
1403 return queue->ctrl->tag_set.tags[queue_idx - 1]; in nvme_rdma_tagset()
1414 struct nvme_rdma_ctrl *ctrl = to_rdma_ctrl(arg); in nvme_rdma_submit_async_event() local
1415 struct nvme_rdma_queue *queue = &ctrl->queues[0]; in nvme_rdma_submit_async_event()
1417 struct nvme_rdma_qe *sqe = &ctrl->async_event_sqe; in nvme_rdma_submit_async_event()
1447 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_process_nvme_rsp()
1450 nvme_rdma_error_recovery(queue->ctrl); in nvme_rdma_process_nvme_rsp()
1460 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_process_nvme_rsp()
1463 nvme_rdma_error_recovery(queue->ctrl); in nvme_rdma_process_nvme_rsp()
1470 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_process_nvme_rsp()
1473 nvme_rdma_error_recovery(queue->ctrl); in nvme_rdma_process_nvme_rsp()
1506 nvme_complete_async_event(&queue->ctrl->ctrl, cqe->status, in nvme_rdma_recv_done()
1547 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_conn_rejected()
1551 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_conn_rejected()
1560 struct nvme_ctrl *ctrl = &queue->ctrl->ctrl; in nvme_rdma_addr_resolved() local
1567 if (ctrl->opts->tos >= 0) in nvme_rdma_addr_resolved()
1568 rdma_set_service_type(queue->cm_id, ctrl->opts->tos); in nvme_rdma_addr_resolved()
1571 dev_err(ctrl->device, "rdma_resolve_route failed (%d).\n", in nvme_rdma_addr_resolved()
1585 struct nvme_rdma_ctrl *ctrl = queue->ctrl; in nvme_rdma_route_resolved() local
1616 priv.hsqsize = cpu_to_le16(queue->ctrl->ctrl.sqsize); in nvme_rdma_route_resolved()
1621 dev_err(ctrl->ctrl.device, in nvme_rdma_route_resolved()
1639 dev_dbg(queue->ctrl->ctrl.device, "%s (%d): status %d id %p\n", in nvme_rdma_cm_handler()
1665 dev_dbg(queue->ctrl->ctrl.device, in nvme_rdma_cm_handler()
1672 dev_dbg(queue->ctrl->ctrl.device, in nvme_rdma_cm_handler()
1674 nvme_rdma_error_recovery(queue->ctrl); in nvme_rdma_cm_handler()
1680 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_cm_handler()
1682 nvme_rdma_error_recovery(queue->ctrl); in nvme_rdma_cm_handler()
1699 struct nvme_rdma_ctrl *ctrl = queue->ctrl; in nvme_rdma_timeout() local
1701 dev_warn(ctrl->ctrl.device, "I/O %d QID %d timeout\n", in nvme_rdma_timeout()
1709 if (ctrl->ctrl.state == NVME_CTRL_RESETTING) in nvme_rdma_timeout()
1712 if (ctrl->ctrl.state != NVME_CTRL_LIVE) { in nvme_rdma_timeout()
1718 flush_work(&ctrl->err_work); in nvme_rdma_timeout()
1719 nvme_rdma_teardown_io_queues(ctrl, false); in nvme_rdma_timeout()
1720 nvme_rdma_teardown_admin_queue(ctrl, false); in nvme_rdma_timeout()
1724 dev_warn(ctrl->ctrl.device, "starting error recovery\n"); in nvme_rdma_timeout()
1725 nvme_rdma_error_recovery(ctrl); in nvme_rdma_timeout()
1746 if (!nvmf_check_ready(&queue->ctrl->ctrl, rq, queue_ready)) in nvme_rdma_queue_rq()
1747 return nvmf_fail_nonready_command(&queue->ctrl->ctrl, rq); in nvme_rdma_queue_rq()
1769 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_queue_rq()
1821 struct nvme_rdma_ctrl *ctrl = set->driver_data; in nvme_rdma_map_queues() local
1822 struct nvmf_ctrl_options *opts = ctrl->ctrl.opts; in nvme_rdma_map_queues()
1824 if (opts->nr_write_queues && ctrl->io_queues[HCTX_TYPE_READ]) { in nvme_rdma_map_queues()
1827 ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_rdma_map_queues()
1830 ctrl->io_queues[HCTX_TYPE_READ]; in nvme_rdma_map_queues()
1832 ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_rdma_map_queues()
1836 ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_rdma_map_queues()
1839 ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_rdma_map_queues()
1843 ctrl->device->dev, 0); in nvme_rdma_map_queues()
1845 ctrl->device->dev, 0); in nvme_rdma_map_queues()
1847 if (opts->nr_poll_queues && ctrl->io_queues[HCTX_TYPE_POLL]) { in nvme_rdma_map_queues()
1850 ctrl->io_queues[HCTX_TYPE_POLL]; in nvme_rdma_map_queues()
1852 ctrl->io_queues[HCTX_TYPE_DEFAULT] + in nvme_rdma_map_queues()
1853 ctrl->io_queues[HCTX_TYPE_READ]; in nvme_rdma_map_queues()
1857 dev_info(ctrl->ctrl.device, in nvme_rdma_map_queues()
1859 ctrl->io_queues[HCTX_TYPE_DEFAULT], in nvme_rdma_map_queues()
1860 ctrl->io_queues[HCTX_TYPE_READ], in nvme_rdma_map_queues()
1861 ctrl->io_queues[HCTX_TYPE_POLL]); in nvme_rdma_map_queues()
1886 static void nvme_rdma_shutdown_ctrl(struct nvme_rdma_ctrl *ctrl, bool shutdown) in nvme_rdma_shutdown_ctrl() argument
1888 cancel_work_sync(&ctrl->err_work); in nvme_rdma_shutdown_ctrl()
1889 cancel_delayed_work_sync(&ctrl->reconnect_work); in nvme_rdma_shutdown_ctrl()
1891 nvme_rdma_teardown_io_queues(ctrl, shutdown); in nvme_rdma_shutdown_ctrl()
1892 blk_mq_quiesce_queue(ctrl->ctrl.admin_q); in nvme_rdma_shutdown_ctrl()
1894 nvme_shutdown_ctrl(&ctrl->ctrl); in nvme_rdma_shutdown_ctrl()
1896 nvme_disable_ctrl(&ctrl->ctrl); in nvme_rdma_shutdown_ctrl()
1897 nvme_rdma_teardown_admin_queue(ctrl, shutdown); in nvme_rdma_shutdown_ctrl()
1900 static void nvme_rdma_delete_ctrl(struct nvme_ctrl *ctrl) in nvme_rdma_delete_ctrl() argument
1902 nvme_rdma_shutdown_ctrl(to_rdma_ctrl(ctrl), true); in nvme_rdma_delete_ctrl()
1907 struct nvme_rdma_ctrl *ctrl = in nvme_rdma_reset_ctrl_work() local
1908 container_of(work, struct nvme_rdma_ctrl, ctrl.reset_work); in nvme_rdma_reset_ctrl_work()
1910 nvme_stop_ctrl(&ctrl->ctrl); in nvme_rdma_reset_ctrl_work()
1911 nvme_rdma_shutdown_ctrl(ctrl, false); in nvme_rdma_reset_ctrl_work()
1913 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) { in nvme_rdma_reset_ctrl_work()
1919 if (nvme_rdma_setup_ctrl(ctrl, false)) in nvme_rdma_reset_ctrl_work()
1925 ++ctrl->ctrl.nr_reconnects; in nvme_rdma_reset_ctrl_work()
1926 nvme_rdma_reconnect_or_remove(ctrl); in nvme_rdma_reset_ctrl_work()
1957 struct nvme_rdma_ctrl *ctrl; in nvme_rdma_existing_controller() local
1961 list_for_each_entry(ctrl, &nvme_rdma_ctrl_list, list) { in nvme_rdma_existing_controller()
1962 found = nvmf_ip_options_match(&ctrl->ctrl, opts); in nvme_rdma_existing_controller()
1974 struct nvme_rdma_ctrl *ctrl; in nvme_rdma_create_ctrl() local
1978 ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); in nvme_rdma_create_ctrl()
1979 if (!ctrl) in nvme_rdma_create_ctrl()
1981 ctrl->ctrl.opts = opts; in nvme_rdma_create_ctrl()
1982 INIT_LIST_HEAD(&ctrl->list); in nvme_rdma_create_ctrl()
1995 opts->traddr, opts->trsvcid, &ctrl->addr); in nvme_rdma_create_ctrl()
2004 opts->host_traddr, NULL, &ctrl->src_addr); in nvme_rdma_create_ctrl()
2017 INIT_DELAYED_WORK(&ctrl->reconnect_work, in nvme_rdma_create_ctrl()
2019 INIT_WORK(&ctrl->err_work, nvme_rdma_error_recovery_work); in nvme_rdma_create_ctrl()
2020 INIT_WORK(&ctrl->ctrl.reset_work, nvme_rdma_reset_ctrl_work); in nvme_rdma_create_ctrl()
2022 ctrl->ctrl.queue_count = opts->nr_io_queues + opts->nr_write_queues + in nvme_rdma_create_ctrl()
2024 ctrl->ctrl.sqsize = opts->queue_size - 1; in nvme_rdma_create_ctrl()
2025 ctrl->ctrl.kato = opts->kato; in nvme_rdma_create_ctrl()
2028 ctrl->queues = kcalloc(ctrl->ctrl.queue_count, sizeof(*ctrl->queues), in nvme_rdma_create_ctrl()
2030 if (!ctrl->queues) in nvme_rdma_create_ctrl()
2033 ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_rdma_ctrl_ops, in nvme_rdma_create_ctrl()
2038 changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING); in nvme_rdma_create_ctrl()
2041 ret = nvme_rdma_setup_ctrl(ctrl, true); in nvme_rdma_create_ctrl()
2045 dev_info(ctrl->ctrl.device, "new ctrl: NQN \"%s\", addr %pISpcs\n", in nvme_rdma_create_ctrl()
2046 ctrl->ctrl.opts->subsysnqn, &ctrl->addr); in nvme_rdma_create_ctrl()
2048 nvme_get_ctrl(&ctrl->ctrl); in nvme_rdma_create_ctrl()
2051 list_add_tail(&ctrl->list, &nvme_rdma_ctrl_list); in nvme_rdma_create_ctrl()
2054 return &ctrl->ctrl; in nvme_rdma_create_ctrl()
2057 nvme_uninit_ctrl(&ctrl->ctrl); in nvme_rdma_create_ctrl()
2058 nvme_put_ctrl(&ctrl->ctrl); in nvme_rdma_create_ctrl()
2063 kfree(ctrl->queues); in nvme_rdma_create_ctrl()
2065 kfree(ctrl); in nvme_rdma_create_ctrl()
2082 struct nvme_rdma_ctrl *ctrl; in nvme_rdma_remove_one() local
2100 list_for_each_entry(ctrl, &nvme_rdma_ctrl_list, list) { in nvme_rdma_remove_one()
2101 if (ctrl->device->dev != ib_device) in nvme_rdma_remove_one()
2103 nvme_delete_ctrl(&ctrl->ctrl); in nvme_rdma_remove_one()
2136 struct nvme_rdma_ctrl *ctrl; in nvme_rdma_cleanup_module() local
2142 list_for_each_entry(ctrl, &nvme_rdma_ctrl_list, list) in nvme_rdma_cleanup_module()
2143 nvme_delete_ctrl(&ctrl->ctrl); in nvme_rdma_cleanup_module()