Skip to content

Commit 2352460

Browse files
committed
libzrdma: Add init framework code for ZTE DingHai rdma-core driver
This patch add code mainframework for RDMA userspace library of zxdh zrdma. Including operation functions for register zxdh device zrdma. on-behalf-of: @ZTE li.fuyan@zte.com Signed-off-by: zte_lifuyan <li.fuyan@zte.com.cn>
1 parent 86c99fb commit 2352460

File tree

14 files changed

+1234
-0
lines changed

14 files changed

+1234
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,7 @@ add_subdirectory(providers/mthca)
742742
add_subdirectory(providers/ocrdma)
743743
add_subdirectory(providers/qedr)
744744
add_subdirectory(providers/vmw_pvrdma)
745+
add_subdirectory(providers/zrdma)
745746
endif()
746747

747748
add_subdirectory(providers/hfi1verbs)

kernel-headers/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ publish_internal_headers(rdma
2626
rdma/rvt-abi.h
2727
rdma/siw-abi.h
2828
rdma/vmw_pvrdma-abi.h
29+
rdma/zxdh-abi.h
2930
)
3031

3132
publish_internal_headers(rdma/hfi
@@ -80,6 +81,7 @@ rdma_kernel_provider_abi(
8081
rdma/rdma_user_rxe.h
8182
rdma/siw-abi.h
8283
rdma/vmw_pvrdma-abi.h
84+
rdma/zxdh-abi.h
8385
)
8486

8587
publish_headers(infiniband

kernel-headers/rdma/ib_user_ioctl_verbs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ enum rdma_driver_id {
255255
RDMA_DRIVER_SIW,
256256
RDMA_DRIVER_ERDMA,
257257
RDMA_DRIVER_MANA,
258+
RDMA_DRIVER_ZXDH,
258259
};
259260

260261
enum ib_uverbs_gid_type {

kernel-headers/rdma/zxdh-abi.h

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR Linux-OpenIB) */
2+
/*
3+
* Copyright (c) 2024 ZTE Corporation.
4+
*
5+
* This software is available to you under a choice of one of two
6+
* licenses. You may choose to be licensed under the terms of the GNU
7+
* General Public License (GPL) Version 2, available from the file
8+
* COPYING in the main directory of this source tree, or the
9+
* OpenIB.org BSD license below:
10+
*
11+
* Redistribution and use in source and binary forms, with or
12+
* without modification, are permitted provided that the following
13+
* conditions are met:
14+
*
15+
* - Redistributions of source code must retain the above
16+
* copyright notice, this list of conditions and the following
17+
* disclaimer.
18+
*
19+
* - Redistributions in binary form must reproduce the above
20+
* copyright notice, this list of conditions and the following
21+
* disclaimer in the documentation and/or other materials
22+
* provided with the distribution.
23+
*
24+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28+
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
29+
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31+
* SOFTWARE.
32+
*/
33+
34+
#ifndef ZXDH_ABI_H
35+
#define ZXDH_ABI_H
36+
37+
#include <linux/types.h>
38+
39+
/* user-space whose last ABI ver is 5 */
40+
#define ZXDH_ABI_VER 5
41+
#define ZXDH_CONTEXT_VER_V1 5
42+
43+
enum zxdh_memreg_type {
44+
ZXDH_MEMREG_TYPE_MEM = 0,
45+
ZXDH_MEMREG_TYPE_QP = 1,
46+
ZXDH_MEMREG_TYPE_CQ = 2,
47+
ZXDH_MEMREG_TYPE_SRQ = 3,
48+
};
49+
50+
enum zxdh_db_addr_type {
51+
ZXDH_DB_ADDR_PHY = 0,
52+
ZXDH_DB_ADDR_BAR = 1,
53+
};
54+
55+
struct zxdh_alloc_ucontext_req {
56+
__u32 rsvd32;
57+
__u8 userspace_ver;
58+
__u8 rsvd8[3];
59+
};
60+
61+
struct zxdh_alloc_ucontext_resp {
62+
__u32 max_pds;
63+
__u32 max_qps;
64+
__u32 wq_size; /* size of the WQs (SQ+RQ) in the mmaped area */
65+
__u8 kernel_ver;
66+
__u8 db_addr_type;
67+
__u16 rdma_tool_flags;
68+
__aligned_u64 feature_flags;
69+
__aligned_u64 sq_db_mmap_key;
70+
__aligned_u64 cq_db_mmap_key;
71+
__aligned_u64 sq_db_pa;
72+
__aligned_u64 cq_db_pa;
73+
__u32 max_hw_wq_frags;
74+
__u32 max_hw_read_sges;
75+
__u32 max_hw_inline;
76+
__u32 max_hw_rq_quanta;
77+
__u32 max_hw_srq_quanta;
78+
__u32 max_hw_wq_quanta;
79+
__u32 max_hw_srq_wr;
80+
__u32 min_hw_cq_size;
81+
__u32 max_hw_cq_size;
82+
__u16 max_hw_sq_chunk;
83+
__u8 rsvd;
84+
__u8 chip_rev;
85+
};
86+
87+
struct zxdh_alloc_pd_resp {
88+
__u32 pd_id;
89+
__u8 rsvd[4];
90+
};
91+
92+
struct zxdh_resize_cq_req {
93+
__aligned_u64 user_cq_buffer;
94+
};
95+
96+
struct zxdh_create_cq_req {
97+
__aligned_u64 user_cq_buf;
98+
__aligned_u64 user_shadow_area;
99+
};
100+
101+
struct zxdh_create_qp_req {
102+
__aligned_u64 user_wqe_bufs;
103+
__aligned_u64 user_compl_ctx;
104+
};
105+
106+
struct zxdh_create_srq_req {
107+
__aligned_u64 user_wqe_bufs;
108+
__aligned_u64 user_compl_ctx;
109+
__aligned_u64 user_wqe_list;
110+
__aligned_u64 user_wqe_db;
111+
};
112+
113+
struct zxdh_mem_reg_req {
114+
__u32 reg_type; /* enum zxdh_memreg_type */
115+
__u32 cq_pages;
116+
__u32 rq_pages;
117+
__u32 sq_pages;
118+
__u32 srq_pages;
119+
__u16 srq_list_pages;
120+
__u8 rsvd[2];
121+
};
122+
123+
struct zxdh_reg_mr_resp {
124+
__u32 mr_pa_low;
125+
__u32 mr_pa_hig;
126+
__u16 host_page_size;
127+
__u16 leaf_pbl_size;
128+
__u8 rsvd[4];
129+
};
130+
131+
struct zxdh_modify_qp_req {
132+
__u8 sq_flush;
133+
__u8 rq_flush;
134+
__u8 rsvd[6];
135+
};
136+
137+
struct zxdh_create_cq_resp {
138+
__u32 cq_id;
139+
__u32 cq_size;
140+
};
141+
142+
struct zxdh_create_qp_resp {
143+
__u32 qp_id;
144+
__u32 actual_sq_size;
145+
__u32 actual_rq_size;
146+
__u32 zxdh_drv_opt;
147+
__u16 push_idx;
148+
__u8 lsmm;
149+
__u8 rsvd;
150+
__u32 qp_caps;
151+
};
152+
153+
struct zxdh_create_srq_resp {
154+
__u32 srq_id;
155+
__u32 actual_srq_size;
156+
__u32 actual_srq_list_size;
157+
__u8 rsvd[4];
158+
};
159+
160+
struct zxdh_modify_qp_resp {
161+
__aligned_u64 push_wqe_mmap_key;
162+
__aligned_u64 push_db_mmap_key;
163+
__u16 push_offset;
164+
__u8 push_valid;
165+
__u8 rsvd[5];
166+
};
167+
168+
struct zxdh_create_ah_resp {
169+
__u32 ah_id;
170+
__u8 rsvd[4];
171+
};
172+
#endif /* ZXDH_ABI_H */

libibverbs/verbs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2267,6 +2267,7 @@ struct ibv_device **ibv_get_device_list(int *num_devices);
22672267
none, none, none)
22682268

22692269
struct verbs_devices_ops;
2270+
extern const struct verbs_device_ops verbs_provider_zrdma;
22702271
extern const struct verbs_device_ops verbs_provider_bnxt_re;
22712272
extern const struct verbs_device_ops verbs_provider_cxgb4;
22722273
extern const struct verbs_device_ops verbs_provider_efa;

providers/zrdma/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
2+
rdma_shared_provider(zrdma libzrdma.map
3+
1 1.1.${PACKAGE_VERSION}
4+
zxdh_zrdma.c
5+
zxdh_verbs.c
6+
)
7+
8+
rdma_pkg_config("zrdma" "libibverbs" "${CMAKE_THREAD_LIBS_INIT}")

providers/zrdma/libzrdma.map

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/* Export symbols should be added below according to
2+
Documentation/versioning.md document. */
3+
ZRDMA_1.0 {
4+
local: *;
5+
};

providers/zrdma/zxdh_abi.h

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR Linux-OpenIB) */
2+
/*
3+
* Copyright (c) 2024 ZTE Corporation.
4+
*
5+
* This software is available to you under a choice of one of two
6+
* licenses. You may choose to be licensed under the terms of the GNU
7+
* General Public License (GPL) Version 2, available from the file
8+
* COPYING in the main directory of this source tree, or the
9+
* OpenIB.org BSD license below:
10+
*
11+
* Redistribution and use in source and binary forms, with or
12+
* without modification, are permitted provided that the following
13+
* conditions are met:
14+
*
15+
* - Redistributions of source code must retain the above
16+
* copyright notice, this list of conditions and the following
17+
* disclaimer.
18+
*
19+
* - Redistributions in binary form must reproduce the above
20+
* copyright notice, this list of conditions and the following
21+
* disclaimer in the documentation and/or other materials
22+
* provided with the distribution.
23+
*
24+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28+
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
29+
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31+
* SOFTWARE.
32+
*/
33+
#ifndef __ZXDH_ABI_H__
34+
#define __ZXDH_ABI_H__
35+
36+
#include <infiniband/kern-abi.h>
37+
#include <rdma/zxdh-abi.h>
38+
#include <kernel-abi/zxdh-abi.h>
39+
#include "zxdh_verbs.h"
40+
41+
#define ZXDH_MIN_ABI_VERSION 0
42+
#define ZXDH_MAX_ABI_VERSION 5
43+
44+
DECLARE_DRV_CMD(zxdh_ualloc_pd, IB_USER_VERBS_CMD_ALLOC_PD, empty,
45+
zxdh_alloc_pd_resp);
46+
DECLARE_DRV_CMD(zxdh_ucreate_cq, IB_USER_VERBS_CMD_CREATE_CQ,
47+
zxdh_create_cq_req, zxdh_create_cq_resp);
48+
DECLARE_DRV_CMD(zxdh_ucreate_cq_ex, IB_USER_VERBS_EX_CMD_CREATE_CQ,
49+
zxdh_create_cq_req, zxdh_create_cq_resp);
50+
DECLARE_DRV_CMD(zxdh_uresize_cq, IB_USER_VERBS_CMD_RESIZE_CQ,
51+
zxdh_resize_cq_req, empty);
52+
DECLARE_DRV_CMD(zxdh_ucreate_qp, IB_USER_VERBS_CMD_CREATE_QP,
53+
zxdh_create_qp_req, zxdh_create_qp_resp);
54+
DECLARE_DRV_CMD(zxdh_umodify_qp, IB_USER_VERBS_EX_CMD_MODIFY_QP,
55+
zxdh_modify_qp_req, zxdh_modify_qp_resp);
56+
DECLARE_DRV_CMD(zxdh_get_context, IB_USER_VERBS_CMD_GET_CONTEXT,
57+
zxdh_alloc_ucontext_req, zxdh_alloc_ucontext_resp);
58+
DECLARE_DRV_CMD(zxdh_ureg_mr, IB_USER_VERBS_CMD_REG_MR, zxdh_mem_reg_req,
59+
zxdh_reg_mr_resp);
60+
DECLARE_DRV_CMD(zxdh_urereg_mr, IB_USER_VERBS_CMD_REREG_MR, zxdh_mem_reg_req,
61+
empty);
62+
DECLARE_DRV_CMD(zxdh_ucreate_ah, IB_USER_VERBS_CMD_CREATE_AH, empty,
63+
zxdh_create_ah_resp);
64+
DECLARE_DRV_CMD(zxdh_ucreate_srq, IB_USER_VERBS_CMD_CREATE_SRQ,
65+
zxdh_create_srq_req, zxdh_create_srq_resp);
66+
#endif /* __ZXDH_ABI_H__ */

