Lines Matching +full:ctrl +full:- +full:module

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>
115 * Use non-standard 128 bytes SQEs.
156 * this structure as the first member of their request-private data.
165 struct nvme_ctrl *ctrl; member
185 if (!req->q->queuedata) in nvme_req_qid()
188 return req->mq_hctx->queue_num + 1; in nvme_req_qid()
212 * @NVME_CTRL_DEAD: Controller is non-present/unresponsive during
419 * there is a 1:1 relation to our namespace structures, that is ->list
451 return IS_ENABLED(CONFIG_NVME_MULTIPATH) && head->disk; in nvme_ns_head_multipath()
462 struct nvme_ctrl *ctrl; member
502 return ns->pi_type && ns->ms == ns->pi_size; in nvme_ns_has_pi()
507 struct module *module; member
511 int (*reg_read32)(struct nvme_ctrl *ctrl, u32 off, u32 *val);
512 int (*reg_write32)(struct nvme_ctrl *ctrl, u32 off, u32 val);
513 int (*reg_read64)(struct nvme_ctrl *ctrl, u32 off, u64 *val);
514 void (*free_ctrl)(struct nvme_ctrl *ctrl);
515 void (*submit_async_event)(struct nvme_ctrl *ctrl);
516 void (*delete_ctrl)(struct nvme_ctrl *ctrl);
517 void (*stop_ctrl)(struct nvme_ctrl *ctrl);
518 int (*get_address)(struct nvme_ctrl *ctrl, char *buf, int size);
519 void (*print_device_info)(struct nvme_ctrl *ctrl);
520 bool (*supports_pci_p2pdma)(struct nvme_ctrl *ctrl);
535 return nvme_cid_install_genctr(nvme_req(rq)->genctr) | rq->tag; in nvme_cid()
551 if (unlikely(nvme_genctr_mask(nvme_req(rq)->genctr) != genctr)) { in nvme_find_rq()
552 dev_err(nvme_req(rq)->ctrl->device, in nvme_find_rq()
554 tag, genctr, nvme_genctr_mask(nvme_req(rq)->genctr)); in nvme_find_rq()
571 while (s[len - 1] == ' ') in nvme_strlen()
572 len--; in nvme_strlen()
576 static inline void nvme_print_device_info(struct nvme_ctrl *ctrl) in nvme_print_device_info() argument
578 struct nvme_subsystem *subsys = ctrl->subsys; in nvme_print_device_info()
580 if (ctrl->ops->print_device_info) { in nvme_print_device_info()
581 ctrl->ops->print_device_info(ctrl); in nvme_print_device_info()
585 dev_err(ctrl->device, in nvme_print_device_info()
586 "VID:%04x model:%.*s firmware:%.*s\n", subsys->vendor_id, in nvme_print_device_info()
587 nvme_strlen(subsys->model, sizeof(subsys->model)), in nvme_print_device_info()
588 subsys->model, nvme_strlen(subsys->firmware_rev, in nvme_print_device_info()
589 sizeof(subsys->firmware_rev)), in nvme_print_device_info()
590 subsys->firmware_rev); in nvme_print_device_info()
609 bool nvme_wait_reset(struct nvme_ctrl *ctrl);
610 int nvme_try_sched_reset(struct nvme_ctrl *ctrl);
612 static inline int nvme_reset_subsystem(struct nvme_ctrl *ctrl) in nvme_reset_subsystem() argument
616 if (!ctrl->subsystem) in nvme_reset_subsystem()
617 return -ENOTTY; in nvme_reset_subsystem()
618 if (!nvme_wait_reset(ctrl)) in nvme_reset_subsystem()
619 return -EBUSY; in nvme_reset_subsystem()
621 ret = ctrl->ops->reg_write32(ctrl, NVME_REG_NSSR, 0x4E564D65); in nvme_reset_subsystem()
625 return nvme_try_sched_reset(ctrl); in nvme_reset_subsystem()
633 return sector >> (ns->lba_shift - SECTOR_SHIFT); in nvme_sect_to_lba()
641 return lba << (ns->lba_shift - SECTOR_SHIFT); in nvme_lba_to_sect()
645 * Convert byte length to nvme's 0-based num dwords
649 return (len >> 2) - 1; in nvme_bytes_to_numd()
672 * if blk-mq will need to use IPI magic to complete the request, and if yes do
680 struct nvme_ctrl *ctrl = rq->ctrl; in nvme_try_complete_req() local
682 if (!(ctrl->quirks & NVME_QUIRK_SKIP_CID_GEN)) in nvme_try_complete_req()
683 rq->genctr++; in nvme_try_complete_req()
685 rq->status = le16_to_cpu(status) >> 1; in nvme_try_complete_req()
686 rq->result = result; in nvme_try_complete_req()
689 if (unlikely(blk_should_fake_timeout(req->q))) in nvme_try_complete_req()
694 static inline void nvme_get_ctrl(struct nvme_ctrl *ctrl) in nvme_get_ctrl() argument
696 get_device(ctrl->device); in nvme_get_ctrl()
699 static inline void nvme_put_ctrl(struct nvme_ctrl *ctrl) in nvme_put_ctrl() argument
701 put_device(ctrl->device); in nvme_put_ctrl()
718 rq_list_for_each(&iob->req_list, req) { in nvme_complete_batch()
727 void nvme_cancel_tagset(struct nvme_ctrl *ctrl);
728 void nvme_cancel_admin_tagset(struct nvme_ctrl *ctrl);
729 bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
731 int nvme_disable_ctrl(struct nvme_ctrl *ctrl);
732 int nvme_enable_ctrl(struct nvme_ctrl *ctrl);
733 int nvme_shutdown_ctrl(struct nvme_ctrl *ctrl);
734 int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,
736 void nvme_uninit_ctrl(struct nvme_ctrl *ctrl);
737 void nvme_start_ctrl(struct nvme_ctrl *ctrl);
738 void nvme_stop_ctrl(struct nvme_ctrl *ctrl);
739 int nvme_init_ctrl_finish(struct nvme_ctrl *ctrl);
740 int nvme_alloc_admin_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set,
743 void nvme_remove_admin_tag_set(struct nvme_ctrl *ctrl);
744 int nvme_alloc_io_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set,
747 void nvme_remove_io_tag_set(struct nvme_ctrl *ctrl);
749 void nvme_remove_namespaces(struct nvme_ctrl *ctrl);
754 void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status,
757 void nvme_stop_queues(struct nvme_ctrl *ctrl);
758 void nvme_start_queues(struct nvme_ctrl *ctrl);
759 void nvme_stop_admin_queue(struct nvme_ctrl *ctrl);
760 void nvme_start_admin_queue(struct nvme_ctrl *ctrl);
761 void nvme_kill_queues(struct nvme_ctrl *ctrl);
762 void nvme_sync_queues(struct nvme_ctrl *ctrl);
763 void nvme_sync_io_queues(struct nvme_ctrl *ctrl);
764 void nvme_unfreeze(struct nvme_ctrl *ctrl);
765 void nvme_wait_freeze(struct nvme_ctrl *ctrl);
766 int nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl, long timeout);
767 void nvme_start_freeze(struct nvme_ctrl *ctrl);
774 #define NVME_QID_ANY -1
778 blk_status_t nvme_fail_nonready_command(struct nvme_ctrl *ctrl,
780 bool __nvme_check_ready(struct nvme_ctrl *ctrl, struct request *rq,
783 static inline bool nvme_check_ready(struct nvme_ctrl *ctrl, struct request *rq, in nvme_check_ready() argument
786 if (likely(ctrl->state == NVME_CTRL_LIVE)) in nvme_check_ready()
788 if (ctrl->ops->flags & NVME_F_FABRICS && in nvme_check_ready()
789 ctrl->state == NVME_CTRL_DELETING) in nvme_check_ready()
791 return __nvme_check_ready(ctrl, rq, queue_live); in nvme_check_ready()
803 static inline bool nvme_is_unique_nsid(struct nvme_ctrl *ctrl, in nvme_is_unique_nsid() argument
806 return head->shared || in nvme_is_unique_nsid()
807 (ctrl->oacs & NVME_CTRL_OACS_NS_MNGT_SUPP) || in nvme_is_unique_nsid()
808 (ctrl->subsys->cmic & NVME_CTRL_CMIC_ANA) || in nvme_is_unique_nsid()
809 (ctrl->ctratt & NVME_CTRL_CTRATT_NVM_SETS); in nvme_is_unique_nsid()
824 int nvme_set_queue_count(struct nvme_ctrl *ctrl, int *count);
825 void nvme_stop_keep_alive(struct nvme_ctrl *ctrl);
826 int nvme_reset_ctrl(struct nvme_ctrl *ctrl);
827 int nvme_reset_ctrl_sync(struct nvme_ctrl *ctrl);
828 int nvme_delete_ctrl(struct nvme_ctrl *ctrl);
829 void nvme_queue_scan(struct nvme_ctrl *ctrl);
830 int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp, u8 csi,
835 const struct file_operations *fops, struct module *owner);
863 static inline bool nvme_ctrl_use_ana(struct nvme_ctrl *ctrl) in nvme_ctrl_use_ana() argument
865 return ctrl->ana_log_buf != NULL; in nvme_ctrl_use_ana()
873 void nvme_kick_requeue_lists(struct nvme_ctrl *ctrl);
874 int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl,struct nvme_ns_head *head);
877 int nvme_mpath_init_identify(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id);
878 void nvme_mpath_init_ctrl(struct nvme_ctrl *ctrl);
879 void nvme_mpath_update(struct nvme_ctrl *ctrl);
880 void nvme_mpath_uninit(struct nvme_ctrl *ctrl);
881 void nvme_mpath_stop(struct nvme_ctrl *ctrl);
884 void nvme_mpath_clear_ctrl_paths(struct nvme_ctrl *ctrl);
889 struct nvme_ns *ns = req->q->queuedata; in nvme_trace_bio_complete()
891 if (req->cmd_flags & REQ_NVME_MPATH) in nvme_trace_bio_complete()
892 trace_block_bio_complete(ns->head->disk->queue, req->bio); in nvme_trace_bio_complete()
902 static inline bool nvme_ctrl_use_ana(struct nvme_ctrl *ctrl) in nvme_ctrl_use_ana() argument
909 static inline void nvme_kick_requeue_lists(struct nvme_ctrl *ctrl) in nvme_kick_requeue_lists() argument
912 static inline int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl, in nvme_mpath_alloc_disk() argument
930 static inline void nvme_mpath_clear_ctrl_paths(struct nvme_ctrl *ctrl) in nvme_mpath_clear_ctrl_paths() argument
939 static inline void nvme_mpath_init_ctrl(struct nvme_ctrl *ctrl) in nvme_mpath_init_ctrl() argument
942 static inline int nvme_mpath_init_identify(struct nvme_ctrl *ctrl, in nvme_mpath_init_identify() argument
945 if (ctrl->subsys->cmic & NVME_CTRL_CMIC_ANA) in nvme_mpath_init_identify()
946 dev_warn(ctrl->device, in nvme_mpath_init_identify()
947 "Please enable CONFIG_NVME_MULTIPATH for full support of multi-port devices.\n"); in nvme_mpath_init_identify()
950 static inline void nvme_mpath_update(struct nvme_ctrl *ctrl) in nvme_mpath_update() argument
953 static inline void nvme_mpath_uninit(struct nvme_ctrl *ctrl) in nvme_mpath_uninit() argument
956 static inline void nvme_mpath_stop(struct nvme_ctrl *ctrl) in nvme_mpath_stop() argument
991 dev_warn(ns->ctrl->device, in nvme_update_zone_info()
993 return -EPROTONOSUPPORT; in nvme_update_zone_info()
999 return dev_to_disk(dev)->private_data; in nvme_get_ns_from_dev()
1003 int nvme_hwmon_init(struct nvme_ctrl *ctrl);
1004 void nvme_hwmon_exit(struct nvme_ctrl *ctrl);
1006 static inline int nvme_hwmon_init(struct nvme_ctrl *ctrl) in nvme_hwmon_init() argument
1011 static inline void nvme_hwmon_exit(struct nvme_ctrl *ctrl) in nvme_hwmon_exit() argument
1016 static inline bool nvme_ctrl_sgl_supported(struct nvme_ctrl *ctrl) in nvme_ctrl_sgl_supported() argument
1018 return ctrl->sgls & ((1 << 0) | (1 << 1)); in nvme_ctrl_sgl_supported()
1022 void nvme_auth_init_ctrl(struct nvme_ctrl *ctrl);
1023 void nvme_auth_stop(struct nvme_ctrl *ctrl);
1024 int nvme_auth_negotiate(struct nvme_ctrl *ctrl, int qid);
1025 int nvme_auth_wait(struct nvme_ctrl *ctrl, int qid);
1026 void nvme_auth_reset(struct nvme_ctrl *ctrl);
1027 void nvme_auth_free(struct nvme_ctrl *ctrl);
1029 static inline void nvme_auth_init_ctrl(struct nvme_ctrl *ctrl) {}; in nvme_auth_init_ctrl() argument
1030 static inline void nvme_auth_stop(struct nvme_ctrl *ctrl) {}; in nvme_auth_stop() argument
1031 static inline int nvme_auth_negotiate(struct nvme_ctrl *ctrl, int qid) in nvme_auth_negotiate() argument
1033 return -EPROTONOSUPPORT; in nvme_auth_negotiate()
1035 static inline int nvme_auth_wait(struct nvme_ctrl *ctrl, int qid) in nvme_auth_wait() argument
1039 static inline void nvme_auth_free(struct nvme_ctrl *ctrl) {}; in nvme_auth_free() argument
1042 u32 nvme_command_effects(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
1045 void nvme_passthru_end(struct nvme_ctrl *ctrl, u32 effects,
1048 struct nvme_ns *nvme_find_get_ns(struct nvme_ctrl *ctrl, unsigned nsid);
1051 static inline bool nvme_multi_css(struct nvme_ctrl *ctrl) in nvme_multi_css() argument
1053 return (ctrl->ctrl_config & NVME_CC_CSS_MASK) == NVME_CC_CSS_CSI; in nvme_multi_css()