Lines Matching full:req
28 static u32 nvmet_feat_data_len(struct nvmet_req *req, u32 cdw10) in nvmet_feat_data_len() argument
32 return sizeof(req->sq->ctrl->hostid); in nvmet_feat_data_len()
43 static void nvmet_execute_get_log_page_noop(struct nvmet_req *req) in nvmet_execute_get_log_page_noop() argument
45 nvmet_req_complete(req, nvmet_zero_sgl(req, 0, req->transfer_len)); in nvmet_execute_get_log_page_noop()
48 static void nvmet_execute_get_log_page_error(struct nvmet_req *req) in nvmet_execute_get_log_page_error() argument
50 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_get_log_page_error()
60 if (nvmet_copy_to_sgl(req, offset, &ctrl->slots[slot], in nvmet_execute_get_log_page_error()
71 nvmet_req_complete(req, 0); in nvmet_execute_get_log_page_error()
74 static u16 nvmet_get_smart_log_nsid(struct nvmet_req *req, in nvmet_get_smart_log_nsid() argument
80 ns = nvmet_find_namespace(req->sq->ctrl, req->cmd->get_log_page.nsid); in nvmet_get_smart_log_nsid()
83 le32_to_cpu(req->cmd->get_log_page.nsid)); in nvmet_get_smart_log_nsid()
84 req->error_loc = offsetof(struct nvme_rw_command, nsid); in nvmet_get_smart_log_nsid()
109 static u16 nvmet_get_smart_log_all(struct nvmet_req *req, in nvmet_get_smart_log_all() argument
118 ctrl = req->sq->ctrl; in nvmet_get_smart_log_all()
139 static void nvmet_execute_get_log_page_smart(struct nvmet_req *req) in nvmet_execute_get_log_page_smart() argument
145 if (req->transfer_len != sizeof(*log)) in nvmet_execute_get_log_page_smart()
152 if (req->cmd->get_log_page.nsid == cpu_to_le32(NVME_NSID_ALL)) in nvmet_execute_get_log_page_smart()
153 status = nvmet_get_smart_log_all(req, log); in nvmet_execute_get_log_page_smart()
155 status = nvmet_get_smart_log_nsid(req, log); in nvmet_execute_get_log_page_smart()
159 spin_lock_irqsave(&req->sq->ctrl->error_lock, flags); in nvmet_execute_get_log_page_smart()
160 put_unaligned_le64(req->sq->ctrl->err_counter, in nvmet_execute_get_log_page_smart()
162 spin_unlock_irqrestore(&req->sq->ctrl->error_lock, flags); in nvmet_execute_get_log_page_smart()
164 status = nvmet_copy_to_sgl(req, 0, log, sizeof(*log)); in nvmet_execute_get_log_page_smart()
168 nvmet_req_complete(req, status); in nvmet_execute_get_log_page_smart()
171 static void nvmet_execute_get_log_cmd_effects_ns(struct nvmet_req *req) in nvmet_execute_get_log_cmd_effects_ns() argument
194 status = nvmet_copy_to_sgl(req, 0, log, sizeof(*log)); in nvmet_execute_get_log_cmd_effects_ns()
198 nvmet_req_complete(req, status); in nvmet_execute_get_log_cmd_effects_ns()
201 static void nvmet_execute_get_log_changed_ns(struct nvmet_req *req) in nvmet_execute_get_log_changed_ns() argument
203 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_get_log_changed_ns()
207 if (req->transfer_len != NVME_MAX_CHANGED_NAMESPACES * sizeof(__le32)) in nvmet_execute_get_log_changed_ns()
215 status = nvmet_copy_to_sgl(req, 0, ctrl->changed_ns_list, len); in nvmet_execute_get_log_changed_ns()
217 status = nvmet_zero_sgl(req, len, req->transfer_len - len); in nvmet_execute_get_log_changed_ns()
219 nvmet_clear_aen_bit(req, NVME_AEN_BIT_NS_ATTR); in nvmet_execute_get_log_changed_ns()
222 nvmet_req_complete(req, status); in nvmet_execute_get_log_changed_ns()
225 static u32 nvmet_format_ana_group(struct nvmet_req *req, u32 grpid, in nvmet_format_ana_group() argument
228 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_format_ana_group()
233 if (!(req->cmd->get_log_page.lsp & NVME_ANA_LOG_RGO)) { in nvmet_format_ana_group()
242 desc->state = req->port->ana_state[grpid]; in nvmet_format_ana_group()
247 static void nvmet_execute_get_log_page_ana(struct nvmet_req *req) in nvmet_execute_get_log_page_ana() argument
267 len = nvmet_format_ana_group(req, grpid, desc); in nvmet_execute_get_log_page_ana()
268 status = nvmet_copy_to_sgl(req, offset, desc, len); in nvmet_execute_get_log_page_ana()
281 nvmet_clear_aen_bit(req, NVME_AEN_BIT_ANA_CHANGE); in nvmet_execute_get_log_page_ana()
287 status = nvmet_copy_to_sgl(req, 0, &hdr, sizeof(hdr)); in nvmet_execute_get_log_page_ana()
289 nvmet_req_complete(req, status); in nvmet_execute_get_log_page_ana()
292 static void nvmet_execute_get_log_page(struct nvmet_req *req) in nvmet_execute_get_log_page() argument
294 if (!nvmet_check_transfer_len(req, nvmet_get_log_page_len(req->cmd))) in nvmet_execute_get_log_page()
297 switch (req->cmd->get_log_page.lid) { in nvmet_execute_get_log_page()
299 return nvmet_execute_get_log_page_error(req); in nvmet_execute_get_log_page()
301 return nvmet_execute_get_log_page_smart(req); in nvmet_execute_get_log_page()
308 return nvmet_execute_get_log_page_noop(req); in nvmet_execute_get_log_page()
310 return nvmet_execute_get_log_changed_ns(req); in nvmet_execute_get_log_page()
312 return nvmet_execute_get_log_cmd_effects_ns(req); in nvmet_execute_get_log_page()
314 return nvmet_execute_get_log_page_ana(req); in nvmet_execute_get_log_page()
317 req->cmd->get_log_page.lid, req->sq->qid); in nvmet_execute_get_log_page()
318 req->error_loc = offsetof(struct nvme_get_log_page_command, lid); in nvmet_execute_get_log_page()
319 nvmet_req_complete(req, NVME_SC_INVALID_FIELD | NVME_SC_DNR); in nvmet_execute_get_log_page()
336 static void nvmet_execute_identify_ctrl(struct nvmet_req *req) in nvmet_execute_identify_ctrl() argument
338 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_identify_ctrl()
428 if (req->port->inline_data_size) in nvmet_execute_identify_ctrl()
439 cmd_capsule_size += req->port->inline_data_size; in nvmet_execute_identify_ctrl()
462 status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id)); in nvmet_execute_identify_ctrl()
466 nvmet_req_complete(req, status); in nvmet_execute_identify_ctrl()
469 static void nvmet_execute_identify_ns(struct nvmet_req *req) in nvmet_execute_identify_ns() argument
471 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_identify_ns()
476 if (le32_to_cpu(req->cmd->identify.nsid) == NVME_NSID_ALL) { in nvmet_execute_identify_ns()
477 req->error_loc = offsetof(struct nvme_identify, nsid); in nvmet_execute_identify_ns()
489 ns = nvmet_find_namespace(ctrl, req->cmd->identify.nsid); in nvmet_execute_identify_ns()
500 switch (req->port->ana_state[ns->anagrpid]) { in nvmet_execute_identify_ns()
544 status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id)); in nvmet_execute_identify_ns()
547 nvmet_req_complete(req, status); in nvmet_execute_identify_ns()
550 static void nvmet_execute_identify_nslist(struct nvmet_req *req) in nvmet_execute_identify_nslist() argument
553 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_identify_nslist()
556 u32 min_nsid = le32_to_cpu(req->cmd->identify.nsid); in nvmet_execute_identify_nslist()
575 status = nvmet_copy_to_sgl(req, 0, list, buf_size); in nvmet_execute_identify_nslist()
579 nvmet_req_complete(req, status); in nvmet_execute_identify_nslist()
582 static u16 nvmet_copy_ns_identifier(struct nvmet_req *req, u8 type, u8 len, in nvmet_copy_ns_identifier() argument
591 status = nvmet_copy_to_sgl(req, *off, &desc, sizeof(desc)); in nvmet_copy_ns_identifier()
596 status = nvmet_copy_to_sgl(req, *off, id, len); in nvmet_copy_ns_identifier()
604 static void nvmet_execute_identify_desclist(struct nvmet_req *req) in nvmet_execute_identify_desclist() argument
610 ns = nvmet_find_namespace(req->sq->ctrl, req->cmd->identify.nsid); in nvmet_execute_identify_desclist()
612 req->error_loc = offsetof(struct nvme_identify, nsid); in nvmet_execute_identify_desclist()
618 status = nvmet_copy_ns_identifier(req, NVME_NIDT_UUID, in nvmet_execute_identify_desclist()
625 status = nvmet_copy_ns_identifier(req, NVME_NIDT_NGUID, in nvmet_execute_identify_desclist()
632 if (sg_zero_buffer(req->sg, req->sg_cnt, NVME_IDENTIFY_DATA_SIZE - off, in nvmet_execute_identify_desclist()
638 nvmet_req_complete(req, status); in nvmet_execute_identify_desclist()
641 static void nvmet_execute_identify(struct nvmet_req *req) in nvmet_execute_identify() argument
643 if (!nvmet_check_transfer_len(req, NVME_IDENTIFY_DATA_SIZE)) in nvmet_execute_identify()
646 switch (req->cmd->identify.cns) { in nvmet_execute_identify()
648 return nvmet_execute_identify_ns(req); in nvmet_execute_identify()
650 return nvmet_execute_identify_ctrl(req); in nvmet_execute_identify()
652 return nvmet_execute_identify_nslist(req); in nvmet_execute_identify()
654 return nvmet_execute_identify_desclist(req); in nvmet_execute_identify()
658 req->cmd->identify.cns, req->sq->qid); in nvmet_execute_identify()
659 req->error_loc = offsetof(struct nvme_identify, cns); in nvmet_execute_identify()
660 nvmet_req_complete(req, NVME_SC_INVALID_FIELD | NVME_SC_DNR); in nvmet_execute_identify()
670 static void nvmet_execute_abort(struct nvmet_req *req) in nvmet_execute_abort() argument
672 if (!nvmet_check_transfer_len(req, 0)) in nvmet_execute_abort()
674 nvmet_set_result(req, 1); in nvmet_execute_abort()
675 nvmet_req_complete(req, 0); in nvmet_execute_abort()
678 static u16 nvmet_write_protect_flush_sync(struct nvmet_req *req) in nvmet_write_protect_flush_sync() argument
682 if (req->ns->file) in nvmet_write_protect_flush_sync()
683 status = nvmet_file_flush(req); in nvmet_write_protect_flush_sync()
685 status = nvmet_bdev_flush(req); in nvmet_write_protect_flush_sync()
688 pr_err("write protect flush failed nsid: %u\n", req->ns->nsid); in nvmet_write_protect_flush_sync()
692 static u16 nvmet_set_feat_write_protect(struct nvmet_req *req) in nvmet_set_feat_write_protect() argument
694 u32 write_protect = le32_to_cpu(req->cmd->common.cdw11); in nvmet_set_feat_write_protect()
695 struct nvmet_subsys *subsys = req->sq->ctrl->subsys; in nvmet_set_feat_write_protect()
698 req->ns = nvmet_find_namespace(req->sq->ctrl, req->cmd->rw.nsid); in nvmet_set_feat_write_protect()
699 if (unlikely(!req->ns)) { in nvmet_set_feat_write_protect()
700 req->error_loc = offsetof(struct nvme_common_command, nsid); in nvmet_set_feat_write_protect()
707 req->ns->readonly = true; in nvmet_set_feat_write_protect()
708 status = nvmet_write_protect_flush_sync(req); in nvmet_set_feat_write_protect()
710 req->ns->readonly = false; in nvmet_set_feat_write_protect()
713 req->ns->readonly = false; in nvmet_set_feat_write_protect()
721 nvmet_ns_changed(subsys, req->ns->nsid); in nvmet_set_feat_write_protect()
726 u16 nvmet_set_feat_kato(struct nvmet_req *req) in nvmet_set_feat_kato() argument
728 u32 val32 = le32_to_cpu(req->cmd->common.cdw11); in nvmet_set_feat_kato()
730 nvmet_stop_keep_alive_timer(req->sq->ctrl); in nvmet_set_feat_kato()
731 req->sq->ctrl->kato = DIV_ROUND_UP(val32, 1000); in nvmet_set_feat_kato()
732 nvmet_start_keep_alive_timer(req->sq->ctrl); in nvmet_set_feat_kato()
734 nvmet_set_result(req, req->sq->ctrl->kato); in nvmet_set_feat_kato()
739 u16 nvmet_set_feat_async_event(struct nvmet_req *req, u32 mask) in nvmet_set_feat_async_event() argument
741 u32 val32 = le32_to_cpu(req->cmd->common.cdw11); in nvmet_set_feat_async_event()
744 req->error_loc = offsetof(struct nvme_common_command, cdw11); in nvmet_set_feat_async_event()
748 WRITE_ONCE(req->sq->ctrl->aen_enabled, val32); in nvmet_set_feat_async_event()
749 nvmet_set_result(req, val32); in nvmet_set_feat_async_event()
754 void nvmet_execute_set_features(struct nvmet_req *req) in nvmet_execute_set_features() argument
756 struct nvmet_subsys *subsys = req->sq->ctrl->subsys; in nvmet_execute_set_features()
757 u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10); in nvmet_execute_set_features()
758 u32 cdw11 = le32_to_cpu(req->cmd->common.cdw11); in nvmet_execute_set_features()
763 if (!nvmet_check_transfer_len(req, 0)) in nvmet_execute_set_features()
774 nvmet_set_result(req, in nvmet_execute_set_features()
778 status = nvmet_set_feat_kato(req); in nvmet_execute_set_features()
781 status = nvmet_set_feat_async_event(req, NVMET_AEN_CFG_ALL); in nvmet_execute_set_features()
787 status = nvmet_set_feat_write_protect(req); in nvmet_execute_set_features()
790 req->error_loc = offsetof(struct nvme_common_command, cdw10); in nvmet_execute_set_features()
795 nvmet_req_complete(req, status); in nvmet_execute_set_features()
798 static u16 nvmet_get_feat_write_protect(struct nvmet_req *req) in nvmet_get_feat_write_protect() argument
800 struct nvmet_subsys *subsys = req->sq->ctrl->subsys; in nvmet_get_feat_write_protect()
803 req->ns = nvmet_find_namespace(req->sq->ctrl, req->cmd->common.nsid); in nvmet_get_feat_write_protect()
804 if (!req->ns) { in nvmet_get_feat_write_protect()
805 req->error_loc = offsetof(struct nvme_common_command, nsid); in nvmet_get_feat_write_protect()
809 if (req->ns->readonly == true) in nvmet_get_feat_write_protect()
813 nvmet_set_result(req, result); in nvmet_get_feat_write_protect()
819 void nvmet_get_feat_kato(struct nvmet_req *req) in nvmet_get_feat_kato() argument
821 nvmet_set_result(req, req->sq->ctrl->kato * 1000); in nvmet_get_feat_kato()
824 void nvmet_get_feat_async_event(struct nvmet_req *req) in nvmet_get_feat_async_event() argument
826 nvmet_set_result(req, READ_ONCE(req->sq->ctrl->aen_enabled)); in nvmet_get_feat_async_event()
829 void nvmet_execute_get_features(struct nvmet_req *req) in nvmet_execute_get_features() argument
831 struct nvmet_subsys *subsys = req->sq->ctrl->subsys; in nvmet_execute_get_features()
832 u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10); in nvmet_execute_get_features()
835 if (!nvmet_check_transfer_len(req, nvmet_feat_data_len(req, cdw10))) in nvmet_execute_get_features()
861 nvmet_get_feat_async_event(req); in nvmet_execute_get_features()
864 nvmet_set_result(req, 1); in nvmet_execute_get_features()
867 nvmet_set_result(req, in nvmet_execute_get_features()
871 nvmet_get_feat_kato(req); in nvmet_execute_get_features()
875 if (!(req->cmd->common.cdw11 & cpu_to_le32(1 << 0))) { in nvmet_execute_get_features()
876 req->error_loc = in nvmet_execute_get_features()
882 status = nvmet_copy_to_sgl(req, 0, &req->sq->ctrl->hostid, in nvmet_execute_get_features()
883 sizeof(req->sq->ctrl->hostid)); in nvmet_execute_get_features()
886 status = nvmet_get_feat_write_protect(req); in nvmet_execute_get_features()
889 req->error_loc = in nvmet_execute_get_features()
895 nvmet_req_complete(req, status); in nvmet_execute_get_features()
898 void nvmet_execute_async_event(struct nvmet_req *req) in nvmet_execute_async_event() argument
900 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_async_event()
902 if (!nvmet_check_transfer_len(req, 0)) in nvmet_execute_async_event()
908 nvmet_req_complete(req, NVME_SC_ASYNC_LIMIT | NVME_SC_DNR); in nvmet_execute_async_event()
911 ctrl->async_event_cmds[ctrl->nr_async_event_cmds++] = req; in nvmet_execute_async_event()
917 void nvmet_execute_keep_alive(struct nvmet_req *req) in nvmet_execute_keep_alive() argument
919 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_keep_alive()
921 if (!nvmet_check_transfer_len(req, 0)) in nvmet_execute_keep_alive()
928 nvmet_req_complete(req, 0); in nvmet_execute_keep_alive()
931 u16 nvmet_parse_admin_cmd(struct nvmet_req *req) in nvmet_parse_admin_cmd() argument
933 struct nvme_command *cmd = req->cmd; in nvmet_parse_admin_cmd()
937 return nvmet_parse_fabrics_cmd(req); in nvmet_parse_admin_cmd()
938 if (req->sq->ctrl->subsys->type == NVME_NQN_DISC) in nvmet_parse_admin_cmd()
939 return nvmet_parse_discovery_cmd(req); in nvmet_parse_admin_cmd()
941 ret = nvmet_check_ctrl_status(req, cmd); in nvmet_parse_admin_cmd()
945 if (nvmet_req_passthru_ctrl(req)) in nvmet_parse_admin_cmd()
946 return nvmet_parse_passthru_admin_cmd(req); in nvmet_parse_admin_cmd()
950 req->execute = nvmet_execute_get_log_page; in nvmet_parse_admin_cmd()
953 req->execute = nvmet_execute_identify; in nvmet_parse_admin_cmd()
956 req->execute = nvmet_execute_abort; in nvmet_parse_admin_cmd()
959 req->execute = nvmet_execute_set_features; in nvmet_parse_admin_cmd()
962 req->execute = nvmet_execute_get_features; in nvmet_parse_admin_cmd()
965 req->execute = nvmet_execute_async_event; in nvmet_parse_admin_cmd()
968 req->execute = nvmet_execute_keep_alive; in nvmet_parse_admin_cmd()
973 req->sq->qid); in nvmet_parse_admin_cmd()
974 req->error_loc = offsetof(struct nvme_common_command, opcode); in nvmet_parse_admin_cmd()