xref: /linux/include/linux/nvme-rdma.h (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (c) 2015 Mellanox Technologies. All rights reserved.
4  */
5 
6 #ifndef _LINUX_NVME_RDMA_H
7 #define _LINUX_NVME_RDMA_H
8 
9 #define NVME_RDMA_IP_PORT		4420
10 
11 #define NVME_RDMA_MAX_QUEUE_SIZE 256
12 #define NVME_RDMA_MAX_METADATA_QUEUE_SIZE 128
13 #define NVME_RDMA_DEFAULT_QUEUE_SIZE 128
14 
15 enum nvme_rdma_cm_fmt {
16 	NVME_RDMA_CM_FMT_1_0 = 0x0,
17 };
18 
19 enum nvme_rdma_cm_status {
20 	NVME_RDMA_CM_INVALID_LEN	= 0x01,
21 	NVME_RDMA_CM_INVALID_RECFMT	= 0x02,
22 	NVME_RDMA_CM_INVALID_QID	= 0x03,
23 	NVME_RDMA_CM_INVALID_HSQSIZE	= 0x04,
24 	NVME_RDMA_CM_INVALID_HRQSIZE	= 0x05,
25 	NVME_RDMA_CM_NO_RSC		= 0x06,
26 	NVME_RDMA_CM_INVALID_IRD	= 0x07,
27 	NVME_RDMA_CM_INVALID_ORD	= 0x08,
28 	NVME_RDMA_CM_INVALID_CNTLID	= 0x09,
29 };
30 
31 static inline const char *nvme_rdma_cm_msg(enum nvme_rdma_cm_status status)
32 {
33 	switch (status) {
34 	case NVME_RDMA_CM_INVALID_LEN:
35 		return "invalid length";
36 	case NVME_RDMA_CM_INVALID_RECFMT:
37 		return "invalid record format";
38 	case NVME_RDMA_CM_INVALID_QID:
39 		return "invalid queue ID";
40 	case NVME_RDMA_CM_INVALID_HSQSIZE:
41 		return "invalid host SQ size";
42 	case NVME_RDMA_CM_INVALID_HRQSIZE:
43 		return "invalid host RQ size";
44 	case NVME_RDMA_CM_NO_RSC:
45 		return "resource not found";
46 	case NVME_RDMA_CM_INVALID_IRD:
47 		return "invalid IRD";
48 	case NVME_RDMA_CM_INVALID_ORD:
49 		return "Invalid ORD";
50 	case NVME_RDMA_CM_INVALID_CNTLID:
51 		return "invalid controller ID";
52 	default:
53 		return "unrecognized reason";
54 	}
55 }
56 
57 /**
58  * struct nvme_rdma_cm_req - rdma connect request
59  *
60  * @recfmt:        format of the RDMA Private Data
61  * @qid:           queue Identifier for the Admin or I/O Queue
62  * @hrqsize:       host receive queue size to be created
63  * @hsqsize:       host send queue size to be created
64  */
65 struct nvme_rdma_cm_req {
66 	__le16		recfmt;
67 	__le16		qid;
68 	__le16		hrqsize;
69 	__le16		hsqsize;
70 	__le16		cntlid;
71 	u8		rsvd[22];
72 };
73 
74 /**
75  * struct nvme_rdma_cm_rep - rdma connect reply
76  *
77  * @recfmt:        format of the RDMA Private Data
78  * @crqsize:       controller receive queue size
79  */
80 struct nvme_rdma_cm_rep {
81 	__le16		recfmt;
82 	__le16		crqsize;
83 	u8		rsvd[28];
84 };
85 
86 /**
87  * struct nvme_rdma_cm_rej - rdma connect reject
88  *
89  * @recfmt:        format of the RDMA Private Data
90  * @sts:           error status for the associated connect request
91  */
92 struct nvme_rdma_cm_rej {
93 	__le16		recfmt;
94 	__le16		sts;
95 };
96 
97 #endif /* _LINUX_NVME_RDMA_H */
98