]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
nvme-rdma: move nvme cm status helper to .h file
authorMax Gurtovoy <maxg@mellanox.com>
Mon, 20 Feb 2017 11:44:28 +0000 (13:44 +0200)
committerJens Axboe <axboe@fb.com>
Wed, 22 Feb 2017 20:34:00 +0000 (13:34 -0700)
This will enable the usage for nvme rdma target.
Also move from a lookup array to a switch statement.

Signed-off-by: Max Gurtovoy <maxg@mellanox.com>
Reviewed-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>
drivers/nvme/host/rdma.c
include/linux/nvme-rdma.h

index aedac6e28c6fb5f9b6c57f1f48000f754ac4f3e2..ee789b38bae599b9c95b1a9da70019d6106ac608 100644 (file)
 
 #define NVME_RDMA_MAX_INLINE_SEGMENTS  1
 
-static const char *const nvme_rdma_cm_status_strs[] = {
-       [NVME_RDMA_CM_INVALID_LEN]      = "invalid length",
-       [NVME_RDMA_CM_INVALID_RECFMT]   = "invalid record format",
-       [NVME_RDMA_CM_INVALID_QID]      = "invalid queue ID",
-       [NVME_RDMA_CM_INVALID_HSQSIZE]  = "invalid host SQ size",
-       [NVME_RDMA_CM_INVALID_HRQSIZE]  = "invalid host RQ size",
-       [NVME_RDMA_CM_NO_RSC]           = "resource not found",
-       [NVME_RDMA_CM_INVALID_IRD]      = "invalid IRD",
-       [NVME_RDMA_CM_INVALID_ORD]      = "Invalid ORD",
-};
-
-static const char *nvme_rdma_cm_msg(enum nvme_rdma_cm_status status)
-{
-       size_t index = status;
-
-       if (index < ARRAY_SIZE(nvme_rdma_cm_status_strs) &&
-           nvme_rdma_cm_status_strs[index])
-               return nvme_rdma_cm_status_strs[index];
-       else
-               return "unrecognized reason";
-};
-
 /*
  * We handle AEN commands ourselves and don't even let the
  * block layer know about them.
index bf240a3cbf9990835e3e3106eff701ec86f8c73e..a72fd04aa5e1eac103dd94165edece813663b456 100644 (file)
@@ -29,6 +29,30 @@ enum nvme_rdma_cm_status {
        NVME_RDMA_CM_INVALID_ORD        = 0x08,
 };
 
+static inline const char *nvme_rdma_cm_msg(enum nvme_rdma_cm_status status)
+{
+       switch (status) {
+       case NVME_RDMA_CM_INVALID_LEN:
+               return "invalid length";
+       case NVME_RDMA_CM_INVALID_RECFMT:
+               return "invalid record format";
+       case NVME_RDMA_CM_INVALID_QID:
+               return "invalid queue ID";
+       case NVME_RDMA_CM_INVALID_HSQSIZE:
+               return "invalid host SQ size";
+       case NVME_RDMA_CM_INVALID_HRQSIZE:
+               return "invalid host RQ size";
+       case NVME_RDMA_CM_NO_RSC:
+               return "resource not found";
+       case NVME_RDMA_CM_INVALID_IRD:
+               return "invalid IRD";
+       case NVME_RDMA_CM_INVALID_ORD:
+               return "Invalid ORD";
+       default:
+               return "unrecognized reason";
+       }
+}
+
 /**
  * struct nvme_rdma_cm_req - rdma connect request
  *