nvmet: add support to Discovery controllers for commands
authorJay Sternberg <jay.e.sternberg@intel.com>
Mon, 12 Nov 2018 21:56:38 +0000 (13:56 -0800)
committerJens Axboe <axboe@kernel.dk>
Sat, 8 Dec 2018 05:26:56 +0000 (22:26 -0700)
Add custom get/set features to commands allowed by Discovery controllers.

Signed-off-by: Jay Sternberg <jay.e.sternberg@intel.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/nvme/target/discovery.c

index 6e0f91eb34ce1e4fd003f5beb08c181b347b216b..050e4d759b65de753d3a0cbc67797e26cb1a974b 100644 (file)
@@ -183,6 +183,47 @@ out:
        nvmet_req_complete(req, status);
 }
 
+static void nvmet_execute_disc_set_features(struct nvmet_req *req)
+{
+       u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10[0]);
+       u16 stat;
+
+       switch (cdw10 & 0xff) {
+       case NVME_FEAT_KATO:
+               stat = nvmet_set_feat_kato(req);
+               break;
+       case NVME_FEAT_ASYNC_EVENT:
+               stat = nvmet_set_feat_async_event(req,
+                                                 NVMET_DISC_AEN_CFG_OPTIONAL);
+               break;
+       default:
+               stat = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
+               break;
+       }
+
+       nvmet_req_complete(req, stat);
+}
+
+static void nvmet_execute_disc_get_features(struct nvmet_req *req)
+{
+       u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10[0]);
+       u16 stat = 0;
+
+       switch (cdw10 & 0xff) {
+       case NVME_FEAT_KATO:
+               nvmet_get_feat_kato(req);
+               break;
+       case NVME_FEAT_ASYNC_EVENT:
+               nvmet_get_feat_async_event(req);
+               break;
+       default:
+               stat = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
+               break;
+       }
+
+       nvmet_req_complete(req, stat);
+}
+
 u16 nvmet_parse_discovery_cmd(struct nvmet_req *req)
 {
        struct nvme_command *cmd = req->cmd;
@@ -194,6 +235,18 @@ u16 nvmet_parse_discovery_cmd(struct nvmet_req *req)
        }
 
        switch (cmd->common.opcode) {
+       case nvme_admin_set_features:
+               req->execute = nvmet_execute_disc_set_features;
+               req->data_len = 0;
+               return 0;
+       case nvme_admin_get_features:
+               req->execute = nvmet_execute_disc_get_features;
+               req->data_len = 0;
+               return 0;
+       case nvme_admin_async_event:
+               req->execute = nvmet_execute_async_event;
+               req->data_len = 0;
+               return 0;
        case nvme_admin_keep_alive:
                req->execute = nvmet_execute_keep_alive;
                req->data_len = 0;