Lines Matching +full:blk +full:- +full:ctrl

1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (c) 2011-2014, Intel Corporation.
13 #include <linux/blk-mq.h>
14 #include <linux/sed-opal.h>
15 #include <linux/fault-inject.h>
18 #include <linux/t10-pi.h>
124 * Use non-standard 128 bytes SQEs.
173 * MSI (but not MSI-X) interrupts are broken and never fire.
185 * this structure as the first member of their request-private data.
197 struct nvme_ctrl *ctrl; member
219 if (!req->q->queuedata) in nvme_req_qid()
222 return req->mq_hctx->queue_num + 1; in nvme_req_qid()
246 * @NVME_CTRL_DEAD: Controller is non-present/unresponsive during
415 static inline enum nvme_ctrl_state nvme_ctrl_state(struct nvme_ctrl *ctrl) in nvme_ctrl_state() argument
417 return READ_ONCE(ctrl->state); in nvme_ctrl_state()
466 * there is a 1:1 relation to our namespace structures, that is ->list
519 return IS_ENABLED(CONFIG_NVME_MULTIPATH) && head->disk; in nvme_ns_head_multipath()
531 struct nvme_ctrl *ctrl; member
558 return head->pi_type && head->ms == head->pi_size; in nvme_ns_has_pi()
570 int (*reg_read32)(struct nvme_ctrl *ctrl, u32 off, u32 *val);
571 int (*reg_write32)(struct nvme_ctrl *ctrl, u32 off, u32 val);
572 int (*reg_read64)(struct nvme_ctrl *ctrl, u32 off, u64 *val);
573 void (*free_ctrl)(struct nvme_ctrl *ctrl);
574 void (*submit_async_event)(struct nvme_ctrl *ctrl);
575 int (*subsystem_reset)(struct nvme_ctrl *ctrl);
576 void (*delete_ctrl)(struct nvme_ctrl *ctrl);
577 void (*stop_ctrl)(struct nvme_ctrl *ctrl);
578 int (*get_address)(struct nvme_ctrl *ctrl, char *buf, int size);
579 void (*print_device_info)(struct nvme_ctrl *ctrl);
580 bool (*supports_pci_p2pdma)(struct nvme_ctrl *ctrl);
595 return nvme_cid_install_genctr(nvme_req(rq)->genctr) | rq->tag; in nvme_cid()
611 if (unlikely(nvme_genctr_mask(nvme_req(rq)->genctr) != genctr)) { in nvme_find_rq()
612 dev_err(nvme_req(rq)->ctrl->device, in nvme_find_rq()
614 tag, genctr, nvme_genctr_mask(nvme_req(rq)->genctr)); in nvme_find_rq()
631 while (s[len - 1] == ' ') in nvme_strlen()
632 len--; in nvme_strlen()
636 static inline void nvme_print_device_info(struct nvme_ctrl *ctrl) in nvme_print_device_info() argument
638 struct nvme_subsystem *subsys = ctrl->subsys; in nvme_print_device_info()
640 if (ctrl->ops->print_device_info) { in nvme_print_device_info()
641 ctrl->ops->print_device_info(ctrl); in nvme_print_device_info()
645 dev_err(ctrl->device, in nvme_print_device_info()
646 "VID:%04x model:%.*s firmware:%.*s\n", subsys->vendor_id, in nvme_print_device_info()
647 nvme_strlen(subsys->model, sizeof(subsys->model)), in nvme_print_device_info()
648 subsys->model, nvme_strlen(subsys->firmware_rev, in nvme_print_device_info()
649 sizeof(subsys->firmware_rev)), in nvme_print_device_info()
650 subsys->firmware_rev); in nvme_print_device_info()
669 bool nvme_wait_reset(struct nvme_ctrl *ctrl);
670 int nvme_try_sched_reset(struct nvme_ctrl *ctrl);
672 static inline int nvme_reset_subsystem(struct nvme_ctrl *ctrl) in nvme_reset_subsystem() argument
674 if (!ctrl->subsystem || !ctrl->ops->subsystem_reset) in nvme_reset_subsystem()
675 return -ENOTTY; in nvme_reset_subsystem()
676 return ctrl->ops->subsystem_reset(ctrl); in nvme_reset_subsystem()
684 return sector >> (head->lba_shift - SECTOR_SHIFT); in nvme_sect_to_lba()
692 return lba << (head->lba_shift - SECTOR_SHIFT); in nvme_lba_to_sect()
696 * Convert byte length to nvme's 0-based num dwords
700 return (len >> 2) - 1; in nvme_bytes_to_numd()
723 * if blk-mq will need to use IPI magic to complete the request, and if yes do
731 struct nvme_ctrl *ctrl = rq->ctrl; in nvme_try_complete_req() local
733 if (!(ctrl->quirks & NVME_QUIRK_SKIP_CID_GEN)) in nvme_try_complete_req()
734 rq->genctr++; in nvme_try_complete_req()
736 rq->status = le16_to_cpu(status) >> 1; in nvme_try_complete_req()
737 rq->result = result; in nvme_try_complete_req()
740 if (unlikely(blk_should_fake_timeout(req->q))) in nvme_try_complete_req()
745 static inline void nvme_get_ctrl(struct nvme_ctrl *ctrl) in nvme_get_ctrl() argument
747 get_device(ctrl->device); in nvme_get_ctrl()
750 static inline void nvme_put_ctrl(struct nvme_ctrl *ctrl) in nvme_put_ctrl() argument
752 put_device(ctrl->device); in nvme_put_ctrl()
764 static inline bool nvme_state_terminal(struct nvme_ctrl *ctrl) in nvme_state_terminal() argument
766 switch (nvme_ctrl_state(ctrl)) { in nvme_state_terminal()
777 WARN_ONCE(1, "Unhandled ctrl state:%d", ctrl->state); in nvme_state_terminal()
791 rq_list_for_each(&iob->req_list, req) { in nvme_complete_batch()
800 void nvme_cancel_tagset(struct nvme_ctrl *ctrl);
801 void nvme_cancel_admin_tagset(struct nvme_ctrl *ctrl);
802 bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
804 int nvme_disable_ctrl(struct nvme_ctrl *ctrl, bool shutdown);
805 int nvme_enable_ctrl(struct nvme_ctrl *ctrl);
806 int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,
808 int nvme_add_ctrl(struct nvme_ctrl *ctrl);
809 void nvme_uninit_ctrl(struct nvme_ctrl *ctrl);
810 void nvme_start_ctrl(struct nvme_ctrl *ctrl);
811 void nvme_stop_ctrl(struct nvme_ctrl *ctrl);
812 int nvme_init_ctrl_finish(struct nvme_ctrl *ctrl, bool was_suspended);
813 int nvme_alloc_admin_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set,
815 void nvme_remove_admin_tag_set(struct nvme_ctrl *ctrl);
816 int nvme_alloc_io_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set,
819 void nvme_remove_io_tag_set(struct nvme_ctrl *ctrl);
821 void nvme_remove_namespaces(struct nvme_ctrl *ctrl);
823 void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status,
826 void nvme_quiesce_io_queues(struct nvme_ctrl *ctrl);
827 void nvme_unquiesce_io_queues(struct nvme_ctrl *ctrl);
828 void nvme_quiesce_admin_queue(struct nvme_ctrl *ctrl);
829 void nvme_unquiesce_admin_queue(struct nvme_ctrl *ctrl);
830 void nvme_mark_namespaces_dead(struct nvme_ctrl *ctrl);
831 void nvme_sync_queues(struct nvme_ctrl *ctrl);
832 void nvme_sync_io_queues(struct nvme_ctrl *ctrl);
833 void nvme_unfreeze(struct nvme_ctrl *ctrl);
834 void nvme_wait_freeze(struct nvme_ctrl *ctrl);
835 int nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl, long timeout);
836 void nvme_start_freeze(struct nvme_ctrl *ctrl);
843 #define NVME_QID_ANY -1
847 blk_status_t nvme_fail_nonready_command(struct nvme_ctrl *ctrl,
849 bool __nvme_check_ready(struct nvme_ctrl *ctrl, struct request *rq,
852 static inline bool nvme_check_ready(struct nvme_ctrl *ctrl, struct request *rq, in nvme_check_ready() argument
855 enum nvme_ctrl_state state = nvme_ctrl_state(ctrl); in nvme_check_ready()
859 if (ctrl->ops->flags & NVME_F_FABRICS && state == NVME_CTRL_DELETING) in nvme_check_ready()
861 return __nvme_check_ready(ctrl, rq, queue_live, state); in nvme_check_ready()
873 static inline bool nvme_is_unique_nsid(struct nvme_ctrl *ctrl, in nvme_is_unique_nsid() argument
876 return head->shared || in nvme_is_unique_nsid()
877 (ctrl->oacs & NVME_CTRL_OACS_NS_MNGT_SUPP) || in nvme_is_unique_nsid()
878 (ctrl->subsys->cmic & NVME_CTRL_CMIC_ANA) || in nvme_is_unique_nsid()
879 (ctrl->ctratt & NVME_CTRL_CTRATT_NVM_SETS); in nvme_is_unique_nsid()
909 int nvme_set_queue_count(struct nvme_ctrl *ctrl, int *count);
910 void nvme_stop_keep_alive(struct nvme_ctrl *ctrl);
911 int nvme_reset_ctrl(struct nvme_ctrl *ctrl);
912 int nvme_reset_ctrl_sync(struct nvme_ctrl *ctrl);
913 int nvme_delete_ctrl(struct nvme_ctrl *ctrl);
914 void nvme_queue_scan(struct nvme_ctrl *ctrl);
915 int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp, u8 csi,
937 int nvme_identify_ns(struct nvme_ctrl *ctrl, unsigned nsid,
951 void nvme_delete_ctrl_sync(struct nvme_ctrl *ctrl);
954 static inline bool nvme_ctrl_use_ana(struct nvme_ctrl *ctrl) in nvme_ctrl_use_ana() argument
956 return ctrl->ana_log_buf != NULL; in nvme_ctrl_use_ana()
964 void nvme_kick_requeue_lists(struct nvme_ctrl *ctrl);
965 int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl,struct nvme_ns_head *head);
970 int nvme_mpath_init_identify(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id);
971 void nvme_mpath_init_ctrl(struct nvme_ctrl *ctrl);
972 void nvme_mpath_update(struct nvme_ctrl *ctrl);
973 void nvme_mpath_uninit(struct nvme_ctrl *ctrl);
974 void nvme_mpath_stop(struct nvme_ctrl *ctrl);
977 void nvme_mpath_clear_ctrl_paths(struct nvme_ctrl *ctrl);
984 struct nvme_ns *ns = req->q->queuedata; in nvme_trace_bio_complete()
986 if ((req->cmd_flags & REQ_NVME_MPATH) && req->bio) in nvme_trace_bio_complete()
987 trace_block_bio_complete(ns->head->disk->queue, req->bio); in nvme_trace_bio_complete()
1000 return disk->fops == &nvme_ns_head_ops; in nvme_disk_is_ns_head()
1004 if (test_bit(NVME_NSHEAD_QUEUE_IF_NO_PATH, &head->flags)) in nvme_mpath_queue_if_no_path()
1010 static inline bool nvme_ctrl_use_ana(struct nvme_ctrl *ctrl) in nvme_ctrl_use_ana() argument
1017 static inline void nvme_kick_requeue_lists(struct nvme_ctrl *ctrl) in nvme_kick_requeue_lists() argument
1020 static inline int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl, in nvme_mpath_alloc_disk() argument
1044 static inline void nvme_mpath_clear_ctrl_paths(struct nvme_ctrl *ctrl) in nvme_mpath_clear_ctrl_paths() argument
1053 static inline void nvme_mpath_init_ctrl(struct nvme_ctrl *ctrl) in nvme_mpath_init_ctrl() argument
1056 static inline int nvme_mpath_init_identify(struct nvme_ctrl *ctrl, in nvme_mpath_init_identify() argument
1059 if (ctrl->subsys->cmic & NVME_CTRL_CMIC_ANA) in nvme_mpath_init_identify()
1060 dev_warn(ctrl->device, in nvme_mpath_init_identify()
1061 "Please enable CONFIG_NVME_MULTIPATH for full support of multi-port devices.\n"); in nvme_mpath_init_identify()
1064 static inline void nvme_mpath_update(struct nvme_ctrl *ctrl) in nvme_mpath_update() argument
1067 static inline void nvme_mpath_uninit(struct nvme_ctrl *ctrl) in nvme_mpath_uninit() argument
1070 static inline void nvme_mpath_stop(struct nvme_ctrl *ctrl) in nvme_mpath_stop() argument
1134 return disk->private_data; in nvme_get_ns_from_dev()
1138 int nvme_hwmon_init(struct nvme_ctrl *ctrl);
1139 void nvme_hwmon_exit(struct nvme_ctrl *ctrl);
1141 static inline int nvme_hwmon_init(struct nvme_ctrl *ctrl) in nvme_hwmon_init() argument
1146 static inline void nvme_hwmon_exit(struct nvme_ctrl *ctrl) in nvme_hwmon_exit() argument
1153 if (rq->cmd_flags & REQ_NVME_MPATH) in nvme_start_request()
1158 static inline bool nvme_ctrl_sgl_supported(struct nvme_ctrl *ctrl) in nvme_ctrl_sgl_supported() argument
1160 return ctrl->sgls & (NVME_CTRL_SGLS_BYTE_ALIGNED | in nvme_ctrl_sgl_supported()
1164 static inline bool nvme_ctrl_meta_sgl_supported(struct nvme_ctrl *ctrl) in nvme_ctrl_meta_sgl_supported() argument
1166 if (ctrl->ops->flags & NVME_F_FABRICS) in nvme_ctrl_meta_sgl_supported()
1168 return ctrl->sgls & NVME_CTRL_SGLS_MSDS; in nvme_ctrl_meta_sgl_supported()
1174 int nvme_auth_init_ctrl(struct nvme_ctrl *ctrl);
1175 void nvme_auth_stop(struct nvme_ctrl *ctrl);
1176 int nvme_auth_negotiate(struct nvme_ctrl *ctrl, int qid);
1177 int nvme_auth_wait(struct nvme_ctrl *ctrl, int qid);
1178 void nvme_auth_free(struct nvme_ctrl *ctrl);
1179 void nvme_auth_revoke_tls_key(struct nvme_ctrl *ctrl);
1181 static inline int nvme_auth_init_ctrl(struct nvme_ctrl *ctrl) in nvme_auth_init_ctrl() argument
1192 static inline void nvme_auth_stop(struct nvme_ctrl *ctrl) {}; in nvme_auth_stop() argument
1193 static inline int nvme_auth_negotiate(struct nvme_ctrl *ctrl, int qid) in nvme_auth_negotiate() argument
1195 return -EPROTONOSUPPORT; in nvme_auth_negotiate()
1197 static inline int nvme_auth_wait(struct nvme_ctrl *ctrl, int qid) in nvme_auth_wait() argument
1199 return -EPROTONOSUPPORT; in nvme_auth_wait()
1201 static inline void nvme_auth_free(struct nvme_ctrl *ctrl) {}; in nvme_auth_free() argument
1202 static inline void nvme_auth_revoke_tls_key(struct nvme_ctrl *ctrl) {}; in nvme_auth_revoke_tls_key() argument
1205 u32 nvme_command_effects(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
1207 u32 nvme_passthru_start(struct nvme_ctrl *ctrl, struct nvme_ns *ns, u8 opcode);
1209 void nvme_passthru_end(struct nvme_ctrl *ctrl, struct nvme_ns *ns, u32 effects,
1212 struct nvme_ns *nvme_find_get_ns(struct nvme_ctrl *ctrl, unsigned nsid);
1216 static inline bool nvme_multi_css(struct nvme_ctrl *ctrl) in nvme_multi_css() argument
1218 return (ctrl->ctrl_config & NVME_CC_CSS_MASK) == NVME_CC_CSS_CSI; in nvme_multi_css()