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()
85 nvmet_req_complete(req, status); in nvmet_execute_create_sq()
88 static void nvmet_execute_delete_cq(struct nvmet_req *req) in nvmet_execute_delete_cq() argument
90 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_delete_cq()
91 u16 cqid = le16_to_cpu(req->cmd->delete_queue.qid); in nvmet_execute_delete_cq()
95 status = nvmet_report_invalid_opcode(req); in nvmet_execute_delete_cq()
111 nvmet_req_complete(req, status); in nvmet_execute_delete_cq()
114 static void nvmet_execute_create_cq(struct nvmet_req *req) in nvmet_execute_create_cq() argument
116 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_create_cq()
117 struct nvme_command *cmd = req->cmd; in nvmet_execute_create_cq()
126 status = nvmet_report_invalid_opcode(req); in nvmet_execute_create_cq()
148 nvmet_req_complete(req, status); in nvmet_execute_create_cq()
164 static u32 nvmet_feat_data_len(struct nvmet_req *req, u32 cdw10) in nvmet_feat_data_len() argument
168 return sizeof(req->sq->ctrl->hostid); in nvmet_feat_data_len()
179 static void nvmet_execute_get_log_page_noop(struct nvmet_req *req) in nvmet_execute_get_log_page_noop() argument
181 nvmet_req_complete(req, nvmet_zero_sgl(req, 0, req->transfer_len)); in nvmet_execute_get_log_page_noop()
184 static void nvmet_execute_get_log_page_error(struct nvmet_req *req) in nvmet_execute_get_log_page_error() argument
186 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_get_log_page_error()
196 if (nvmet_copy_to_sgl(req, offset, &ctrl->slots[slot], in nvmet_execute_get_log_page_error()
207 nvmet_req_complete(req, 0); in nvmet_execute_get_log_page_error()
210 static void nvmet_execute_get_supported_log_pages(struct nvmet_req *req) in nvmet_execute_get_supported_log_pages() argument
233 status = nvmet_copy_to_sgl(req, 0, logs, sizeof(*logs)); in nvmet_execute_get_supported_log_pages()
236 nvmet_req_complete(req, status); in nvmet_execute_get_supported_log_pages()
239 static u16 nvmet_get_smart_log_nsid(struct nvmet_req *req, in nvmet_get_smart_log_nsid() argument
245 status = nvmet_req_find_ns(req); in nvmet_get_smart_log_nsid()
250 if (!req->ns->bdev) in nvmet_get_smart_log_nsid()
253 host_reads = part_stat_read(req->ns->bdev, ios[READ]); in nvmet_get_smart_log_nsid()
255 DIV_ROUND_UP(part_stat_read(req->ns->bdev, sectors[READ]), 1000); in nvmet_get_smart_log_nsid()
256 host_writes = part_stat_read(req->ns->bdev, ios[WRITE]); in nvmet_get_smart_log_nsid()
258 DIV_ROUND_UP(part_stat_read(req->ns->bdev, sectors[WRITE]), 1000); in nvmet_get_smart_log_nsid()
268 static u16 nvmet_get_smart_log_all(struct nvmet_req *req, in nvmet_get_smart_log_all() argument
277 ctrl = req->sq->ctrl; in nvmet_get_smart_log_all()
298 static void nvmet_execute_get_log_page_rmi(struct nvmet_req *req) in nvmet_execute_get_log_page_rmi() argument
304 req->cmd->common.nsid = cpu_to_le32(le16_to_cpu( in nvmet_execute_get_log_page_rmi()
305 req->cmd->get_log_page.lsi)); in nvmet_execute_get_log_page_rmi()
306 status = nvmet_req_find_ns(req); in nvmet_execute_get_log_page_rmi()
310 if (!req->ns->bdev || bdev_nonrot(req->ns->bdev)) { in nvmet_execute_get_log_page_rmi()
315 if (req->transfer_len != sizeof(*log)) { in nvmet_execute_get_log_page_rmi()
324 log->endgid = req->cmd->get_log_page.lsi; in nvmet_execute_get_log_page_rmi()
325 disk = req->ns->bdev->bd_disk; in nvmet_execute_get_log_page_rmi()
331 status = nvmet_copy_to_sgl(req, 0, log, sizeof(*log)); in nvmet_execute_get_log_page_rmi()
334 nvmet_req_complete(req, status); in nvmet_execute_get_log_page_rmi()
337 static void nvmet_execute_get_log_page_smart(struct nvmet_req *req) in nvmet_execute_get_log_page_smart() argument
343 if (req->transfer_len != sizeof(*log)) in nvmet_execute_get_log_page_smart()
350 if (req->cmd->get_log_page.nsid == cpu_to_le32(NVME_NSID_ALL)) in nvmet_execute_get_log_page_smart()
351 status = nvmet_get_smart_log_all(req, log); in nvmet_execute_get_log_page_smart()
353 status = nvmet_get_smart_log_nsid(req, log); in nvmet_execute_get_log_page_smart()
357 spin_lock_irqsave(&req->sq->ctrl->error_lock, flags); in nvmet_execute_get_log_page_smart()
358 put_unaligned_le64(req->sq->ctrl->err_counter, in nvmet_execute_get_log_page_smart()
360 spin_unlock_irqrestore(&req->sq->ctrl->error_lock, flags); in nvmet_execute_get_log_page_smart()
362 status = nvmet_copy_to_sgl(req, 0, log, sizeof(*log)); in nvmet_execute_get_log_page_smart()
366 nvmet_req_complete(req, status); in nvmet_execute_get_log_page_smart()
415 static void nvmet_execute_get_log_cmd_effects_ns(struct nvmet_req *req) in nvmet_execute_get_log_cmd_effects_ns() argument
417 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_get_log_cmd_effects_ns()
427 switch (req->cmd->get_log_page.csi) { in nvmet_execute_get_log_cmd_effects_ns()
446 status = nvmet_copy_to_sgl(req, 0, log, sizeof(*log)); in nvmet_execute_get_log_cmd_effects_ns()
450 nvmet_req_complete(req, status); in nvmet_execute_get_log_cmd_effects_ns()
453 static void nvmet_execute_get_log_changed_ns(struct nvmet_req *req) in nvmet_execute_get_log_changed_ns() argument
455 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_get_log_changed_ns()
459 if (req->transfer_len != NVME_MAX_CHANGED_NAMESPACES * sizeof(__le32)) in nvmet_execute_get_log_changed_ns()
467 status = nvmet_copy_to_sgl(req, 0, ctrl->changed_ns_list, len); in nvmet_execute_get_log_changed_ns()
469 status = nvmet_zero_sgl(req, len, req->transfer_len - len); in nvmet_execute_get_log_changed_ns()
471 nvmet_clear_aen_bit(req, NVME_AEN_BIT_NS_ATTR); in nvmet_execute_get_log_changed_ns()
474 nvmet_req_complete(req, status); in nvmet_execute_get_log_changed_ns()
477 static u32 nvmet_format_ana_group(struct nvmet_req *req, u32 grpid, in nvmet_format_ana_group() argument
480 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_format_ana_group()
485 if (!(req->cmd->get_log_page.lsp & NVME_ANA_LOG_RGO)) { in nvmet_format_ana_group()
495 desc->state = req->port->ana_state[grpid]; in nvmet_format_ana_group()
500 static void nvmet_execute_get_log_page_endgrp(struct nvmet_req *req) in nvmet_execute_get_log_page_endgrp() argument
510 req->cmd->common.nsid = cpu_to_le32(le16_to_cpu( in nvmet_execute_get_log_page_endgrp()
511 req->cmd->get_log_page.lsi)); in nvmet_execute_get_log_page_endgrp()
512 status = nvmet_req_find_ns(req); in nvmet_execute_get_log_page_endgrp()
522 if (!req->ns->bdev) in nvmet_execute_get_log_page_endgrp()
525 host_reads = part_stat_read(req->ns->bdev, ios[READ]); in nvmet_execute_get_log_page_endgrp()
527 DIV_ROUND_UP(part_stat_read(req->ns->bdev, sectors[READ]), 1000); in nvmet_execute_get_log_page_endgrp()
528 host_writes = part_stat_read(req->ns->bdev, ios[WRITE]); in nvmet_execute_get_log_page_endgrp()
530 DIV_ROUND_UP(part_stat_read(req->ns->bdev, sectors[WRITE]), 1000); in nvmet_execute_get_log_page_endgrp()
537 status = nvmet_copy_to_sgl(req, 0, log, sizeof(*log)); in nvmet_execute_get_log_page_endgrp()
540 nvmet_req_complete(req, status); in nvmet_execute_get_log_page_endgrp()
543 static void nvmet_execute_get_log_page_ana(struct nvmet_req *req) in nvmet_execute_get_log_page_ana() argument
563 len = nvmet_format_ana_group(req, grpid, desc); in nvmet_execute_get_log_page_ana()
564 status = nvmet_copy_to_sgl(req, offset, desc, len); in nvmet_execute_get_log_page_ana()
577 nvmet_clear_aen_bit(req, NVME_AEN_BIT_ANA_CHANGE); in nvmet_execute_get_log_page_ana()
583 status = nvmet_copy_to_sgl(req, 0, &hdr, sizeof(hdr)); in nvmet_execute_get_log_page_ana()
585 nvmet_req_complete(req, status); in nvmet_execute_get_log_page_ana()
588 static void nvmet_execute_get_log_page_features(struct nvmet_req *req) in nvmet_execute_get_log_page_features() argument
612 status = nvmet_copy_to_sgl(req, 0, features, sizeof(*features)); in nvmet_execute_get_log_page_features()
615 nvmet_req_complete(req, status); in nvmet_execute_get_log_page_features()
618 static void nvmet_execute_get_log_page(struct nvmet_req *req) in nvmet_execute_get_log_page() argument
620 if (!nvmet_check_transfer_len(req, nvmet_get_log_page_len(req->cmd))) in nvmet_execute_get_log_page()
623 switch (req->cmd->get_log_page.lid) { in nvmet_execute_get_log_page()
625 return nvmet_execute_get_supported_log_pages(req); in nvmet_execute_get_log_page()
627 return nvmet_execute_get_log_page_error(req); in nvmet_execute_get_log_page()
629 return nvmet_execute_get_log_page_smart(req); in nvmet_execute_get_log_page()
636 return nvmet_execute_get_log_page_noop(req); in nvmet_execute_get_log_page()
638 return nvmet_execute_get_log_changed_ns(req); in nvmet_execute_get_log_page()
640 return nvmet_execute_get_log_cmd_effects_ns(req); in nvmet_execute_get_log_page()
642 return nvmet_execute_get_log_page_endgrp(req); in nvmet_execute_get_log_page()
644 return nvmet_execute_get_log_page_ana(req); in nvmet_execute_get_log_page()
646 return nvmet_execute_get_log_page_features(req); in nvmet_execute_get_log_page()
648 return nvmet_execute_get_log_page_rmi(req); in nvmet_execute_get_log_page()
650 return nvmet_execute_get_log_page_resv(req); in nvmet_execute_get_log_page()
653 req->cmd->get_log_page.lid, req->sq->qid); in nvmet_execute_get_log_page()
654 req->error_loc = offsetof(struct nvme_get_log_page_command, lid); in nvmet_execute_get_log_page()
655 nvmet_req_complete(req, NVME_SC_INVALID_FIELD | NVME_STATUS_DNR); in nvmet_execute_get_log_page()
658 static void nvmet_execute_identify_ctrl(struct nvmet_req *req) in nvmet_execute_identify_ctrl() argument
660 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_identify_ctrl()
762 if (req->port->inline_data_size) in nvmet_execute_identify_ctrl()
773 cmd_capsule_size += req->port->inline_data_size; in nvmet_execute_identify_ctrl()
803 status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id)); in nvmet_execute_identify_ctrl()
807 nvmet_req_complete(req, status); in nvmet_execute_identify_ctrl()
810 static void nvmet_execute_identify_ns(struct nvmet_req *req) in nvmet_execute_identify_ns() argument
815 if (le32_to_cpu(req->cmd->identify.nsid) == NVME_NSID_ALL) { in nvmet_execute_identify_ns()
816 req->error_loc = offsetof(struct nvme_identify, nsid); in nvmet_execute_identify_ns()
828 status = nvmet_req_find_ns(req); in nvmet_execute_identify_ns()
834 if (nvmet_ns_revalidate(req->ns)) { in nvmet_execute_identify_ns()
835 mutex_lock(&req->ns->subsys->lock); in nvmet_execute_identify_ns()
836 nvmet_ns_changed(req->ns->subsys, req->ns->nsid); in nvmet_execute_identify_ns()
837 mutex_unlock(&req->ns->subsys->lock); in nvmet_execute_identify_ns()
845 cpu_to_le64(req->ns->size >> req->ns->blksize_shift); in nvmet_execute_identify_ns()
846 switch (req->port->ana_state[req->ns->anagrpid]) { in nvmet_execute_identify_ns()
855 if (req->ns->bdev) in nvmet_execute_identify_ns()
856 nvmet_bdev_set_limits(req->ns->bdev, id); in nvmet_execute_identify_ns()
870 id->anagrpid = cpu_to_le32(req->ns->anagrpid); in nvmet_execute_identify_ns()
872 if (req->ns->pr.enable) in nvmet_execute_identify_ns()
885 id->endgid = cpu_to_le16(req->ns->nsid); in nvmet_execute_identify_ns()
887 memcpy(&id->nguid, &req->ns->nguid, sizeof(id->nguid)); in nvmet_execute_identify_ns()
889 id->lbaf[0].ds = req->ns->blksize_shift; in nvmet_execute_identify_ns()
891 if (req->sq->ctrl->pi_support && nvmet_ns_has_pi(req->ns)) { in nvmet_execute_identify_ns()
896 id->dps = req->ns->pi_type; in nvmet_execute_identify_ns()
898 id->lbaf[0].ms = cpu_to_le16(req->ns->metadata_size); in nvmet_execute_identify_ns()
901 if (req->ns->readonly) in nvmet_execute_identify_ns()
905 status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id)); in nvmet_execute_identify_ns()
909 nvmet_req_complete(req, status); in nvmet_execute_identify_ns()
912 static void nvmet_execute_identify_endgrp_list(struct nvmet_req *req) in nvmet_execute_identify_endgrp_list() argument
914 u16 min_endgid = le16_to_cpu(req->cmd->identify.cnssid); in nvmet_execute_identify_endgrp_list()
916 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_identify_endgrp_list()
939 status = nvmet_copy_to_sgl(req, 0, list, buf_size); in nvmet_execute_identify_endgrp_list()
942 nvmet_req_complete(req, status); in nvmet_execute_identify_endgrp_list()
945 static void nvmet_execute_identify_nslist(struct nvmet_req *req, bool match_css) in nvmet_execute_identify_nslist() argument
948 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_identify_nslist()
951 u32 min_nsid = le32_to_cpu(req->cmd->identify.nsid); in nvmet_execute_identify_nslist()
961 req->error_loc = offsetof(struct nvme_identify, nsid); in nvmet_execute_identify_nslist()
975 if (match_css && req->ns->csi != req->cmd->identify.csi) in nvmet_execute_identify_nslist()
982 status = nvmet_copy_to_sgl(req, 0, list, buf_size); in nvmet_execute_identify_nslist()
986 nvmet_req_complete(req, status); in nvmet_execute_identify_nslist()
989 static u16 nvmet_copy_ns_identifier(struct nvmet_req *req, u8 type, u8 len, in nvmet_copy_ns_identifier() argument
998 status = nvmet_copy_to_sgl(req, *off, &desc, sizeof(desc)); in nvmet_copy_ns_identifier()
1003 status = nvmet_copy_to_sgl(req, *off, id, len); in nvmet_copy_ns_identifier()
1011 static void nvmet_execute_identify_desclist(struct nvmet_req *req) in nvmet_execute_identify_desclist() argument
1016 status = nvmet_req_find_ns(req); in nvmet_execute_identify_desclist()
1020 if (memchr_inv(&req->ns->uuid, 0, sizeof(req->ns->uuid))) { in nvmet_execute_identify_desclist()
1021 status = nvmet_copy_ns_identifier(req, NVME_NIDT_UUID, in nvmet_execute_identify_desclist()
1023 &req->ns->uuid, &off); in nvmet_execute_identify_desclist()
1027 if (memchr_inv(req->ns->nguid, 0, sizeof(req->ns->nguid))) { in nvmet_execute_identify_desclist()
1028 status = nvmet_copy_ns_identifier(req, NVME_NIDT_NGUID, in nvmet_execute_identify_desclist()
1030 &req->ns->nguid, &off); in nvmet_execute_identify_desclist()
1035 status = nvmet_copy_ns_identifier(req, NVME_NIDT_CSI, in nvmet_execute_identify_desclist()
1037 &req->ns->csi, &off); in nvmet_execute_identify_desclist()
1041 if (sg_zero_buffer(req->sg, req->sg_cnt, NVME_IDENTIFY_DATA_SIZE - off, in nvmet_execute_identify_desclist()
1046 nvmet_req_complete(req, status); in nvmet_execute_identify_desclist()
1049 static void nvmet_execute_identify_ctrl_nvm(struct nvmet_req *req) in nvmet_execute_identify_ctrl_nvm() argument
1052 nvmet_req_complete(req, in nvmet_execute_identify_ctrl_nvm()
1053 nvmet_zero_sgl(req, 0, sizeof(struct nvme_id_ctrl_nvm))); in nvmet_execute_identify_ctrl_nvm()
1056 static void nvme_execute_identify_ns_nvm(struct nvmet_req *req) in nvme_execute_identify_ns_nvm() argument
1061 status = nvmet_req_find_ns(req); in nvme_execute_identify_ns_nvm()
1070 status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id)); in nvme_execute_identify_ns_nvm()
1073 nvmet_req_complete(req, status); in nvme_execute_identify_ns_nvm()
1076 static void nvmet_execute_id_cs_indep(struct nvmet_req *req) in nvmet_execute_id_cs_indep() argument
1081 status = nvmet_req_find_ns(req); in nvmet_execute_id_cs_indep()
1092 id->anagrpid = cpu_to_le32(req->ns->anagrpid); in nvmet_execute_id_cs_indep()
1094 if (req->ns->readonly) in nvmet_execute_id_cs_indep()
1096 if (req->ns->bdev && !bdev_nonrot(req->ns->bdev)) in nvmet_execute_id_cs_indep()
1103 if (req->ns->bdev && !bdev_write_cache(req->ns->bdev)) in nvmet_execute_id_cs_indep()
1106 status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id)); in nvmet_execute_id_cs_indep()
1109 nvmet_req_complete(req, status); in nvmet_execute_id_cs_indep()
1112 static void nvmet_execute_identify(struct nvmet_req *req) in nvmet_execute_identify() argument
1114 if (!nvmet_check_transfer_len(req, NVME_IDENTIFY_DATA_SIZE)) in nvmet_execute_identify()
1117 switch (req->cmd->identify.cns) { in nvmet_execute_identify()
1119 nvmet_execute_identify_ns(req); in nvmet_execute_identify()
1122 nvmet_execute_identify_ctrl(req); in nvmet_execute_identify()
1125 nvmet_execute_identify_nslist(req, false); in nvmet_execute_identify()
1128 nvmet_execute_identify_desclist(req); in nvmet_execute_identify()
1131 switch (req->cmd->identify.csi) { in nvmet_execute_identify()
1133 nvme_execute_identify_ns_nvm(req); in nvmet_execute_identify()
1137 nvmet_execute_identify_ns_zns(req); in nvmet_execute_identify()
1144 switch (req->cmd->identify.csi) { in nvmet_execute_identify()
1146 nvmet_execute_identify_ctrl_nvm(req); in nvmet_execute_identify()
1150 nvmet_execute_identify_ctrl_zns(req); in nvmet_execute_identify()
1157 nvmet_execute_identify_nslist(req, true); in nvmet_execute_identify()
1160 nvmet_execute_id_cs_indep(req); in nvmet_execute_identify()
1163 nvmet_execute_identify_endgrp_list(req); in nvmet_execute_identify()
1168 req->cmd->identify.cns, req->sq->qid); in nvmet_execute_identify()
1169 req->error_loc = offsetof(struct nvme_identify, cns); in nvmet_execute_identify()
1170 nvmet_req_complete(req, NVME_SC_INVALID_FIELD | NVME_STATUS_DNR); in nvmet_execute_identify()
1180 static void nvmet_execute_abort(struct nvmet_req *req) in nvmet_execute_abort() argument
1182 if (!nvmet_check_transfer_len(req, 0)) in nvmet_execute_abort()
1184 nvmet_set_result(req, 1); in nvmet_execute_abort()
1185 nvmet_req_complete(req, 0); in nvmet_execute_abort()
1188 static u16 nvmet_write_protect_flush_sync(struct nvmet_req *req) in nvmet_write_protect_flush_sync() argument
1192 if (req->ns->file) in nvmet_write_protect_flush_sync()
1193 status = nvmet_file_flush(req); in nvmet_write_protect_flush_sync()
1195 status = nvmet_bdev_flush(req); in nvmet_write_protect_flush_sync()
1198 pr_err("write protect flush failed nsid: %u\n", req->ns->nsid); in nvmet_write_protect_flush_sync()
1202 static u16 nvmet_set_feat_write_protect(struct nvmet_req *req) in nvmet_set_feat_write_protect() argument
1204 u32 write_protect = le32_to_cpu(req->cmd->common.cdw11); in nvmet_set_feat_write_protect()
1205 struct nvmet_subsys *subsys = nvmet_req_subsys(req); in nvmet_set_feat_write_protect()
1208 status = nvmet_req_find_ns(req); in nvmet_set_feat_write_protect()
1215 req->ns->readonly = true; in nvmet_set_feat_write_protect()
1216 status = nvmet_write_protect_flush_sync(req); in nvmet_set_feat_write_protect()
1218 req->ns->readonly = false; in nvmet_set_feat_write_protect()
1221 req->ns->readonly = false; in nvmet_set_feat_write_protect()
1229 nvmet_ns_changed(subsys, req->ns->nsid); in nvmet_set_feat_write_protect()
1234 u16 nvmet_set_feat_kato(struct nvmet_req *req) in nvmet_set_feat_kato() argument
1236 u32 val32 = le32_to_cpu(req->cmd->common.cdw11); in nvmet_set_feat_kato()
1238 nvmet_stop_keep_alive_timer(req->sq->ctrl); in nvmet_set_feat_kato()
1239 req->sq->ctrl->kato = DIV_ROUND_UP(val32, 1000); in nvmet_set_feat_kato()
1240 nvmet_start_keep_alive_timer(req->sq->ctrl); in nvmet_set_feat_kato()
1242 nvmet_set_result(req, req->sq->ctrl->kato); in nvmet_set_feat_kato()
1247 u16 nvmet_set_feat_async_event(struct nvmet_req *req, u32 mask) in nvmet_set_feat_async_event() argument
1249 u32 val32 = le32_to_cpu(req->cmd->common.cdw11); in nvmet_set_feat_async_event()
1252 req->error_loc = offsetof(struct nvme_common_command, cdw11); in nvmet_set_feat_async_event()
1256 WRITE_ONCE(req->sq->ctrl->aen_enabled, val32); in nvmet_set_feat_async_event()
1257 nvmet_set_result(req, val32); in nvmet_set_feat_async_event()
1262 static u16 nvmet_set_feat_host_id(struct nvmet_req *req) in nvmet_set_feat_host_id() argument
1264 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_set_feat_host_id()
1278 if (!(req->cmd->common.cdw11 & cpu_to_le32(1 << 0))) { in nvmet_set_feat_host_id()
1279 req->error_loc = offsetof(struct nvme_common_command, cdw11); in nvmet_set_feat_host_id()
1283 return nvmet_copy_from_sgl(req, 0, &req->sq->ctrl->hostid, in nvmet_set_feat_host_id()
1284 sizeof(req->sq->ctrl->hostid)); in nvmet_set_feat_host_id()
1287 static u16 nvmet_set_feat_irq_coalesce(struct nvmet_req *req) in nvmet_set_feat_irq_coalesce() argument
1289 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_set_feat_irq_coalesce()
1290 u32 cdw11 = le32_to_cpu(req->cmd->common.cdw11); in nvmet_set_feat_irq_coalesce()
1301 req->error_loc = offsetof(struct nvme_common_command, cdw10); in nvmet_set_feat_irq_coalesce()
1308 static u16 nvmet_set_feat_irq_config(struct nvmet_req *req) in nvmet_set_feat_irq_config() argument
1310 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_set_feat_irq_config()
1311 u32 cdw11 = le32_to_cpu(req->cmd->common.cdw11); in nvmet_set_feat_irq_config()
1322 req->error_loc = offsetof(struct nvme_common_command, cdw10); in nvmet_set_feat_irq_config()
1329 static u16 nvmet_set_feat_arbitration(struct nvmet_req *req) in nvmet_set_feat_arbitration() argument
1331 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_set_feat_arbitration()
1332 u32 cdw11 = le32_to_cpu(req->cmd->common.cdw11); in nvmet_set_feat_arbitration()
1341 req->error_loc = offsetof(struct nvme_common_command, cdw10); in nvmet_set_feat_arbitration()
1348 void nvmet_execute_set_features(struct nvmet_req *req) in nvmet_execute_set_features() argument
1350 struct nvmet_subsys *subsys = nvmet_req_subsys(req); in nvmet_execute_set_features()
1351 u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10); in nvmet_execute_set_features()
1352 u32 cdw11 = le32_to_cpu(req->cmd->common.cdw11); in nvmet_execute_set_features()
1357 if (!nvmet_check_data_len_lte(req, 0)) in nvmet_execute_set_features()
1362 status = nvmet_set_feat_arbitration(req); in nvmet_execute_set_features()
1371 nvmet_set_result(req, in nvmet_execute_set_features()
1375 status = nvmet_set_feat_irq_coalesce(req); in nvmet_execute_set_features()
1378 status = nvmet_set_feat_irq_config(req); in nvmet_execute_set_features()
1381 status = nvmet_set_feat_kato(req); in nvmet_execute_set_features()
1384 status = nvmet_set_feat_async_event(req, NVMET_AEN_CFG_ALL); in nvmet_execute_set_features()
1387 status = nvmet_set_feat_host_id(req); in nvmet_execute_set_features()
1390 status = nvmet_set_feat_write_protect(req); in nvmet_execute_set_features()
1393 status = nvmet_set_feat_resv_notif_mask(req, cdw11); in nvmet_execute_set_features()
1396 req->error_loc = offsetof(struct nvme_common_command, cdw10); in nvmet_execute_set_features()
1401 nvmet_req_complete(req, status); in nvmet_execute_set_features()
1404 static u16 nvmet_get_feat_write_protect(struct nvmet_req *req) in nvmet_get_feat_write_protect() argument
1406 struct nvmet_subsys *subsys = nvmet_req_subsys(req); in nvmet_get_feat_write_protect()
1409 result = nvmet_req_find_ns(req); in nvmet_get_feat_write_protect()
1414 if (req->ns->readonly == true) in nvmet_get_feat_write_protect()
1418 nvmet_set_result(req, result); in nvmet_get_feat_write_protect()
1424 static u16 nvmet_get_feat_irq_coalesce(struct nvmet_req *req) in nvmet_get_feat_irq_coalesce() argument
1426 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_get_feat_irq_coalesce()
1435 req->error_loc = offsetof(struct nvme_common_command, cdw10); in nvmet_get_feat_irq_coalesce()
1443 nvmet_set_result(req, ((u32)irqc.time << 8) | (u32)irqc.thr); in nvmet_get_feat_irq_coalesce()
1448 static u16 nvmet_get_feat_irq_config(struct nvmet_req *req) in nvmet_get_feat_irq_config() argument
1450 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_get_feat_irq_config()
1451 u32 iv = le32_to_cpu(req->cmd->common.cdw11) & 0xffff; in nvmet_get_feat_irq_config()
1460 req->error_loc = offsetof(struct nvme_common_command, cdw10); in nvmet_get_feat_irq_config()
1468 nvmet_set_result(req, ((u32)irqcfg.cd << 16) | iv); in nvmet_get_feat_irq_config()
1473 static u16 nvmet_get_feat_arbitration(struct nvmet_req *req) in nvmet_get_feat_arbitration() argument
1475 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_get_feat_arbitration()
1480 req->error_loc = offsetof(struct nvme_common_command, cdw10); in nvmet_get_feat_arbitration()
1488 nvmet_set_result(req, in nvmet_get_feat_arbitration()
1497 void nvmet_get_feat_kato(struct nvmet_req *req) in nvmet_get_feat_kato() argument
1499 nvmet_set_result(req, req->sq->ctrl->kato * 1000); in nvmet_get_feat_kato()
1502 void nvmet_get_feat_async_event(struct nvmet_req *req) in nvmet_get_feat_async_event() argument
1504 nvmet_set_result(req, READ_ONCE(req->sq->ctrl->aen_enabled)); in nvmet_get_feat_async_event()
1507 void nvmet_execute_get_features(struct nvmet_req *req) in nvmet_execute_get_features() argument
1509 struct nvmet_subsys *subsys = nvmet_req_subsys(req); in nvmet_execute_get_features()
1510 u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10); in nvmet_execute_get_features()
1513 if (!nvmet_check_transfer_len(req, nvmet_feat_data_len(req, cdw10))) in nvmet_execute_get_features()
1533 status = nvmet_get_feat_arbitration(req); in nvmet_execute_get_features()
1536 status = nvmet_get_feat_irq_coalesce(req); in nvmet_execute_get_features()
1539 status = nvmet_get_feat_irq_config(req); in nvmet_execute_get_features()
1542 nvmet_get_feat_async_event(req); in nvmet_execute_get_features()
1545 nvmet_set_result(req, 1); in nvmet_execute_get_features()
1548 nvmet_set_result(req, in nvmet_execute_get_features()
1552 nvmet_get_feat_kato(req); in nvmet_execute_get_features()
1556 if (!(req->cmd->common.cdw11 & cpu_to_le32(1 << 0))) { in nvmet_execute_get_features()
1557 req->error_loc = in nvmet_execute_get_features()
1563 status = nvmet_copy_to_sgl(req, 0, &req->sq->ctrl->hostid, in nvmet_execute_get_features()
1564 sizeof(req->sq->ctrl->hostid)); in nvmet_execute_get_features()
1567 status = nvmet_get_feat_write_protect(req); in nvmet_execute_get_features()
1570 status = nvmet_get_feat_resv_notif_mask(req); in nvmet_execute_get_features()
1573 req->error_loc = in nvmet_execute_get_features()
1579 nvmet_req_complete(req, status); in nvmet_execute_get_features()
1582 void nvmet_execute_async_event(struct nvmet_req *req) in nvmet_execute_async_event() argument
1584 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_async_event()
1586 if (!nvmet_check_transfer_len(req, 0)) in nvmet_execute_async_event()
1592 nvmet_req_complete(req, NVME_SC_ASYNC_LIMIT | NVME_STATUS_DNR); in nvmet_execute_async_event()
1595 ctrl->async_event_cmds[ctrl->nr_async_event_cmds++] = req; in nvmet_execute_async_event()
1601 void nvmet_execute_keep_alive(struct nvmet_req *req) in nvmet_execute_keep_alive() argument
1603 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_keep_alive()
1606 if (!nvmet_check_transfer_len(req, 0)) in nvmet_execute_keep_alive()
1618 nvmet_req_complete(req, status); in nvmet_execute_keep_alive()
1621 u32 nvmet_admin_cmd_data_len(struct nvmet_req *req) in nvmet_admin_cmd_data_len() argument
1623 struct nvme_command *cmd = req->cmd; in nvmet_admin_cmd_data_len()
1626 return nvmet_fabrics_admin_cmd_data_len(req); in nvmet_admin_cmd_data_len()
1627 if (nvmet_is_disc_subsys(nvmet_req_subsys(req))) in nvmet_admin_cmd_data_len()
1628 return nvmet_discovery_cmd_data_len(req); in nvmet_admin_cmd_data_len()
1636 return nvmet_feat_data_len(req, le32_to_cpu(cmd->common.cdw10)); in nvmet_admin_cmd_data_len()
1642 u16 nvmet_parse_admin_cmd(struct nvmet_req *req) in nvmet_parse_admin_cmd() argument
1644 struct nvme_command *cmd = req->cmd; in nvmet_parse_admin_cmd()
1648 return nvmet_parse_fabrics_admin_cmd(req); in nvmet_parse_admin_cmd()
1649 if (nvmet_is_disc_subsys(nvmet_req_subsys(req))) in nvmet_parse_admin_cmd()
1650 return nvmet_parse_discovery_cmd(req); in nvmet_parse_admin_cmd()
1652 ret = nvmet_check_ctrl_status(req); in nvmet_parse_admin_cmd()
1657 if (nvmet_is_pci_ctrl(req->sq->ctrl) && !req->sq->qid && in nvmet_parse_admin_cmd()
1661 if (nvmet_is_passthru_req(req)) in nvmet_parse_admin_cmd()
1662 return nvmet_parse_passthru_admin_cmd(req); in nvmet_parse_admin_cmd()
1666 req->execute = nvmet_execute_delete_sq; in nvmet_parse_admin_cmd()
1669 req->execute = nvmet_execute_create_sq; in nvmet_parse_admin_cmd()
1672 req->execute = nvmet_execute_get_log_page; in nvmet_parse_admin_cmd()
1675 req->execute = nvmet_execute_delete_cq; in nvmet_parse_admin_cmd()
1678 req->execute = nvmet_execute_create_cq; in nvmet_parse_admin_cmd()
1681 req->execute = nvmet_execute_identify; in nvmet_parse_admin_cmd()
1684 req->execute = nvmet_execute_abort; in nvmet_parse_admin_cmd()
1687 req->execute = nvmet_execute_set_features; in nvmet_parse_admin_cmd()
1690 req->execute = nvmet_execute_get_features; in nvmet_parse_admin_cmd()
1693 req->execute = nvmet_execute_async_event; in nvmet_parse_admin_cmd()
1696 req->execute = nvmet_execute_keep_alive; in nvmet_parse_admin_cmd()
1699 return nvmet_report_invalid_opcode(req); in nvmet_parse_admin_cmd()