admin-cmd.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. /*
  2. * NVMe admin command implementation.
  3. * Copyright (c) 2015-2016 HGST, a Western Digital Company.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms and conditions of the GNU General Public License,
  7. * version 2, as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. */
  14. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  15. #include <linux/module.h>
  16. #include <linux/rculist.h>
  17. #include <generated/utsrelease.h>
  18. #include <asm/unaligned.h>
  19. #include "nvmet.h"
  20. u32 nvmet_get_log_page_len(struct nvme_command *cmd)
  21. {
  22. u32 len = le16_to_cpu(cmd->get_log_page.numdu);
  23. len <<= 16;
  24. len += le16_to_cpu(cmd->get_log_page.numdl);
  25. /* NUMD is a 0's based value */
  26. len += 1;
  27. len *= sizeof(u32);
  28. return len;
  29. }
  30. static void nvmet_execute_get_log_page_noop(struct nvmet_req *req)
  31. {
  32. nvmet_req_complete(req, nvmet_zero_sgl(req, 0, req->data_len));
  33. }
  34. static u16 nvmet_get_smart_log_nsid(struct nvmet_req *req,
  35. struct nvme_smart_log *slog)
  36. {
  37. struct nvmet_ns *ns;
  38. u64 host_reads, host_writes, data_units_read, data_units_written;
  39. ns = nvmet_find_namespace(req->sq->ctrl, req->cmd->get_log_page.nsid);
  40. if (!ns) {
  41. pr_err("nvmet : Could not find namespace id : %d\n",
  42. le32_to_cpu(req->cmd->get_log_page.nsid));
  43. return NVME_SC_INVALID_NS;
  44. }
  45. /* we don't have the right data for file backed ns */
  46. if (!ns->bdev)
  47. goto out;
  48. host_reads = part_stat_read(ns->bdev->bd_part, ios[READ]);
  49. data_units_read = part_stat_read(ns->bdev->bd_part, sectors[READ]);
  50. host_writes = part_stat_read(ns->bdev->bd_part, ios[WRITE]);
  51. data_units_written = part_stat_read(ns->bdev->bd_part, sectors[WRITE]);
  52. put_unaligned_le64(host_reads, &slog->host_reads[0]);
  53. put_unaligned_le64(data_units_read, &slog->data_units_read[0]);
  54. put_unaligned_le64(host_writes, &slog->host_writes[0]);
  55. put_unaligned_le64(data_units_written, &slog->data_units_written[0]);
  56. out:
  57. nvmet_put_namespace(ns);
  58. return NVME_SC_SUCCESS;
  59. }
  60. static u16 nvmet_get_smart_log_all(struct nvmet_req *req,
  61. struct nvme_smart_log *slog)
  62. {
  63. u64 host_reads = 0, host_writes = 0;
  64. u64 data_units_read = 0, data_units_written = 0;
  65. struct nvmet_ns *ns;
  66. struct nvmet_ctrl *ctrl;
  67. ctrl = req->sq->ctrl;
  68. rcu_read_lock();
  69. list_for_each_entry_rcu(ns, &ctrl->subsys->namespaces, dev_link) {
  70. /* we don't have the right data for file backed ns */
  71. if (!ns->bdev)
  72. continue;
  73. host_reads += part_stat_read(ns->bdev->bd_part, ios[READ]);
  74. data_units_read +=
  75. part_stat_read(ns->bdev->bd_part, sectors[READ]);
  76. host_writes += part_stat_read(ns->bdev->bd_part, ios[WRITE]);
  77. data_units_written +=
  78. part_stat_read(ns->bdev->bd_part, sectors[WRITE]);
  79. }
  80. rcu_read_unlock();
  81. put_unaligned_le64(host_reads, &slog->host_reads[0]);
  82. put_unaligned_le64(data_units_read, &slog->data_units_read[0]);
  83. put_unaligned_le64(host_writes, &slog->host_writes[0]);
  84. put_unaligned_le64(data_units_written, &slog->data_units_written[0]);
  85. return NVME_SC_SUCCESS;
  86. }
  87. static void nvmet_execute_get_log_page_smart(struct nvmet_req *req)
  88. {
  89. struct nvme_smart_log *log;
  90. u16 status = NVME_SC_INTERNAL;
  91. if (req->data_len != sizeof(*log))
  92. goto out;
  93. log = kzalloc(sizeof(*log), GFP_KERNEL);
  94. if (!log)
  95. goto out;
  96. if (req->cmd->get_log_page.nsid == cpu_to_le32(NVME_NSID_ALL))
  97. status = nvmet_get_smart_log_all(req, log);
  98. else
  99. status = nvmet_get_smart_log_nsid(req, log);
  100. if (status)
  101. goto out_free_log;
  102. status = nvmet_copy_to_sgl(req, 0, log, sizeof(*log));
  103. out_free_log:
  104. kfree(log);
  105. out:
  106. nvmet_req_complete(req, status);
  107. }
  108. static void nvmet_execute_get_log_changed_ns(struct nvmet_req *req)
  109. {
  110. struct nvmet_ctrl *ctrl = req->sq->ctrl;
  111. u16 status = NVME_SC_INTERNAL;
  112. size_t len;
  113. if (req->data_len != NVME_MAX_CHANGED_NAMESPACES * sizeof(__le32))
  114. goto out;
  115. mutex_lock(&ctrl->lock);
  116. if (ctrl->nr_changed_ns == U32_MAX)
  117. len = sizeof(__le32);
  118. else
  119. len = ctrl->nr_changed_ns * sizeof(__le32);
  120. status = nvmet_copy_to_sgl(req, 0, ctrl->changed_ns_list, len);
  121. if (!status)
  122. status = nvmet_zero_sgl(req, len, req->data_len - len);
  123. ctrl->nr_changed_ns = 0;
  124. clear_bit(NVME_AEN_CFG_NS_ATTR, &ctrl->aen_masked);
  125. mutex_unlock(&ctrl->lock);
  126. out:
  127. nvmet_req_complete(req, status);
  128. }
  129. static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
  130. {
  131. struct nvmet_ctrl *ctrl = req->sq->ctrl;
  132. struct nvme_id_ctrl *id;
  133. u16 status = 0;
  134. const char model[] = "Linux";
  135. id = kzalloc(sizeof(*id), GFP_KERNEL);
  136. if (!id) {
  137. status = NVME_SC_INTERNAL;
  138. goto out;
  139. }
  140. /* XXX: figure out how to assign real vendors IDs. */
  141. id->vid = 0;
  142. id->ssvid = 0;
  143. memset(id->sn, ' ', sizeof(id->sn));
  144. bin2hex(id->sn, &ctrl->subsys->serial,
  145. min(sizeof(ctrl->subsys->serial), sizeof(id->sn) / 2));
  146. memcpy_and_pad(id->mn, sizeof(id->mn), model, sizeof(model) - 1, ' ');
  147. memcpy_and_pad(id->fr, sizeof(id->fr),
  148. UTS_RELEASE, strlen(UTS_RELEASE), ' ');
  149. id->rab = 6;
  150. /*
  151. * XXX: figure out how we can assign a IEEE OUI, but until then
  152. * the safest is to leave it as zeroes.
  153. */
  154. /* we support multiple ports and multiples hosts: */
  155. id->cmic = (1 << 0) | (1 << 1);
  156. /* no limit on data transfer sizes for now */
  157. id->mdts = 0;
  158. id->cntlid = cpu_to_le16(ctrl->cntlid);
  159. id->ver = cpu_to_le32(ctrl->subsys->ver);
  160. /* XXX: figure out what to do about RTD3R/RTD3 */
  161. id->oaes = cpu_to_le32(NVMET_AEN_CFG_OPTIONAL);
  162. id->ctratt = cpu_to_le32(1 << 0);
  163. id->oacs = 0;
  164. /*
  165. * We don't really have a practical limit on the number of abort
  166. * comands. But we don't do anything useful for abort either, so
  167. * no point in allowing more abort commands than the spec requires.
  168. */
  169. id->acl = 3;
  170. id->aerl = NVMET_ASYNC_EVENTS - 1;
  171. /* first slot is read-only, only one slot supported */
  172. id->frmw = (1 << 0) | (1 << 1);
  173. id->lpa = (1 << 0) | (1 << 2);
  174. id->elpe = NVMET_ERROR_LOG_SLOTS - 1;
  175. id->npss = 0;
  176. /* We support keep-alive timeout in granularity of seconds */
  177. id->kas = cpu_to_le16(NVMET_KAS);
  178. id->sqes = (0x6 << 4) | 0x6;
  179. id->cqes = (0x4 << 4) | 0x4;
  180. /* no enforcement soft-limit for maxcmd - pick arbitrary high value */
  181. id->maxcmd = cpu_to_le16(NVMET_MAX_CMD);
  182. id->nn = cpu_to_le32(ctrl->subsys->max_nsid);
  183. id->oncs = cpu_to_le16(NVME_CTRL_ONCS_DSM |
  184. NVME_CTRL_ONCS_WRITE_ZEROES);
  185. /* XXX: don't report vwc if the underlying device is write through */
  186. id->vwc = NVME_CTRL_VWC_PRESENT;
  187. /*
  188. * We can't support atomic writes bigger than a LBA without support
  189. * from the backend device.
  190. */
  191. id->awun = 0;
  192. id->awupf = 0;
  193. id->sgls = cpu_to_le32(1 << 0); /* we always support SGLs */
  194. if (ctrl->ops->has_keyed_sgls)
  195. id->sgls |= cpu_to_le32(1 << 2);
  196. if (ctrl->ops->sqe_inline_size)
  197. id->sgls |= cpu_to_le32(1 << 20);
  198. strcpy(id->subnqn, ctrl->subsys->subsysnqn);
  199. /* Max command capsule size is sqe + single page of in-capsule data */
  200. id->ioccsz = cpu_to_le32((sizeof(struct nvme_command) +
  201. ctrl->ops->sqe_inline_size) / 16);
  202. /* Max response capsule size is cqe */
  203. id->iorcsz = cpu_to_le32(sizeof(struct nvme_completion) / 16);
  204. id->msdbd = ctrl->ops->msdbd;
  205. /*
  206. * Meh, we don't really support any power state. Fake up the same
  207. * values that qemu does.
  208. */
  209. id->psd[0].max_power = cpu_to_le16(0x9c4);
  210. id->psd[0].entry_lat = cpu_to_le32(0x10);
  211. id->psd[0].exit_lat = cpu_to_le32(0x4);
  212. status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id));
  213. kfree(id);
  214. out:
  215. nvmet_req_complete(req, status);
  216. }
  217. static void nvmet_execute_identify_ns(struct nvmet_req *req)
  218. {
  219. struct nvmet_ns *ns;
  220. struct nvme_id_ns *id;
  221. u16 status = 0;
  222. if (le32_to_cpu(req->cmd->identify.nsid) == NVME_NSID_ALL) {
  223. status = NVME_SC_INVALID_NS | NVME_SC_DNR;
  224. goto out;
  225. }
  226. id = kzalloc(sizeof(*id), GFP_KERNEL);
  227. if (!id) {
  228. status = NVME_SC_INTERNAL;
  229. goto out;
  230. }
  231. /* return an all zeroed buffer if we can't find an active namespace */
  232. ns = nvmet_find_namespace(req->sq->ctrl, req->cmd->identify.nsid);
  233. if (!ns)
  234. goto done;
  235. /*
  236. * nuse = ncap = nsze isn't always true, but we have no way to find
  237. * that out from the underlying device.
  238. */
  239. id->ncap = id->nuse = id->nsze =
  240. cpu_to_le64(ns->size >> ns->blksize_shift);
  241. /*
  242. * We just provide a single LBA format that matches what the
  243. * underlying device reports.
  244. */
  245. id->nlbaf = 0;
  246. id->flbas = 0;
  247. /*
  248. * Our namespace might always be shared. Not just with other
  249. * controllers, but also with any other user of the block device.
  250. */
  251. id->nmic = (1 << 0);
  252. memcpy(&id->nguid, &ns->nguid, sizeof(uuid_le));
  253. id->lbaf[0].ds = ns->blksize_shift;
  254. nvmet_put_namespace(ns);
  255. done:
  256. status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id));
  257. kfree(id);
  258. out:
  259. nvmet_req_complete(req, status);
  260. }
  261. static void nvmet_execute_identify_nslist(struct nvmet_req *req)
  262. {
  263. static const int buf_size = NVME_IDENTIFY_DATA_SIZE;
  264. struct nvmet_ctrl *ctrl = req->sq->ctrl;
  265. struct nvmet_ns *ns;
  266. u32 min_nsid = le32_to_cpu(req->cmd->identify.nsid);
  267. __le32 *list;
  268. u16 status = 0;
  269. int i = 0;
  270. list = kzalloc(buf_size, GFP_KERNEL);
  271. if (!list) {
  272. status = NVME_SC_INTERNAL;
  273. goto out;
  274. }
  275. rcu_read_lock();
  276. list_for_each_entry_rcu(ns, &ctrl->subsys->namespaces, dev_link) {
  277. if (ns->nsid <= min_nsid)
  278. continue;
  279. list[i++] = cpu_to_le32(ns->nsid);
  280. if (i == buf_size / sizeof(__le32))
  281. break;
  282. }
  283. rcu_read_unlock();
  284. status = nvmet_copy_to_sgl(req, 0, list, buf_size);
  285. kfree(list);
  286. out:
  287. nvmet_req_complete(req, status);
  288. }
  289. static u16 nvmet_copy_ns_identifier(struct nvmet_req *req, u8 type, u8 len,
  290. void *id, off_t *off)
  291. {
  292. struct nvme_ns_id_desc desc = {
  293. .nidt = type,
  294. .nidl = len,
  295. };
  296. u16 status;
  297. status = nvmet_copy_to_sgl(req, *off, &desc, sizeof(desc));
  298. if (status)
  299. return status;
  300. *off += sizeof(desc);
  301. status = nvmet_copy_to_sgl(req, *off, id, len);
  302. if (status)
  303. return status;
  304. *off += len;
  305. return 0;
  306. }
  307. static void nvmet_execute_identify_desclist(struct nvmet_req *req)
  308. {
  309. struct nvmet_ns *ns;
  310. u16 status = 0;
  311. off_t off = 0;
  312. ns = nvmet_find_namespace(req->sq->ctrl, req->cmd->identify.nsid);
  313. if (!ns) {
  314. status = NVME_SC_INVALID_NS | NVME_SC_DNR;
  315. goto out;
  316. }
  317. if (memchr_inv(&ns->uuid, 0, sizeof(ns->uuid))) {
  318. status = nvmet_copy_ns_identifier(req, NVME_NIDT_UUID,
  319. NVME_NIDT_UUID_LEN,
  320. &ns->uuid, &off);
  321. if (status)
  322. goto out_put_ns;
  323. }
  324. if (memchr_inv(ns->nguid, 0, sizeof(ns->nguid))) {
  325. status = nvmet_copy_ns_identifier(req, NVME_NIDT_NGUID,
  326. NVME_NIDT_NGUID_LEN,
  327. &ns->nguid, &off);
  328. if (status)
  329. goto out_put_ns;
  330. }
  331. if (sg_zero_buffer(req->sg, req->sg_cnt, NVME_IDENTIFY_DATA_SIZE - off,
  332. off) != NVME_IDENTIFY_DATA_SIZE - off)
  333. status = NVME_SC_INTERNAL | NVME_SC_DNR;
  334. out_put_ns:
  335. nvmet_put_namespace(ns);
  336. out:
  337. nvmet_req_complete(req, status);
  338. }
  339. /*
  340. * A "minimum viable" abort implementation: the command is mandatory in the
  341. * spec, but we are not required to do any useful work. We couldn't really
  342. * do a useful abort, so don't bother even with waiting for the command
  343. * to be exectuted and return immediately telling the command to abort
  344. * wasn't found.
  345. */
  346. static void nvmet_execute_abort(struct nvmet_req *req)
  347. {
  348. nvmet_set_result(req, 1);
  349. nvmet_req_complete(req, 0);
  350. }
  351. static void nvmet_execute_set_features(struct nvmet_req *req)
  352. {
  353. struct nvmet_subsys *subsys = req->sq->ctrl->subsys;
  354. u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10[0]);
  355. u32 val32;
  356. u16 status = 0;
  357. switch (cdw10 & 0xff) {
  358. case NVME_FEAT_NUM_QUEUES:
  359. nvmet_set_result(req,
  360. (subsys->max_qid - 1) | ((subsys->max_qid - 1) << 16));
  361. break;
  362. case NVME_FEAT_KATO:
  363. val32 = le32_to_cpu(req->cmd->common.cdw10[1]);
  364. req->sq->ctrl->kato = DIV_ROUND_UP(val32, 1000);
  365. nvmet_set_result(req, req->sq->ctrl->kato);
  366. break;
  367. case NVME_FEAT_ASYNC_EVENT:
  368. val32 = le32_to_cpu(req->cmd->common.cdw10[1]);
  369. if (val32 & ~NVMET_AEN_CFG_ALL) {
  370. status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
  371. break;
  372. }
  373. WRITE_ONCE(req->sq->ctrl->aen_enabled, val32);
  374. nvmet_set_result(req, val32);
  375. break;
  376. case NVME_FEAT_HOST_ID:
  377. status = NVME_SC_CMD_SEQ_ERROR | NVME_SC_DNR;
  378. break;
  379. default:
  380. status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
  381. break;
  382. }
  383. nvmet_req_complete(req, status);
  384. }
  385. static void nvmet_execute_get_features(struct nvmet_req *req)
  386. {
  387. struct nvmet_subsys *subsys = req->sq->ctrl->subsys;
  388. u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10[0]);
  389. u16 status = 0;
  390. switch (cdw10 & 0xff) {
  391. /*
  392. * These features are mandatory in the spec, but we don't
  393. * have a useful way to implement them. We'll eventually
  394. * need to come up with some fake values for these.
  395. */
  396. #if 0
  397. case NVME_FEAT_ARBITRATION:
  398. break;
  399. case NVME_FEAT_POWER_MGMT:
  400. break;
  401. case NVME_FEAT_TEMP_THRESH:
  402. break;
  403. case NVME_FEAT_ERR_RECOVERY:
  404. break;
  405. case NVME_FEAT_IRQ_COALESCE:
  406. break;
  407. case NVME_FEAT_IRQ_CONFIG:
  408. break;
  409. case NVME_FEAT_WRITE_ATOMIC:
  410. break;
  411. #endif
  412. case NVME_FEAT_ASYNC_EVENT:
  413. nvmet_set_result(req, READ_ONCE(req->sq->ctrl->aen_enabled));
  414. break;
  415. case NVME_FEAT_VOLATILE_WC:
  416. nvmet_set_result(req, 1);
  417. break;
  418. case NVME_FEAT_NUM_QUEUES:
  419. nvmet_set_result(req,
  420. (subsys->max_qid-1) | ((subsys->max_qid-1) << 16));
  421. break;
  422. case NVME_FEAT_KATO:
  423. nvmet_set_result(req, req->sq->ctrl->kato * 1000);
  424. break;
  425. case NVME_FEAT_HOST_ID:
  426. /* need 128-bit host identifier flag */
  427. if (!(req->cmd->common.cdw10[1] & cpu_to_le32(1 << 0))) {
  428. status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
  429. break;
  430. }
  431. status = nvmet_copy_to_sgl(req, 0, &req->sq->ctrl->hostid,
  432. sizeof(req->sq->ctrl->hostid));
  433. break;
  434. default:
  435. status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
  436. break;
  437. }
  438. nvmet_req_complete(req, status);
  439. }
  440. static void nvmet_execute_async_event(struct nvmet_req *req)
  441. {
  442. struct nvmet_ctrl *ctrl = req->sq->ctrl;
  443. mutex_lock(&ctrl->lock);
  444. if (ctrl->nr_async_event_cmds >= NVMET_ASYNC_EVENTS) {
  445. mutex_unlock(&ctrl->lock);
  446. nvmet_req_complete(req, NVME_SC_ASYNC_LIMIT | NVME_SC_DNR);
  447. return;
  448. }
  449. ctrl->async_event_cmds[ctrl->nr_async_event_cmds++] = req;
  450. mutex_unlock(&ctrl->lock);
  451. schedule_work(&ctrl->async_event_work);
  452. }
  453. static void nvmet_execute_keep_alive(struct nvmet_req *req)
  454. {
  455. struct nvmet_ctrl *ctrl = req->sq->ctrl;
  456. pr_debug("ctrl %d update keep-alive timer for %d secs\n",
  457. ctrl->cntlid, ctrl->kato);
  458. mod_delayed_work(system_wq, &ctrl->ka_work, ctrl->kato * HZ);
  459. nvmet_req_complete(req, 0);
  460. }
  461. u16 nvmet_parse_admin_cmd(struct nvmet_req *req)
  462. {
  463. struct nvme_command *cmd = req->cmd;
  464. u16 ret;
  465. ret = nvmet_check_ctrl_status(req, cmd);
  466. if (unlikely(ret))
  467. return ret;
  468. switch (cmd->common.opcode) {
  469. case nvme_admin_get_log_page:
  470. req->data_len = nvmet_get_log_page_len(cmd);
  471. switch (cmd->get_log_page.lid) {
  472. case NVME_LOG_ERROR:
  473. /*
  474. * We currently never set the More bit in the status
  475. * field, so all error log entries are invalid and can
  476. * be zeroed out. This is called a minum viable
  477. * implementation (TM) of this mandatory log page.
  478. */
  479. req->execute = nvmet_execute_get_log_page_noop;
  480. return 0;
  481. case NVME_LOG_SMART:
  482. req->execute = nvmet_execute_get_log_page_smart;
  483. return 0;
  484. case NVME_LOG_FW_SLOT:
  485. /*
  486. * We only support a single firmware slot which always
  487. * is active, so we can zero out the whole firmware slot
  488. * log and still claim to fully implement this mandatory
  489. * log page.
  490. */
  491. req->execute = nvmet_execute_get_log_page_noop;
  492. return 0;
  493. case NVME_LOG_CHANGED_NS:
  494. req->execute = nvmet_execute_get_log_changed_ns;
  495. return 0;
  496. }
  497. break;
  498. case nvme_admin_identify:
  499. req->data_len = NVME_IDENTIFY_DATA_SIZE;
  500. switch (cmd->identify.cns) {
  501. case NVME_ID_CNS_NS:
  502. req->execute = nvmet_execute_identify_ns;
  503. return 0;
  504. case NVME_ID_CNS_CTRL:
  505. req->execute = nvmet_execute_identify_ctrl;
  506. return 0;
  507. case NVME_ID_CNS_NS_ACTIVE_LIST:
  508. req->execute = nvmet_execute_identify_nslist;
  509. return 0;
  510. case NVME_ID_CNS_NS_DESC_LIST:
  511. req->execute = nvmet_execute_identify_desclist;
  512. return 0;
  513. }
  514. break;
  515. case nvme_admin_abort_cmd:
  516. req->execute = nvmet_execute_abort;
  517. req->data_len = 0;
  518. return 0;
  519. case nvme_admin_set_features:
  520. req->execute = nvmet_execute_set_features;
  521. req->data_len = 0;
  522. return 0;
  523. case nvme_admin_get_features:
  524. req->execute = nvmet_execute_get_features;
  525. req->data_len = 0;
  526. return 0;
  527. case nvme_admin_async_event:
  528. req->execute = nvmet_execute_async_event;
  529. req->data_len = 0;
  530. return 0;
  531. case nvme_admin_keep_alive:
  532. req->execute = nvmet_execute_keep_alive;
  533. req->data_len = 0;
  534. return 0;
  535. }
  536. pr_err("unhandled cmd %d on qid %d\n", cmd->common.opcode,
  537. req->sq->qid);
  538. return NVME_SC_INVALID_OPCODE | NVME_SC_DNR;
  539. }