providers/zrdma/zxdh_defs.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR Linux-OpenIB) */
2+
/*
3+
* Copyright (c) 2024 ZTE Corporation.
4+
*
5+
* This software is available to you under a choice of one of two
6+
* licenses. You may choose to be licensed under the terms of the GNU
7+
* General Public License (GPL) Version 2, available from the file
8+
* COPYING in the main directory of this source tree, or the
9+
* OpenIB.org BSD license below:
10+
*
11+
* Redistribution and use in source and binary forms, with or
12+
* without modification, are permitted provided that the following
13+
* conditions are met:
14+
*
15+
* - Redistributions of source code must retain the above
16+
* copyright notice, this list of conditions and the following
17+
* disclaimer.
18+
*
19+
* - Redistributions in binary form must reproduce the above
20+
* copyright notice, this list of conditions and the following
21+
* disclaimer in the documentation and/or other materials
22+
* provided with the distribution.
23+
*
24+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28+
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
29+
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31+
* SOFTWARE.
32+
*/
33+
#ifndef __ZXDH_DEFS_H__
34+
#define __ZXDH_DEFS_H__
35+
36+
#define ZXDH_HW_PAGE_SIZE 4096
37+
38+
#endif /* __ZXDH_DEFS_H__ */

providers/zrdma/zxdh_devids.h

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR Linux-OpenIB) */
2+
/*
3+
* Copyright (c) 2024 ZTE Corporation.
4+
*
5+
* This software is available to you under a choice of one of two
6+
* licenses. You may choose to be licensed under the terms of the GNU
7+
* General Public License (GPL) Version 2, available from the file
8+
* COPYING in the main directory of this source tree, or the
9+
* OpenIB.org BSD license below:
10+
*
11+
* Redistribution and use in source and binary forms, with or
12+
* without modification, are permitted provided that the following
13+
* conditions are met:
14+
*
15+
* - Redistributions of source code must retain the above
16+
* copyright notice, this list of conditions and the following
17+
* disclaimer.
18+
*
19+
* - Redistributions in binary form must reproduce the above
20+
* copyright notice, this list of conditions and the following
21+
* disclaimer in the documentation and/or other materials
22+
* provided with the distribution.
23+
*
24+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28+
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
29+
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31+
* SOFTWARE.
32+
*/
33+
#ifndef __ZXDH_DEVIDS_H__
34+
#define __ZXDH_DEVIDS_H__
35+
36+
/* ZXDH VENDOR ID */
37+
#define PCI_VENDOR_ID_ZXDH_EVB 0x16c3
38+
#define PCI_VENDOR_ID_ZXDH_E312 0x1cf2
39+
#define PCI_VENDOR_ID_ZXDH_E310 0x1cf2
40+
#define PCI_VENDOR_ID_ZXDH_E310_RDMA 0x1cf2
41+
#define PCI_VENDOR_ID_ZXDH_E316 0x1cf2
42+
#define PCI_VENDOR_ID_ZXDH_X512 0x1cf2
43+
/* ZXDH Devices ID */
44+
#define ZXDH_DEV_ID_ADAPTIVE_EVB_PF 0x8040 /* ZXDH EVB PF DEVICE ID*/
45+
#define ZXDH_DEV_ID_ADAPTIVE_EVB_VF 0x8041 /* ZXDH EVB VF DEVICE ID*/
46+
#define ZXDH_DEV_ID_ADAPTIVE_E312_PF 0x8049 /* ZXDH E312 PF DEVICE ID*/
47+
#define ZXDH_DEV_ID_ADAPTIVE_E312_VF 0x8060 /* ZXDH E312 VF DEVICE ID*/
48+
#define ZXDH_DEV_ID_ADAPTIVE_E310_PF 0x8061 /* ZXDH E310 PF DEVICE ID*/
49+
#define ZXDH_DEV_ID_ADAPTIVE_E310_VF 0x8062 /* ZXDH E310 VF DEVICE ID*/
50+
#define ZXDH_DEV_ID_ADAPTIVE_E310_RDMA_PF 0x8084 /* ZXDH E310_RDMA PF DEVICE ID*/
51+
#define ZXDH_DEV_ID_ADAPTIVE_E310_RDMA_VF 0x8085 /* ZXDH E310_RDMA VF DEVICE ID*/
52+
#define ZXDH_DEV_ID_ADAPTIVE_E316_PF 0x807e /* ZXDH E316 PF DEVICE ID*/
53+
#define ZXDH_DEV_ID_ADAPTIVE_E316_VF 0x807f /* ZXDH E316 VF DEVICE ID*/
54+
#define ZXDH_DEV_ID_ADAPTIVE_X512_PF 0x806B /* ZXDH X512 PF DEVICE ID*/
55+
#define ZXDH_DEV_ID_ADAPTIVE_X512_VF 0x806C /* ZXDH X512 VF DEVICE ID*/
56+
#endif /* __ZXDH_DEVIDS_H__ */

0 commit comments

Comments
 (0)