this repo has no description
1open Libbpf
2(** Libbpf_maps provide a convenient API's for handling maps,
3 currently only Ringbuffers are supported *)
4
5module RingBuffer : sig
6 type t
7
8 type callback =
9 unit Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> int
10
11 val init : bpf_map -> callback:callback -> (t -> unit) -> unit
12 (** [init bpf_map callback] loads [callback] into the ring buffer
13 map provided by [bpf_map]. bpf map is freed by default when
14 the OCaml process exits
15
16 TO BE ADDED [ctx_ptr] allows the callback function to access
17 user provided context. *)
18
19 val poll : t -> timeout:int -> int
20 (** [poll t timeout] polls the ringbuffer to execute the loaded
21 callbacks on any pending entries, The function returns if
22 there are no entries in the given timeout,
23
24 Error code is returned if something went wrong, Ctrl-C will
25 cause -EINTR *)
26
27 val consume : t -> int
28 (** [consume t] runs callbacks on all entries in the ringbuffer
29 without event polling. Use this only if trying to squeeze
30 extra performance with busy-waiting.
31
32 Error code is returned if something went wrong Ctrl-C will
33 cause -EINTR *)
34
35 val get_epoll_fd : t -> int
36 (** [get_epoll_fd t] returns a file descriptor that can be used
37 to sleep until data is available in the ring(s) *)
38end