rdma_sys/
types.rs

1use crate::*;
2
3/// This file defines the types directly or indirectly involving union,
4/// in that BindGen cannot handle union very well, so mannually define them.
5
6/// Struct types involve union in <infiniband/verbs.h>
7
8// ibv_gid related union and struct types
9#[repr(C)]
10#[derive(Clone, Copy)]
11pub struct ibv_gid_global_t {
12    pub subnet_prefix: __be64,
13    pub interface_id: __be64,
14}
15
16#[repr(C)]
17#[derive(Clone, Copy)]
18pub union ibv_gid {
19    pub raw: [u8; 16],
20    pub global: ibv_gid_global_t,
21}
22
23// ibv_async_event related union and struct type
24#[repr(C)]
25pub union ibv_async_event_element_t {
26    pub cq: *mut ibv_cq,
27    pub qp: *mut ibv_qp,
28    pub srq: *mut ibv_srq,
29    pub wq: *mut ibv_wq,
30    pub port_num: c_int,
31}
32
33#[repr(C)]
34pub struct ibv_async_event {
35    pub element: ibv_async_event_element_t,
36    pub event_type: ibv_event_type,
37}
38
39// ibv_wc related union and struct types
40#[repr(C)]
41pub union imm_data_invalidated_rkey_union_t {
42    /// When (wc_flags & IBV_WC_WITH_IMM): Immediate data in network byte order.
43    pub imm_data: __be32,
44    /// When (wc_flags & IBV_WC_WITH_INV): Stores the invalidated rkey.
45    pub invalidated_rkey: u32,
46}
47
48#[repr(C)]
49pub struct ibv_wc {
50    pub wr_id: u64,
51    pub status: ibv_wc_status::Type,
52    pub opcode: ibv_wc_opcode::Type,
53    pub vendor_err: u32,
54    pub byte_len: u32,
55    pub imm_data_invalidated_rkey_union: imm_data_invalidated_rkey_union_t,
56    pub qp_num: u32,
57    pub src_qp: u32,
58    pub wc_flags: c_uint,
59    pub pkey_index: u16,
60    pub slid: u16,
61    pub sl: u8,
62    pub dlid_path_bits: u8,
63}
64
65#[repr(C)]
66#[derive(Clone, Copy)]
67pub struct ibv_global_route {
68    pub dgid: ibv_gid,
69    pub flow_label: u32,
70    pub sgid_index: u8,
71    pub hop_limit: u8,
72    pub traffic_class: u8,
73}
74
75// ibv_send_wr related union and struct types
76#[repr(C)]
77#[derive(Copy, Clone)]
78pub struct ibv_mw_bind_info {
79    pub mr: *mut ibv_mr,
80    pub addr: u64,
81    pub length: u64,
82    pub mw_access_flags: ::std::os::raw::c_uint,
83}
84
85#[repr(C)]
86#[derive(Clone, Copy)]
87pub struct rdma_t {
88    pub remote_addr: u64,
89    pub rkey: u32,
90}
91
92#[repr(C)]
93#[derive(Clone, Copy)]
94pub struct atomic_t {
95    pub remote_addr: u64,
96    pub compare_add: u64,
97    pub swap: u64,
98    pub rkey: u32,
99}
100
101#[repr(C)]
102#[derive(Clone, Copy)]
103pub struct ud_t {
104    pub ah: *mut ibv_ah,
105    pub remote_qpn: u32,
106    pub remote_qkey: u32,
107}
108
109#[repr(C)]
110pub union wr_t {
111    pub rdma: rdma_t,
112    pub atomic: atomic_t,
113    pub ud: ud_t,
114}
115
116#[repr(C)]
117#[derive(Clone, Copy)]
118pub struct xrc_t {
119    pub remote_srqn: u32,
120}
121
122#[repr(C)]
123pub union qp_type_t {
124    pub xrc: xrc_t,
125}
126
127#[repr(C)]
128#[derive(Clone, Copy)]
129pub struct bind_mw_t {
130    pub mw: *mut ibv_mw,
131    pub rkey: u32,
132    pub bind_info: ibv_mw_bind_info,
133}
134
135#[repr(C)]
136#[derive(Clone, Copy)]
137pub struct tso_t {
138    pub hdr: *mut c_void,
139    pub hdr_sz: u16,
140    pub mss: u16,
141}
142
143#[repr(C)]
144pub union bind_mw_tso_union_t {
145    pub bind_mw: bind_mw_t,
146    pub tso: tso_t,
147}
148
149#[repr(C)]
150pub struct ibv_send_wr {
151    pub wr_id: u64,
152    pub next: *mut Self,
153    pub sg_list: *mut ibv_sge,
154    pub num_sge: c_int,
155    pub opcode: ibv_wr_opcode::Type,
156    pub send_flags: c_uint,
157    /// When opcode is *_WITH_IMM: Immediate data in network byte order.
158    /// When opcode is *_INV: Stores the rkey to invalidate
159    pub imm_data_invalidated_rkey_union: imm_data_invalidated_rkey_union_t,
160    pub wr: wr_t,
161    pub qp_type: qp_type_t,
162    pub bind_mw_tso_union: bind_mw_tso_union_t,
163}
164
165#[repr(C)]
166#[derive(Copy, Clone)]
167pub struct add_t {
168    pub recv_wr_id: u64,
169    pub sg_list: *mut ibv_sge,
170    pub num_sge: c_int,
171    pub tag: u64,
172    pub mask: u64,
173}
174
175#[repr(C)]
176#[derive(Copy, Clone)]
177pub struct tm_t {
178    pub unexpected_cnt: u32,
179    pub handle: u32,
180    pub add: add_t,
181}
182
183#[repr(C)]
184pub struct ibv_ops_wr {
185    wr_id: u64,
186    next: *mut Self,
187    opcode: ibv_ops_wr_opcode::Type,
188    flags: c_int,
189    tm: tm_t,
190}
191
192// ibv_flow_spec related union and struct types
193#[repr(C)]
194#[derive(Clone, Copy)]
195pub struct hdr_t {
196    pub type_: ibv_flow_spec_type::Type,
197    pub size: u16,
198}
199
200#[repr(C)]
201pub union ibv_flow_spec_union_t {
202    pub hdr: hdr_t,
203    pub eth: ibv_flow_spec_eth,
204    pub ipv4: ibv_flow_spec_ipv4,
205    pub tcp_udp: ibv_flow_spec_tcp_udp,
206    pub ipv4_ext: ibv_flow_spec_ipv4_ext,
207    pub ipv6: ibv_flow_spec_ipv6,
208    pub esp: ibv_flow_spec_esp,
209    pub tunnel: ibv_flow_spec_tunnel,
210    pub gre: ibv_flow_spec_gre,
211    pub mpls: ibv_flow_spec_mpls,
212    pub flow_tag: ibv_flow_spec_action_tag,
213    pub drop: ibv_flow_spec_action_drop,
214    pub handle: ibv_flow_spec_action_handle,
215    pub flow_count: ibv_flow_spec_counter_action,
216}
217
218#[repr(C)]
219pub struct ibv_flow_spec {
220    pub ibv_flow_spec_union: ibv_flow_spec_union_t,
221}
222
223/// Struct types involve union in <rdma/rdma_cma.h>
224
225// rdma_addr related union and struct types
226#[repr(C)]
227#[derive(Clone, Copy)]
228pub struct rdma_ib_addr {
229    pub sgid: ibv_gid,
230    pub dgid: ibv_gid,
231    pub pkey: __be16,
232}
233
234#[repr(C)]
235pub union src_addr_union_t {
236    pub src_addr: libc::sockaddr,
237    pub src_sin: libc::sockaddr_in,
238    pub src_sin6: libc::sockaddr_in6,
239    pub src_storage: libc::sockaddr_storage,
240}
241
242#[repr(C)]
243pub union dst_addr_union_t {
244    pub dst_addr: libc::sockaddr,
245    pub dst_sin: libc::sockaddr_in,
246    pub dst_sin6: libc::sockaddr_in6,
247    pub dst_storage: libc::sockaddr_storage,
248}
249
250#[repr(C)]
251pub union addr_union_t {
252    pub ibaddr: rdma_ib_addr,
253}
254
255#[repr(C)]
256pub struct rdma_addr {
257    pub src_addr_union: src_addr_union_t,
258    pub dst_addr_union: dst_addr_union_t,
259    pub addr: addr_union_t,
260}
261
262/// rdma_cm_event related union and struct types
263
264#[repr(C)]
265#[derive(Clone, Copy)]
266pub struct ibv_ah_attr {
267    pub grh: ibv_global_route,
268    pub dlid: u16,
269    pub sl: u8,
270    pub src_path_bits: u8,
271    pub static_rate: u8,
272    pub is_global: u8,
273    pub port_num: u8,
274}
275
276#[repr(C)]
277#[derive(Clone, Copy)]
278pub struct rdma_ud_param {
279    pub private_data: *const ::std::os::raw::c_void,
280    pub private_data_len: u8,
281    pub ah_attr: ibv_ah_attr,
282    pub qp_num: u32,
283    pub qkey: u32,
284}
285
286#[repr(C)]
287pub union param_t {
288    pub conn: rdma_conn_param,
289    pub ud: rdma_ud_param,
290}
291
292#[repr(C)]
293pub struct rdma_cm_event {
294    pub id: *mut rdma_cm_id,
295    pub listen_id: *mut rdma_cm_id,
296    pub event: rdma_cm_event_type::Type,
297    pub status: c_int,
298    pub param: param_t,
299}