-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathib.h
More file actions
104 lines (76 loc) · 2.75 KB
/
ib.h
File metadata and controls
104 lines (76 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* Copyright (c) 2016--2021 Wu, Xingbo <wuxb45@gmail.com>
*
* All rights reserved. No warranty, explicit or implicit, provided.
*/
#pragma once
#include <infiniband/verbs.h>
#ifdef __cplusplus
extern "C" {
#endif
struct ib_port;
struct ib_socket {
struct ib_port * port;
u64 depth;
struct ibv_qp * qp; // queue pair 0 (send for UD)
struct ibv_cq * cq; // completion queue
struct ibv_wc wcs[]; // work-completion buffer
};
struct ib_remote_ptr {
u8 * rptr;
size_t len;
u32 rkey;
};
extern struct ib_port *
ib_port_create(const u64 index);
extern void
ib_port_destroy(struct ib_port * const port);
extern struct ibv_mr *
ib_mr_helper(struct ib_port *port, void *addr, size_t length);
extern bool
ib_mr_send_rptr_fd(const int fd, struct ibv_mr * const mr);
extern bool
ib_mr_recv_rptr_fd(const int fd, struct ib_remote_ptr * const rptr);
extern void *
ib_sge_fill_off(struct ibv_sge * const sg, struct ibv_mr * const mr, const size_t off, const size_t size);
extern u64
ib_sge_fill_ptr(struct ibv_sge * const sg, struct ibv_mr * const mr, void * const ptr, const size_t size);
extern struct ib_socket *
ib_socket_create(struct ib_port * const port, const u64 depth);
extern bool
ib_socket_connect_fd(struct ib_socket * const s, const int fd);
extern void
ib_socket_destroy(struct ib_socket * const s);
// send
extern void
ib_wr_fill_send(struct ibv_send_wr * const wr, const u64 id, struct ibv_sge * const sg);
extern void
ib_wr_fill_send_imm(struct ibv_send_wr * const wr, const u64 id, struct ibv_sge * const sg, const u32 imm);
extern void
ib_wr_fill_write(struct ibv_send_wr * const wr, const u64 id, struct ibv_sge * const sg,
const struct ib_remote_ptr * const rptr, const u32 off);
extern void
ib_wr_fill_write_imm(struct ibv_send_wr * const wr, const u64 id, struct ibv_sge * const sg,
const struct ib_remote_ptr * const rptr, const u32 off, const u32 imm);
extern void
ib_wr_fill_read(struct ibv_send_wr * const wr, const u64 id, struct ibv_sge * const sg,
const struct ib_remote_ptr * const rptr, const u32 off);
extern void
ib_wr_fill_recv(struct ibv_recv_wr * const wr, const u64 id, struct ibv_sge * const sg,
struct ibv_recv_wr * const prev);
extern void
ib_swr_link(struct ibv_send_wr * const wrs, const u32 nr);
extern void
ib_rwr_link(struct ibv_recv_wr * const wrs, const u32 nr);
extern bool
ib_socket_post_send(struct ib_socket * const s, struct ibv_send_wr * const wr, const bool signaled);
extern bool
ib_socket_post_recv_sge(struct ib_socket * const s, const u64 id, struct ibv_sge * const sg);
extern bool
ib_socket_post_recv(struct ib_socket * const s, struct ibv_recv_wr * const wr);
extern int
ib_socket_poll(struct ib_socket * const s);
#ifdef __cplusplus
}
#endif
// vim:fdm=marker