• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #![allow(
2     dead_code,
3     non_snake_case,
4     non_camel_case_types,
5     non_upper_case_globals
6 )]
7 
8 pub const RTE_CACHE_LINE_SIZE: u32 = 64;
9 pub const RTE_MEMPOOL_OPS_NAMESIZE: u32 = 32;
10 pub const RTE_MEMPOOL_MAX_OPS_IDX: u32 = 16;
11 pub const RTE_HEAP_NUM_FREELISTS: u32 = 13;
12 #[repr(C)]
13 #[derive(Debug, Copy, Clone)]
14 pub struct rte_mempool {
15     _unused: [u8; 0],
16 }
17 /// Prototype for implementation specific data provisioning function.
18 ///
19 /// The function should provide the implementation specific memory for
20 /// for use by the other mempool ops functions in a given mempool ops struct.
21 /// E.g. the default ops provides an instance of the rte_ring for this purpose.
22 /// it will most likely point to a different type of data structure, and
23 /// will be transparent to the application programmer.
24 /// This function should set mp->pool_data.
25 pub type rte_mempool_alloc_t = ::std::option::Option<
26     unsafe extern "C" fn(mp: *mut rte_mempool) -> ::std::os::raw::c_int,
27 >;
28 /// Free the opaque private data pointed to by mp->pool_data pointer.
29 pub type rte_mempool_free_t =
30     ::std::option::Option<unsafe extern "C" fn(mp: *mut rte_mempool)>;
31 /// Enqueue an object into the external pool.
32 pub type rte_mempool_enqueue_t = ::std::option::Option<
33     unsafe extern "C" fn(
34         mp: *mut rte_mempool,
35         obj_table: *const *mut ::std::os::raw::c_void,
36         n: ::std::os::raw::c_uint,
37     ) -> ::std::os::raw::c_int,
38 >;
39 /// Dequeue an object from the external pool.
40 pub type rte_mempool_dequeue_t = ::std::option::Option<
41     unsafe extern "C" fn(
42         mp: *mut rte_mempool,
43         obj_table: *mut *mut ::std::os::raw::c_void,
44         n: ::std::os::raw::c_uint,
45     ) -> ::std::os::raw::c_int,
46 >;
47 /// Return the number of available objects in the external pool.
48 pub type rte_mempool_get_count = ::std::option::Option<
49     unsafe extern "C" fn(mp: *const rte_mempool) -> ::std::os::raw::c_uint,
50 >;
51 /// Structure defining mempool operations structure
52 #[repr(C)]
53 #[repr(align(64))]
54 #[derive(Copy, Clone)]
55 pub struct rte_mempool_ops {
56     ///< Name of mempool ops struct.
57     pub name: [::std::os::raw::c_char; 32usize],
58     ///< Allocate private data.
59     pub alloc: rte_mempool_alloc_t,
60     ///< Free the external pool.
61     pub free: rte_mempool_free_t,
62     ///< Enqueue an object.
63     pub enqueue: rte_mempool_enqueue_t,
64     ///< Dequeue an object.
65     pub dequeue: rte_mempool_dequeue_t,
66     ///< Get qty of available objs.
67     pub get_count: rte_mempool_get_count,
68 }
69 #[test]
bindgen_test_layout_rte_mempool_ops()70 fn bindgen_test_layout_rte_mempool_ops() {
71     const UNINIT: ::std::mem::MaybeUninit<rte_mempool_ops> =
72         ::std::mem::MaybeUninit::uninit();
73     let ptr = UNINIT.as_ptr();
74     assert_eq!(
75         ::std::mem::size_of::<rte_mempool_ops>(),
76         128usize,
77         concat!("Size of: ", stringify!(rte_mempool_ops))
78     );
79     assert_eq!(
80         ::std::mem::align_of::<rte_mempool_ops>(),
81         64usize,
82         concat!("Alignment of ", stringify!(rte_mempool_ops))
83     );
84     assert_eq!(
85         unsafe { ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize },
86         0usize,
87         concat!(
88             "Offset of field: ",
89             stringify!(rte_mempool_ops),
90             "::",
91             stringify!(name)
92         )
93     );
94     assert_eq!(
95         unsafe { ::std::ptr::addr_of!((*ptr).alloc) as usize - ptr as usize },
96         32usize,
97         concat!(
98             "Offset of field: ",
99             stringify!(rte_mempool_ops),
100             "::",
101             stringify!(alloc)
102         )
103     );
104     assert_eq!(
105         unsafe { ::std::ptr::addr_of!((*ptr).free) as usize - ptr as usize },
106         40usize,
107         concat!(
108             "Offset of field: ",
109             stringify!(rte_mempool_ops),
110             "::",
111             stringify!(free)
112         )
113     );
114     assert_eq!(
115         unsafe { ::std::ptr::addr_of!((*ptr).enqueue) as usize - ptr as usize },
116         48usize,
117         concat!(
118             "Offset of field: ",
119             stringify!(rte_mempool_ops),
120             "::",
121             stringify!(enqueue)
122         )
123     );
124     assert_eq!(
125         unsafe { ::std::ptr::addr_of!((*ptr).dequeue) as usize - ptr as usize },
126         56usize,
127         concat!(
128             "Offset of field: ",
129             stringify!(rte_mempool_ops),
130             "::",
131             stringify!(dequeue)
132         )
133     );
134     assert_eq!(
135         unsafe {
136             ::std::ptr::addr_of!((*ptr).get_count) as usize - ptr as usize
137         },
138         64usize,
139         concat!(
140             "Offset of field: ",
141             stringify!(rte_mempool_ops),
142             "::",
143             stringify!(get_count)
144         )
145     );
146 }
147 impl Default for rte_mempool_ops {
default() -> Self148     fn default() -> Self {
149         let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
150         unsafe {
151             ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
152             s.assume_init()
153         }
154     }
155 }
156 impl ::std::cmp::PartialEq for rte_mempool_ops {
eq(&self, other: &rte_mempool_ops) -> bool157     fn eq(&self, other: &rte_mempool_ops) -> bool {
158         self.name == other.name &&
159             self.alloc == other.alloc &&
160             self.free == other.free &&
161             self.enqueue == other.enqueue &&
162             self.dequeue == other.dequeue &&
163             self.get_count == other.get_count
164     }
165 }
166 /// The rte_spinlock_t type.
167 #[repr(C)]
168 #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
169 pub struct rte_spinlock_t {
170     ///< lock status 0 = unlocked, 1 = locked
171     pub locked: ::std::os::raw::c_int,
172 }
173 #[test]
bindgen_test_layout_rte_spinlock_t()174 fn bindgen_test_layout_rte_spinlock_t() {
175     const UNINIT: ::std::mem::MaybeUninit<rte_spinlock_t> =
176         ::std::mem::MaybeUninit::uninit();
177     let ptr = UNINIT.as_ptr();
178     assert_eq!(
179         ::std::mem::size_of::<rte_spinlock_t>(),
180         4usize,
181         concat!("Size of: ", stringify!(rte_spinlock_t))
182     );
183     assert_eq!(
184         ::std::mem::align_of::<rte_spinlock_t>(),
185         4usize,
186         concat!("Alignment of ", stringify!(rte_spinlock_t))
187     );
188     assert_eq!(
189         unsafe { ::std::ptr::addr_of!((*ptr).locked) as usize - ptr as usize },
190         0usize,
191         concat!(
192             "Offset of field: ",
193             stringify!(rte_spinlock_t),
194             "::",
195             stringify!(locked)
196         )
197     );
198 }
199 /// Structure storing the table of registered ops structs, each of which contain
200 /// the function pointers for the mempool ops functions.
201 /// Each process has its own storage for this ops struct array so that
202 /// the mempools can be shared across primary and secondary processes.
203 /// The indices used to access the array are valid across processes, whereas
204 /// any function pointers stored directly in the mempool struct would not be.
205 /// This results in us simply having "ops_index" in the mempool struct.
206 #[repr(C)]
207 #[repr(align(64))]
208 #[derive(Copy, Clone)]
209 pub struct rte_mempool_ops_table {
210     ///< Spinlock for add/delete.
211     pub sl: rte_spinlock_t,
212     ///< Number of used ops structs in the table.
213     pub num_ops: u32,
214     pub __bindgen_padding_0: [u64; 7usize],
215     /// Storage for all possible ops structs.
216     pub ops: [rte_mempool_ops; 16usize],
217 }
218 #[test]
bindgen_test_layout_rte_mempool_ops_table()219 fn bindgen_test_layout_rte_mempool_ops_table() {
220     const UNINIT: ::std::mem::MaybeUninit<rte_mempool_ops_table> =
221         ::std::mem::MaybeUninit::uninit();
222     let ptr = UNINIT.as_ptr();
223     assert_eq!(
224         ::std::mem::size_of::<rte_mempool_ops_table>(),
225         2112usize,
226         concat!("Size of: ", stringify!(rte_mempool_ops_table))
227     );
228     assert_eq!(
229         ::std::mem::align_of::<rte_mempool_ops_table>(),
230         64usize,
231         concat!("Alignment of ", stringify!(rte_mempool_ops_table))
232     );
233     assert_eq!(
234         unsafe { ::std::ptr::addr_of!((*ptr).sl) as usize - ptr as usize },
235         0usize,
236         concat!(
237             "Offset of field: ",
238             stringify!(rte_mempool_ops_table),
239             "::",
240             stringify!(sl)
241         )
242     );
243     assert_eq!(
244         unsafe { ::std::ptr::addr_of!((*ptr).num_ops) as usize - ptr as usize },
245         4usize,
246         concat!(
247             "Offset of field: ",
248             stringify!(rte_mempool_ops_table),
249             "::",
250             stringify!(num_ops)
251         )
252     );
253     assert_eq!(
254         unsafe { ::std::ptr::addr_of!((*ptr).ops) as usize - ptr as usize },
255         64usize,
256         concat!(
257             "Offset of field: ",
258             stringify!(rte_mempool_ops_table),
259             "::",
260             stringify!(ops)
261         )
262     );
263 }
264 impl Default for rte_mempool_ops_table {
default() -> Self265     fn default() -> Self {
266         let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
267         unsafe {
268             ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
269             s.assume_init()
270         }
271     }
272 }
273 /// Structure to hold malloc heap
274 #[repr(C)]
275 #[repr(align(64))]
276 #[derive(Copy, Clone)]
277 pub struct malloc_heap {
278     pub lock: rte_spinlock_t,
279     pub free_head: [malloc_heap__bindgen_ty_1; 13usize],
280     pub alloc_count: ::std::os::raw::c_uint,
281     pub total_size: usize,
282 }
283 #[repr(C)]
284 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
285 pub struct malloc_heap__bindgen_ty_1 {
286     pub lh_first: *mut malloc_elem,
287 }
288 #[test]
bindgen_test_layout_malloc_heap__bindgen_ty_1()289 fn bindgen_test_layout_malloc_heap__bindgen_ty_1() {
290     const UNINIT: ::std::mem::MaybeUninit<malloc_heap__bindgen_ty_1> =
291         ::std::mem::MaybeUninit::uninit();
292     let ptr = UNINIT.as_ptr();
293     assert_eq!(
294         ::std::mem::size_of::<malloc_heap__bindgen_ty_1>(),
295         8usize,
296         concat!("Size of: ", stringify!(malloc_heap__bindgen_ty_1))
297     );
298     assert_eq!(
299         ::std::mem::align_of::<malloc_heap__bindgen_ty_1>(),
300         8usize,
301         concat!("Alignment of ", stringify!(malloc_heap__bindgen_ty_1))
302     );
303     assert_eq!(
304         unsafe {
305             ::std::ptr::addr_of!((*ptr).lh_first) as usize - ptr as usize
306         },
307         0usize,
308         concat!(
309             "Offset of field: ",
310             stringify!(malloc_heap__bindgen_ty_1),
311             "::",
312             stringify!(lh_first)
313         )
314     );
315 }
316 impl Default for malloc_heap__bindgen_ty_1 {
default() -> Self317     fn default() -> Self {
318         let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
319         unsafe {
320             ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
321             s.assume_init()
322         }
323     }
324 }
325 #[test]
bindgen_test_layout_malloc_heap()326 fn bindgen_test_layout_malloc_heap() {
327     const UNINIT: ::std::mem::MaybeUninit<malloc_heap> =
328         ::std::mem::MaybeUninit::uninit();
329     let ptr = UNINIT.as_ptr();
330     assert_eq!(
331         ::std::mem::size_of::<malloc_heap>(),
332         128usize,
333         concat!("Size of: ", stringify!(malloc_heap))
334     );
335     assert_eq!(
336         ::std::mem::align_of::<malloc_heap>(),
337         64usize,
338         concat!("Alignment of ", stringify!(malloc_heap))
339     );
340     assert_eq!(
341         unsafe { ::std::ptr::addr_of!((*ptr).lock) as usize - ptr as usize },
342         0usize,
343         concat!(
344             "Offset of field: ",
345             stringify!(malloc_heap),
346             "::",
347             stringify!(lock)
348         )
349     );
350     assert_eq!(
351         unsafe {
352             ::std::ptr::addr_of!((*ptr).free_head) as usize - ptr as usize
353         },
354         8usize,
355         concat!(
356             "Offset of field: ",
357             stringify!(malloc_heap),
358             "::",
359             stringify!(free_head)
360         )
361     );
362     assert_eq!(
363         unsafe {
364             ::std::ptr::addr_of!((*ptr).alloc_count) as usize - ptr as usize
365         },
366         112usize,
367         concat!(
368             "Offset of field: ",
369             stringify!(malloc_heap),
370             "::",
371             stringify!(alloc_count)
372         )
373     );
374     assert_eq!(
375         unsafe {
376             ::std::ptr::addr_of!((*ptr).total_size) as usize - ptr as usize
377         },
378         120usize,
379         concat!(
380             "Offset of field: ",
381             stringify!(malloc_heap),
382             "::",
383             stringify!(total_size)
384         )
385     );
386 }
387 impl Default for malloc_heap {
default() -> Self388     fn default() -> Self {
389         let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
390         unsafe {
391             ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
392             s.assume_init()
393         }
394     }
395 }
396 impl ::std::cmp::PartialEq for malloc_heap {
eq(&self, other: &malloc_heap) -> bool397     fn eq(&self, other: &malloc_heap) -> bool {
398         self.lock == other.lock &&
399             self.free_head == other.free_head &&
400             self.alloc_count == other.alloc_count &&
401             self.total_size == other.total_size
402     }
403 }
404 #[repr(C)]
405 #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
406 pub struct malloc_elem {
407     pub _address: u8,
408 }
409