Lines Matching full:ctrl

89 	struct nvme_rdma_ctrl	*ctrl;  member
125 struct nvme_ctrl ctrl; member
130 static inline struct nvme_rdma_ctrl *to_rdma_ctrl(struct nvme_ctrl *ctrl) in to_rdma_ctrl() argument
132 return container_of(ctrl, struct nvme_rdma_ctrl, ctrl); in to_rdma_ctrl()
161 return queue - queue->ctrl->queues; in nvme_rdma_queue_idx()
167 queue->ctrl->io_queues[HCTX_TYPE_DEFAULT] + in nvme_rdma_poll_queue()
168 queue->ctrl->io_queues[HCTX_TYPE_READ]; in nvme_rdma_poll_queue()
300 struct nvme_rdma_ctrl *ctrl = set->driver_data; in nvme_rdma_init_request() local
302 int queue_idx = (set == &ctrl->tag_set) ? hctx_idx + 1 : 0; in nvme_rdma_init_request()
303 struct nvme_rdma_queue *queue = &ctrl->queues[queue_idx]; in nvme_rdma_init_request()
305 nvme_req(rq)->ctrl = &ctrl->ctrl; in nvme_rdma_init_request()
325 struct nvme_rdma_ctrl *ctrl = data; in nvme_rdma_init_hctx() local
326 struct nvme_rdma_queue *queue = &ctrl->queues[hctx_idx + 1]; in nvme_rdma_init_hctx()
328 BUG_ON(hctx_idx >= ctrl->ctrl.queue_count); in nvme_rdma_init_hctx()
337 struct nvme_rdma_ctrl *ctrl = data; in nvme_rdma_init_admin_hctx() local
338 struct nvme_rdma_queue *queue = &ctrl->queues[0]; in nvme_rdma_init_admin_hctx()
540 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_create_queue_ib()
551 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_create_queue_ib()
576 static int nvme_rdma_alloc_queue(struct nvme_rdma_ctrl *ctrl, in nvme_rdma_alloc_queue() argument
583 queue = &ctrl->queues[idx]; in nvme_rdma_alloc_queue()
585 queue->ctrl = ctrl; in nvme_rdma_alloc_queue()
586 if (idx && ctrl->ctrl.max_integrity_segments) in nvme_rdma_alloc_queue()
593 queue->cmnd_capsule_len = ctrl->ctrl.ioccsz * 16; in nvme_rdma_alloc_queue()
602 dev_info(ctrl->ctrl.device, in nvme_rdma_alloc_queue()
608 if (ctrl->ctrl.opts->mask & NVMF_OPT_HOST_TRADDR) in nvme_rdma_alloc_queue()
609 src_addr = (struct sockaddr *)&ctrl->src_addr; in nvme_rdma_alloc_queue()
613 (struct sockaddr *)&ctrl->addr, in nvme_rdma_alloc_queue()
616 dev_info(ctrl->ctrl.device, in nvme_rdma_alloc_queue()
623 dev_info(ctrl->ctrl.device, in nvme_rdma_alloc_queue()
664 static void nvme_rdma_free_io_queues(struct nvme_rdma_ctrl *ctrl) in nvme_rdma_free_io_queues() argument
668 for (i = 1; i < ctrl->ctrl.queue_count; i++) in nvme_rdma_free_io_queues()
669 nvme_rdma_free_queue(&ctrl->queues[i]); in nvme_rdma_free_io_queues()
672 static void nvme_rdma_stop_io_queues(struct nvme_rdma_ctrl *ctrl) in nvme_rdma_stop_io_queues() argument
676 for (i = 1; i < ctrl->ctrl.queue_count; i++) in nvme_rdma_stop_io_queues()
677 nvme_rdma_stop_queue(&ctrl->queues[i]); in nvme_rdma_stop_io_queues()
680 static int nvme_rdma_start_queue(struct nvme_rdma_ctrl *ctrl, int idx) in nvme_rdma_start_queue() argument
682 struct nvme_rdma_queue *queue = &ctrl->queues[idx]; in nvme_rdma_start_queue()
686 ret = nvmf_connect_io_queue(&ctrl->ctrl, idx); in nvme_rdma_start_queue()
688 ret = nvmf_connect_admin_queue(&ctrl->ctrl); in nvme_rdma_start_queue()
695 dev_info(ctrl->ctrl.device, in nvme_rdma_start_queue()
701 static int nvme_rdma_start_io_queues(struct nvme_rdma_ctrl *ctrl) in nvme_rdma_start_io_queues() argument
705 for (i = 1; i < ctrl->ctrl.queue_count; i++) { in nvme_rdma_start_io_queues()
706 ret = nvme_rdma_start_queue(ctrl, i); in nvme_rdma_start_io_queues()
715 nvme_rdma_stop_queue(&ctrl->queues[i]); in nvme_rdma_start_io_queues()
719 static int nvme_rdma_alloc_io_queues(struct nvme_rdma_ctrl *ctrl) in nvme_rdma_alloc_io_queues() argument
721 struct nvmf_ctrl_options *opts = ctrl->ctrl.opts; in nvme_rdma_alloc_io_queues()
722 struct ib_device *ibdev = ctrl->device->dev; in nvme_rdma_alloc_io_queues()
734 ret = nvme_set_queue_count(&ctrl->ctrl, &nr_io_queues); in nvme_rdma_alloc_io_queues()
739 dev_err(ctrl->ctrl.device, in nvme_rdma_alloc_io_queues()
744 ctrl->ctrl.queue_count = nr_io_queues + 1; in nvme_rdma_alloc_io_queues()
745 dev_info(ctrl->ctrl.device, in nvme_rdma_alloc_io_queues()
754 ctrl->io_queues[HCTX_TYPE_READ] = nr_read_queues; in nvme_rdma_alloc_io_queues()
755 nr_io_queues -= ctrl->io_queues[HCTX_TYPE_READ]; in nvme_rdma_alloc_io_queues()
756 ctrl->io_queues[HCTX_TYPE_DEFAULT] = in nvme_rdma_alloc_io_queues()
758 nr_io_queues -= ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_rdma_alloc_io_queues()
765 ctrl->io_queues[HCTX_TYPE_DEFAULT] = in nvme_rdma_alloc_io_queues()
767 nr_io_queues -= ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_rdma_alloc_io_queues()
772 ctrl->io_queues[HCTX_TYPE_POLL] = in nvme_rdma_alloc_io_queues()
776 for (i = 1; i < ctrl->ctrl.queue_count; i++) { in nvme_rdma_alloc_io_queues()
777 ret = nvme_rdma_alloc_queue(ctrl, i, in nvme_rdma_alloc_io_queues()
778 ctrl->ctrl.sqsize + 1); in nvme_rdma_alloc_io_queues()
787 nvme_rdma_free_queue(&ctrl->queues[i]); in nvme_rdma_alloc_io_queues()
795 struct nvme_rdma_ctrl *ctrl = to_rdma_ctrl(nctrl); in nvme_rdma_alloc_tagset() local
800 set = &ctrl->admin_tag_set; in nvme_rdma_alloc_tagset()
808 set->driver_data = ctrl; in nvme_rdma_alloc_tagset()
813 set = &ctrl->tag_set; in nvme_rdma_alloc_tagset()
825 set->driver_data = ctrl; in nvme_rdma_alloc_tagset()
838 static void nvme_rdma_destroy_admin_queue(struct nvme_rdma_ctrl *ctrl, in nvme_rdma_destroy_admin_queue() argument
842 blk_cleanup_queue(ctrl->ctrl.admin_q); in nvme_rdma_destroy_admin_queue()
843 blk_cleanup_queue(ctrl->ctrl.fabrics_q); in nvme_rdma_destroy_admin_queue()
844 blk_mq_free_tag_set(ctrl->ctrl.admin_tagset); in nvme_rdma_destroy_admin_queue()
846 if (ctrl->async_event_sqe.data) { in nvme_rdma_destroy_admin_queue()
847 cancel_work_sync(&ctrl->ctrl.async_event_work); in nvme_rdma_destroy_admin_queue()
848 nvme_rdma_free_qe(ctrl->device->dev, &ctrl->async_event_sqe, in nvme_rdma_destroy_admin_queue()
850 ctrl->async_event_sqe.data = NULL; in nvme_rdma_destroy_admin_queue()
852 nvme_rdma_free_queue(&ctrl->queues[0]); in nvme_rdma_destroy_admin_queue()
855 static int nvme_rdma_configure_admin_queue(struct nvme_rdma_ctrl *ctrl, in nvme_rdma_configure_admin_queue() argument
861 error = nvme_rdma_alloc_queue(ctrl, 0, NVME_AQ_DEPTH); in nvme_rdma_configure_admin_queue()
865 ctrl->device = ctrl->queues[0].device; in nvme_rdma_configure_admin_queue()
866 ctrl->ctrl.numa_node = ibdev_to_node(ctrl->device->dev); in nvme_rdma_configure_admin_queue()
869 if (ctrl->device->dev->attrs.device_cap_flags & in nvme_rdma_configure_admin_queue()
873 ctrl->max_fr_pages = nvme_rdma_get_max_fr_pages(ctrl->device->dev, in nvme_rdma_configure_admin_queue()
881 error = nvme_rdma_alloc_qe(ctrl->device->dev, &ctrl->async_event_sqe, in nvme_rdma_configure_admin_queue()
887 ctrl->ctrl.admin_tagset = nvme_rdma_alloc_tagset(&ctrl->ctrl, true); in nvme_rdma_configure_admin_queue()
888 if (IS_ERR(ctrl->ctrl.admin_tagset)) { in nvme_rdma_configure_admin_queue()
889 error = PTR_ERR(ctrl->ctrl.admin_tagset); in nvme_rdma_configure_admin_queue()
893 ctrl->ctrl.fabrics_q = blk_mq_init_queue(&ctrl->admin_tag_set); in nvme_rdma_configure_admin_queue()
894 if (IS_ERR(ctrl->ctrl.fabrics_q)) { in nvme_rdma_configure_admin_queue()
895 error = PTR_ERR(ctrl->ctrl.fabrics_q); in nvme_rdma_configure_admin_queue()
899 ctrl->ctrl.admin_q = blk_mq_init_queue(&ctrl->admin_tag_set); in nvme_rdma_configure_admin_queue()
900 if (IS_ERR(ctrl->ctrl.admin_q)) { in nvme_rdma_configure_admin_queue()
901 error = PTR_ERR(ctrl->ctrl.admin_q); in nvme_rdma_configure_admin_queue()
906 error = nvme_rdma_start_queue(ctrl, 0); in nvme_rdma_configure_admin_queue()
910 error = nvme_enable_ctrl(&ctrl->ctrl); in nvme_rdma_configure_admin_queue()
914 ctrl->ctrl.max_segments = ctrl->max_fr_pages; in nvme_rdma_configure_admin_queue()
915 ctrl->ctrl.max_hw_sectors = ctrl->max_fr_pages << (ilog2(SZ_4K) - 9); in nvme_rdma_configure_admin_queue()
917 ctrl->ctrl.max_integrity_segments = ctrl->max_fr_pages; in nvme_rdma_configure_admin_queue()
919 ctrl->ctrl.max_integrity_segments = 0; in nvme_rdma_configure_admin_queue()
921 blk_mq_unquiesce_queue(ctrl->ctrl.admin_q); in nvme_rdma_configure_admin_queue()
923 error = nvme_init_ctrl_finish(&ctrl->ctrl); in nvme_rdma_configure_admin_queue()
930 blk_mq_quiesce_queue(ctrl->ctrl.admin_q); in nvme_rdma_configure_admin_queue()
931 blk_sync_queue(ctrl->ctrl.admin_q); in nvme_rdma_configure_admin_queue()
933 nvme_rdma_stop_queue(&ctrl->queues[0]); in nvme_rdma_configure_admin_queue()
934 nvme_cancel_admin_tagset(&ctrl->ctrl); in nvme_rdma_configure_admin_queue()
937 blk_cleanup_queue(ctrl->ctrl.admin_q); in nvme_rdma_configure_admin_queue()
940 blk_cleanup_queue(ctrl->ctrl.fabrics_q); in nvme_rdma_configure_admin_queue()
943 blk_mq_free_tag_set(ctrl->ctrl.admin_tagset); in nvme_rdma_configure_admin_queue()
945 if (ctrl->async_event_sqe.data) { in nvme_rdma_configure_admin_queue()
946 nvme_rdma_free_qe(ctrl->device->dev, &ctrl->async_event_sqe, in nvme_rdma_configure_admin_queue()
948 ctrl->async_event_sqe.data = NULL; in nvme_rdma_configure_admin_queue()
951 nvme_rdma_free_queue(&ctrl->queues[0]); in nvme_rdma_configure_admin_queue()
955 static void nvme_rdma_destroy_io_queues(struct nvme_rdma_ctrl *ctrl, in nvme_rdma_destroy_io_queues() argument
959 blk_cleanup_queue(ctrl->ctrl.connect_q); in nvme_rdma_destroy_io_queues()
960 blk_mq_free_tag_set(ctrl->ctrl.tagset); in nvme_rdma_destroy_io_queues()
962 nvme_rdma_free_io_queues(ctrl); in nvme_rdma_destroy_io_queues()
965 static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new) in nvme_rdma_configure_io_queues() argument
969 ret = nvme_rdma_alloc_io_queues(ctrl); in nvme_rdma_configure_io_queues()
974 ctrl->ctrl.tagset = nvme_rdma_alloc_tagset(&ctrl->ctrl, false); in nvme_rdma_configure_io_queues()
975 if (IS_ERR(ctrl->ctrl.tagset)) { in nvme_rdma_configure_io_queues()
976 ret = PTR_ERR(ctrl->ctrl.tagset); in nvme_rdma_configure_io_queues()
980 ctrl->ctrl.connect_q = blk_mq_init_queue(&ctrl->tag_set); in nvme_rdma_configure_io_queues()
981 if (IS_ERR(ctrl->ctrl.connect_q)) { in nvme_rdma_configure_io_queues()
982 ret = PTR_ERR(ctrl->ctrl.connect_q); in nvme_rdma_configure_io_queues()
987 ret = nvme_rdma_start_io_queues(ctrl); in nvme_rdma_configure_io_queues()
992 nvme_start_queues(&ctrl->ctrl); in nvme_rdma_configure_io_queues()
993 if (!nvme_wait_freeze_timeout(&ctrl->ctrl, NVME_IO_TIMEOUT)) { in nvme_rdma_configure_io_queues()
1002 blk_mq_update_nr_hw_queues(ctrl->ctrl.tagset, in nvme_rdma_configure_io_queues()
1003 ctrl->ctrl.queue_count - 1); in nvme_rdma_configure_io_queues()
1004 nvme_unfreeze(&ctrl->ctrl); in nvme_rdma_configure_io_queues()
1010 nvme_stop_queues(&ctrl->ctrl); in nvme_rdma_configure_io_queues()
1011 nvme_sync_io_queues(&ctrl->ctrl); in nvme_rdma_configure_io_queues()
1012 nvme_rdma_stop_io_queues(ctrl); in nvme_rdma_configure_io_queues()
1014 nvme_cancel_tagset(&ctrl->ctrl); in nvme_rdma_configure_io_queues()
1016 blk_cleanup_queue(ctrl->ctrl.connect_q); in nvme_rdma_configure_io_queues()
1019 blk_mq_free_tag_set(ctrl->ctrl.tagset); in nvme_rdma_configure_io_queues()
1021 nvme_rdma_free_io_queues(ctrl); in nvme_rdma_configure_io_queues()
1025 static void nvme_rdma_teardown_admin_queue(struct nvme_rdma_ctrl *ctrl, in nvme_rdma_teardown_admin_queue() argument
1028 blk_mq_quiesce_queue(ctrl->ctrl.admin_q); in nvme_rdma_teardown_admin_queue()
1029 blk_sync_queue(ctrl->ctrl.admin_q); in nvme_rdma_teardown_admin_queue()
1030 nvme_rdma_stop_queue(&ctrl->queues[0]); in nvme_rdma_teardown_admin_queue()
1031 nvme_cancel_admin_tagset(&ctrl->ctrl); in nvme_rdma_teardown_admin_queue()
1033 blk_mq_unquiesce_queue(ctrl->ctrl.admin_q); in nvme_rdma_teardown_admin_queue()
1034 nvme_rdma_destroy_admin_queue(ctrl, remove); in nvme_rdma_teardown_admin_queue()
1037 static void nvme_rdma_teardown_io_queues(struct nvme_rdma_ctrl *ctrl, in nvme_rdma_teardown_io_queues() argument
1040 if (ctrl->ctrl.queue_count > 1) { in nvme_rdma_teardown_io_queues()
1041 nvme_start_freeze(&ctrl->ctrl); in nvme_rdma_teardown_io_queues()
1042 nvme_stop_queues(&ctrl->ctrl); in nvme_rdma_teardown_io_queues()
1043 nvme_sync_io_queues(&ctrl->ctrl); in nvme_rdma_teardown_io_queues()
1044 nvme_rdma_stop_io_queues(ctrl); in nvme_rdma_teardown_io_queues()
1045 nvme_cancel_tagset(&ctrl->ctrl); in nvme_rdma_teardown_io_queues()
1047 nvme_start_queues(&ctrl->ctrl); in nvme_rdma_teardown_io_queues()
1048 nvme_rdma_destroy_io_queues(ctrl, remove); in nvme_rdma_teardown_io_queues()
1054 struct nvme_rdma_ctrl *ctrl = to_rdma_ctrl(nctrl); in nvme_rdma_free_ctrl() local
1056 if (list_empty(&ctrl->list)) in nvme_rdma_free_ctrl()
1060 list_del(&ctrl->list); in nvme_rdma_free_ctrl()
1065 kfree(ctrl->queues); in nvme_rdma_free_ctrl()
1066 kfree(ctrl); in nvme_rdma_free_ctrl()
1069 static void nvme_rdma_reconnect_or_remove(struct nvme_rdma_ctrl *ctrl) in nvme_rdma_reconnect_or_remove() argument
1072 if (ctrl->ctrl.state != NVME_CTRL_CONNECTING) { in nvme_rdma_reconnect_or_remove()
1073 WARN_ON_ONCE(ctrl->ctrl.state == NVME_CTRL_NEW || in nvme_rdma_reconnect_or_remove()
1074 ctrl->ctrl.state == NVME_CTRL_LIVE); in nvme_rdma_reconnect_or_remove()
1078 if (nvmf_should_reconnect(&ctrl->ctrl)) { in nvme_rdma_reconnect_or_remove()
1079 dev_info(ctrl->ctrl.device, "Reconnecting in %d seconds...\n", in nvme_rdma_reconnect_or_remove()
1080 ctrl->ctrl.opts->reconnect_delay); in nvme_rdma_reconnect_or_remove()
1081 queue_delayed_work(nvme_wq, &ctrl->reconnect_work, in nvme_rdma_reconnect_or_remove()
1082 ctrl->ctrl.opts->reconnect_delay * HZ); in nvme_rdma_reconnect_or_remove()
1084 nvme_delete_ctrl(&ctrl->ctrl); in nvme_rdma_reconnect_or_remove()
1088 static int nvme_rdma_setup_ctrl(struct nvme_rdma_ctrl *ctrl, bool new) in nvme_rdma_setup_ctrl() argument
1093 ret = nvme_rdma_configure_admin_queue(ctrl, new); in nvme_rdma_setup_ctrl()
1097 if (ctrl->ctrl.icdoff) { in nvme_rdma_setup_ctrl()
1098 dev_err(ctrl->ctrl.device, "icdoff is not supported!\n"); in nvme_rdma_setup_ctrl()
1102 if (!(ctrl->ctrl.sgls & (1 << 2))) { in nvme_rdma_setup_ctrl()
1103 dev_err(ctrl->ctrl.device, in nvme_rdma_setup_ctrl()
1108 if (ctrl->ctrl.opts->queue_size > ctrl->ctrl.sqsize + 1) { in nvme_rdma_setup_ctrl()
1109 dev_warn(ctrl->ctrl.device, in nvme_rdma_setup_ctrl()
1110 "queue_size %zu > ctrl sqsize %u, clamping down\n", in nvme_rdma_setup_ctrl()
1111 ctrl->ctrl.opts->queue_size, ctrl->ctrl.sqsize + 1); in nvme_rdma_setup_ctrl()
1114 if (ctrl->ctrl.sqsize + 1 > ctrl->ctrl.maxcmd) { in nvme_rdma_setup_ctrl()
1115 dev_warn(ctrl->ctrl.device, in nvme_rdma_setup_ctrl()
1116 "sqsize %u > ctrl maxcmd %u, clamping down\n", in nvme_rdma_setup_ctrl()
1117 ctrl->ctrl.sqsize + 1, ctrl->ctrl.maxcmd); in nvme_rdma_setup_ctrl()
1118 ctrl->ctrl.sqsize = ctrl->ctrl.maxcmd - 1; in nvme_rdma_setup_ctrl()
1121 if (ctrl->ctrl.sgls & (1 << 20)) in nvme_rdma_setup_ctrl()
1122 ctrl->use_inline_data = true; in nvme_rdma_setup_ctrl()
1124 if (ctrl->ctrl.queue_count > 1) { in nvme_rdma_setup_ctrl()
1125 ret = nvme_rdma_configure_io_queues(ctrl, new); in nvme_rdma_setup_ctrl()
1130 changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE); in nvme_rdma_setup_ctrl()
1133 * state change failure is ok if we started ctrl delete, in nvme_rdma_setup_ctrl()
1137 WARN_ON_ONCE(ctrl->ctrl.state != NVME_CTRL_DELETING && in nvme_rdma_setup_ctrl()
1138 ctrl->ctrl.state != NVME_CTRL_DELETING_NOIO); in nvme_rdma_setup_ctrl()
1144 nvme_start_ctrl(&ctrl->ctrl); in nvme_rdma_setup_ctrl()
1148 if (ctrl->ctrl.queue_count > 1) { in nvme_rdma_setup_ctrl()
1149 nvme_stop_queues(&ctrl->ctrl); in nvme_rdma_setup_ctrl()
1150 nvme_sync_io_queues(&ctrl->ctrl); in nvme_rdma_setup_ctrl()
1151 nvme_rdma_stop_io_queues(ctrl); in nvme_rdma_setup_ctrl()
1152 nvme_cancel_tagset(&ctrl->ctrl); in nvme_rdma_setup_ctrl()
1153 nvme_rdma_destroy_io_queues(ctrl, new); in nvme_rdma_setup_ctrl()
1156 blk_mq_quiesce_queue(ctrl->ctrl.admin_q); in nvme_rdma_setup_ctrl()
1157 blk_sync_queue(ctrl->ctrl.admin_q); in nvme_rdma_setup_ctrl()
1158 nvme_rdma_stop_queue(&ctrl->queues[0]); in nvme_rdma_setup_ctrl()
1159 nvme_cancel_admin_tagset(&ctrl->ctrl); in nvme_rdma_setup_ctrl()
1160 nvme_rdma_destroy_admin_queue(ctrl, new); in nvme_rdma_setup_ctrl()
1166 struct nvme_rdma_ctrl *ctrl = container_of(to_delayed_work(work), in nvme_rdma_reconnect_ctrl_work() local
1169 ++ctrl->ctrl.nr_reconnects; in nvme_rdma_reconnect_ctrl_work()
1171 if (nvme_rdma_setup_ctrl(ctrl, false)) in nvme_rdma_reconnect_ctrl_work()
1174 dev_info(ctrl->ctrl.device, "Successfully reconnected (%d attempts)\n", in nvme_rdma_reconnect_ctrl_work()
1175 ctrl->ctrl.nr_reconnects); in nvme_rdma_reconnect_ctrl_work()
1177 ctrl->ctrl.nr_reconnects = 0; in nvme_rdma_reconnect_ctrl_work()
1182 dev_info(ctrl->ctrl.device, "Failed reconnect attempt %d\n", in nvme_rdma_reconnect_ctrl_work()
1183 ctrl->ctrl.nr_reconnects); in nvme_rdma_reconnect_ctrl_work()
1184 nvme_rdma_reconnect_or_remove(ctrl); in nvme_rdma_reconnect_ctrl_work()
1189 struct nvme_rdma_ctrl *ctrl = container_of(work, in nvme_rdma_error_recovery_work() local
1192 nvme_stop_keep_alive(&ctrl->ctrl); in nvme_rdma_error_recovery_work()
1193 nvme_rdma_teardown_io_queues(ctrl, false); in nvme_rdma_error_recovery_work()
1194 nvme_start_queues(&ctrl->ctrl); in nvme_rdma_error_recovery_work()
1195 nvme_rdma_teardown_admin_queue(ctrl, false); in nvme_rdma_error_recovery_work()
1196 blk_mq_unquiesce_queue(ctrl->ctrl.admin_q); in nvme_rdma_error_recovery_work()
1198 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) { in nvme_rdma_error_recovery_work()
1199 /* state change failure is ok if we started ctrl delete */ in nvme_rdma_error_recovery_work()
1200 WARN_ON_ONCE(ctrl->ctrl.state != NVME_CTRL_DELETING && in nvme_rdma_error_recovery_work()
1201 ctrl->ctrl.state != NVME_CTRL_DELETING_NOIO); in nvme_rdma_error_recovery_work()
1205 nvme_rdma_reconnect_or_remove(ctrl); in nvme_rdma_error_recovery_work()
1208 static void nvme_rdma_error_recovery(struct nvme_rdma_ctrl *ctrl) in nvme_rdma_error_recovery() argument
1210 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RESETTING)) in nvme_rdma_error_recovery()
1213 dev_warn(ctrl->ctrl.device, "starting error recovery\n"); in nvme_rdma_error_recovery()
1214 queue_work(nvme_reset_wq, &ctrl->err_work); in nvme_rdma_error_recovery()
1231 struct nvme_rdma_ctrl *ctrl = queue->ctrl; in nvme_rdma_wr_error() local
1233 if (ctrl->ctrl.state == NVME_CTRL_LIVE) in nvme_rdma_wr_error()
1234 dev_info(ctrl->ctrl.device, in nvme_rdma_wr_error()
1238 nvme_rdma_error_recovery(ctrl); in nvme_rdma_wr_error()
1335 sg->addr = cpu_to_le64(queue->ctrl->ctrl.icdoff); in nvme_rdma_map_sg_inline()
1367 * Align the MR to a 4K page size to match the ctrl page size and in nvme_rdma_map_sg_fr()
1579 queue->ctrl->use_inline_data && in nvme_rdma_map_data()
1653 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_post_send()
1679 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_post_recv()
1690 return queue->ctrl->admin_tag_set.tags[queue_idx]; in nvme_rdma_tagset()
1691 return queue->ctrl->tag_set.tags[queue_idx - 1]; in nvme_rdma_tagset()
1702 struct nvme_rdma_ctrl *ctrl = to_rdma_ctrl(arg); in nvme_rdma_submit_async_event() local
1703 struct nvme_rdma_queue *queue = &ctrl->queues[0]; in nvme_rdma_submit_async_event()
1705 struct nvme_rdma_qe *sqe = &ctrl->async_event_sqe; in nvme_rdma_submit_async_event()
1735 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_process_nvme_rsp()
1738 nvme_rdma_error_recovery(queue->ctrl); in nvme_rdma_process_nvme_rsp()
1749 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_process_nvme_rsp()
1752 nvme_rdma_error_recovery(queue->ctrl); in nvme_rdma_process_nvme_rsp()
1759 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_process_nvme_rsp()
1762 nvme_rdma_error_recovery(queue->ctrl); in nvme_rdma_process_nvme_rsp()
1787 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_recv_done()
1789 nvme_rdma_error_recovery(queue->ctrl); in nvme_rdma_recv_done()
1802 nvme_complete_async_event(&queue->ctrl->ctrl, cqe->status, in nvme_rdma_recv_done()
1839 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_conn_rejected()
1843 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_conn_rejected()
1852 struct nvme_ctrl *ctrl = &queue->ctrl->ctrl; in nvme_rdma_addr_resolved() local
1859 if (ctrl->opts->tos >= 0) in nvme_rdma_addr_resolved()
1860 rdma_set_service_type(queue->cm_id, ctrl->opts->tos); in nvme_rdma_addr_resolved()
1863 dev_err(ctrl->device, "rdma_resolve_route failed (%d).\n", in nvme_rdma_addr_resolved()
1877 struct nvme_rdma_ctrl *ctrl = queue->ctrl; in nvme_rdma_route_resolved() local
1908 priv.hsqsize = cpu_to_le16(queue->ctrl->ctrl.sqsize); in nvme_rdma_route_resolved()
1913 dev_err(ctrl->ctrl.device, in nvme_rdma_route_resolved()
1927 dev_dbg(queue->ctrl->ctrl.device, "%s (%d): status %d id %p\n", in nvme_rdma_cm_handler()
1950 dev_dbg(queue->ctrl->ctrl.device, in nvme_rdma_cm_handler()
1957 dev_dbg(queue->ctrl->ctrl.device, in nvme_rdma_cm_handler()
1959 nvme_rdma_error_recovery(queue->ctrl); in nvme_rdma_cm_handler()
1965 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_cm_handler()
1967 nvme_rdma_error_recovery(queue->ctrl); in nvme_rdma_cm_handler()
1996 struct nvme_rdma_ctrl *ctrl = queue->ctrl; in nvme_rdma_timeout() local
1998 dev_warn(ctrl->ctrl.device, "I/O %d QID %d timeout\n", in nvme_rdma_timeout()
2001 if (ctrl->ctrl.state != NVME_CTRL_LIVE) { in nvme_rdma_timeout()
2006 * - ctrl disable/shutdown fabrics requests in nvme_rdma_timeout()
2023 nvme_rdma_error_recovery(ctrl); in nvme_rdma_timeout()
2043 if (!nvme_check_ready(&queue->ctrl->ctrl, rq, queue_ready)) in nvme_rdma_queue_rq()
2044 return nvme_fail_nonready_command(&queue->ctrl->ctrl, rq); in nvme_rdma_queue_rq()
2075 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_queue_rq()
2163 struct nvme_rdma_ctrl *ctrl = set->driver_data; in nvme_rdma_map_queues() local
2164 struct nvmf_ctrl_options *opts = ctrl->ctrl.opts; in nvme_rdma_map_queues()
2166 if (opts->nr_write_queues && ctrl->io_queues[HCTX_TYPE_READ]) { in nvme_rdma_map_queues()
2169 ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_rdma_map_queues()
2172 ctrl->io_queues[HCTX_TYPE_READ]; in nvme_rdma_map_queues()
2174 ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_rdma_map_queues()
2178 ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_rdma_map_queues()
2181 ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_rdma_map_queues()
2185 ctrl->device->dev, 0); in nvme_rdma_map_queues()
2187 ctrl->device->dev, 0); in nvme_rdma_map_queues()
2189 if (opts->nr_poll_queues && ctrl->io_queues[HCTX_TYPE_POLL]) { in nvme_rdma_map_queues()
2192 ctrl->io_queues[HCTX_TYPE_POLL]; in nvme_rdma_map_queues()
2194 ctrl->io_queues[HCTX_TYPE_DEFAULT] + in nvme_rdma_map_queues()
2195 ctrl->io_queues[HCTX_TYPE_READ]; in nvme_rdma_map_queues()
2199 dev_info(ctrl->ctrl.device, in nvme_rdma_map_queues()
2201 ctrl->io_queues[HCTX_TYPE_DEFAULT], in nvme_rdma_map_queues()
2202 ctrl->io_queues[HCTX_TYPE_READ], in nvme_rdma_map_queues()
2203 ctrl->io_queues[HCTX_TYPE_POLL]); in nvme_rdma_map_queues()
2228 static void nvme_rdma_shutdown_ctrl(struct nvme_rdma_ctrl *ctrl, bool shutdown) in nvme_rdma_shutdown_ctrl() argument
2230 cancel_work_sync(&ctrl->err_work); in nvme_rdma_shutdown_ctrl()
2231 cancel_delayed_work_sync(&ctrl->reconnect_work); in nvme_rdma_shutdown_ctrl()
2233 nvme_rdma_teardown_io_queues(ctrl, shutdown); in nvme_rdma_shutdown_ctrl()
2234 blk_mq_quiesce_queue(ctrl->ctrl.admin_q); in nvme_rdma_shutdown_ctrl()
2236 nvme_shutdown_ctrl(&ctrl->ctrl); in nvme_rdma_shutdown_ctrl()
2238 nvme_disable_ctrl(&ctrl->ctrl); in nvme_rdma_shutdown_ctrl()
2239 nvme_rdma_teardown_admin_queue(ctrl, shutdown); in nvme_rdma_shutdown_ctrl()
2242 static void nvme_rdma_delete_ctrl(struct nvme_ctrl *ctrl) in nvme_rdma_delete_ctrl() argument
2244 nvme_rdma_shutdown_ctrl(to_rdma_ctrl(ctrl), true); in nvme_rdma_delete_ctrl()
2249 struct nvme_rdma_ctrl *ctrl = in nvme_rdma_reset_ctrl_work() local
2250 container_of(work, struct nvme_rdma_ctrl, ctrl.reset_work); in nvme_rdma_reset_ctrl_work()
2252 nvme_stop_ctrl(&ctrl->ctrl); in nvme_rdma_reset_ctrl_work()
2253 nvme_rdma_shutdown_ctrl(ctrl, false); in nvme_rdma_reset_ctrl_work()
2255 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) { in nvme_rdma_reset_ctrl_work()
2261 if (nvme_rdma_setup_ctrl(ctrl, false)) in nvme_rdma_reset_ctrl_work()
2267 ++ctrl->ctrl.nr_reconnects; in nvme_rdma_reset_ctrl_work()
2268 nvme_rdma_reconnect_or_remove(ctrl); in nvme_rdma_reset_ctrl_work()
2299 struct nvme_rdma_ctrl *ctrl; in nvme_rdma_existing_controller() local
2303 list_for_each_entry(ctrl, &nvme_rdma_ctrl_list, list) { in nvme_rdma_existing_controller()
2304 found = nvmf_ip_options_match(&ctrl->ctrl, opts); in nvme_rdma_existing_controller()
2316 struct nvme_rdma_ctrl *ctrl; in nvme_rdma_create_ctrl() local
2320 ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); in nvme_rdma_create_ctrl()
2321 if (!ctrl) in nvme_rdma_create_ctrl()
2323 ctrl->ctrl.opts = opts; in nvme_rdma_create_ctrl()
2324 INIT_LIST_HEAD(&ctrl->list); in nvme_rdma_create_ctrl()
2337 opts->traddr, opts->trsvcid, &ctrl->addr); in nvme_rdma_create_ctrl()
2346 opts->host_traddr, NULL, &ctrl->src_addr); in nvme_rdma_create_ctrl()
2359 INIT_DELAYED_WORK(&ctrl->reconnect_work, in nvme_rdma_create_ctrl()
2361 INIT_WORK(&ctrl->err_work, nvme_rdma_error_recovery_work); in nvme_rdma_create_ctrl()
2362 INIT_WORK(&ctrl->ctrl.reset_work, nvme_rdma_reset_ctrl_work); in nvme_rdma_create_ctrl()
2364 ctrl->ctrl.queue_count = opts->nr_io_queues + opts->nr_write_queues + in nvme_rdma_create_ctrl()
2366 ctrl->ctrl.sqsize = opts->queue_size - 1; in nvme_rdma_create_ctrl()
2367 ctrl->ctrl.kato = opts->kato; in nvme_rdma_create_ctrl()
2370 ctrl->queues = kcalloc(ctrl->ctrl.queue_count, sizeof(*ctrl->queues), in nvme_rdma_create_ctrl()
2372 if (!ctrl->queues) in nvme_rdma_create_ctrl()
2375 ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_rdma_ctrl_ops, in nvme_rdma_create_ctrl()
2380 changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING); in nvme_rdma_create_ctrl()
2383 ret = nvme_rdma_setup_ctrl(ctrl, true); in nvme_rdma_create_ctrl()
2387 dev_info(ctrl->ctrl.device, "new ctrl: NQN \"%s\", addr %pISpcs\n", in nvme_rdma_create_ctrl()
2388 ctrl->ctrl.opts->subsysnqn, &ctrl->addr); in nvme_rdma_create_ctrl()
2391 list_add_tail(&ctrl->list, &nvme_rdma_ctrl_list); in nvme_rdma_create_ctrl()
2394 return &ctrl->ctrl; in nvme_rdma_create_ctrl()
2397 nvme_uninit_ctrl(&ctrl->ctrl); in nvme_rdma_create_ctrl()
2398 nvme_put_ctrl(&ctrl->ctrl); in nvme_rdma_create_ctrl()
2403 kfree(ctrl->queues); in nvme_rdma_create_ctrl()
2405 kfree(ctrl); in nvme_rdma_create_ctrl()
2422 struct nvme_rdma_ctrl *ctrl; in nvme_rdma_remove_one() local
2440 list_for_each_entry(ctrl, &nvme_rdma_ctrl_list, list) { in nvme_rdma_remove_one()
2441 if (ctrl->device->dev != ib_device) in nvme_rdma_remove_one()
2443 nvme_delete_ctrl(&ctrl->ctrl); in nvme_rdma_remove_one()
2476 struct nvme_rdma_ctrl *ctrl; in nvme_rdma_cleanup_module() local
2482 list_for_each_entry(ctrl, &nvme_rdma_ctrl_list, list) in nvme_rdma_cleanup_module()
2483 nvme_delete_ctrl(&ctrl->ctrl); in nvme_rdma_cleanup_module()