Lines Matching full:ctrl
90 struct nvme_rdma_ctrl *ctrl; member
126 struct nvme_ctrl ctrl; member
131 static inline struct nvme_rdma_ctrl *to_rdma_ctrl(struct nvme_ctrl *ctrl) in to_rdma_ctrl() argument
133 return container_of(ctrl, struct nvme_rdma_ctrl, ctrl); in to_rdma_ctrl()
162 return queue - queue->ctrl->queues; in nvme_rdma_queue_idx()
168 queue->ctrl->io_queues[HCTX_TYPE_DEFAULT] + in nvme_rdma_poll_queue()
169 queue->ctrl->io_queues[HCTX_TYPE_READ]; in nvme_rdma_poll_queue()
298 struct nvme_rdma_ctrl *ctrl = to_rdma_ctrl(set->driver_data); in nvme_rdma_init_request() local
300 int queue_idx = (set == &ctrl->tag_set) ? hctx_idx + 1 : 0; in nvme_rdma_init_request()
301 struct nvme_rdma_queue *queue = &ctrl->queues[queue_idx]; in nvme_rdma_init_request()
303 nvme_req(rq)->ctrl = &ctrl->ctrl; in nvme_rdma_init_request()
323 struct nvme_rdma_ctrl *ctrl = to_rdma_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 = to_rdma_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()
583 queue->ctrl = ctrl; in nvme_rdma_alloc_queue()
584 if (idx && ctrl->ctrl.max_integrity_segments) in nvme_rdma_alloc_queue()
591 queue->cmnd_capsule_len = ctrl->ctrl.ioccsz * 16; in nvme_rdma_alloc_queue()
600 dev_info(ctrl->ctrl.device, in nvme_rdma_alloc_queue()
606 if (ctrl->ctrl.opts->mask & NVMF_OPT_HOST_TRADDR) in nvme_rdma_alloc_queue()
607 src_addr = (struct sockaddr *)&ctrl->src_addr; in nvme_rdma_alloc_queue()
611 (struct sockaddr *)&ctrl->addr, in nvme_rdma_alloc_queue()
614 dev_info(ctrl->ctrl.device, in nvme_rdma_alloc_queue()
621 dev_info(ctrl->ctrl.device, in nvme_rdma_alloc_queue()
662 static void nvme_rdma_free_io_queues(struct nvme_rdma_ctrl *ctrl) in nvme_rdma_free_io_queues() argument
666 for (i = 1; i < ctrl->ctrl.queue_count; i++) in nvme_rdma_free_io_queues()
667 nvme_rdma_free_queue(&ctrl->queues[i]); in nvme_rdma_free_io_queues()
670 static void nvme_rdma_stop_io_queues(struct nvme_rdma_ctrl *ctrl) in nvme_rdma_stop_io_queues() argument
674 for (i = 1; i < ctrl->ctrl.queue_count; i++) in nvme_rdma_stop_io_queues()
675 nvme_rdma_stop_queue(&ctrl->queues[i]); in nvme_rdma_stop_io_queues()
678 static int nvme_rdma_start_queue(struct nvme_rdma_ctrl *ctrl, int idx) in nvme_rdma_start_queue() argument
680 struct nvme_rdma_queue *queue = &ctrl->queues[idx]; in nvme_rdma_start_queue()
684 ret = nvmf_connect_io_queue(&ctrl->ctrl, idx); in nvme_rdma_start_queue()
686 ret = nvmf_connect_admin_queue(&ctrl->ctrl); in nvme_rdma_start_queue()
693 dev_info(ctrl->ctrl.device, in nvme_rdma_start_queue()
699 static int nvme_rdma_start_io_queues(struct nvme_rdma_ctrl *ctrl, in nvme_rdma_start_io_queues() argument
705 ret = nvme_rdma_start_queue(ctrl, i); in nvme_rdma_start_io_queues()
714 nvme_rdma_stop_queue(&ctrl->queues[i]); in nvme_rdma_start_io_queues()
718 static int nvme_rdma_alloc_io_queues(struct nvme_rdma_ctrl *ctrl) in nvme_rdma_alloc_io_queues() argument
720 struct nvmf_ctrl_options *opts = ctrl->ctrl.opts; in nvme_rdma_alloc_io_queues()
721 struct ib_device *ibdev = ctrl->device->dev; in nvme_rdma_alloc_io_queues()
733 ret = nvme_set_queue_count(&ctrl->ctrl, &nr_io_queues); in nvme_rdma_alloc_io_queues()
738 dev_err(ctrl->ctrl.device, in nvme_rdma_alloc_io_queues()
743 ctrl->ctrl.queue_count = nr_io_queues + 1; in nvme_rdma_alloc_io_queues()
744 dev_info(ctrl->ctrl.device, in nvme_rdma_alloc_io_queues()
753 ctrl->io_queues[HCTX_TYPE_READ] = nr_read_queues; in nvme_rdma_alloc_io_queues()
754 nr_io_queues -= ctrl->io_queues[HCTX_TYPE_READ]; 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()
764 ctrl->io_queues[HCTX_TYPE_DEFAULT] = in nvme_rdma_alloc_io_queues()
766 nr_io_queues -= ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_rdma_alloc_io_queues()
771 ctrl->io_queues[HCTX_TYPE_POLL] = in nvme_rdma_alloc_io_queues()
775 for (i = 1; i < ctrl->ctrl.queue_count; i++) { in nvme_rdma_alloc_io_queues()
776 ret = nvme_rdma_alloc_queue(ctrl, i, in nvme_rdma_alloc_io_queues()
777 ctrl->ctrl.sqsize + 1); in nvme_rdma_alloc_io_queues()
786 nvme_rdma_free_queue(&ctrl->queues[i]); in nvme_rdma_alloc_io_queues()
791 static int nvme_rdma_alloc_tag_set(struct nvme_ctrl *ctrl) in nvme_rdma_alloc_tag_set() argument
796 if (ctrl->max_integrity_segments) in nvme_rdma_alloc_tag_set()
800 return nvme_alloc_io_tag_set(ctrl, &to_rdma_ctrl(ctrl)->tag_set, in nvme_rdma_alloc_tag_set()
804 static void nvme_rdma_destroy_admin_queue(struct nvme_rdma_ctrl *ctrl) in nvme_rdma_destroy_admin_queue() argument
806 if (ctrl->async_event_sqe.data) { in nvme_rdma_destroy_admin_queue()
807 cancel_work_sync(&ctrl->ctrl.async_event_work); in nvme_rdma_destroy_admin_queue()
808 nvme_rdma_free_qe(ctrl->device->dev, &ctrl->async_event_sqe, in nvme_rdma_destroy_admin_queue()
810 ctrl->async_event_sqe.data = NULL; in nvme_rdma_destroy_admin_queue()
812 nvme_rdma_free_queue(&ctrl->queues[0]); in nvme_rdma_destroy_admin_queue()
815 static int nvme_rdma_configure_admin_queue(struct nvme_rdma_ctrl *ctrl, in nvme_rdma_configure_admin_queue() argument
821 error = nvme_rdma_alloc_queue(ctrl, 0, NVME_AQ_DEPTH); in nvme_rdma_configure_admin_queue()
825 ctrl->device = ctrl->queues[0].device; in nvme_rdma_configure_admin_queue()
826 ctrl->ctrl.numa_node = ibdev_to_node(ctrl->device->dev); in nvme_rdma_configure_admin_queue()
829 if (ctrl->device->dev->attrs.kernel_cap_flags & in nvme_rdma_configure_admin_queue()
833 ctrl->max_fr_pages = nvme_rdma_get_max_fr_pages(ctrl->device->dev, in nvme_rdma_configure_admin_queue()
841 error = nvme_rdma_alloc_qe(ctrl->device->dev, &ctrl->async_event_sqe, in nvme_rdma_configure_admin_queue()
847 error = nvme_alloc_admin_tag_set(&ctrl->ctrl, in nvme_rdma_configure_admin_queue()
848 &ctrl->admin_tag_set, &nvme_rdma_admin_mq_ops, in nvme_rdma_configure_admin_queue()
857 error = nvme_rdma_start_queue(ctrl, 0); in nvme_rdma_configure_admin_queue()
861 error = nvme_enable_ctrl(&ctrl->ctrl); in nvme_rdma_configure_admin_queue()
865 ctrl->ctrl.max_segments = ctrl->max_fr_pages; in nvme_rdma_configure_admin_queue()
866 ctrl->ctrl.max_hw_sectors = ctrl->max_fr_pages << (ilog2(SZ_4K) - 9); in nvme_rdma_configure_admin_queue()
868 ctrl->ctrl.max_integrity_segments = ctrl->max_fr_pages; in nvme_rdma_configure_admin_queue()
870 ctrl->ctrl.max_integrity_segments = 0; in nvme_rdma_configure_admin_queue()
872 nvme_start_admin_queue(&ctrl->ctrl); in nvme_rdma_configure_admin_queue()
874 error = nvme_init_ctrl_finish(&ctrl->ctrl); in nvme_rdma_configure_admin_queue()
881 nvme_stop_admin_queue(&ctrl->ctrl); in nvme_rdma_configure_admin_queue()
882 blk_sync_queue(ctrl->ctrl.admin_q); in nvme_rdma_configure_admin_queue()
884 nvme_rdma_stop_queue(&ctrl->queues[0]); in nvme_rdma_configure_admin_queue()
885 nvme_cancel_admin_tagset(&ctrl->ctrl); in nvme_rdma_configure_admin_queue()
888 nvme_remove_admin_tag_set(&ctrl->ctrl); in nvme_rdma_configure_admin_queue()
890 if (ctrl->async_event_sqe.data) { in nvme_rdma_configure_admin_queue()
891 nvme_rdma_free_qe(ctrl->device->dev, &ctrl->async_event_sqe, in nvme_rdma_configure_admin_queue()
893 ctrl->async_event_sqe.data = NULL; in nvme_rdma_configure_admin_queue()
896 nvme_rdma_free_queue(&ctrl->queues[0]); in nvme_rdma_configure_admin_queue()
900 static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new) in nvme_rdma_configure_io_queues() argument
904 ret = nvme_rdma_alloc_io_queues(ctrl); in nvme_rdma_configure_io_queues()
909 ret = nvme_rdma_alloc_tag_set(&ctrl->ctrl); in nvme_rdma_configure_io_queues()
919 nr_queues = min(ctrl->tag_set.nr_hw_queues + 1, ctrl->ctrl.queue_count); in nvme_rdma_configure_io_queues()
920 ret = nvme_rdma_start_io_queues(ctrl, 1, nr_queues); in nvme_rdma_configure_io_queues()
925 nvme_start_queues(&ctrl->ctrl); in nvme_rdma_configure_io_queues()
926 if (!nvme_wait_freeze_timeout(&ctrl->ctrl, NVME_IO_TIMEOUT)) { in nvme_rdma_configure_io_queues()
935 blk_mq_update_nr_hw_queues(ctrl->ctrl.tagset, in nvme_rdma_configure_io_queues()
936 ctrl->ctrl.queue_count - 1); in nvme_rdma_configure_io_queues()
937 nvme_unfreeze(&ctrl->ctrl); in nvme_rdma_configure_io_queues()
944 ret = nvme_rdma_start_io_queues(ctrl, nr_queues, in nvme_rdma_configure_io_queues()
945 ctrl->tag_set.nr_hw_queues + 1); in nvme_rdma_configure_io_queues()
952 nvme_stop_queues(&ctrl->ctrl); in nvme_rdma_configure_io_queues()
953 nvme_sync_io_queues(&ctrl->ctrl); in nvme_rdma_configure_io_queues()
954 nvme_rdma_stop_io_queues(ctrl); in nvme_rdma_configure_io_queues()
956 nvme_cancel_tagset(&ctrl->ctrl); in nvme_rdma_configure_io_queues()
958 nvme_remove_io_tag_set(&ctrl->ctrl); in nvme_rdma_configure_io_queues()
960 nvme_rdma_free_io_queues(ctrl); in nvme_rdma_configure_io_queues()
964 static void nvme_rdma_teardown_admin_queue(struct nvme_rdma_ctrl *ctrl, in nvme_rdma_teardown_admin_queue() argument
967 nvme_stop_admin_queue(&ctrl->ctrl); in nvme_rdma_teardown_admin_queue()
968 blk_sync_queue(ctrl->ctrl.admin_q); in nvme_rdma_teardown_admin_queue()
969 nvme_rdma_stop_queue(&ctrl->queues[0]); in nvme_rdma_teardown_admin_queue()
970 nvme_cancel_admin_tagset(&ctrl->ctrl); in nvme_rdma_teardown_admin_queue()
972 nvme_start_admin_queue(&ctrl->ctrl); in nvme_rdma_teardown_admin_queue()
973 nvme_remove_admin_tag_set(&ctrl->ctrl); in nvme_rdma_teardown_admin_queue()
975 nvme_rdma_destroy_admin_queue(ctrl); in nvme_rdma_teardown_admin_queue()
978 static void nvme_rdma_teardown_io_queues(struct nvme_rdma_ctrl *ctrl, in nvme_rdma_teardown_io_queues() argument
981 if (ctrl->ctrl.queue_count > 1) { in nvme_rdma_teardown_io_queues()
982 nvme_start_freeze(&ctrl->ctrl); in nvme_rdma_teardown_io_queues()
983 nvme_stop_queues(&ctrl->ctrl); in nvme_rdma_teardown_io_queues()
984 nvme_sync_io_queues(&ctrl->ctrl); in nvme_rdma_teardown_io_queues()
985 nvme_rdma_stop_io_queues(ctrl); in nvme_rdma_teardown_io_queues()
986 nvme_cancel_tagset(&ctrl->ctrl); in nvme_rdma_teardown_io_queues()
988 nvme_start_queues(&ctrl->ctrl); in nvme_rdma_teardown_io_queues()
989 nvme_remove_io_tag_set(&ctrl->ctrl); in nvme_rdma_teardown_io_queues()
991 nvme_rdma_free_io_queues(ctrl); in nvme_rdma_teardown_io_queues()
997 struct nvme_rdma_ctrl *ctrl = to_rdma_ctrl(nctrl); in nvme_rdma_stop_ctrl() local
999 flush_work(&ctrl->err_work); in nvme_rdma_stop_ctrl()
1000 cancel_delayed_work_sync(&ctrl->reconnect_work); in nvme_rdma_stop_ctrl()
1005 struct nvme_rdma_ctrl *ctrl = to_rdma_ctrl(nctrl); in nvme_rdma_free_ctrl() local
1007 if (list_empty(&ctrl->list)) in nvme_rdma_free_ctrl()
1011 list_del(&ctrl->list); in nvme_rdma_free_ctrl()
1016 kfree(ctrl->queues); in nvme_rdma_free_ctrl()
1017 kfree(ctrl); in nvme_rdma_free_ctrl()
1020 static void nvme_rdma_reconnect_or_remove(struct nvme_rdma_ctrl *ctrl) in nvme_rdma_reconnect_or_remove() argument
1023 if (ctrl->ctrl.state != NVME_CTRL_CONNECTING) { in nvme_rdma_reconnect_or_remove()
1024 WARN_ON_ONCE(ctrl->ctrl.state == NVME_CTRL_NEW || in nvme_rdma_reconnect_or_remove()
1025 ctrl->ctrl.state == NVME_CTRL_LIVE); in nvme_rdma_reconnect_or_remove()
1029 if (nvmf_should_reconnect(&ctrl->ctrl)) { in nvme_rdma_reconnect_or_remove()
1030 dev_info(ctrl->ctrl.device, "Reconnecting in %d seconds...\n", in nvme_rdma_reconnect_or_remove()
1031 ctrl->ctrl.opts->reconnect_delay); in nvme_rdma_reconnect_or_remove()
1032 queue_delayed_work(nvme_wq, &ctrl->reconnect_work, in nvme_rdma_reconnect_or_remove()
1033 ctrl->ctrl.opts->reconnect_delay * HZ); in nvme_rdma_reconnect_or_remove()
1035 nvme_delete_ctrl(&ctrl->ctrl); in nvme_rdma_reconnect_or_remove()
1039 static int nvme_rdma_setup_ctrl(struct nvme_rdma_ctrl *ctrl, bool new) in nvme_rdma_setup_ctrl() argument
1044 ret = nvme_rdma_configure_admin_queue(ctrl, new); in nvme_rdma_setup_ctrl()
1048 if (ctrl->ctrl.icdoff) { in nvme_rdma_setup_ctrl()
1050 dev_err(ctrl->ctrl.device, "icdoff is not supported!\n"); in nvme_rdma_setup_ctrl()
1054 if (!(ctrl->ctrl.sgls & (1 << 2))) { in nvme_rdma_setup_ctrl()
1056 dev_err(ctrl->ctrl.device, in nvme_rdma_setup_ctrl()
1061 if (ctrl->ctrl.opts->queue_size > ctrl->ctrl.sqsize + 1) { in nvme_rdma_setup_ctrl()
1062 dev_warn(ctrl->ctrl.device, in nvme_rdma_setup_ctrl()
1063 "queue_size %zu > ctrl sqsize %u, clamping down\n", in nvme_rdma_setup_ctrl()
1064 ctrl->ctrl.opts->queue_size, ctrl->ctrl.sqsize + 1); in nvme_rdma_setup_ctrl()
1067 if (ctrl->ctrl.sqsize + 1 > NVME_RDMA_MAX_QUEUE_SIZE) { in nvme_rdma_setup_ctrl()
1068 dev_warn(ctrl->ctrl.device, in nvme_rdma_setup_ctrl()
1069 "ctrl sqsize %u > max queue size %u, clamping down\n", in nvme_rdma_setup_ctrl()
1070 ctrl->ctrl.sqsize + 1, NVME_RDMA_MAX_QUEUE_SIZE); in nvme_rdma_setup_ctrl()
1071 ctrl->ctrl.sqsize = NVME_RDMA_MAX_QUEUE_SIZE - 1; in nvme_rdma_setup_ctrl()
1074 if (ctrl->ctrl.sqsize + 1 > ctrl->ctrl.maxcmd) { in nvme_rdma_setup_ctrl()
1075 dev_warn(ctrl->ctrl.device, in nvme_rdma_setup_ctrl()
1076 "sqsize %u > ctrl maxcmd %u, clamping down\n", in nvme_rdma_setup_ctrl()
1077 ctrl->ctrl.sqsize + 1, ctrl->ctrl.maxcmd); in nvme_rdma_setup_ctrl()
1078 ctrl->ctrl.sqsize = ctrl->ctrl.maxcmd - 1; in nvme_rdma_setup_ctrl()
1081 if (ctrl->ctrl.sgls & (1 << 20)) in nvme_rdma_setup_ctrl()
1082 ctrl->use_inline_data = true; in nvme_rdma_setup_ctrl()
1084 if (ctrl->ctrl.queue_count > 1) { in nvme_rdma_setup_ctrl()
1085 ret = nvme_rdma_configure_io_queues(ctrl, new); in nvme_rdma_setup_ctrl()
1090 changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE); in nvme_rdma_setup_ctrl()
1093 * state change failure is ok if we started ctrl delete, in nvme_rdma_setup_ctrl()
1097 WARN_ON_ONCE(ctrl->ctrl.state != NVME_CTRL_DELETING && in nvme_rdma_setup_ctrl()
1098 ctrl->ctrl.state != NVME_CTRL_DELETING_NOIO); in nvme_rdma_setup_ctrl()
1104 nvme_start_ctrl(&ctrl->ctrl); in nvme_rdma_setup_ctrl()
1108 if (ctrl->ctrl.queue_count > 1) { in nvme_rdma_setup_ctrl()
1109 nvme_stop_queues(&ctrl->ctrl); in nvme_rdma_setup_ctrl()
1110 nvme_sync_io_queues(&ctrl->ctrl); in nvme_rdma_setup_ctrl()
1111 nvme_rdma_stop_io_queues(ctrl); in nvme_rdma_setup_ctrl()
1112 nvme_cancel_tagset(&ctrl->ctrl); in nvme_rdma_setup_ctrl()
1114 nvme_remove_io_tag_set(&ctrl->ctrl); in nvme_rdma_setup_ctrl()
1115 nvme_rdma_free_io_queues(ctrl); in nvme_rdma_setup_ctrl()
1118 nvme_stop_admin_queue(&ctrl->ctrl); in nvme_rdma_setup_ctrl()
1119 blk_sync_queue(ctrl->ctrl.admin_q); in nvme_rdma_setup_ctrl()
1120 nvme_rdma_stop_queue(&ctrl->queues[0]); in nvme_rdma_setup_ctrl()
1121 nvme_cancel_admin_tagset(&ctrl->ctrl); in nvme_rdma_setup_ctrl()
1123 nvme_remove_admin_tag_set(&ctrl->ctrl); in nvme_rdma_setup_ctrl()
1124 nvme_rdma_destroy_admin_queue(ctrl); in nvme_rdma_setup_ctrl()
1130 struct nvme_rdma_ctrl *ctrl = container_of(to_delayed_work(work), in nvme_rdma_reconnect_ctrl_work() local
1133 ++ctrl->ctrl.nr_reconnects; in nvme_rdma_reconnect_ctrl_work()
1135 if (nvme_rdma_setup_ctrl(ctrl, false)) in nvme_rdma_reconnect_ctrl_work()
1138 dev_info(ctrl->ctrl.device, "Successfully reconnected (%d attempts)\n", in nvme_rdma_reconnect_ctrl_work()
1139 ctrl->ctrl.nr_reconnects); in nvme_rdma_reconnect_ctrl_work()
1141 ctrl->ctrl.nr_reconnects = 0; in nvme_rdma_reconnect_ctrl_work()
1146 dev_info(ctrl->ctrl.device, "Failed reconnect attempt %d\n", in nvme_rdma_reconnect_ctrl_work()
1147 ctrl->ctrl.nr_reconnects); in nvme_rdma_reconnect_ctrl_work()
1148 nvme_rdma_reconnect_or_remove(ctrl); in nvme_rdma_reconnect_ctrl_work()
1153 struct nvme_rdma_ctrl *ctrl = container_of(work, in nvme_rdma_error_recovery_work() local
1156 nvme_auth_stop(&ctrl->ctrl); in nvme_rdma_error_recovery_work()
1157 nvme_stop_keep_alive(&ctrl->ctrl); in nvme_rdma_error_recovery_work()
1158 flush_work(&ctrl->ctrl.async_event_work); in nvme_rdma_error_recovery_work()
1159 nvme_rdma_teardown_io_queues(ctrl, false); in nvme_rdma_error_recovery_work()
1160 nvme_start_queues(&ctrl->ctrl); in nvme_rdma_error_recovery_work()
1161 nvme_rdma_teardown_admin_queue(ctrl, false); in nvme_rdma_error_recovery_work()
1162 nvme_start_admin_queue(&ctrl->ctrl); in nvme_rdma_error_recovery_work()
1164 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) { in nvme_rdma_error_recovery_work()
1165 /* state change failure is ok if we started ctrl delete */ in nvme_rdma_error_recovery_work()
1166 WARN_ON_ONCE(ctrl->ctrl.state != NVME_CTRL_DELETING && in nvme_rdma_error_recovery_work()
1167 ctrl->ctrl.state != NVME_CTRL_DELETING_NOIO); in nvme_rdma_error_recovery_work()
1171 nvme_rdma_reconnect_or_remove(ctrl); in nvme_rdma_error_recovery_work()
1174 static void nvme_rdma_error_recovery(struct nvme_rdma_ctrl *ctrl) in nvme_rdma_error_recovery() argument
1176 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RESETTING)) in nvme_rdma_error_recovery()
1179 dev_warn(ctrl->ctrl.device, "starting error recovery\n"); in nvme_rdma_error_recovery()
1180 queue_work(nvme_reset_wq, &ctrl->err_work); in nvme_rdma_error_recovery()
1197 struct nvme_rdma_ctrl *ctrl = queue->ctrl; in nvme_rdma_wr_error() local
1199 if (ctrl->ctrl.state == NVME_CTRL_LIVE) in nvme_rdma_wr_error()
1200 dev_info(ctrl->ctrl.device, in nvme_rdma_wr_error()
1204 nvme_rdma_error_recovery(ctrl); in nvme_rdma_wr_error()
1308 sg->addr = cpu_to_le64(queue->ctrl->ctrl.icdoff); in nvme_rdma_map_sg_inline()
1340 * Align the MR to a 4K page size to match the ctrl page size and in nvme_rdma_map_sg_fr()
1575 queue->ctrl->use_inline_data && in nvme_rdma_map_data()
1638 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_post_send()
1664 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_post_recv()
1675 return queue->ctrl->admin_tag_set.tags[queue_idx]; in nvme_rdma_tagset()
1676 return queue->ctrl->tag_set.tags[queue_idx - 1]; in nvme_rdma_tagset()
1687 struct nvme_rdma_ctrl *ctrl = to_rdma_ctrl(arg); in nvme_rdma_submit_async_event() local
1688 struct nvme_rdma_queue *queue = &ctrl->queues[0]; in nvme_rdma_submit_async_event()
1690 struct nvme_rdma_qe *sqe = &ctrl->async_event_sqe; in nvme_rdma_submit_async_event()
1720 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_process_nvme_rsp()
1723 nvme_rdma_error_recovery(queue->ctrl); in nvme_rdma_process_nvme_rsp()
1734 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_process_nvme_rsp()
1737 nvme_rdma_error_recovery(queue->ctrl); in nvme_rdma_process_nvme_rsp()
1744 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_process_nvme_rsp()
1747 nvme_rdma_error_recovery(queue->ctrl); in nvme_rdma_process_nvme_rsp()
1772 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_recv_done()
1774 nvme_rdma_error_recovery(queue->ctrl); in nvme_rdma_recv_done()
1787 nvme_complete_async_event(&queue->ctrl->ctrl, cqe->status, in nvme_rdma_recv_done()
1824 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_conn_rejected()
1828 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_conn_rejected()
1837 struct nvme_ctrl *ctrl = &queue->ctrl->ctrl; in nvme_rdma_addr_resolved() local
1844 if (ctrl->opts->tos >= 0) in nvme_rdma_addr_resolved()
1845 rdma_set_service_type(queue->cm_id, ctrl->opts->tos); in nvme_rdma_addr_resolved()
1848 dev_err(ctrl->device, "rdma_resolve_route failed (%d).\n", in nvme_rdma_addr_resolved()
1862 struct nvme_rdma_ctrl *ctrl = queue->ctrl; in nvme_rdma_route_resolved() local
1893 priv.hsqsize = cpu_to_le16(queue->ctrl->ctrl.sqsize); in nvme_rdma_route_resolved()
1898 dev_err(ctrl->ctrl.device, in nvme_rdma_route_resolved()
1912 dev_dbg(queue->ctrl->ctrl.device, "%s (%d): status %d id %p\n", in nvme_rdma_cm_handler()
1935 dev_dbg(queue->ctrl->ctrl.device, in nvme_rdma_cm_handler()
1942 dev_dbg(queue->ctrl->ctrl.device, in nvme_rdma_cm_handler()
1944 nvme_rdma_error_recovery(queue->ctrl); in nvme_rdma_cm_handler()
1950 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_cm_handler()
1952 nvme_rdma_error_recovery(queue->ctrl); in nvme_rdma_cm_handler()
1977 struct nvme_rdma_ctrl *ctrl = queue->ctrl; in nvme_rdma_timeout() local
1979 dev_warn(ctrl->ctrl.device, "I/O %d QID %d timeout\n", in nvme_rdma_timeout()
1982 if (ctrl->ctrl.state != NVME_CTRL_LIVE) { in nvme_rdma_timeout()
1987 * - ctrl disable/shutdown fabrics requests in nvme_rdma_timeout()
2004 nvme_rdma_error_recovery(ctrl); in nvme_rdma_timeout()
2024 if (!nvme_check_ready(&queue->ctrl->ctrl, rq, queue_ready)) in nvme_rdma_queue_rq()
2025 return nvme_fail_nonready_command(&queue->ctrl->ctrl, rq); in nvme_rdma_queue_rq()
2056 dev_err(queue->ctrl->ctrl.device, in nvme_rdma_queue_rq()
2144 struct nvme_rdma_ctrl *ctrl = to_rdma_ctrl(set->driver_data); in nvme_rdma_map_queues() local
2145 struct nvmf_ctrl_options *opts = ctrl->ctrl.opts; in nvme_rdma_map_queues()
2147 if (opts->nr_write_queues && ctrl->io_queues[HCTX_TYPE_READ]) { in nvme_rdma_map_queues()
2150 ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_rdma_map_queues()
2153 ctrl->io_queues[HCTX_TYPE_READ]; in nvme_rdma_map_queues()
2155 ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_rdma_map_queues()
2159 ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_rdma_map_queues()
2162 ctrl->io_queues[HCTX_TYPE_DEFAULT]; in nvme_rdma_map_queues()
2166 ctrl->device->dev, 0); in nvme_rdma_map_queues()
2168 ctrl->device->dev, 0); in nvme_rdma_map_queues()
2170 if (opts->nr_poll_queues && ctrl->io_queues[HCTX_TYPE_POLL]) { in nvme_rdma_map_queues()
2173 ctrl->io_queues[HCTX_TYPE_POLL]; in nvme_rdma_map_queues()
2175 ctrl->io_queues[HCTX_TYPE_DEFAULT] + in nvme_rdma_map_queues()
2176 ctrl->io_queues[HCTX_TYPE_READ]; in nvme_rdma_map_queues()
2180 dev_info(ctrl->ctrl.device, in nvme_rdma_map_queues()
2182 ctrl->io_queues[HCTX_TYPE_DEFAULT], in nvme_rdma_map_queues()
2183 ctrl->io_queues[HCTX_TYPE_READ], in nvme_rdma_map_queues()
2184 ctrl->io_queues[HCTX_TYPE_POLL]); in nvme_rdma_map_queues()
2207 static void nvme_rdma_shutdown_ctrl(struct nvme_rdma_ctrl *ctrl, bool shutdown) in nvme_rdma_shutdown_ctrl() argument
2209 nvme_rdma_teardown_io_queues(ctrl, shutdown); in nvme_rdma_shutdown_ctrl()
2210 nvme_stop_admin_queue(&ctrl->ctrl); in nvme_rdma_shutdown_ctrl()
2212 nvme_shutdown_ctrl(&ctrl->ctrl); in nvme_rdma_shutdown_ctrl()
2214 nvme_disable_ctrl(&ctrl->ctrl); in nvme_rdma_shutdown_ctrl()
2215 nvme_rdma_teardown_admin_queue(ctrl, shutdown); in nvme_rdma_shutdown_ctrl()
2218 static void nvme_rdma_delete_ctrl(struct nvme_ctrl *ctrl) in nvme_rdma_delete_ctrl() argument
2220 nvme_rdma_shutdown_ctrl(to_rdma_ctrl(ctrl), true); in nvme_rdma_delete_ctrl()
2225 struct nvme_rdma_ctrl *ctrl = in nvme_rdma_reset_ctrl_work() local
2226 container_of(work, struct nvme_rdma_ctrl, ctrl.reset_work); in nvme_rdma_reset_ctrl_work()
2228 nvme_stop_ctrl(&ctrl->ctrl); in nvme_rdma_reset_ctrl_work()
2229 nvme_rdma_shutdown_ctrl(ctrl, false); in nvme_rdma_reset_ctrl_work()
2231 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) { in nvme_rdma_reset_ctrl_work()
2237 if (nvme_rdma_setup_ctrl(ctrl, false)) in nvme_rdma_reset_ctrl_work()
2243 ++ctrl->ctrl.nr_reconnects; in nvme_rdma_reset_ctrl_work()
2244 nvme_rdma_reconnect_or_remove(ctrl); in nvme_rdma_reset_ctrl_work()
2276 struct nvme_rdma_ctrl *ctrl; in nvme_rdma_existing_controller() local
2280 list_for_each_entry(ctrl, &nvme_rdma_ctrl_list, list) { in nvme_rdma_existing_controller()
2281 found = nvmf_ip_options_match(&ctrl->ctrl, opts); in nvme_rdma_existing_controller()
2293 struct nvme_rdma_ctrl *ctrl; in nvme_rdma_create_ctrl() local
2297 ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); in nvme_rdma_create_ctrl()
2298 if (!ctrl) in nvme_rdma_create_ctrl()
2300 ctrl->ctrl.opts = opts; in nvme_rdma_create_ctrl()
2301 INIT_LIST_HEAD(&ctrl->list); in nvme_rdma_create_ctrl()
2314 opts->traddr, opts->trsvcid, &ctrl->addr); in nvme_rdma_create_ctrl()
2323 opts->host_traddr, NULL, &ctrl->src_addr); in nvme_rdma_create_ctrl()
2336 INIT_DELAYED_WORK(&ctrl->reconnect_work, in nvme_rdma_create_ctrl()
2338 INIT_WORK(&ctrl->err_work, nvme_rdma_error_recovery_work); in nvme_rdma_create_ctrl()
2339 INIT_WORK(&ctrl->ctrl.reset_work, nvme_rdma_reset_ctrl_work); in nvme_rdma_create_ctrl()
2341 ctrl->ctrl.queue_count = opts->nr_io_queues + opts->nr_write_queues + in nvme_rdma_create_ctrl()
2343 ctrl->ctrl.sqsize = opts->queue_size - 1; in nvme_rdma_create_ctrl()
2344 ctrl->ctrl.kato = opts->kato; in nvme_rdma_create_ctrl()
2347 ctrl->queues = kcalloc(ctrl->ctrl.queue_count, sizeof(*ctrl->queues), in nvme_rdma_create_ctrl()
2349 if (!ctrl->queues) in nvme_rdma_create_ctrl()
2352 ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_rdma_ctrl_ops, in nvme_rdma_create_ctrl()
2357 changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING); in nvme_rdma_create_ctrl()
2360 ret = nvme_rdma_setup_ctrl(ctrl, true); in nvme_rdma_create_ctrl()
2364 dev_info(ctrl->ctrl.device, "new ctrl: NQN \"%s\", addr %pISpcs\n", in nvme_rdma_create_ctrl()
2365 nvmf_ctrl_subsysnqn(&ctrl->ctrl), &ctrl->addr); in nvme_rdma_create_ctrl()
2368 list_add_tail(&ctrl->list, &nvme_rdma_ctrl_list); in nvme_rdma_create_ctrl()
2371 return &ctrl->ctrl; in nvme_rdma_create_ctrl()
2374 nvme_uninit_ctrl(&ctrl->ctrl); in nvme_rdma_create_ctrl()
2375 nvme_put_ctrl(&ctrl->ctrl); in nvme_rdma_create_ctrl()
2380 kfree(ctrl->queues); in nvme_rdma_create_ctrl()
2382 kfree(ctrl); in nvme_rdma_create_ctrl()
2399 struct nvme_rdma_ctrl *ctrl; in nvme_rdma_remove_one() local
2417 list_for_each_entry(ctrl, &nvme_rdma_ctrl_list, list) { in nvme_rdma_remove_one()
2418 if (ctrl->device->dev != ib_device) in nvme_rdma_remove_one()
2420 nvme_delete_ctrl(&ctrl->ctrl); in nvme_rdma_remove_one()
2453 struct nvme_rdma_ctrl *ctrl; in nvme_rdma_cleanup_module() local
2459 list_for_each_entry(ctrl, &nvme_rdma_ctrl_list, list) in nvme_rdma_cleanup_module()
2460 nvme_delete_ctrl(&ctrl->ctrl); in nvme_rdma_cleanup_module()