Lines Matching refs:req

27 static inline void nvmet_clear_aen(struct nvmet_req *req, u32 aen_bit)  in nvmet_clear_aen()  argument
29 int rae = le32_to_cpu(req->cmd->common.cdw10[0]) & 1 << 15; in nvmet_clear_aen()
32 clear_bit(aen_bit, &req->sq->ctrl->aen_masked); in nvmet_clear_aen()
48 static void nvmet_execute_get_log_page_noop(struct nvmet_req *req) in nvmet_execute_get_log_page_noop() argument
50 nvmet_req_complete(req, nvmet_zero_sgl(req, 0, req->data_len)); in nvmet_execute_get_log_page_noop()
53 static u16 nvmet_get_smart_log_nsid(struct nvmet_req *req, in nvmet_get_smart_log_nsid() argument
59 ns = nvmet_find_namespace(req->sq->ctrl, req->cmd->get_log_page.nsid); in nvmet_get_smart_log_nsid()
62 le32_to_cpu(req->cmd->get_log_page.nsid)); in nvmet_get_smart_log_nsid()
85 static u16 nvmet_get_smart_log_all(struct nvmet_req *req, in nvmet_get_smart_log_all() argument
93 ctrl = req->sq->ctrl; in nvmet_get_smart_log_all()
118 static void nvmet_execute_get_log_page_smart(struct nvmet_req *req) in nvmet_execute_get_log_page_smart() argument
123 if (req->data_len != sizeof(*log)) in nvmet_execute_get_log_page_smart()
130 if (req->cmd->get_log_page.nsid == cpu_to_le32(NVME_NSID_ALL)) in nvmet_execute_get_log_page_smart()
131 status = nvmet_get_smart_log_all(req, log); in nvmet_execute_get_log_page_smart()
133 status = nvmet_get_smart_log_nsid(req, log); in nvmet_execute_get_log_page_smart()
137 status = nvmet_copy_to_sgl(req, 0, log, sizeof(*log)); in nvmet_execute_get_log_page_smart()
141 nvmet_req_complete(req, status); in nvmet_execute_get_log_page_smart()
144 static void nvmet_execute_get_log_cmd_effects_ns(struct nvmet_req *req) in nvmet_execute_get_log_cmd_effects_ns() argument
167 status = nvmet_copy_to_sgl(req, 0, log, sizeof(*log)); in nvmet_execute_get_log_cmd_effects_ns()
171 nvmet_req_complete(req, status); in nvmet_execute_get_log_cmd_effects_ns()
174 static void nvmet_execute_get_log_changed_ns(struct nvmet_req *req) in nvmet_execute_get_log_changed_ns() argument
176 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_get_log_changed_ns()
180 if (req->data_len != NVME_MAX_CHANGED_NAMESPACES * sizeof(__le32)) in nvmet_execute_get_log_changed_ns()
188 status = nvmet_copy_to_sgl(req, 0, ctrl->changed_ns_list, len); in nvmet_execute_get_log_changed_ns()
190 status = nvmet_zero_sgl(req, len, req->data_len - len); in nvmet_execute_get_log_changed_ns()
192 nvmet_clear_aen(req, NVME_AEN_CFG_NS_ATTR); in nvmet_execute_get_log_changed_ns()
195 nvmet_req_complete(req, status); in nvmet_execute_get_log_changed_ns()
198 static u32 nvmet_format_ana_group(struct nvmet_req *req, u32 grpid, in nvmet_format_ana_group() argument
201 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_format_ana_group()
205 if (!(req->cmd->get_log_page.lsp & NVME_ANA_LOG_RGO)) { in nvmet_format_ana_group()
216 desc->state = req->port->ana_state[grpid]; in nvmet_format_ana_group()
221 static void nvmet_execute_get_log_page_ana(struct nvmet_req *req) in nvmet_execute_get_log_page_ana() argument
241 len = nvmet_format_ana_group(req, grpid, desc); in nvmet_execute_get_log_page_ana()
242 status = nvmet_copy_to_sgl(req, offset, desc, len); in nvmet_execute_get_log_page_ana()
255 nvmet_clear_aen(req, NVME_AEN_CFG_ANA_CHANGE); in nvmet_execute_get_log_page_ana()
261 status = nvmet_copy_to_sgl(req, 0, &hdr, sizeof(hdr)); in nvmet_execute_get_log_page_ana()
263 nvmet_req_complete(req, status); in nvmet_execute_get_log_page_ana()
266 static void nvmet_execute_identify_ctrl(struct nvmet_req *req) in nvmet_execute_identify_ctrl() argument
268 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_identify_ctrl()
353 if (req->port->inline_data_size) in nvmet_execute_identify_ctrl()
360 req->port->inline_data_size) / 16); in nvmet_execute_identify_ctrl()
381 status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id)); in nvmet_execute_identify_ctrl()
385 nvmet_req_complete(req, status); in nvmet_execute_identify_ctrl()
388 static void nvmet_execute_identify_ns(struct nvmet_req *req) in nvmet_execute_identify_ns() argument
394 if (le32_to_cpu(req->cmd->identify.nsid) == NVME_NSID_ALL) { in nvmet_execute_identify_ns()
406 ns = nvmet_find_namespace(req->sq->ctrl, req->cmd->identify.nsid); in nvmet_execute_identify_ns()
415 switch (req->port->ana_state[ns->anagrpid]) { in nvmet_execute_identify_ns()
446 status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id)); in nvmet_execute_identify_ns()
449 nvmet_req_complete(req, status); in nvmet_execute_identify_ns()
452 static void nvmet_execute_identify_nslist(struct nvmet_req *req) in nvmet_execute_identify_nslist() argument
455 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_identify_nslist()
457 u32 min_nsid = le32_to_cpu(req->cmd->identify.nsid); in nvmet_execute_identify_nslist()
478 status = nvmet_copy_to_sgl(req, 0, list, buf_size); in nvmet_execute_identify_nslist()
482 nvmet_req_complete(req, status); in nvmet_execute_identify_nslist()
485 static u16 nvmet_copy_ns_identifier(struct nvmet_req *req, u8 type, u8 len, in nvmet_copy_ns_identifier() argument
494 status = nvmet_copy_to_sgl(req, *off, &desc, sizeof(desc)); in nvmet_copy_ns_identifier()
499 status = nvmet_copy_to_sgl(req, *off, id, len); in nvmet_copy_ns_identifier()
507 static void nvmet_execute_identify_desclist(struct nvmet_req *req) in nvmet_execute_identify_desclist() argument
513 ns = nvmet_find_namespace(req->sq->ctrl, req->cmd->identify.nsid); in nvmet_execute_identify_desclist()
520 status = nvmet_copy_ns_identifier(req, NVME_NIDT_UUID, in nvmet_execute_identify_desclist()
527 status = nvmet_copy_ns_identifier(req, NVME_NIDT_NGUID, in nvmet_execute_identify_desclist()
534 if (sg_zero_buffer(req->sg, req->sg_cnt, NVME_IDENTIFY_DATA_SIZE - off, in nvmet_execute_identify_desclist()
540 nvmet_req_complete(req, status); in nvmet_execute_identify_desclist()
550 static void nvmet_execute_abort(struct nvmet_req *req) in nvmet_execute_abort() argument
552 nvmet_set_result(req, 1); in nvmet_execute_abort()
553 nvmet_req_complete(req, 0); in nvmet_execute_abort()
556 static u16 nvmet_write_protect_flush_sync(struct nvmet_req *req) in nvmet_write_protect_flush_sync() argument
560 if (req->ns->file) in nvmet_write_protect_flush_sync()
561 status = nvmet_file_flush(req); in nvmet_write_protect_flush_sync()
563 status = nvmet_bdev_flush(req); in nvmet_write_protect_flush_sync()
566 pr_err("write protect flush failed nsid: %u\n", req->ns->nsid); in nvmet_write_protect_flush_sync()
570 static u16 nvmet_set_feat_write_protect(struct nvmet_req *req) in nvmet_set_feat_write_protect() argument
572 u32 write_protect = le32_to_cpu(req->cmd->common.cdw10[1]); in nvmet_set_feat_write_protect()
573 struct nvmet_subsys *subsys = req->sq->ctrl->subsys; in nvmet_set_feat_write_protect()
576 req->ns = nvmet_find_namespace(req->sq->ctrl, req->cmd->rw.nsid); in nvmet_set_feat_write_protect()
577 if (unlikely(!req->ns)) in nvmet_set_feat_write_protect()
583 req->ns->readonly = true; in nvmet_set_feat_write_protect()
584 status = nvmet_write_protect_flush_sync(req); in nvmet_set_feat_write_protect()
586 req->ns->readonly = false; in nvmet_set_feat_write_protect()
589 req->ns->readonly = false; in nvmet_set_feat_write_protect()
597 nvmet_ns_changed(subsys, req->ns->nsid); in nvmet_set_feat_write_protect()
602 static void nvmet_execute_set_features(struct nvmet_req *req) in nvmet_execute_set_features() argument
604 struct nvmet_subsys *subsys = req->sq->ctrl->subsys; in nvmet_execute_set_features()
605 u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10[0]); in nvmet_execute_set_features()
611 nvmet_set_result(req, in nvmet_execute_set_features()
615 val32 = le32_to_cpu(req->cmd->common.cdw10[1]); in nvmet_execute_set_features()
616 req->sq->ctrl->kato = DIV_ROUND_UP(val32, 1000); in nvmet_execute_set_features()
617 nvmet_set_result(req, req->sq->ctrl->kato); in nvmet_execute_set_features()
620 val32 = le32_to_cpu(req->cmd->common.cdw10[1]); in nvmet_execute_set_features()
626 WRITE_ONCE(req->sq->ctrl->aen_enabled, val32); in nvmet_execute_set_features()
627 nvmet_set_result(req, val32); in nvmet_execute_set_features()
633 status = nvmet_set_feat_write_protect(req); in nvmet_execute_set_features()
640 nvmet_req_complete(req, status); in nvmet_execute_set_features()
643 static u16 nvmet_get_feat_write_protect(struct nvmet_req *req) in nvmet_get_feat_write_protect() argument
645 struct nvmet_subsys *subsys = req->sq->ctrl->subsys; in nvmet_get_feat_write_protect()
648 req->ns = nvmet_find_namespace(req->sq->ctrl, req->cmd->common.nsid); in nvmet_get_feat_write_protect()
649 if (!req->ns) in nvmet_get_feat_write_protect()
653 if (req->ns->readonly == true) in nvmet_get_feat_write_protect()
657 nvmet_set_result(req, result); in nvmet_get_feat_write_protect()
663 static void nvmet_execute_get_features(struct nvmet_req *req) in nvmet_execute_get_features() argument
665 struct nvmet_subsys *subsys = req->sq->ctrl->subsys; in nvmet_execute_get_features()
666 u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10[0]); in nvmet_execute_get_features()
692 nvmet_set_result(req, READ_ONCE(req->sq->ctrl->aen_enabled)); in nvmet_execute_get_features()
695 nvmet_set_result(req, 1); in nvmet_execute_get_features()
698 nvmet_set_result(req, in nvmet_execute_get_features()
702 nvmet_set_result(req, req->sq->ctrl->kato * 1000); in nvmet_execute_get_features()
706 if (!(req->cmd->common.cdw10[1] & cpu_to_le32(1 << 0))) { in nvmet_execute_get_features()
711 status = nvmet_copy_to_sgl(req, 0, &req->sq->ctrl->hostid, in nvmet_execute_get_features()
712 sizeof(req->sq->ctrl->hostid)); in nvmet_execute_get_features()
715 status = nvmet_get_feat_write_protect(req); in nvmet_execute_get_features()
722 nvmet_req_complete(req, status); in nvmet_execute_get_features()
725 static void nvmet_execute_async_event(struct nvmet_req *req) in nvmet_execute_async_event() argument
727 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_async_event()
732 nvmet_req_complete(req, NVME_SC_ASYNC_LIMIT | NVME_SC_DNR); in nvmet_execute_async_event()
735 ctrl->async_event_cmds[ctrl->nr_async_event_cmds++] = req; in nvmet_execute_async_event()
741 static void nvmet_execute_keep_alive(struct nvmet_req *req) in nvmet_execute_keep_alive() argument
743 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_keep_alive()
749 nvmet_req_complete(req, 0); in nvmet_execute_keep_alive()
752 u16 nvmet_parse_admin_cmd(struct nvmet_req *req) in nvmet_parse_admin_cmd() argument
754 struct nvme_command *cmd = req->cmd; in nvmet_parse_admin_cmd()
757 ret = nvmet_check_ctrl_status(req, cmd); in nvmet_parse_admin_cmd()
763 req->data_len = nvmet_get_log_page_len(cmd); in nvmet_parse_admin_cmd()
773 req->execute = nvmet_execute_get_log_page_noop; in nvmet_parse_admin_cmd()
776 req->execute = nvmet_execute_get_log_page_smart; in nvmet_parse_admin_cmd()
785 req->execute = nvmet_execute_get_log_page_noop; in nvmet_parse_admin_cmd()
788 req->execute = nvmet_execute_get_log_changed_ns; in nvmet_parse_admin_cmd()
791 req->execute = nvmet_execute_get_log_cmd_effects_ns; in nvmet_parse_admin_cmd()
794 req->execute = nvmet_execute_get_log_page_ana; in nvmet_parse_admin_cmd()
799 req->data_len = NVME_IDENTIFY_DATA_SIZE; in nvmet_parse_admin_cmd()
802 req->execute = nvmet_execute_identify_ns; in nvmet_parse_admin_cmd()
805 req->execute = nvmet_execute_identify_ctrl; in nvmet_parse_admin_cmd()
808 req->execute = nvmet_execute_identify_nslist; in nvmet_parse_admin_cmd()
811 req->execute = nvmet_execute_identify_desclist; in nvmet_parse_admin_cmd()
816 req->execute = nvmet_execute_abort; in nvmet_parse_admin_cmd()
817 req->data_len = 0; in nvmet_parse_admin_cmd()
820 req->execute = nvmet_execute_set_features; in nvmet_parse_admin_cmd()
821 req->data_len = 0; in nvmet_parse_admin_cmd()
824 req->execute = nvmet_execute_get_features; in nvmet_parse_admin_cmd()
825 req->data_len = 0; in nvmet_parse_admin_cmd()
828 req->execute = nvmet_execute_async_event; in nvmet_parse_admin_cmd()
829 req->data_len = 0; in nvmet_parse_admin_cmd()
832 req->execute = nvmet_execute_keep_alive; in nvmet_parse_admin_cmd()
833 req->data_len = 0; in nvmet_parse_admin_cmd()
838 req->sq->qid); in nvmet_parse_admin_cmd()