aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nvme/target/admin-cmd.c
diff options
context:
space:
mode:
authorParav Pandit <parav@mellanox.com>2017-02-28 00:21:33 -0500
committerJens Axboe <axboe@fb.com>2017-04-04 11:48:23 -0400
commit64a0ca88eaa66e3d219296b17aa08b78894e42c8 (patch)
treeda9d6c8470ede1cc415e7117d29cd3a5a9baed1d /drivers/nvme/target/admin-cmd.c
parent4151dd9a58c6b2758514fc88a1a3b02f9ab8b076 (diff)
nvmet: Introduced helper routine for controller status check.
This patch introduces helper function for checking controller status during admin and io command processing which returns u16 status. As to bring consistency on returning status, other friend functions also now return u16 status instead of int to match the spec. As part of the theseerror log prints in also prints qid on which command error occured. Signed-off-by: Parav Pandit <parav@mellanox.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/nvme/target/admin-cmd.c')
-rw-r--r--drivers/nvme/target/admin-cmd.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 42b8bba97e7d..105ace88d07e 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -480,22 +480,16 @@ static void nvmet_execute_keep_alive(struct nvmet_req *req)
480 nvmet_req_complete(req, 0); 480 nvmet_req_complete(req, 0);
481} 481}
482 482
483int nvmet_parse_admin_cmd(struct nvmet_req *req) 483u16 nvmet_parse_admin_cmd(struct nvmet_req *req)
484{ 484{
485 struct nvme_command *cmd = req->cmd; 485 struct nvme_command *cmd = req->cmd;
486 u16 ret;
486 487
487 req->ns = NULL; 488 req->ns = NULL;
488 489
489 if (unlikely(!(req->sq->ctrl->cc & NVME_CC_ENABLE))) { 490 ret = nvmet_check_ctrl_status(req, cmd);
490 pr_err("got admin cmd %d while CC.EN == 0\n", 491 if (unlikely(ret))
491 cmd->common.opcode); 492 return ret;
492 return NVME_SC_CMD_SEQ_ERROR | NVME_SC_DNR;
493 }
494 if (unlikely(!(req->sq->ctrl->csts & NVME_CSTS_RDY))) {
495 pr_err("got admin cmd %d while CSTS.RDY == 0\n",
496 cmd->common.opcode);
497 return NVME_SC_CMD_SEQ_ERROR | NVME_SC_DNR;
498 }
499 493
500 switch (cmd->common.opcode) { 494 switch (cmd->common.opcode) {
501 case nvme_admin_get_log_page: 495 case nvme_admin_get_log_page:
@@ -545,6 +539,7 @@ int nvmet_parse_admin_cmd(struct nvmet_req *req)
545 return 0; 539 return 0;
546 } 540 }
547 541
548 pr_err("unhandled cmd %d\n", cmd->common.opcode); 542 pr_err("unhandled cmd %d on qid %d\n", cmd->common.opcode,
543 req->sq->qid);
549 return NVME_SC_INVALID_OPCODE | NVME_SC_DNR; 544 return NVME_SC_INVALID_OPCODE | NVME_SC_DNR;
550} 545}