Skip to content

Commit 15d7d9c

Browse files
committed
libxscale: Introduce xscale user space RDMA provider
libxscale is a user-space driver that provides RDMA capabilities to user applications. The current patch includes the following components: 1. basic compile framework 2. register/unregister user-space driver via verbs 3. query_port 4. query_device_ex Signed-off-by: Tian Xin <tianx@yunsilicon.com> Signed-off-by: Wei Honggang <weihg@yunsilicon.com> Signed-off-by: Zhao Qianwei <zhaoqw@yunsilicon.com> Signed-off-by: Li Qiang <liq@yunsilicon.com> Signed-off-by: Yan Lei <jacky@yunsilicon.com>
1 parent dd29f7c commit 15d7d9c

File tree

7 files changed

+785
-0
lines changed

7 files changed

+785
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,7 @@ add_subdirectory(providers/mthca)
729729
add_subdirectory(providers/ocrdma)
730730
add_subdirectory(providers/qedr)
731731
add_subdirectory(providers/vmw_pvrdma)
732+
add_subdirectory(providers/xscale)
732733
endif()
733734

734735
add_subdirectory(providers/hfi1verbs)

MAINTAINERS

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,12 @@ PYVERBS
189189
M: Edward Srouji <edwards@mellanox.com>
190190
S: Supported
191191
F: pyverbs/
192+
193+
XSCALE USERSPACE PROVIDER (for xsc_ib.ko)
194+
M: Wei Honggang <weihg@yunsilicon.com>
195+
M: Zhao Qianwei <zhaoqw@yunsilicon.com>
196+
M: Li Qiang <liq@yunsilicon.com>
197+
M: Tian Xin <tianx@yunsilicon.com>
198+
M: Yan Lei <jacky@yunsilicon.com>
199+
S: Supported
200+
F: providers/xscale/

providers/xscale/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
rdma_provider(xscale
2+
xscale.c
3+
verbs.c
4+
)

providers/xscale/verbs.c

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright (c) 2021 - 2022, Shanghai Yunsilicon Technology Co., Ltd.
4+
* All rights reserved.
5+
*/
6+
7+
#include <config.h>
8+
9+
#include <stdlib.h>
10+
#include <stdio.h>
11+
#include <stdatomic.h>
12+
#include <string.h>
13+
#include <pthread.h>
14+
#include <errno.h>
15+
#include <limits.h>
16+
#include <sys/types.h>
17+
#include <sys/stat.h>
18+
#include <fcntl.h>
19+
#include <unistd.h>
20+
#include <sys/mman.h>
21+
#include <ccan/array_size.h>
22+
23+
#include <util/compiler.h>
24+
#include <util/mmio.h>
25+
#include <rdma/ib_user_ioctl_cmds.h>
26+
#include <infiniband/cmd_write.h>
27+
28+
#include "xscale.h"
29+
#include "xsc-abi.h"
30+
31+
int xsc_query_port(struct ibv_context *context, u8 port,
32+
struct ibv_port_attr *attr)
33+
{
34+
struct ibv_query_port cmd;
35+
36+
return ibv_cmd_query_port(context, port, attr, &cmd, sizeof(cmd));
37+
}
38+
39+
static void xsc_set_fw_version(struct ibv_device_attr *attr,
40+
union xsc_ib_fw_ver *fw_ver)
41+
{
42+
u8 ver_major = fw_ver->s.ver_major;
43+
u8 ver_minor = fw_ver->s.ver_minor;
44+
u16 ver_patch = fw_ver->s.ver_patch;
45+
u32 ver_tweak = fw_ver->s.ver_tweak;
46+
47+
if (ver_tweak == 0) {
48+
snprintf(attr->fw_ver, sizeof(attr->fw_ver), "v%u.%u.%u",
49+
ver_major, ver_minor, ver_patch);
50+
} else {
51+
snprintf(attr->fw_ver, sizeof(attr->fw_ver), "v%u.%u.%u+%u",
52+
ver_major, ver_minor, ver_patch, ver_tweak);
53+
}
54+
}
55+
56+
int xsc_query_device_ex(struct ibv_context *context,
57+
const struct ibv_query_device_ex_input *input,
58+
struct ibv_device_attr_ex *attr, size_t attr_size)
59+
{
60+
struct ib_uverbs_ex_query_device_resp resp;
61+
size_t resp_size = sizeof(resp);
62+
union xsc_ib_fw_ver raw_fw_ver;
63+
int err;
64+
65+
raw_fw_ver.data = 0;
66+
err = ibv_cmd_query_device_any(context, input, attr, attr_size,
67+
&resp, &resp_size);
68+
if (err)
69+
return err;
70+
71+
raw_fw_ver.data = resp.base.fw_ver;
72+
xsc_set_fw_version(&attr->orig_attr, &raw_fw_ver);
73+
74+
return 0;
75+
}

providers/xscale/xsc-abi.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Copyright (c) 2021 - 2022, Shanghai Yunsilicon Technology Co., Ltd.
4+
* All rights reserved.
5+
*/
6+
7+
#ifndef XSC_ABI_H
8+
#define XSC_ABI_H
9+
10+
#include <infiniband/kern-abi.h>
11+
#include <infiniband/verbs.h>
12+
#include <rdma/xsc-abi.h>
13+
#include <kernel-abi/xsc-abi.h>
14+
15+
#define XSC_UVERBS_MIN_ABI_VERSION 1
16+
#define XSC_UVERBS_MAX_ABI_VERSION 1
17+
18+
DECLARE_DRV_CMD(xsc_alloc_ucontext, IB_USER_VERBS_CMD_GET_CONTEXT,
19+
empty, xsc_ib_alloc_ucontext_resp);
20+
DECLARE_DRV_CMD(xsc_alloc_pd, IB_USER_VERBS_CMD_ALLOC_PD, empty,
21+
xsc_ib_alloc_pd_resp);
22+
DECLARE_DRV_CMD(xsc_create_cq, IB_USER_VERBS_CMD_CREATE_CQ, xsc_ib_create_cq,
23+
xsc_ib_create_cq_resp);
24+
DECLARE_DRV_CMD(xsc_create_cq_ex, IB_USER_VERBS_EX_CMD_CREATE_CQ,
25+
xsc_ib_create_cq, xsc_ib_create_cq_resp);
26+
DECLARE_DRV_CMD(xsc_create_qp_ex, IB_USER_VERBS_EX_CMD_CREATE_QP,
27+
xsc_ib_create_qp, xsc_ib_create_qp_resp);
28+
DECLARE_DRV_CMD(xsc_create_qp, IB_USER_VERBS_CMD_CREATE_QP, xsc_ib_create_qp,
29+
xsc_ib_create_qp_resp);
30+
31+
#endif /* XSC_ABI_H */

0 commit comments

Comments
 (0)