Lines Matching full:req

15 static void nvmet_execute_delete_sq(struct nvmet_req *req)  in nvmet_execute_delete_sq()  argument
17 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_delete_sq()
18 u16 sqid = le16_to_cpu(req->cmd->delete_queue.qid); in nvmet_execute_delete_sq()
22 status = nvmet_report_invalid_opcode(req); in nvmet_execute_delete_sq()
38 nvmet_req_complete(req, status); in nvmet_execute_delete_sq()
41 static void nvmet_execute_create_sq(struct nvmet_req *req) in nvmet_execute_create_sq() argument
43 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_create_sq()
44 struct nvme_command *cmd = req->cmd; in nvmet_execute_create_sq()
53 status = nvmet_report_invalid_opcode(req); in nvmet_execute_create_sq()
80 nvmet_req_complete(req, status); in nvmet_execute_create_sq()
83 static void nvmet_execute_delete_cq(struct nvmet_req *req) in nvmet_execute_delete_cq() argument
85 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_delete_cq()
86 u16 cqid = le16_to_cpu(req->cmd->delete_queue.qid); in nvmet_execute_delete_cq()
90 status = nvmet_report_invalid_opcode(req); in nvmet_execute_delete_cq()
107 nvmet_req_complete(req, status); in nvmet_execute_delete_cq()
110 static void nvmet_execute_create_cq(struct nvmet_req *req) in nvmet_execute_create_cq() argument
112 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_create_cq()
113 struct nvme_command *cmd = req->cmd; in nvmet_execute_create_cq()
122 status = nvmet_report_invalid_opcode(req); in nvmet_execute_create_cq()
139 nvmet_req_complete(req, status); in nvmet_execute_create_cq()
155 static u32 nvmet_feat_data_len(struct nvmet_req *req, u32 cdw10) in nvmet_feat_data_len() argument
159 return sizeof(req->sq->ctrl->hostid); in nvmet_feat_data_len()
170 static void nvmet_execute_get_log_page_noop(struct nvmet_req *req) in nvmet_execute_get_log_page_noop() argument
172 nvmet_req_complete(req, nvmet_zero_sgl(req, 0, req->transfer_len)); in nvmet_execute_get_log_page_noop()
175 static void nvmet_execute_get_log_page_error(struct nvmet_req *req) in nvmet_execute_get_log_page_error() argument
177 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_get_log_page_error()
187 if (nvmet_copy_to_sgl(req, offset, &ctrl->slots[slot], in nvmet_execute_get_log_page_error()
198 nvmet_req_complete(req, 0); in nvmet_execute_get_log_page_error()
201 static void nvmet_execute_get_supported_log_pages(struct nvmet_req *req) in nvmet_execute_get_supported_log_pages() argument
224 status = nvmet_copy_to_sgl(req, 0, logs, sizeof(*logs)); in nvmet_execute_get_supported_log_pages()
227 nvmet_req_complete(req, status); in nvmet_execute_get_supported_log_pages()
230 static u16 nvmet_get_smart_log_nsid(struct nvmet_req *req, in nvmet_get_smart_log_nsid() argument
236 status = nvmet_req_find_ns(req); in nvmet_get_smart_log_nsid()
241 if (!req->ns->bdev) in nvmet_get_smart_log_nsid()
244 host_reads = part_stat_read(req->ns->bdev, ios[READ]); in nvmet_get_smart_log_nsid()
246 DIV_ROUND_UP(part_stat_read(req->ns->bdev, sectors[READ]), 1000); in nvmet_get_smart_log_nsid()
247 host_writes = part_stat_read(req->ns->bdev, ios[WRITE]); in nvmet_get_smart_log_nsid()
249 DIV_ROUND_UP(part_stat_read(req->ns->bdev, sectors[WRITE]), 1000); in nvmet_get_smart_log_nsid()
259 static u16 nvmet_get_smart_log_all(struct nvmet_req *req, in nvmet_get_smart_log_all() argument
268 ctrl = req->sq->ctrl; in nvmet_get_smart_log_all()
289 static void nvmet_execute_get_log_page_rmi(struct nvmet_req *req) in nvmet_execute_get_log_page_rmi() argument
295 req->cmd->common.nsid = cpu_to_le32(le16_to_cpu( in nvmet_execute_get_log_page_rmi()
296 req->cmd->get_log_page.lsi)); in nvmet_execute_get_log_page_rmi()
297 status = nvmet_req_find_ns(req); in nvmet_execute_get_log_page_rmi()
301 if (!req->ns->bdev || bdev_nonrot(req->ns->bdev)) { in nvmet_execute_get_log_page_rmi()
306 if (req->transfer_len != sizeof(*log)) { in nvmet_execute_get_log_page_rmi()
315 log->endgid = req->cmd->get_log_page.lsi; in nvmet_execute_get_log_page_rmi()
316 disk = req->ns->bdev->bd_disk; in nvmet_execute_get_log_page_rmi()
322 status = nvmet_copy_to_sgl(req, 0, log, sizeof(*log)); in nvmet_execute_get_log_page_rmi()
325 nvmet_req_complete(req, status); in nvmet_execute_get_log_page_rmi()
328 static void nvmet_execute_get_log_page_smart(struct nvmet_req *req) in nvmet_execute_get_log_page_smart() argument
334 if (req->transfer_len != sizeof(*log)) in nvmet_execute_get_log_page_smart()
341 if (req->cmd->get_log_page.nsid == cpu_to_le32(NVME_NSID_ALL)) in nvmet_execute_get_log_page_smart()
342 status = nvmet_get_smart_log_all(req, log); in nvmet_execute_get_log_page_smart()
344 status = nvmet_get_smart_log_nsid(req, log); in nvmet_execute_get_log_page_smart()
348 spin_lock_irqsave(&req->sq->ctrl->error_lock, flags); in nvmet_execute_get_log_page_smart()
349 put_unaligned_le64(req->sq->ctrl->err_counter, in nvmet_execute_get_log_page_smart()
351 spin_unlock_irqrestore(&req->sq->ctrl->error_lock, flags); in nvmet_execute_get_log_page_smart()
353 status = nvmet_copy_to_sgl(req, 0, log, sizeof(*log)); in nvmet_execute_get_log_page_smart()
357 nvmet_req_complete(req, status); in nvmet_execute_get_log_page_smart()
406 static void nvmet_execute_get_log_cmd_effects_ns(struct nvmet_req *req) in nvmet_execute_get_log_cmd_effects_ns() argument
408 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_get_log_cmd_effects_ns()
418 switch (req->cmd->get_log_page.csi) { in nvmet_execute_get_log_cmd_effects_ns()
437 status = nvmet_copy_to_sgl(req, 0, log, sizeof(*log)); in nvmet_execute_get_log_cmd_effects_ns()
441 nvmet_req_complete(req, status); in nvmet_execute_get_log_cmd_effects_ns()
444 static void nvmet_execute_get_log_changed_ns(struct nvmet_req *req) in nvmet_execute_get_log_changed_ns() argument
446 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_get_log_changed_ns()
450 if (req->transfer_len != NVME_MAX_CHANGED_NAMESPACES * sizeof(__le32)) in nvmet_execute_get_log_changed_ns()
458 status = nvmet_copy_to_sgl(req, 0, ctrl->changed_ns_list, len); in nvmet_execute_get_log_changed_ns()
460 status = nvmet_zero_sgl(req, len, req->transfer_len - len); in nvmet_execute_get_log_changed_ns()
462 nvmet_clear_aen_bit(req, NVME_AEN_BIT_NS_ATTR); in nvmet_execute_get_log_changed_ns()
465 nvmet_req_complete(req, status); in nvmet_execute_get_log_changed_ns()
468 static u32 nvmet_format_ana_group(struct nvmet_req *req, u32 grpid, in nvmet_format_ana_group() argument
471 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_format_ana_group()
476 if (!(req->cmd->get_log_page.lsp & NVME_ANA_LOG_RGO)) { in nvmet_format_ana_group()
486 desc->state = req->port->ana_state[grpid]; in nvmet_format_ana_group()
491 static void nvmet_execute_get_log_page_endgrp(struct nvmet_req *req) in nvmet_execute_get_log_page_endgrp() argument
501 req->cmd->common.nsid = cpu_to_le32(le16_to_cpu( in nvmet_execute_get_log_page_endgrp()
502 req->cmd->get_log_page.lsi)); in nvmet_execute_get_log_page_endgrp()
503 status = nvmet_req_find_ns(req); in nvmet_execute_get_log_page_endgrp()
513 if (!req->ns->bdev) in nvmet_execute_get_log_page_endgrp()
516 host_reads = part_stat_read(req->ns->bdev, ios[READ]); in nvmet_execute_get_log_page_endgrp()
518 DIV_ROUND_UP(part_stat_read(req->ns->bdev, sectors[READ]), 1000); in nvmet_execute_get_log_page_endgrp()
519 host_writes = part_stat_read(req->ns->bdev, ios[WRITE]); in nvmet_execute_get_log_page_endgrp()
521 DIV_ROUND_UP(part_stat_read(req->ns->bdev, sectors[WRITE]), 1000); in nvmet_execute_get_log_page_endgrp()
528 status = nvmet_copy_to_sgl(req, 0, log, sizeof(*log)); in nvmet_execute_get_log_page_endgrp()
531 nvmet_req_complete(req, status); in nvmet_execute_get_log_page_endgrp()
534 static void nvmet_execute_get_log_page_ana(struct nvmet_req *req) in nvmet_execute_get_log_page_ana() argument
554 len = nvmet_format_ana_group(req, grpid, desc); in nvmet_execute_get_log_page_ana()
555 status = nvmet_copy_to_sgl(req, offset, desc, len); in nvmet_execute_get_log_page_ana()
568 nvmet_clear_aen_bit(req, NVME_AEN_BIT_ANA_CHANGE); in nvmet_execute_get_log_page_ana()
574 status = nvmet_copy_to_sgl(req, 0, &hdr, sizeof(hdr)); in nvmet_execute_get_log_page_ana()
576 nvmet_req_complete(req, status); in nvmet_execute_get_log_page_ana()
579 static void nvmet_execute_get_log_page_features(struct nvmet_req *req) in nvmet_execute_get_log_page_features() argument
603 status = nvmet_copy_to_sgl(req, 0, features, sizeof(*features)); in nvmet_execute_get_log_page_features()
606 nvmet_req_complete(req, status); in nvmet_execute_get_log_page_features()
609 static void nvmet_execute_get_log_page(struct nvmet_req *req) in nvmet_execute_get_log_page() argument
611 if (!nvmet_check_transfer_len(req, nvmet_get_log_page_len(req->cmd))) in nvmet_execute_get_log_page()
614 switch (req->cmd->get_log_page.lid) { in nvmet_execute_get_log_page()
616 return nvmet_execute_get_supported_log_pages(req); in nvmet_execute_get_log_page()
618 return nvmet_execute_get_log_page_error(req); in nvmet_execute_get_log_page()
620 return nvmet_execute_get_log_page_smart(req); in nvmet_execute_get_log_page()
627 return nvmet_execute_get_log_page_noop(req); in nvmet_execute_get_log_page()
629 return nvmet_execute_get_log_changed_ns(req); in nvmet_execute_get_log_page()
631 return nvmet_execute_get_log_cmd_effects_ns(req); in nvmet_execute_get_log_page()
633 return nvmet_execute_get_log_page_endgrp(req); in nvmet_execute_get_log_page()
635 return nvmet_execute_get_log_page_ana(req); in nvmet_execute_get_log_page()
637 return nvmet_execute_get_log_page_features(req); in nvmet_execute_get_log_page()
639 return nvmet_execute_get_log_page_rmi(req); in nvmet_execute_get_log_page()
641 return nvmet_execute_get_log_page_resv(req); in nvmet_execute_get_log_page()
644 req->cmd->get_log_page.lid, req->sq->qid); in nvmet_execute_get_log_page()
645 req->error_loc = offsetof(struct nvme_get_log_page_command, lid); in nvmet_execute_get_log_page()
646 nvmet_req_complete(req, NVME_SC_INVALID_FIELD | NVME_STATUS_DNR); in nvmet_execute_get_log_page()
649 static void nvmet_execute_identify_ctrl(struct nvmet_req *req) in nvmet_execute_identify_ctrl() argument
651 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_identify_ctrl()
753 if (req->port->inline_data_size) in nvmet_execute_identify_ctrl()
764 cmd_capsule_size += req->port->inline_data_size; in nvmet_execute_identify_ctrl()
794 status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id)); in nvmet_execute_identify_ctrl()
798 nvmet_req_complete(req, status); in nvmet_execute_identify_ctrl()
801 static void nvmet_execute_identify_ns(struct nvmet_req *req) in nvmet_execute_identify_ns() argument
806 if (le32_to_cpu(req->cmd->identify.nsid) == NVME_NSID_ALL) { in nvmet_execute_identify_ns()
807 req->error_loc = offsetof(struct nvme_identify, nsid); in nvmet_execute_identify_ns()
819 status = nvmet_req_find_ns(req); in nvmet_execute_identify_ns()
825 if (nvmet_ns_revalidate(req->ns)) { in nvmet_execute_identify_ns()
826 mutex_lock(&req->ns->subsys->lock); in nvmet_execute_identify_ns()
827 nvmet_ns_changed(req->ns->subsys, req->ns->nsid); in nvmet_execute_identify_ns()
828 mutex_unlock(&req->ns->subsys->lock); in nvmet_execute_identify_ns()
836 cpu_to_le64(req->ns->size >> req->ns->blksize_shift); in nvmet_execute_identify_ns()
837 switch (req->port->ana_state[req->ns->anagrpid]) { in nvmet_execute_identify_ns()
846 if (req->ns->bdev) in nvmet_execute_identify_ns()
847 nvmet_bdev_set_limits(req->ns->bdev, id); in nvmet_execute_identify_ns()
861 id->anagrpid = cpu_to_le32(req->ns->anagrpid); in nvmet_execute_identify_ns()
863 if (req->ns->pr.enable) in nvmet_execute_identify_ns()
876 id->endgid = cpu_to_le16(req->ns->nsid); in nvmet_execute_identify_ns()
878 memcpy(&id->nguid, &req->ns->nguid, sizeof(id->nguid)); in nvmet_execute_identify_ns()
880 id->lbaf[0].ds = req->ns->blksize_shift; in nvmet_execute_identify_ns()
882 if (req->sq->ctrl->pi_support && nvmet_ns_has_pi(req->ns)) { in nvmet_execute_identify_ns()
887 id->dps = req->ns->pi_type; in nvmet_execute_identify_ns()
889 id->lbaf[0].ms = cpu_to_le16(req->ns->metadata_size); in nvmet_execute_identify_ns()
892 if (req->ns->readonly) in nvmet_execute_identify_ns()
896 status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id)); in nvmet_execute_identify_ns()
900 nvmet_req_complete(req, status); in nvmet_execute_identify_ns()
903 static void nvmet_execute_identify_endgrp_list(struct nvmet_req *req) in nvmet_execute_identify_endgrp_list() argument
905 u16 min_endgid = le16_to_cpu(req->cmd->identify.cnssid); in nvmet_execute_identify_endgrp_list()
907 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_identify_endgrp_list()
930 status = nvmet_copy_to_sgl(req, 0, list, buf_size); in nvmet_execute_identify_endgrp_list()
933 nvmet_req_complete(req, status); in nvmet_execute_identify_endgrp_list()
936 static void nvmet_execute_identify_nslist(struct nvmet_req *req, bool match_css) in nvmet_execute_identify_nslist() argument
939 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_identify_nslist()
942 u32 min_nsid = le32_to_cpu(req->cmd->identify.nsid); in nvmet_execute_identify_nslist()
952 req->error_loc = offsetof(struct nvme_identify, nsid); in nvmet_execute_identify_nslist()
966 if (match_css && req->ns->csi != req->cmd->identify.csi) in nvmet_execute_identify_nslist()
973 status = nvmet_copy_to_sgl(req, 0, list, buf_size); in nvmet_execute_identify_nslist()
977 nvmet_req_complete(req, status); in nvmet_execute_identify_nslist()
980 static u16 nvmet_copy_ns_identifier(struct nvmet_req *req, u8 type, u8 len, in nvmet_copy_ns_identifier() argument
989 status = nvmet_copy_to_sgl(req, *off, &desc, sizeof(desc)); in nvmet_copy_ns_identifier()
994 status = nvmet_copy_to_sgl(req, *off, id, len); in nvmet_copy_ns_identifier()
1002 static void nvmet_execute_identify_desclist(struct nvmet_req *req) in nvmet_execute_identify_desclist() argument
1007 status = nvmet_req_find_ns(req); in nvmet_execute_identify_desclist()
1011 if (memchr_inv(&req->ns->uuid, 0, sizeof(req->ns->uuid))) { in nvmet_execute_identify_desclist()
1012 status = nvmet_copy_ns_identifier(req, NVME_NIDT_UUID, in nvmet_execute_identify_desclist()
1014 &req->ns->uuid, &off); in nvmet_execute_identify_desclist()
1018 if (memchr_inv(req->ns->nguid, 0, sizeof(req->ns->nguid))) { in nvmet_execute_identify_desclist()
1019 status = nvmet_copy_ns_identifier(req, NVME_NIDT_NGUID, in nvmet_execute_identify_desclist()
1021 &req->ns->nguid, &off); in nvmet_execute_identify_desclist()
1026 status = nvmet_copy_ns_identifier(req, NVME_NIDT_CSI, in nvmet_execute_identify_desclist()
1028 &req->ns->csi, &off); in nvmet_execute_identify_desclist()
1032 if (sg_zero_buffer(req->sg, req->sg_cnt, NVME_IDENTIFY_DATA_SIZE - off, in nvmet_execute_identify_desclist()
1037 nvmet_req_complete(req, status); in nvmet_execute_identify_desclist()
1040 static void nvmet_execute_identify_ctrl_nvm(struct nvmet_req *req) in nvmet_execute_identify_ctrl_nvm() argument
1043 nvmet_req_complete(req, in nvmet_execute_identify_ctrl_nvm()
1044 nvmet_zero_sgl(req, 0, sizeof(struct nvme_id_ctrl_nvm))); in nvmet_execute_identify_ctrl_nvm()
1047 static void nvme_execute_identify_ns_nvm(struct nvmet_req *req) in nvme_execute_identify_ns_nvm() argument
1052 status = nvmet_req_find_ns(req); in nvme_execute_identify_ns_nvm()
1061 status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id)); in nvme_execute_identify_ns_nvm()
1064 nvmet_req_complete(req, status); in nvme_execute_identify_ns_nvm()
1067 static void nvmet_execute_id_cs_indep(struct nvmet_req *req) in nvmet_execute_id_cs_indep() argument
1072 status = nvmet_req_find_ns(req); in nvmet_execute_id_cs_indep()
1083 id->anagrpid = cpu_to_le32(req->ns->anagrpid); in nvmet_execute_id_cs_indep()
1085 if (req->ns->readonly) in nvmet_execute_id_cs_indep()
1087 if (req->ns->bdev && !bdev_nonrot(req->ns->bdev)) in nvmet_execute_id_cs_indep()
1094 if (req->ns->bdev && !bdev_write_cache(req->ns->bdev)) in nvmet_execute_id_cs_indep()
1097 status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id)); in nvmet_execute_id_cs_indep()
1100 nvmet_req_complete(req, status); in nvmet_execute_id_cs_indep()
1103 static void nvmet_execute_identify(struct nvmet_req *req) in nvmet_execute_identify() argument
1105 if (!nvmet_check_transfer_len(req, NVME_IDENTIFY_DATA_SIZE)) in nvmet_execute_identify()
1108 switch (req->cmd->identify.cns) { in nvmet_execute_identify()
1110 nvmet_execute_identify_ns(req); in nvmet_execute_identify()
1113 nvmet_execute_identify_ctrl(req); in nvmet_execute_identify()
1116 nvmet_execute_identify_nslist(req, false); in nvmet_execute_identify()
1119 nvmet_execute_identify_desclist(req); in nvmet_execute_identify()
1122 switch (req->cmd->identify.csi) { in nvmet_execute_identify()
1124 nvme_execute_identify_ns_nvm(req); in nvmet_execute_identify()
1128 nvmet_execute_identify_ns_zns(req); in nvmet_execute_identify()
1135 switch (req->cmd->identify.csi) { in nvmet_execute_identify()
1137 nvmet_execute_identify_ctrl_nvm(req); in nvmet_execute_identify()
1141 nvmet_execute_identify_ctrl_zns(req); in nvmet_execute_identify()
1148 nvmet_execute_identify_nslist(req, true); in nvmet_execute_identify()
1151 nvmet_execute_id_cs_indep(req); in nvmet_execute_identify()
1154 nvmet_execute_identify_endgrp_list(req); in nvmet_execute_identify()
1159 req->cmd->identify.cns, req->sq->qid); in nvmet_execute_identify()
1160 req->error_loc = offsetof(struct nvme_identify, cns); in nvmet_execute_identify()
1161 nvmet_req_complete(req, NVME_SC_INVALID_FIELD | NVME_STATUS_DNR); in nvmet_execute_identify()
1171 static void nvmet_execute_abort(struct nvmet_req *req) in nvmet_execute_abort() argument
1173 if (!nvmet_check_transfer_len(req, 0)) in nvmet_execute_abort()
1175 nvmet_set_result(req, 1); in nvmet_execute_abort()
1176 nvmet_req_complete(req, 0); in nvmet_execute_abort()
1179 static u16 nvmet_write_protect_flush_sync(struct nvmet_req *req) in nvmet_write_protect_flush_sync() argument
1183 if (req->ns->file) in nvmet_write_protect_flush_sync()
1184 status = nvmet_file_flush(req); in nvmet_write_protect_flush_sync()
1186 status = nvmet_bdev_flush(req); in nvmet_write_protect_flush_sync()
1189 pr_err("write protect flush failed nsid: %u\n", req->ns->nsid); in nvmet_write_protect_flush_sync()
1193 static u16 nvmet_set_feat_write_protect(struct nvmet_req *req) in nvmet_set_feat_write_protect() argument
1195 u32 write_protect = le32_to_cpu(req->cmd->common.cdw11); in nvmet_set_feat_write_protect()
1196 struct nvmet_subsys *subsys = nvmet_req_subsys(req); in nvmet_set_feat_write_protect()
1199 status = nvmet_req_find_ns(req); in nvmet_set_feat_write_protect()
1206 req->ns->readonly = true; in nvmet_set_feat_write_protect()
1207 status = nvmet_write_protect_flush_sync(req); in nvmet_set_feat_write_protect()
1209 req->ns->readonly = false; in nvmet_set_feat_write_protect()
1212 req->ns->readonly = false; in nvmet_set_feat_write_protect()
1220 nvmet_ns_changed(subsys, req->ns->nsid); in nvmet_set_feat_write_protect()
1225 u16 nvmet_set_feat_kato(struct nvmet_req *req) in nvmet_set_feat_kato() argument
1227 u32 val32 = le32_to_cpu(req->cmd->common.cdw11); in nvmet_set_feat_kato()
1229 nvmet_stop_keep_alive_timer(req->sq->ctrl); in nvmet_set_feat_kato()
1230 req->sq->ctrl->kato = DIV_ROUND_UP(val32, 1000); in nvmet_set_feat_kato()
1231 nvmet_start_keep_alive_timer(req->sq->ctrl); in nvmet_set_feat_kato()
1233 nvmet_set_result(req, req->sq->ctrl->kato); in nvmet_set_feat_kato()
1238 u16 nvmet_set_feat_async_event(struct nvmet_req *req, u32 mask) in nvmet_set_feat_async_event() argument
1240 u32 val32 = le32_to_cpu(req->cmd->common.cdw11); in nvmet_set_feat_async_event()
1243 req->error_loc = offsetof(struct nvme_common_command, cdw11); in nvmet_set_feat_async_event()
1247 WRITE_ONCE(req->sq->ctrl->aen_enabled, val32); in nvmet_set_feat_async_event()
1248 nvmet_set_result(req, val32); in nvmet_set_feat_async_event()
1253 static u16 nvmet_set_feat_host_id(struct nvmet_req *req) in nvmet_set_feat_host_id() argument
1255 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_set_feat_host_id()
1269 if (!(req->cmd->common.cdw11 & cpu_to_le32(1 << 0))) { in nvmet_set_feat_host_id()
1270 req->error_loc = offsetof(struct nvme_common_command, cdw11); in nvmet_set_feat_host_id()
1274 return nvmet_copy_from_sgl(req, 0, &req->sq->ctrl->hostid, in nvmet_set_feat_host_id()
1275 sizeof(req->sq->ctrl->hostid)); in nvmet_set_feat_host_id()
1278 static u16 nvmet_set_feat_irq_coalesce(struct nvmet_req *req) in nvmet_set_feat_irq_coalesce() argument
1280 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_set_feat_irq_coalesce()
1281 u32 cdw11 = le32_to_cpu(req->cmd->common.cdw11); in nvmet_set_feat_irq_coalesce()
1292 req->error_loc = offsetof(struct nvme_common_command, cdw10); in nvmet_set_feat_irq_coalesce()
1299 static u16 nvmet_set_feat_irq_config(struct nvmet_req *req) in nvmet_set_feat_irq_config() argument
1301 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_set_feat_irq_config()
1302 u32 cdw11 = le32_to_cpu(req->cmd->common.cdw11); in nvmet_set_feat_irq_config()
1313 req->error_loc = offsetof(struct nvme_common_command, cdw10); in nvmet_set_feat_irq_config()
1320 static u16 nvmet_set_feat_arbitration(struct nvmet_req *req) in nvmet_set_feat_arbitration() argument
1322 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_set_feat_arbitration()
1323 u32 cdw11 = le32_to_cpu(req->cmd->common.cdw11); in nvmet_set_feat_arbitration()
1332 req->error_loc = offsetof(struct nvme_common_command, cdw10); in nvmet_set_feat_arbitration()
1339 void nvmet_execute_set_features(struct nvmet_req *req) in nvmet_execute_set_features() argument
1341 struct nvmet_subsys *subsys = nvmet_req_subsys(req); in nvmet_execute_set_features()
1342 u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10); in nvmet_execute_set_features()
1343 u32 cdw11 = le32_to_cpu(req->cmd->common.cdw11); in nvmet_execute_set_features()
1348 if (!nvmet_check_data_len_lte(req, 0)) in nvmet_execute_set_features()
1353 status = nvmet_set_feat_arbitration(req); in nvmet_execute_set_features()
1362 nvmet_set_result(req, in nvmet_execute_set_features()
1366 status = nvmet_set_feat_irq_coalesce(req); in nvmet_execute_set_features()
1369 status = nvmet_set_feat_irq_config(req); in nvmet_execute_set_features()
1372 status = nvmet_set_feat_kato(req); in nvmet_execute_set_features()
1375 status = nvmet_set_feat_async_event(req, NVMET_AEN_CFG_ALL); in nvmet_execute_set_features()
1378 status = nvmet_set_feat_host_id(req); in nvmet_execute_set_features()
1381 status = nvmet_set_feat_write_protect(req); in nvmet_execute_set_features()
1384 status = nvmet_set_feat_resv_notif_mask(req, cdw11); in nvmet_execute_set_features()
1387 req->error_loc = offsetof(struct nvme_common_command, cdw10); in nvmet_execute_set_features()
1392 nvmet_req_complete(req, status); in nvmet_execute_set_features()
1395 static u16 nvmet_get_feat_write_protect(struct nvmet_req *req) in nvmet_get_feat_write_protect() argument
1397 struct nvmet_subsys *subsys = nvmet_req_subsys(req); in nvmet_get_feat_write_protect()
1400 result = nvmet_req_find_ns(req); in nvmet_get_feat_write_protect()
1405 if (req->ns->readonly == true) in nvmet_get_feat_write_protect()
1409 nvmet_set_result(req, result); in nvmet_get_feat_write_protect()
1415 static u16 nvmet_get_feat_irq_coalesce(struct nvmet_req *req) in nvmet_get_feat_irq_coalesce() argument
1417 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_get_feat_irq_coalesce()
1426 req->error_loc = offsetof(struct nvme_common_command, cdw10); in nvmet_get_feat_irq_coalesce()
1434 nvmet_set_result(req, ((u32)irqc.time << 8) | (u32)irqc.thr); in nvmet_get_feat_irq_coalesce()
1439 static u16 nvmet_get_feat_irq_config(struct nvmet_req *req) in nvmet_get_feat_irq_config() argument
1441 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_get_feat_irq_config()
1442 u32 iv = le32_to_cpu(req->cmd->common.cdw11) & 0xffff; in nvmet_get_feat_irq_config()
1451 req->error_loc = offsetof(struct nvme_common_command, cdw10); in nvmet_get_feat_irq_config()
1459 nvmet_set_result(req, ((u32)irqcfg.cd << 16) | iv); in nvmet_get_feat_irq_config()
1464 static u16 nvmet_get_feat_arbitration(struct nvmet_req *req) in nvmet_get_feat_arbitration() argument
1466 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_get_feat_arbitration()
1471 req->error_loc = offsetof(struct nvme_common_command, cdw10); in nvmet_get_feat_arbitration()
1479 nvmet_set_result(req, in nvmet_get_feat_arbitration()
1488 void nvmet_get_feat_kato(struct nvmet_req *req) in nvmet_get_feat_kato() argument
1490 nvmet_set_result(req, req->sq->ctrl->kato * 1000); in nvmet_get_feat_kato()
1493 void nvmet_get_feat_async_event(struct nvmet_req *req) in nvmet_get_feat_async_event() argument
1495 nvmet_set_result(req, READ_ONCE(req->sq->ctrl->aen_enabled)); in nvmet_get_feat_async_event()
1498 void nvmet_execute_get_features(struct nvmet_req *req) in nvmet_execute_get_features() argument
1500 struct nvmet_subsys *subsys = nvmet_req_subsys(req); in nvmet_execute_get_features()
1501 u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10); in nvmet_execute_get_features()
1504 if (!nvmet_check_transfer_len(req, nvmet_feat_data_len(req, cdw10))) in nvmet_execute_get_features()
1524 status = nvmet_get_feat_arbitration(req); in nvmet_execute_get_features()
1527 status = nvmet_get_feat_irq_coalesce(req); in nvmet_execute_get_features()
1530 status = nvmet_get_feat_irq_config(req); in nvmet_execute_get_features()
1533 nvmet_get_feat_async_event(req); in nvmet_execute_get_features()
1536 nvmet_set_result(req, 1); in nvmet_execute_get_features()
1539 nvmet_set_result(req, in nvmet_execute_get_features()
1543 nvmet_get_feat_kato(req); in nvmet_execute_get_features()
1547 if (!(req->cmd->common.cdw11 & cpu_to_le32(1 << 0))) { in nvmet_execute_get_features()
1548 req->error_loc = in nvmet_execute_get_features()
1554 status = nvmet_copy_to_sgl(req, 0, &req->sq->ctrl->hostid, in nvmet_execute_get_features()
1555 sizeof(req->sq->ctrl->hostid)); in nvmet_execute_get_features()
1558 status = nvmet_get_feat_write_protect(req); in nvmet_execute_get_features()
1561 status = nvmet_get_feat_resv_notif_mask(req); in nvmet_execute_get_features()
1564 req->error_loc = in nvmet_execute_get_features()
1570 nvmet_req_complete(req, status); in nvmet_execute_get_features()
1573 void nvmet_execute_async_event(struct nvmet_req *req) in nvmet_execute_async_event() argument
1575 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_async_event()
1577 if (!nvmet_check_transfer_len(req, 0)) in nvmet_execute_async_event()
1583 nvmet_req_complete(req, NVME_SC_ASYNC_LIMIT | NVME_STATUS_DNR); in nvmet_execute_async_event()
1586 ctrl->async_event_cmds[ctrl->nr_async_event_cmds++] = req; in nvmet_execute_async_event()
1592 void nvmet_execute_keep_alive(struct nvmet_req *req) in nvmet_execute_keep_alive() argument
1594 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_keep_alive()
1597 if (!nvmet_check_transfer_len(req, 0)) in nvmet_execute_keep_alive()
1609 nvmet_req_complete(req, status); in nvmet_execute_keep_alive()
1612 u32 nvmet_admin_cmd_data_len(struct nvmet_req *req) in nvmet_admin_cmd_data_len() argument
1614 struct nvme_command *cmd = req->cmd; in nvmet_admin_cmd_data_len()
1617 return nvmet_fabrics_admin_cmd_data_len(req); in nvmet_admin_cmd_data_len()
1618 if (nvmet_is_disc_subsys(nvmet_req_subsys(req))) in nvmet_admin_cmd_data_len()
1619 return nvmet_discovery_cmd_data_len(req); in nvmet_admin_cmd_data_len()
1627 return nvmet_feat_data_len(req, le32_to_cpu(cmd->common.cdw10)); in nvmet_admin_cmd_data_len()
1633 u16 nvmet_parse_admin_cmd(struct nvmet_req *req) in nvmet_parse_admin_cmd() argument
1635 struct nvme_command *cmd = req->cmd; in nvmet_parse_admin_cmd()
1639 return nvmet_parse_fabrics_admin_cmd(req); in nvmet_parse_admin_cmd()
1640 if (nvmet_is_disc_subsys(nvmet_req_subsys(req))) in nvmet_parse_admin_cmd()
1641 return nvmet_parse_discovery_cmd(req); in nvmet_parse_admin_cmd()
1643 ret = nvmet_check_ctrl_status(req); in nvmet_parse_admin_cmd()
1648 if (nvmet_is_pci_ctrl(req->sq->ctrl) && !req->sq->qid && in nvmet_parse_admin_cmd()
1652 if (nvmet_is_passthru_req(req)) in nvmet_parse_admin_cmd()
1653 return nvmet_parse_passthru_admin_cmd(req); in nvmet_parse_admin_cmd()
1657 req->execute = nvmet_execute_delete_sq; in nvmet_parse_admin_cmd()
1660 req->execute = nvmet_execute_create_sq; in nvmet_parse_admin_cmd()
1663 req->execute = nvmet_execute_get_log_page; in nvmet_parse_admin_cmd()
1666 req->execute = nvmet_execute_delete_cq; in nvmet_parse_admin_cmd()
1669 req->execute = nvmet_execute_create_cq; in nvmet_parse_admin_cmd()
1672 req->execute = nvmet_execute_identify; in nvmet_parse_admin_cmd()
1675 req->execute = nvmet_execute_abort; in nvmet_parse_admin_cmd()
1678 req->execute = nvmet_execute_set_features; in nvmet_parse_admin_cmd()
1681 req->execute = nvmet_execute_get_features; in nvmet_parse_admin_cmd()
1684 req->execute = nvmet_execute_async_event; in nvmet_parse_admin_cmd()
1687 req->execute = nvmet_execute_keep_alive; in nvmet_parse_admin_cmd()
1690 return nvmet_report_invalid_opcode(req); in nvmet_parse_admin_cmd()