Lines Matching full:ctrl

89 	struct nvme_rdma_ctrl	*ctrl;  member
124 struct nvme_ctrl ctrl; member
129 static inline struct nvme_rdma_ctrl *to_rdma_ctrl(struct nvme_ctrl *ctrl) in to_rdma_ctrl() argument
131 return container_of(ctrl, struct nvme_rdma_ctrl, ctrl); in to_rdma_ctrl()
160 return queue - queue->ctrl->queues; in nvme_rdma_queue_idx()
166 queue->ctrl->io_queues[HCTX_TYPE_DEFAULT] + in nvme_rdma_poll_queue()
167 queue->ctrl->io_queues[HCTX_TYPE_READ]; in nvme_rdma_poll_queue()
299 struct nvme_rdma_ctrl *ctrl = set->driver_data; in nvme_rdma_init_request() local
301 int queue_idx = (set == &ctrl->tag_set) ? hctx_idx + 1 : 0; in nvme_rdma_init_request()
302 struct nvme_rdma_queue *queue = &ctrl->queues[queue_idx]; in nvme_rdma_init_request()
304 nvme_req(rq)->ctrl = &ctrl->ctrl; in nvme_rdma_init_request()
323 struct nvme_rdma_ctrl *ctrl = data; in nvme_rdma_init_hctx() local
324 struct nvme_rdma_queue *queue = &ctrl->queues[hctx_idx + 1]; in nvme_rdma_init_hctx()
326 BUG_ON(hctx_idx >= ctrl->ctrl.queue_count); in nvme_rdma_init_hctx()
335 struct nvme_rdma_ctrl *ctrl = data; in nvme_rdma_init_admin_hctx() local
336 struct nvme_rdma_queue *queue = &ctrl->queues[0]; in nvme_rdma_init_admin_hctx()
538 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_create_queue_ib()
549 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_create_queue_ib()
574 static int nvme_rdma_alloc_queue(struct nvme_rdma_ctrl *ctrl, in nvme_rdma_alloc_queue() argument
581 queue = &ctrl->queues[idx]; in nvme_rdma_alloc_queue()
582 queue->ctrl = ctrl; in nvme_rdma_alloc_queue()
583 if (idx && ctrl->ctrl.max_integrity_segments) in nvme_rdma_alloc_queue()
590 queue->cmnd_capsule_len = ctrl->ctrl.ioccsz * 16; in nvme_rdma_alloc_queue()
599 dev_info(ctrl->ctrl.device, in nvme_rdma_alloc_queue()
604 if (ctrl->ctrl.opts->mask & NVMF_OPT_HOST_TRADDR) in nvme_rdma_alloc_queue()
605 src_addr = (struct sockaddr *)&ctrl->src_addr; in nvme_rdma_alloc_queue()
609 (struct sockaddr *)&ctrl->addr, in nvme_rdma_alloc_queue()
612 dev_info(ctrl->ctrl.device, in nvme_rdma_alloc_queue()
619 dev_info(ctrl->ctrl.device, in nvme_rdma_alloc_queue()
656 static void nvme_rdma_free_io_queues(struct nvme_rdma_ctrl *ctrl) in nvme_rdma_free_io_queues() argument
660 for (i = 1; i < ctrl->ctrl.queue_count; i++) in nvme_rdma_free_io_queues()
661 nvme_rdma_free_queue(&ctrl->queues[i]); in nvme_rdma_free_io_queues()
664 static void nvme_rdma_stop_io_queues(struct nvme_rdma_ctrl *ctrl) in nvme_rdma_stop_io_queues() argument
668 for (i = 1; i < ctrl->ctrl.queue_count; i++) in nvme_rdma_stop_io_queues()
669 nvme_rdma_stop_queue(&ctrl->queues[i]); in nvme_rdma_stop_io_queues()
672 static int nvme_rdma_start_queue(struct nvme_rdma_ctrl *ctrl, int idx) in nvme_rdma_start_queue() argument
674 struct nvme_rdma_queue *queue = &ctrl->queues[idx]; in nvme_rdma_start_queue()
679 ret = nvmf_connect_io_queue(&ctrl->ctrl, idx, poll); in nvme_rdma_start_queue()
681 ret = nvmf_connect_admin_queue(&ctrl->ctrl); in nvme_rdma_start_queue()
688 dev_info(ctrl->ctrl.device, in nvme_rdma_start_queue()
694 static int nvme_rdma_start_io_queues(struct nvme_rdma_ctrl *ctrl) in nvme_rdma_start_io_queues() argument
698 for (i = 1; i < ctrl->ctrl.queue_count; i++) { in nvme_rdma_start_io_queues()
699 ret = nvme_rdma_start_queue(ctrl, i); in nvme_rdma_start_io_queues()
708 nvme_rdma_stop_queue(&ctrl->queues[i]); in nvme_rdma_start_io_queues()
712 static int nvme_rdma_alloc_io_queues(struct nvme_rdma_ctrl *ctrl) in nvme_rdma_alloc_io_queues() argument
714 struct nvmf_ctrl_options *opts = ctrl->ctrl.opts; in nvme_rdma_alloc_io_queues()
715 struct ib_device *ibdev = ctrl->device->dev; in nvme_rdma_alloc_io_queues()
727 ret = nvme_set_queue_count(&ctrl->ctrl, &nr_io_queues); in nvme_rdma_alloc_io_queues()
731 ctrl->ctrl.queue_count = nr_io_queues + 1; in nvme_rdma_alloc_io_queues()
732 if (ctrl->ctrl.queue_count < 2) in nvme_rdma_alloc_io_queues()
735 dev_info(ctrl->ctrl.device, in nvme_rdma_alloc_io_queues()
744 ctrl->io_queues[HCTX_TYPE_READ] = nr_read_queues; in nvme_rdma_alloc_io_queues()
745 nr_io_queues -= ctrl->io_queues[HCTX_TYPE_READ]; in nvme_rdma_alloc_io_queues()
746 ctrl->io_queues[HCTX_TYPE_DEFAULT] = in nvme_rdma_alloc_io_queues()
748 nr_io_queues -= ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_rdma_alloc_io_queues()
755 ctrl->io_queues[HCTX_TYPE_DEFAULT] = in nvme_rdma_alloc_io_queues()
757 nr_io_queues -= ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_rdma_alloc_io_queues()
762 ctrl->io_queues[HCTX_TYPE_POLL] = in nvme_rdma_alloc_io_queues()
766 for (i = 1; i < ctrl->ctrl.queue_count; i++) { in nvme_rdma_alloc_io_queues()
767 ret = nvme_rdma_alloc_queue(ctrl, i, in nvme_rdma_alloc_io_queues()
768 ctrl->ctrl.sqsize + 1); in nvme_rdma_alloc_io_queues()
777 nvme_rdma_free_queue(&ctrl->queues[i]); in nvme_rdma_alloc_io_queues()
785 struct nvme_rdma_ctrl *ctrl = to_rdma_ctrl(nctrl); in nvme_rdma_alloc_tagset() local
790 set = &ctrl->admin_tag_set; in nvme_rdma_alloc_tagset()
798 set->driver_data = ctrl; in nvme_rdma_alloc_tagset()
803 set = &ctrl->tag_set; in nvme_rdma_alloc_tagset()
815 set->driver_data = ctrl; in nvme_rdma_alloc_tagset()
828 static void nvme_rdma_destroy_admin_queue(struct nvme_rdma_ctrl *ctrl, in nvme_rdma_destroy_admin_queue() argument
832 blk_cleanup_queue(ctrl->ctrl.admin_q); in nvme_rdma_destroy_admin_queue()
833 blk_cleanup_queue(ctrl->ctrl.fabrics_q); in nvme_rdma_destroy_admin_queue()
834 blk_mq_free_tag_set(ctrl->ctrl.admin_tagset); in nvme_rdma_destroy_admin_queue()
836 if (ctrl->async_event_sqe.data) { in nvme_rdma_destroy_admin_queue()
837 cancel_work_sync(&ctrl->ctrl.async_event_work); in nvme_rdma_destroy_admin_queue()
838 nvme_rdma_free_qe(ctrl->device->dev, &ctrl->async_event_sqe, in nvme_rdma_destroy_admin_queue()
840 ctrl->async_event_sqe.data = NULL; in nvme_rdma_destroy_admin_queue()
842 nvme_rdma_free_queue(&ctrl->queues[0]); in nvme_rdma_destroy_admin_queue()
845 static int nvme_rdma_configure_admin_queue(struct nvme_rdma_ctrl *ctrl, in nvme_rdma_configure_admin_queue() argument
851 error = nvme_rdma_alloc_queue(ctrl, 0, NVME_AQ_DEPTH); in nvme_rdma_configure_admin_queue()
855 ctrl->device = ctrl->queues[0].device; in nvme_rdma_configure_admin_queue()
856 ctrl->ctrl.numa_node = dev_to_node(ctrl->device->dev->dma_device); in nvme_rdma_configure_admin_queue()
859 if (ctrl->device->dev->attrs.device_cap_flags & in nvme_rdma_configure_admin_queue()
863 ctrl->max_fr_pages = nvme_rdma_get_max_fr_pages(ctrl->device->dev, in nvme_rdma_configure_admin_queue()
871 error = nvme_rdma_alloc_qe(ctrl->device->dev, &ctrl->async_event_sqe, in nvme_rdma_configure_admin_queue()
877 ctrl->ctrl.admin_tagset = nvme_rdma_alloc_tagset(&ctrl->ctrl, true); in nvme_rdma_configure_admin_queue()
878 if (IS_ERR(ctrl->ctrl.admin_tagset)) { in nvme_rdma_configure_admin_queue()
879 error = PTR_ERR(ctrl->ctrl.admin_tagset); in nvme_rdma_configure_admin_queue()
883 ctrl->ctrl.fabrics_q = blk_mq_init_queue(&ctrl->admin_tag_set); in nvme_rdma_configure_admin_queue()
884 if (IS_ERR(ctrl->ctrl.fabrics_q)) { in nvme_rdma_configure_admin_queue()
885 error = PTR_ERR(ctrl->ctrl.fabrics_q); in nvme_rdma_configure_admin_queue()
889 ctrl->ctrl.admin_q = blk_mq_init_queue(&ctrl->admin_tag_set); in nvme_rdma_configure_admin_queue()
890 if (IS_ERR(ctrl->ctrl.admin_q)) { in nvme_rdma_configure_admin_queue()
891 error = PTR_ERR(ctrl->ctrl.admin_q); in nvme_rdma_configure_admin_queue()
896 error = nvme_rdma_start_queue(ctrl, 0); in nvme_rdma_configure_admin_queue()
900 error = nvme_enable_ctrl(&ctrl->ctrl); in nvme_rdma_configure_admin_queue()
904 ctrl->ctrl.max_segments = ctrl->max_fr_pages; in nvme_rdma_configure_admin_queue()
905 ctrl->ctrl.max_hw_sectors = ctrl->max_fr_pages << (ilog2(SZ_4K) - 9); in nvme_rdma_configure_admin_queue()
907 ctrl->ctrl.max_integrity_segments = ctrl->max_fr_pages; in nvme_rdma_configure_admin_queue()
909 ctrl->ctrl.max_integrity_segments = 0; in nvme_rdma_configure_admin_queue()
911 blk_mq_unquiesce_queue(ctrl->ctrl.admin_q); in nvme_rdma_configure_admin_queue()
913 error = nvme_init_identify(&ctrl->ctrl); in nvme_rdma_configure_admin_queue()
920 nvme_rdma_stop_queue(&ctrl->queues[0]); in nvme_rdma_configure_admin_queue()
923 blk_cleanup_queue(ctrl->ctrl.admin_q); in nvme_rdma_configure_admin_queue()
926 blk_cleanup_queue(ctrl->ctrl.fabrics_q); in nvme_rdma_configure_admin_queue()
929 blk_mq_free_tag_set(ctrl->ctrl.admin_tagset); in nvme_rdma_configure_admin_queue()
931 if (ctrl->async_event_sqe.data) { in nvme_rdma_configure_admin_queue()
932 nvme_rdma_free_qe(ctrl->device->dev, &ctrl->async_event_sqe, in nvme_rdma_configure_admin_queue()
934 ctrl->async_event_sqe.data = NULL; in nvme_rdma_configure_admin_queue()
937 nvme_rdma_free_queue(&ctrl->queues[0]); in nvme_rdma_configure_admin_queue()
941 static void nvme_rdma_destroy_io_queues(struct nvme_rdma_ctrl *ctrl, in nvme_rdma_destroy_io_queues() argument
945 blk_cleanup_queue(ctrl->ctrl.connect_q); in nvme_rdma_destroy_io_queues()
946 blk_mq_free_tag_set(ctrl->ctrl.tagset); in nvme_rdma_destroy_io_queues()
948 nvme_rdma_free_io_queues(ctrl); in nvme_rdma_destroy_io_queues()
951 static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new) in nvme_rdma_configure_io_queues() argument
955 ret = nvme_rdma_alloc_io_queues(ctrl); in nvme_rdma_configure_io_queues()
960 ctrl->ctrl.tagset = nvme_rdma_alloc_tagset(&ctrl->ctrl, false); in nvme_rdma_configure_io_queues()
961 if (IS_ERR(ctrl->ctrl.tagset)) { in nvme_rdma_configure_io_queues()
962 ret = PTR_ERR(ctrl->ctrl.tagset); in nvme_rdma_configure_io_queues()
966 ctrl->ctrl.connect_q = blk_mq_init_queue(&ctrl->tag_set); in nvme_rdma_configure_io_queues()
967 if (IS_ERR(ctrl->ctrl.connect_q)) { in nvme_rdma_configure_io_queues()
968 ret = PTR_ERR(ctrl->ctrl.connect_q); in nvme_rdma_configure_io_queues()
973 ret = nvme_rdma_start_io_queues(ctrl); in nvme_rdma_configure_io_queues()
978 nvme_start_queues(&ctrl->ctrl); in nvme_rdma_configure_io_queues()
979 if (!nvme_wait_freeze_timeout(&ctrl->ctrl, NVME_IO_TIMEOUT)) { in nvme_rdma_configure_io_queues()
988 blk_mq_update_nr_hw_queues(ctrl->ctrl.tagset, in nvme_rdma_configure_io_queues()
989 ctrl->ctrl.queue_count - 1); in nvme_rdma_configure_io_queues()
990 nvme_unfreeze(&ctrl->ctrl); in nvme_rdma_configure_io_queues()
996 nvme_stop_queues(&ctrl->ctrl); in nvme_rdma_configure_io_queues()
997 nvme_rdma_stop_io_queues(ctrl); in nvme_rdma_configure_io_queues()
1000 blk_cleanup_queue(ctrl->ctrl.connect_q); in nvme_rdma_configure_io_queues()
1003 blk_mq_free_tag_set(ctrl->ctrl.tagset); in nvme_rdma_configure_io_queues()
1005 nvme_rdma_free_io_queues(ctrl); in nvme_rdma_configure_io_queues()
1009 static void nvme_rdma_teardown_admin_queue(struct nvme_rdma_ctrl *ctrl, in nvme_rdma_teardown_admin_queue() argument
1012 blk_mq_quiesce_queue(ctrl->ctrl.admin_q); in nvme_rdma_teardown_admin_queue()
1013 blk_sync_queue(ctrl->ctrl.admin_q); in nvme_rdma_teardown_admin_queue()
1014 nvme_rdma_stop_queue(&ctrl->queues[0]); in nvme_rdma_teardown_admin_queue()
1015 if (ctrl->ctrl.admin_tagset) { in nvme_rdma_teardown_admin_queue()
1016 blk_mq_tagset_busy_iter(ctrl->ctrl.admin_tagset, in nvme_rdma_teardown_admin_queue()
1017 nvme_cancel_request, &ctrl->ctrl); in nvme_rdma_teardown_admin_queue()
1018 blk_mq_tagset_wait_completed_request(ctrl->ctrl.admin_tagset); in nvme_rdma_teardown_admin_queue()
1021 blk_mq_unquiesce_queue(ctrl->ctrl.admin_q); in nvme_rdma_teardown_admin_queue()
1022 nvme_rdma_destroy_admin_queue(ctrl, remove); in nvme_rdma_teardown_admin_queue()
1025 static void nvme_rdma_teardown_io_queues(struct nvme_rdma_ctrl *ctrl, in nvme_rdma_teardown_io_queues() argument
1028 if (ctrl->ctrl.queue_count > 1) { in nvme_rdma_teardown_io_queues()
1029 nvme_start_freeze(&ctrl->ctrl); in nvme_rdma_teardown_io_queues()
1030 nvme_stop_queues(&ctrl->ctrl); in nvme_rdma_teardown_io_queues()
1031 nvme_sync_io_queues(&ctrl->ctrl); in nvme_rdma_teardown_io_queues()
1032 nvme_rdma_stop_io_queues(ctrl); in nvme_rdma_teardown_io_queues()
1033 if (ctrl->ctrl.tagset) { in nvme_rdma_teardown_io_queues()
1034 blk_mq_tagset_busy_iter(ctrl->ctrl.tagset, in nvme_rdma_teardown_io_queues()
1035 nvme_cancel_request, &ctrl->ctrl); in nvme_rdma_teardown_io_queues()
1036 blk_mq_tagset_wait_completed_request(ctrl->ctrl.tagset); in nvme_rdma_teardown_io_queues()
1039 nvme_start_queues(&ctrl->ctrl); in nvme_rdma_teardown_io_queues()
1040 nvme_rdma_destroy_io_queues(ctrl, remove); in nvme_rdma_teardown_io_queues()
1046 struct nvme_rdma_ctrl *ctrl = to_rdma_ctrl(nctrl); in nvme_rdma_free_ctrl() local
1048 if (list_empty(&ctrl->list)) in nvme_rdma_free_ctrl()
1052 list_del(&ctrl->list); in nvme_rdma_free_ctrl()
1057 kfree(ctrl->queues); in nvme_rdma_free_ctrl()
1058 kfree(ctrl); in nvme_rdma_free_ctrl()
1061 static void nvme_rdma_reconnect_or_remove(struct nvme_rdma_ctrl *ctrl) in nvme_rdma_reconnect_or_remove() argument
1064 if (ctrl->ctrl.state != NVME_CTRL_CONNECTING) { in nvme_rdma_reconnect_or_remove()
1065 WARN_ON_ONCE(ctrl->ctrl.state == NVME_CTRL_NEW || in nvme_rdma_reconnect_or_remove()
1066 ctrl->ctrl.state == NVME_CTRL_LIVE); in nvme_rdma_reconnect_or_remove()
1070 if (nvmf_should_reconnect(&ctrl->ctrl)) { in nvme_rdma_reconnect_or_remove()
1071 dev_info(ctrl->ctrl.device, "Reconnecting in %d seconds...\n", in nvme_rdma_reconnect_or_remove()
1072 ctrl->ctrl.opts->reconnect_delay); in nvme_rdma_reconnect_or_remove()
1073 queue_delayed_work(nvme_wq, &ctrl->reconnect_work, in nvme_rdma_reconnect_or_remove()
1074 ctrl->ctrl.opts->reconnect_delay * HZ); in nvme_rdma_reconnect_or_remove()
1076 nvme_delete_ctrl(&ctrl->ctrl); in nvme_rdma_reconnect_or_remove()
1080 static int nvme_rdma_setup_ctrl(struct nvme_rdma_ctrl *ctrl, bool new) in nvme_rdma_setup_ctrl() argument
1085 ret = nvme_rdma_configure_admin_queue(ctrl, new); in nvme_rdma_setup_ctrl()
1089 if (ctrl->ctrl.icdoff) { in nvme_rdma_setup_ctrl()
1090 dev_err(ctrl->ctrl.device, "icdoff is not supported!\n"); in nvme_rdma_setup_ctrl()
1094 if (!(ctrl->ctrl.sgls & (1 << 2))) { in nvme_rdma_setup_ctrl()
1095 dev_err(ctrl->ctrl.device, in nvme_rdma_setup_ctrl()
1100 if (ctrl->ctrl.opts->queue_size > ctrl->ctrl.sqsize + 1) { in nvme_rdma_setup_ctrl()
1101 dev_warn(ctrl->ctrl.device, in nvme_rdma_setup_ctrl()
1102 "queue_size %zu > ctrl sqsize %u, clamping down\n", in nvme_rdma_setup_ctrl()
1103 ctrl->ctrl.opts->queue_size, ctrl->ctrl.sqsize + 1); in nvme_rdma_setup_ctrl()
1106 if (ctrl->ctrl.sqsize + 1 > ctrl->ctrl.maxcmd) { in nvme_rdma_setup_ctrl()
1107 dev_warn(ctrl->ctrl.device, in nvme_rdma_setup_ctrl()
1108 "sqsize %u > ctrl maxcmd %u, clamping down\n", in nvme_rdma_setup_ctrl()
1109 ctrl->ctrl.sqsize + 1, ctrl->ctrl.maxcmd); in nvme_rdma_setup_ctrl()
1110 ctrl->ctrl.sqsize = ctrl->ctrl.maxcmd - 1; in nvme_rdma_setup_ctrl()
1113 if (ctrl->ctrl.sgls & (1 << 20)) in nvme_rdma_setup_ctrl()
1114 ctrl->use_inline_data = true; in nvme_rdma_setup_ctrl()
1116 if (ctrl->ctrl.queue_count > 1) { in nvme_rdma_setup_ctrl()
1117 ret = nvme_rdma_configure_io_queues(ctrl, new); in nvme_rdma_setup_ctrl()
1122 changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE); in nvme_rdma_setup_ctrl()
1125 * state change failure is ok if we started ctrl delete, in nvme_rdma_setup_ctrl()
1129 WARN_ON_ONCE(ctrl->ctrl.state != NVME_CTRL_DELETING && in nvme_rdma_setup_ctrl()
1130 ctrl->ctrl.state != NVME_CTRL_DELETING_NOIO); in nvme_rdma_setup_ctrl()
1136 nvme_start_ctrl(&ctrl->ctrl); in nvme_rdma_setup_ctrl()
1140 if (ctrl->ctrl.queue_count > 1) in nvme_rdma_setup_ctrl()
1141 nvme_rdma_destroy_io_queues(ctrl, new); in nvme_rdma_setup_ctrl()
1143 nvme_rdma_stop_queue(&ctrl->queues[0]); in nvme_rdma_setup_ctrl()
1144 nvme_rdma_destroy_admin_queue(ctrl, new); in nvme_rdma_setup_ctrl()
1150 struct nvme_rdma_ctrl *ctrl = container_of(to_delayed_work(work), in nvme_rdma_reconnect_ctrl_work() local
1153 ++ctrl->ctrl.nr_reconnects; in nvme_rdma_reconnect_ctrl_work()
1155 if (nvme_rdma_setup_ctrl(ctrl, false)) in nvme_rdma_reconnect_ctrl_work()
1158 dev_info(ctrl->ctrl.device, "Successfully reconnected (%d attempts)\n", in nvme_rdma_reconnect_ctrl_work()
1159 ctrl->ctrl.nr_reconnects); in nvme_rdma_reconnect_ctrl_work()
1161 ctrl->ctrl.nr_reconnects = 0; in nvme_rdma_reconnect_ctrl_work()
1166 dev_info(ctrl->ctrl.device, "Failed reconnect attempt %d\n", in nvme_rdma_reconnect_ctrl_work()
1167 ctrl->ctrl.nr_reconnects); in nvme_rdma_reconnect_ctrl_work()
1168 nvme_rdma_reconnect_or_remove(ctrl); in nvme_rdma_reconnect_ctrl_work()
1173 struct nvme_rdma_ctrl *ctrl = container_of(work, in nvme_rdma_error_recovery_work() local
1176 nvme_stop_keep_alive(&ctrl->ctrl); in nvme_rdma_error_recovery_work()
1177 nvme_rdma_teardown_io_queues(ctrl, false); in nvme_rdma_error_recovery_work()
1178 nvme_start_queues(&ctrl->ctrl); in nvme_rdma_error_recovery_work()
1179 nvme_rdma_teardown_admin_queue(ctrl, false); in nvme_rdma_error_recovery_work()
1180 blk_mq_unquiesce_queue(ctrl->ctrl.admin_q); in nvme_rdma_error_recovery_work()
1182 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) { in nvme_rdma_error_recovery_work()
1183 /* state change failure is ok if we started ctrl delete */ in nvme_rdma_error_recovery_work()
1184 WARN_ON_ONCE(ctrl->ctrl.state != NVME_CTRL_DELETING && in nvme_rdma_error_recovery_work()
1185 ctrl->ctrl.state != NVME_CTRL_DELETING_NOIO); in nvme_rdma_error_recovery_work()
1189 nvme_rdma_reconnect_or_remove(ctrl); in nvme_rdma_error_recovery_work()
1192 static void nvme_rdma_error_recovery(struct nvme_rdma_ctrl *ctrl) in nvme_rdma_error_recovery() argument
1194 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RESETTING)) in nvme_rdma_error_recovery()
1197 dev_warn(ctrl->ctrl.device, "starting error recovery\n"); in nvme_rdma_error_recovery()
1198 queue_work(nvme_reset_wq, &ctrl->err_work); in nvme_rdma_error_recovery()
1215 struct nvme_rdma_ctrl *ctrl = queue->ctrl; in nvme_rdma_wr_error() local
1217 if (ctrl->ctrl.state == NVME_CTRL_LIVE) in nvme_rdma_wr_error()
1218 dev_info(ctrl->ctrl.device, in nvme_rdma_wr_error()
1222 nvme_rdma_error_recovery(ctrl); in nvme_rdma_wr_error()
1318 sg->addr = cpu_to_le64(queue->ctrl->ctrl.icdoff); in nvme_rdma_map_sg_inline()
1350 * Align the MR to a 4K page size to match the ctrl page size and in nvme_rdma_map_sg_fr()
1562 queue->ctrl->use_inline_data && in nvme_rdma_map_data()
1636 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_post_send()
1662 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_post_recv()
1673 return queue->ctrl->admin_tag_set.tags[queue_idx]; in nvme_rdma_tagset()
1674 return queue->ctrl->tag_set.tags[queue_idx - 1]; in nvme_rdma_tagset()
1685 struct nvme_rdma_ctrl *ctrl = to_rdma_ctrl(arg); in nvme_rdma_submit_async_event() local
1686 struct nvme_rdma_queue *queue = &ctrl->queues[0]; in nvme_rdma_submit_async_event()
1688 struct nvme_rdma_qe *sqe = &ctrl->async_event_sqe; in nvme_rdma_submit_async_event()
1718 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_process_nvme_rsp()
1721 nvme_rdma_error_recovery(queue->ctrl); in nvme_rdma_process_nvme_rsp()
1732 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_process_nvme_rsp()
1735 nvme_rdma_error_recovery(queue->ctrl); in nvme_rdma_process_nvme_rsp()
1742 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_process_nvme_rsp()
1745 nvme_rdma_error_recovery(queue->ctrl); in nvme_rdma_process_nvme_rsp()
1770 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_recv_done()
1772 nvme_rdma_error_recovery(queue->ctrl); in nvme_rdma_recv_done()
1785 nvme_complete_async_event(&queue->ctrl->ctrl, cqe->status, in nvme_rdma_recv_done()
1826 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_conn_rejected()
1830 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_conn_rejected()
1839 struct nvme_ctrl *ctrl = &queue->ctrl->ctrl; in nvme_rdma_addr_resolved() local
1846 if (ctrl->opts->tos >= 0) in nvme_rdma_addr_resolved()
1847 rdma_set_service_type(queue->cm_id, ctrl->opts->tos); in nvme_rdma_addr_resolved()
1850 dev_err(ctrl->device, "rdma_resolve_route failed (%d).\n", in nvme_rdma_addr_resolved()
1864 struct nvme_rdma_ctrl *ctrl = queue->ctrl; in nvme_rdma_route_resolved() local
1895 priv.hsqsize = cpu_to_le16(queue->ctrl->ctrl.sqsize); in nvme_rdma_route_resolved()
1900 dev_err(ctrl->ctrl.device, in nvme_rdma_route_resolved()
1918 dev_dbg(queue->ctrl->ctrl.device, "%s (%d): status %d id %p\n", in nvme_rdma_cm_handler()
1943 dev_dbg(queue->ctrl->ctrl.device, in nvme_rdma_cm_handler()
1950 dev_dbg(queue->ctrl->ctrl.device, in nvme_rdma_cm_handler()
1952 nvme_rdma_error_recovery(queue->ctrl); in nvme_rdma_cm_handler()
1958 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_cm_handler()
1960 nvme_rdma_error_recovery(queue->ctrl); in nvme_rdma_cm_handler()
1989 struct nvme_rdma_ctrl *ctrl = queue->ctrl; in nvme_rdma_timeout() local
1991 dev_warn(ctrl->ctrl.device, "I/O %d QID %d timeout\n", in nvme_rdma_timeout()
1994 if (ctrl->ctrl.state != NVME_CTRL_LIVE) { in nvme_rdma_timeout()
1999 * - ctrl disable/shutdown fabrics requests in nvme_rdma_timeout()
2016 nvme_rdma_error_recovery(ctrl); in nvme_rdma_timeout()
2036 if (!nvmf_check_ready(&queue->ctrl->ctrl, rq, queue_ready)) in nvme_rdma_queue_rq()
2037 return nvmf_fail_nonready_command(&queue->ctrl->ctrl, rq); in nvme_rdma_queue_rq()
2068 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_queue_rq()
2154 struct nvme_rdma_ctrl *ctrl = set->driver_data; in nvme_rdma_map_queues() local
2155 struct nvmf_ctrl_options *opts = ctrl->ctrl.opts; in nvme_rdma_map_queues()
2157 if (opts->nr_write_queues && ctrl->io_queues[HCTX_TYPE_READ]) { in nvme_rdma_map_queues()
2160 ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_rdma_map_queues()
2163 ctrl->io_queues[HCTX_TYPE_READ]; in nvme_rdma_map_queues()
2165 ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_rdma_map_queues()
2169 ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_rdma_map_queues()
2172 ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_rdma_map_queues()
2176 ctrl->device->dev, 0); in nvme_rdma_map_queues()
2178 ctrl->device->dev, 0); in nvme_rdma_map_queues()
2180 if (opts->nr_poll_queues && ctrl->io_queues[HCTX_TYPE_POLL]) { in nvme_rdma_map_queues()
2183 ctrl->io_queues[HCTX_TYPE_POLL]; in nvme_rdma_map_queues()
2185 ctrl->io_queues[HCTX_TYPE_DEFAULT] + in nvme_rdma_map_queues()
2186 ctrl->io_queues[HCTX_TYPE_READ]; in nvme_rdma_map_queues()
2190 dev_info(ctrl->ctrl.device, in nvme_rdma_map_queues()
2192 ctrl->io_queues[HCTX_TYPE_DEFAULT], in nvme_rdma_map_queues()
2193 ctrl->io_queues[HCTX_TYPE_READ], in nvme_rdma_map_queues()
2194 ctrl->io_queues[HCTX_TYPE_POLL]); in nvme_rdma_map_queues()
2219 static void nvme_rdma_shutdown_ctrl(struct nvme_rdma_ctrl *ctrl, bool shutdown) in nvme_rdma_shutdown_ctrl() argument
2221 cancel_work_sync(&ctrl->err_work); in nvme_rdma_shutdown_ctrl()
2222 cancel_delayed_work_sync(&ctrl->reconnect_work); in nvme_rdma_shutdown_ctrl()
2224 nvme_rdma_teardown_io_queues(ctrl, shutdown); in nvme_rdma_shutdown_ctrl()
2225 blk_mq_quiesce_queue(ctrl->ctrl.admin_q); in nvme_rdma_shutdown_ctrl()
2227 nvme_shutdown_ctrl(&ctrl->ctrl); in nvme_rdma_shutdown_ctrl()
2229 nvme_disable_ctrl(&ctrl->ctrl); in nvme_rdma_shutdown_ctrl()
2230 nvme_rdma_teardown_admin_queue(ctrl, shutdown); in nvme_rdma_shutdown_ctrl()
2233 static void nvme_rdma_delete_ctrl(struct nvme_ctrl *ctrl) in nvme_rdma_delete_ctrl() argument
2235 nvme_rdma_shutdown_ctrl(to_rdma_ctrl(ctrl), true); in nvme_rdma_delete_ctrl()
2240 struct nvme_rdma_ctrl *ctrl = in nvme_rdma_reset_ctrl_work() local
2241 container_of(work, struct nvme_rdma_ctrl, ctrl.reset_work); in nvme_rdma_reset_ctrl_work()
2243 nvme_stop_ctrl(&ctrl->ctrl); in nvme_rdma_reset_ctrl_work()
2244 nvme_rdma_shutdown_ctrl(ctrl, false); in nvme_rdma_reset_ctrl_work()
2246 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) { in nvme_rdma_reset_ctrl_work()
2252 if (nvme_rdma_setup_ctrl(ctrl, false)) in nvme_rdma_reset_ctrl_work()
2258 ++ctrl->ctrl.nr_reconnects; in nvme_rdma_reset_ctrl_work()
2259 nvme_rdma_reconnect_or_remove(ctrl); in nvme_rdma_reset_ctrl_work()
2290 struct nvme_rdma_ctrl *ctrl; in nvme_rdma_existing_controller() local
2294 list_for_each_entry(ctrl, &nvme_rdma_ctrl_list, list) { in nvme_rdma_existing_controller()
2295 found = nvmf_ip_options_match(&ctrl->ctrl, opts); in nvme_rdma_existing_controller()
2307 struct nvme_rdma_ctrl *ctrl; in nvme_rdma_create_ctrl() local
2311 ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); in nvme_rdma_create_ctrl()
2312 if (!ctrl) in nvme_rdma_create_ctrl()
2314 ctrl->ctrl.opts = opts; in nvme_rdma_create_ctrl()
2315 INIT_LIST_HEAD(&ctrl->list); in nvme_rdma_create_ctrl()
2328 opts->traddr, opts->trsvcid, &ctrl->addr); in nvme_rdma_create_ctrl()
2337 opts->host_traddr, NULL, &ctrl->src_addr); in nvme_rdma_create_ctrl()
2350 INIT_DELAYED_WORK(&ctrl->reconnect_work, in nvme_rdma_create_ctrl()
2352 INIT_WORK(&ctrl->err_work, nvme_rdma_error_recovery_work); in nvme_rdma_create_ctrl()
2353 INIT_WORK(&ctrl->ctrl.reset_work, nvme_rdma_reset_ctrl_work); in nvme_rdma_create_ctrl()
2355 ctrl->ctrl.queue_count = opts->nr_io_queues + opts->nr_write_queues + in nvme_rdma_create_ctrl()
2357 ctrl->ctrl.sqsize = opts->queue_size - 1; in nvme_rdma_create_ctrl()
2358 ctrl->ctrl.kato = opts->kato; in nvme_rdma_create_ctrl()
2361 ctrl->queues = kcalloc(ctrl->ctrl.queue_count, sizeof(*ctrl->queues), in nvme_rdma_create_ctrl()
2363 if (!ctrl->queues) in nvme_rdma_create_ctrl()
2366 ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_rdma_ctrl_ops, in nvme_rdma_create_ctrl()
2371 changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING); in nvme_rdma_create_ctrl()
2374 ret = nvme_rdma_setup_ctrl(ctrl, true); in nvme_rdma_create_ctrl()
2378 dev_info(ctrl->ctrl.device, "new ctrl: NQN \"%s\", addr %pISpcs\n", in nvme_rdma_create_ctrl()
2379 ctrl->ctrl.opts->subsysnqn, &ctrl->addr); in nvme_rdma_create_ctrl()
2382 list_add_tail(&ctrl->list, &nvme_rdma_ctrl_list); in nvme_rdma_create_ctrl()
2385 return &ctrl->ctrl; in nvme_rdma_create_ctrl()
2388 nvme_uninit_ctrl(&ctrl->ctrl); in nvme_rdma_create_ctrl()
2389 nvme_put_ctrl(&ctrl->ctrl); in nvme_rdma_create_ctrl()
2394 kfree(ctrl->queues); in nvme_rdma_create_ctrl()
2396 kfree(ctrl); in nvme_rdma_create_ctrl()
2413 struct nvme_rdma_ctrl *ctrl; in nvme_rdma_remove_one() local
2431 list_for_each_entry(ctrl, &nvme_rdma_ctrl_list, list) { in nvme_rdma_remove_one()
2432 if (ctrl->device->dev != ib_device) in nvme_rdma_remove_one()
2434 nvme_delete_ctrl(&ctrl->ctrl); in nvme_rdma_remove_one()
2467 struct nvme_rdma_ctrl *ctrl; in nvme_rdma_cleanup_module() local
2473 list_for_each_entry(ctrl, &nvme_rdma_ctrl_list, list) in nvme_rdma_cleanup_module()
2474 nvme_delete_ctrl(&ctrl->ctrl); in nvme_rdma_cleanup_module()