Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nvme-rdma: move nvme cm status helper to .h file

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>

authored by

Max Gurtovoy and committed by
Jens Axboe
3ee80c3d faef3af6

+24 -22
-22
drivers/nvme/host/rdma.c
··· 42 42 43 43 #define NVME_RDMA_MAX_INLINE_SEGMENTS 1 44 44 45 - static const char *const nvme_rdma_cm_status_strs[] = { 46 - [NVME_RDMA_CM_INVALID_LEN] = "invalid length", 47 - [NVME_RDMA_CM_INVALID_RECFMT] = "invalid record format", 48 - [NVME_RDMA_CM_INVALID_QID] = "invalid queue ID", 49 - [NVME_RDMA_CM_INVALID_HSQSIZE] = "invalid host SQ size", 50 - [NVME_RDMA_CM_INVALID_HRQSIZE] = "invalid host RQ size", 51 - [NVME_RDMA_CM_NO_RSC] = "resource not found", 52 - [NVME_RDMA_CM_INVALID_IRD] = "invalid IRD", 53 - [NVME_RDMA_CM_INVALID_ORD] = "Invalid ORD", 54 - }; 55 - 56 - static const char *nvme_rdma_cm_msg(enum nvme_rdma_cm_status status) 57 - { 58 - size_t index = status; 59 - 60 - if (index < ARRAY_SIZE(nvme_rdma_cm_status_strs) && 61 - nvme_rdma_cm_status_strs[index]) 62 - return nvme_rdma_cm_status_strs[index]; 63 - else 64 - return "unrecognized reason"; 65 - }; 66 - 67 45 /* 68 46 * We handle AEN commands ourselves and don't even let the 69 47 * block layer know about them.
+24
include/linux/nvme-rdma.h
··· 29 29 NVME_RDMA_CM_INVALID_ORD = 0x08, 30 30 }; 31 31 32 + static inline const char *nvme_rdma_cm_msg(enum nvme_rdma_cm_status status) 33 + { 34 + switch (status) { 35 + case NVME_RDMA_CM_INVALID_LEN: 36 + return "invalid length"; 37 + case NVME_RDMA_CM_INVALID_RECFMT: 38 + return "invalid record format"; 39 + case NVME_RDMA_CM_INVALID_QID: 40 + return "invalid queue ID"; 41 + case NVME_RDMA_CM_INVALID_HSQSIZE: 42 + return "invalid host SQ size"; 43 + case NVME_RDMA_CM_INVALID_HRQSIZE: 44 + return "invalid host RQ size"; 45 + case NVME_RDMA_CM_NO_RSC: 46 + return "resource not found"; 47 + case NVME_RDMA_CM_INVALID_IRD: 48 + return "invalid IRD"; 49 + case NVME_RDMA_CM_INVALID_ORD: 50 + return "Invalid ORD"; 51 + default: 52 + return "unrecognized reason"; 53 + } 54 + } 55 + 32 56 /** 33 57 * struct nvme_rdma_cm_req - rdma connect request 34 58 *