eBPF for Windows
Loading...
Searching...
No Matches
ebpf_api.h
Go to the documentation of this file.
1// Copyright (c) eBPF for Windows contributors
2// SPDX-License-Identifier: MIT
3
4#pragma once
5
6#include "ebpf_core_structs.h"
9#include "ebpf_result.h"
10
11#include <specstrings.h>
12#include <stdbool.h>
13#include <stddef.h>
14#include <stdint.h>
15
16#ifdef __cplusplus
17#include <stdexcept>
18#define EBPF_NO_EXCEPT noexcept
19extern "C"
20{
21#else
22#define EBPF_NO_EXCEPT
23#endif
24
25 typedef int32_t fd_t;
26 extern __declspec(selectany) const fd_t ebpf_fd_invalid = -1;
27 typedef intptr_t ebpf_handle_t;
28
29 struct bpf_object;
30 struct bpf_program;
31 struct bpf_map;
32 struct bpf_link;
33
42 _Must_inspect_result_ ebpf_result_t
44 fd_t fd,
45 _Out_ ebpf_execution_type_t* execution_type,
46 _Outptr_result_z_ const char** file_name,
47 _Outptr_result_z_ const char** section_name) EBPF_NO_EXCEPT;
48
49 typedef struct _ebpf_stat
50 {
52 _Field_z_ const char* key;
53 int value;
55
68
78 _Must_inspect_result_ ebpf_result_t
80 _In_z_ const char* file,
81 bool verbose,
82 _Outptr_result_maybenull_ ebpf_api_program_info_t** infos,
83 _Outptr_result_maybenull_z_ const char** error_message) EBPF_NO_EXCEPT;
84
89 void
91
103 uint32_t
105 _In_z_ const char* file,
106 _In_opt_z_ const char* section_name,
107 _In_opt_z_ const char* program_name,
108 _Outptr_result_maybenull_z_ const char** disassembly,
109 _Outptr_result_maybenull_z_ const char** error_message) EBPF_NO_EXCEPT;
110
117
133
140 _Must_inspect_result_ ebpf_result_t
142 _Outptr_result_buffer_maybenull_(*count) const ebpf_verifier_map_info_t** annotations,
143 _Out_ size_t* count) EBPF_NO_EXCEPT;
144
151
170 _Success_(return == 0) uint32_t ebpf_api_elf_verify_program_from_file(
171 _In_z_ const char* file,
172 _In_opt_z_ const char* section_name,
173 _In_opt_z_ const char* program_name,
174 _In_opt_ const ebpf_program_type_t* program_type,
176 _Outptr_result_maybenull_z_ const char** report,
177 _Outptr_result_maybenull_z_ const char** error_message,
179
199 _Success_(return == 0) uint32_t ebpf_api_elf_verify_program_from_memory(
200 _In_reads_(data_length) const char* data,
201 size_t data_length,
202 _In_opt_z_ const char* section_name,
203 _In_opt_z_ const char* program_name,
204 _In_opt_ const ebpf_program_type_t* program_type,
206 _Outptr_result_maybenull_z_ const char** report,
207 _Outptr_result_maybenull_z_ const char** error_message,
209
214 void
215 ebpf_free_string(_In_opt_ _Post_invalid_ const char* string) EBPF_NO_EXCEPT;
216
222 uint32_t
223 ebpf_api_unpin_object(const uint8_t* name, uint32_t name_length) EBPF_NO_EXCEPT;
224
231 _Must_inspect_result_ ebpf_result_t
232 ebpf_object_unpin(_In_z_ const char* path) EBPF_NO_EXCEPT;
233
256 _Must_inspect_result_ ebpf_result_t
258 fd_t bpf_fd,
259 _Inout_updates_bytes_to_opt_(*info_size, *info_size) void* info,
260 _Inout_opt_ uint32_t* info_size,
261 _Out_opt_ ebpf_object_type_t* type) EBPF_NO_EXCEPT;
262
271 _Must_inspect_result_ ebpf_result_t
273
281 _Must_inspect_result_ ebpf_result_t
283
294 _Must_inspect_result_ ebpf_result_t
296 _Out_ uint16_t* map_count,
297 _Outptr_result_buffer_maybenull_(*map_count) ebpf_map_info_t** map_info) EBPF_NO_EXCEPT;
298
306 void
308 uint16_t map_count,
309 _In_opt_count_(map_count) _Post_ptr_invalid_ const ebpf_map_info_t* map_info) EBPF_NO_EXCEPT;
310
319 ebpf_object_get_execution_type(_In_ const struct bpf_object* object) EBPF_NO_EXCEPT;
320
330 _Must_inspect_result_ ebpf_result_t
331 ebpf_object_set_execution_type(_Inout_ struct bpf_object* object, ebpf_execution_type_t execution_type)
333
347 _Must_inspect_result_ ebpf_result_t
349 _In_z_ const char* file_name,
350 _Inout_ size_t* count_of_maps,
351 _Out_writes_opt_(*count_of_maps) fd_t* map_fds,
352 _Inout_ size_t* count_of_programs,
353 _Out_writes_opt_(*count_of_programs) fd_t* program_fds) EBPF_NO_EXCEPT;
354
372 _Must_inspect_result_ ebpf_result_t
374 _In_ const struct bpf_program* program,
375 _In_opt_ const ebpf_attach_type_t* attach_type,
376 _In_reads_bytes_opt_(attach_params_size) void* attach_parameters,
377 size_t attach_params_size,
378 _Outptr_opt_ struct bpf_link** link) EBPF_NO_EXCEPT;
379
397 _Must_inspect_result_ ebpf_result_t
399 fd_t program_fd,
400 _In_opt_ const ebpf_attach_type_t* attach_type,
401 _In_reads_bytes_opt_(attach_parameters_size) void* attach_parameters,
402 size_t attach_parameters_size,
403 _Outptr_opt_ struct bpf_link** link) EBPF_NO_EXCEPT;
404
413 _Must_inspect_result_ ebpf_result_t
415 fd_t program_fd,
416 _In_opt_ const ebpf_attach_type_t* attach_type,
417 _In_reads_bytes_opt_(attach_parameters_size) void* attach_parameters,
418 size_t attach_parameters_size,
419 _Out_opt_ fd_t* link) EBPF_NO_EXCEPT;
420
430 _Must_inspect_result_ ebpf_result_t
431 ebpf_link_detach(_Inout_ struct bpf_link* link) EBPF_NO_EXCEPT;
432
446 _Must_inspect_result_ ebpf_result_t
448 fd_t program_fd,
449 _In_ const ebpf_attach_type_t* attach_type,
450 _In_reads_bytes_(attach_parameter_size) void* attach_parameter,
451 size_t attach_parameter_size) EBPF_NO_EXCEPT;
452
463 void
464 ebpf_link_close(_Frees_ptr_ struct bpf_link* link) EBPF_NO_EXCEPT;
465
473 _Must_inspect_result_ ebpf_result_t
475
484 _Must_inspect_result_ ebpf_result_t
486
497 _Must_inspect_result_ ebpf_result_t
499 _In_z_ const char* name,
500 _Out_ ebpf_program_type_t* program_type,
501 _Out_ ebpf_attach_type_t* expected_attach_type) EBPF_NO_EXCEPT;
502
510 _Ret_maybenull_z_ const char*
512
520 _Ret_maybenull_z_ const char*
522
535 _Must_inspect_result_ ebpf_result_t
537 _In_z_ const char* start_path,
538 _Out_writes_z_(next_path_len) char* next_path,
539 size_t next_path_len,
540 _Inout_ ebpf_object_type_t* type) EBPF_NO_EXCEPT;
541
552 _Must_inspect_result_ ebpf_result_t
553 ebpf_canonicalize_pin_path(_Out_writes_(output_size) char* output, size_t output_size, _In_z_ const char* input)
555
557
567 _Must_inspect_result_ ebpf_result_t
569
571 {
572 _Readable_bytes_(data_size_in) const uint8_t* data_in;
573 _Writable_bytes_(data_size_out) uint8_t* data_out;
576 _Readable_bytes_(context_size_in) const uint8_t* context_in;
577 _Writable_bytes_(context_size_out) uint8_t* context_out;
580 uint64_t return_value;
582 uint64_t duration;
583 uint32_t flags;
584 uint32_t cpu;
585 size_t batch_size;
587
596 _Must_inspect_result_ ebpf_result_t
598
609 _Must_inspect_result_ ebpf_result_t
611 fd_t ring_buffer_map_fd, _In_reads_bytes_(data_length) const void* data, size_t data_length) EBPF_NO_EXCEPT;
612
628 _Must_inspect_result_ ebpf_result_t
630 fd_t map_fd,
631 _Outptr_result_maybenull_ void** consumer,
632 _Outptr_result_maybenull_ const void** producer,
633 _Outptr_result_buffer_maybenull_(*data_size) const uint8_t** data,
634 _Out_ size_t* data_size) EBPF_NO_EXCEPT;
635
645 _Must_inspect_result_ ebpf_result_t
647 fd_t map_fd, _In_ void* consumer, _In_ const void* producer, _In_ const void* data) EBPF_NO_EXCEPT;
648
662 _Must_inspect_result_ ebpf_result_t
664
672 _Ret_maybenull_ const ebpf_program_type_t*
674
684 _Must_inspect_result_ ebpf_result_t
687
697
707
718 _Must_inspect_result_ ebpf_result_t
720 fd_t perf_event_array_map_fd,
721 _In_reads_bytes_(data_length) const void* data,
722 size_t data_length) EBPF_NO_EXCEPT;
723
730 _Must_inspect_result_ ebpf_result_t
732
733 //
734 // Windows-specific Ring Buffer APIs
735 //
736
737 // Forward declarations and types needed for ring buffer APIs.
738 struct ring_buffer;
739
750
761
773
774 // Compile-time asserts: perf event array producer page must begin with ring buffer producer page layout.
775 static_assert(
776 offsetof(ebpf_perf_event_array_producer_page_t, producer_offset) ==
777 offsetof(ebpf_ring_buffer_producer_page_t, producer_offset),
778 "ebpf_perf_event_array_producer_page_t.producer_offset must be at the same offset as in "
779 "ebpf_ring_buffer_producer_page_t");
780 static_assert(
782 "ebpf_perf_event_array_producer_page_t must be at least as large as ebpf_ring_buffer_producer_page_t");
783 static_assert(
784 offsetof(ebpf_perf_event_array_producer_page_t, lost_records) >= 64,
785 "lost_records must be in a separate cache line from producer_offset");
786
794 typedef int (*ring_buffer_sample_fn)(void* ctx, void* data, size_t size);
795
803 {
804 size_t sz; /* Size of this struct, for forward/backward compatibility (must match ring_buffer_opts). */
805 uint64_t flags; /* Windows-specific ring buffer option flags. */
806 };
807
812 {
813 EBPF_RINGBUF_FLAG_AUTO_CALLBACK = (uint64_t)1 << 0, /* Automatically invoke callback for each record. */
814 };
815
826 _Ret_maybenull_ struct ring_buffer*
828 int map_fd,
829 ring_buffer_sample_fn sample_cb,
830 _In_opt_ void* ctx,
831 _In_opt_ const struct ebpf_ring_buffer_opts* opts) EBPF_NO_EXCEPT;
832
851 _Must_inspect_result_ _Success_(return == EBPF_SUCCESS) ebpf_result_t ebpf_ring_buffer_get_buffer(
852 _In_ struct ring_buffer* rb,
853 uint32_t index,
854 _Outptr_result_maybenull_ ebpf_ring_buffer_consumer_page_t** consumer_page,
855 _Outptr_result_maybenull_ const ebpf_ring_buffer_producer_page_t** producer_page,
856 _Outptr_result_buffer_maybenull_(*data_size) const uint8_t** data,
857 _Out_ uint64_t* data_size) EBPF_NO_EXCEPT;
858
873
874 //
875 // Windows-specific Perf Buffer APIs
876 //
877
882 {
883 size_t sz; /* size of this struct, for forward/backward compatibility */
884 uint64_t flags; /* perf buffer option flags */
885 };
886
891 {
892 EBPF_PERFBUF_FLAG_AUTO_CALLBACK = (uint64_t)1 << 0, /* Automatically invoke callback for each record */
893 };
894 typedef void (*perf_buffer_sample_fn)(void* ctx, int cpu, void* data, uint32_t size);
895 typedef void (*perf_buffer_lost_fn)(void* ctx, int cpu, uint64_t cnt);
896
909 _Ret_maybenull_ struct perf_buffer*
911 int map_fd,
912 size_t page_cnt,
913 perf_buffer_sample_fn sample_cb,
914 perf_buffer_lost_fn lost_cb,
915 _In_opt_ void* ctx,
916 _In_opt_ const struct ebpf_perf_buffer_opts* opts) EBPF_NO_EXCEPT;
917
931 ebpf_perf_buffer_get_wait_handle(_In_ const struct perf_buffer* pb) EBPF_NO_EXCEPT;
932
945 _Must_inspect_result_ ebpf_result_t
947 _In_z_ const char* file_path,
948 _In_z_ const char* section_name,
949 _Out_writes_bytes_opt_(*data_size) uint8_t* data,
950 _Inout_ size_t* data_size) EBPF_NO_EXCEPT;
951
952#ifdef __cplusplus
953}
954#endif
#define bpf_map
Definition bpf_helpers_platform.h:16
_Must_inspect_result_ ebpf_result_t ebpf_program_attach_by_fd(fd_t program_fd, const ebpf_attach_type_t *attach_type, _In_reads_bytes_opt_(attach_parameters_size) void *attach_parameters, size_t attach_parameters_size, _Outptr_opt_ struct bpf_link **link) EBPF_NO_EXCEPT
Attach an eBPF program by program file descriptor.
ebpf_handle_t ebpf_ring_buffer_get_wait_handle(struct ring_buffer *rb) EBPF_NO_EXCEPT
Get the wait handle for a ring buffer manager.
struct _ebpf_stat ebpf_stat_t
void ebpf_free_string(const char *string) EBPF_NO_EXCEPT
Free memory for a string returned from an eBPF API.
struct _ebpf_perf_event_array_producer_page ebpf_perf_event_array_producer_page_t
Perf event array map producer page.
struct _ebpf_test_run_options ebpf_test_run_options_t
_Must_inspect_result_ ebpf_result_t ebpf_api_unlink_program(ebpf_handle_t link_handle) EBPF_NO_EXCEPT
Detach the eBPF program from the link.
void(* perf_buffer_sample_fn)(void *ctx, int cpu, void *data, uint32_t size)
Definition ebpf_api.h:894
_Must_inspect_result_ ebpf_result_t ebpf_duplicate_fd(fd_t fd, fd_t *dup) EBPF_NO_EXCEPT
Duplicate a file descriptor.
_Must_inspect_result_ ebpf_result_t ebpf_map_set_wait_handle(fd_t map_fd, uint64_t index, ebpf_handle_t handle) EBPF_NO_EXCEPT
Set the wait handle that will be signaled for new data.
ebpf_ring_buffer_flags
Ring buffer option flags.
Definition ebpf_api.h:812
@ EBPF_RINGBUF_FLAG_AUTO_CALLBACK
Definition ebpf_api.h:813
uint32_t ebpf_api_unpin_object(const uint8_t *name, uint32_t name_length) EBPF_NO_EXCEPT
Dissociate a name with an object handle.
_ebpf_verification_verbosity
Definition ebpf_api.h:146
@ EBPF_VERIFICATION_VERBOSITY_VERBOSE
Definition ebpf_api.h:149
@ EBPF_VERIFICATION_VERBOSITY_NORMAL
Definition ebpf_api.h:147
@ EBPF_VERIFICATION_VERBOSITY_INFORMATIONAL
Definition ebpf_api.h:148
_Must_inspect_result_ ebpf_result_t ebpf_get_program_info_from_verifier(const ebpf_program_info_t **program_info) EBPF_NO_EXCEPT
Get the set of program information used by the verifier during the last verification.
void ebpf_api_map_info_free(uint16_t map_count, const ebpf_map_info_t *map_info) EBPF_NO_EXCEPT
Helper Function to free array of ebpf_map_info_t allocated by ebpf_api_get_pinned_map_info function.
_Must_inspect_result_ ebpf_result_t ebpf_ring_buffer_map_write(fd_t ring_buffer_map_fd, _In_reads_bytes_(data_length) const void *data, size_t data_length) EBPF_NO_EXCEPT
Write data into the ring buffer map.
_Must_inspect_result_ ebpf_result_t ebpf_program_attach_by_fds(fd_t program_fd, const ebpf_attach_type_t *attach_type, _In_reads_bytes_opt_(attach_parameters_size) void *attach_parameters, size_t attach_parameters_size, _Out_opt_ fd_t *link) EBPF_NO_EXCEPT
Attach an eBPF program by program file descriptor and return the link as a file descriptor.
_Must_inspect_result_ ebpf_result_t ebpf_object_set_execution_type(_Inout_ struct bpf_object *object, ebpf_execution_type_t execution_type) EBPF_NO_EXCEPT
Set the execution type for an eBPF object file.
bpf_attach_type_t ebpf_get_bpf_attach_type(const ebpf_attach_type_t *ebpf_attach_type) EBPF_NO_EXCEPT
Get BPF attach type for the specified eBPF attach type.
_Must_inspect_result_ ebpf_result_t ebpf_ring_buffer_get_buffer(struct ring_buffer *rb, uint32_t index, _Outptr_result_maybenull_ ebpf_ring_buffer_consumer_page_t **consumer_page, _Outptr_result_maybenull_ const ebpf_ring_buffer_producer_page_t **producer_page,(*data_size) const uint8_t **data, uint64_t *data_size) EBPF_NO_EXCEPT
Get pointers to the consumer, producer, and data regions for a specific ring buffer map.
struct _ebpf_verifier_map_info ebpf_verifier_map_info_t
Per-instruction map annotation from the verifier. For map helper calls where the verifier can prove w...
struct perf_buffer * ebpf_perf_buffer__new(int map_fd, size_t page_cnt, perf_buffer_sample_fn sample_cb, perf_buffer_lost_fn lost_cb, void *ctx, const struct ebpf_perf_buffer_opts *opts) EBPF_NO_EXCEPT
Create a new perf buffer manager with Windows-specific options.
_Must_inspect_result_ ebpf_result_t ebpf_object_unpin(const char *path) EBPF_NO_EXCEPT
Unpin the object from the specified path.
ebpf_handle_t ebpf_perf_buffer_get_wait_handle(const struct perf_buffer *pb) EBPF_NO_EXCEPT
Get the wait handle for a perf buffer manager.
_Must_inspect_result_ ebpf_result_t ebpf_program_query_info(fd_t fd, ebpf_execution_type_t *execution_type, _Outptr_result_z_ const char **file_name, _Outptr_result_z_ const char **section_name) EBPF_NO_EXCEPT
Query info about an eBPF program.
#define EBPF_NO_EXCEPT
Definition ebpf_api.h:22
ebpf_execution_type_t ebpf_object_get_execution_type(const struct bpf_object *object) EBPF_NO_EXCEPT
Get the execution type for an eBPF object file.
void ebpf_free_programs(ebpf_api_program_info_t *infos) EBPF_NO_EXCEPT
Free memory returned from ebpf_enumerate_programs.
_Must_inspect_result_ ebpf_result_t ebpf_object_get_info_by_fd(fd_t bpf_fd, _Inout_updates_bytes_to_opt_(*info_size, *info_size) void *info, _Inout_opt_ uint32_t *info_size, _Out_opt_ ebpf_object_type_t *type) EBPF_NO_EXCEPT
Obtain information about the eBPF object referred to by bpf_fd. This function populates up to info_le...
_Must_inspect_result_ ebpf_result_t ebpf_get_next_pinned_object_path(const char *start_path, _Out_writes_z_(next_path_len) char *next_path, size_t next_path_len, _Inout_ ebpf_object_type_t *type) EBPF_NO_EXCEPT
Retrieve the next pinned path of an eBPF object.
uint32_t ebpf_api_elf_verify_program_from_file(const char *file, _In_opt_z_ const char *section_name, _In_opt_z_ const char *program_name, const ebpf_program_type_t *program_type, ebpf_verification_verbosity_t verbosity, const char **report, const char **error_message, _Out_opt_ ebpf_api_verifier_stats_t *stats) EBPF_NO_EXCEPT
Verify that the program is safe to execute.
enum _ebpf_verification_verbosity ebpf_verification_verbosity_t
_Must_inspect_result_ ebpf_result_t ebpf_get_program_type_by_name(const char *name, ebpf_program_type_t *program_type, ebpf_attach_type_t *expected_attach_type) EBPF_NO_EXCEPT
Get eBPF program type and expected attach type by name.
_Must_inspect_result_ ebpf_result_t ebpf_api_get_pinned_map_info(uint16_t *map_count,(*map_count) ebpf_map_info_t **map_info) EBPF_NO_EXCEPT
Returns an array of ebpf_map_info_t for all pinned maps.
_Must_inspect_result_ ebpf_result_t ebpf_program_detach(fd_t program_fd, const ebpf_attach_type_t *attach_type, _In_reads_bytes_(attach_parameter_size) void *attach_parameter, size_t attach_parameter_size) EBPF_NO_EXCEPT
Detach an eBPF program.
void(* perf_buffer_lost_fn)(void *ctx, int cpu, uint64_t cnt)
Definition ebpf_api.h:895
int32_t fd_t
Definition ebpf_api.h:25
_Must_inspect_result_ ebpf_result_t ebpf_close_fd(fd_t fd) EBPF_NO_EXCEPT
Close a file descriptor. Also close the underlying handle.
_Must_inspect_result_ ebpf_result_t ebpf_program_test_run(fd_t program_fd, _Inout_ ebpf_test_run_options_t *options) EBPF_NO_EXCEPT
Run the program in the eBPF VM, measure the execution time, and return the result.
_Must_inspect_result_ ebpf_result_t ebpf_canonicalize_pin_path(_Out_writes_(output_size) char *output, size_t output_size, const char *input) EBPF_NO_EXCEPT
Canonicalize a path using filesystem canonicalization rules.
struct _ebpf_api_program_info ebpf_api_program_info_t
const ebpf_program_type_t * ebpf_get_ebpf_program_type(bpf_prog_type_t bpf_program_type) EBPF_NO_EXCEPT
Get eBPF program type for the specified BPF program type.
bpf_prog_type_t ebpf_get_bpf_program_type(const ebpf_program_type_t *program_type) EBPF_NO_EXCEPT
Get BPF program type for the specified eBPF program type.
_Must_inspect_result_ ebpf_result_t ebpf_link_detach(_Inout_ struct bpf_link *link) EBPF_NO_EXCEPT
Detach an eBPF program from an attach point represented by the bpf_link structure.
_Must_inspect_result_ ebpf_result_t ebpf_get_ebpf_attach_type(bpf_attach_type_t bpf_attach_type, ebpf_attach_type_t *ebpf_attach_type) EBPF_NO_EXCEPT
Get eBPF attach type for the specified BPF attach type.
_Must_inspect_result_ ebpf_result_t ebpf_api_get_data_section(const char *file_path, const char *section_name, _Out_writes_bytes_opt_(*data_size) uint8_t *data, _Inout_ size_t *data_size) EBPF_NO_EXCEPT
Extract data from a named section in a PE or ELF file.
struct _ebpf_ring_buffer_consumer_page ebpf_ring_buffer_consumer_page_t
Ring buffer consumer page definition (public API).
intptr_t ebpf_handle_t
Definition ebpf_api.h:27
void ebpf_link_close(_Frees_ptr_ struct bpf_link *link) EBPF_NO_EXCEPT
_Must_inspect_result_ ebpf_result_t ebpf_get_map_annotations_from_verifier((*count) const ebpf_verifier_map_info_t **annotations, size_t *count) EBPF_NO_EXCEPT
Get map annotations from the most recent verification.
uint32_t ebpf_api_elf_disassemble_program(const char *file, _In_opt_z_ const char *section_name, _In_opt_z_ const char *program_name, const char **disassembly, const char **error_message) EBPF_NO_EXCEPT
Convert an eBPF program to human readable byte code.
_Must_inspect_result_ ebpf_result_t ebpf_api_close_handle(ebpf_handle_t handle) EBPF_NO_EXCEPT
Close an eBPF handle.
_Must_inspect_result_ ebpf_result_t ebpf_object_load_native_by_fds(const char *file_name, _Inout_ size_t *count_of_maps, _Out_writes_opt_(*count_of_maps) fd_t *map_fds, _Inout_ size_t *count_of_programs, _Out_writes_opt_(*count_of_programs) fd_t *program_fds) EBPF_NO_EXCEPT
Load a native image from a file and return map and program file descriptors.
_Ret_maybenull_z_ const char * ebpf_get_attach_type_name(const ebpf_attach_type_t *attach_type) EBPF_NO_EXCEPT
Get the name of a given attach type.
const fd_t ebpf_fd_invalid
_Must_inspect_result_ ebpf_result_t ebpf_perf_event_array_map_write(fd_t perf_event_array_map_fd, _In_reads_bytes_(data_length) const void *data, size_t data_length) EBPF_NO_EXCEPT
Write data into the perf event array map.
_Ret_maybenull_z_ const char * ebpf_get_program_type_name(const ebpf_program_type_t *program_type) EBPF_NO_EXCEPT
Get the name of a given program type.
_Must_inspect_result_ ebpf_result_t ebpf_ring_buffer_map_unmap_buffer(fd_t map_fd, void *consumer, const void *producer, const void *data) EBPF_NO_EXCEPT
Unmap the memory of a map.
_Must_inspect_result_ ebpf_result_t ebpf_program_synchronize() EBPF_NO_EXCEPT
Wait for currently executing eBPF programs to complete.
_Must_inspect_result_ ebpf_result_t ebpf_program_attach(const struct bpf_program *program, const ebpf_attach_type_t *attach_type, _In_reads_bytes_opt_(attach_params_size) void *attach_parameters, size_t attach_params_size, _Outptr_opt_ struct bpf_link **link) EBPF_NO_EXCEPT
Attach an eBPF program.
_Must_inspect_result_ ebpf_result_t ebpf_ring_buffer_map_map_buffer(fd_t map_fd, _Outptr_result_maybenull_ void **consumer, _Outptr_result_maybenull_ const void **producer,(*data_size) const uint8_t **data, size_t *data_size) EBPF_NO_EXCEPT
Map the memory of a map.
int(* ring_buffer_sample_fn)(void *ctx, void *data, size_t size)
Ring buffer sample callback function type.
Definition ebpf_api.h:794
_Must_inspect_result_ ebpf_result_t ebpf_enumerate_programs(const char *file, bool verbose, _Outptr_result_maybenull_ ebpf_api_program_info_t **infos, const char **error_message) EBPF_NO_EXCEPT
Get list of programs and stats in an eBPF file.
ebpf_perf_buffer_flags
Perf buffer option flags (Windows-specific).
Definition ebpf_api.h:891
@ EBPF_PERFBUF_FLAG_AUTO_CALLBACK
Definition ebpf_api.h:892
uint32_t ebpf_api_elf_verify_program_from_memory(_In_reads_(data_length) const char *data, size_t data_length, _In_opt_z_ const char *section_name, _In_opt_z_ const char *program_name, const ebpf_program_type_t *program_type, ebpf_verification_verbosity_t verbosity, const char **report, const char **error_message, _Out_opt_ ebpf_api_verifier_stats_t *stats) EBPF_NO_EXCEPT
Verify that the program is safe to execute.
struct ring_buffer * ebpf_ring_buffer__new(int map_fd, ring_buffer_sample_fn sample_cb, void *ctx, const struct ebpf_ring_buffer_opts *opts) EBPF_NO_EXCEPT
Creates a new ring buffer manager (Windows-specific with flags support).
struct _ebpf_ring_buffer_producer_page ebpf_ring_buffer_producer_page_t
Ring buffer producer page definition (public API).
This file contains eBPF definitions common to eBPF core libraries as well as the eBPF API library.
enum _ebpf_object_type ebpf_object_type_t
enum _ebpf_execution_type ebpf_execution_type_t
@ EBPF_SUCCESS
The operation was successful.
Definition ebpf_result.h:18
enum ebpf_result ebpf_result_t
enum bpf_prog_type bpf_prog_type_t
Definition ebpf_structs.h:274
bpf_attach_type
Definition ebpf_structs.h:293
enum bpf_attach_type bpf_attach_type_t
Definition ebpf_structs.h:401
GUID ebpf_attach_type_t
Definition ebpf_windows.h:62
GUID ebpf_program_type_t
Definition ebpf_windows.h:61
Definition ebpf_api.h:57
_Field_size_(raw_data_size) char *raw_data
_Field_z_ const char * program_name
Definition ebpf_api.h:60
ebpf_stat_t * stats
Definition ebpf_api.h:65
ebpf_program_type_t program_type
Definition ebpf_api.h:61
ebpf_attach_type_t expected_attach_type
Definition ebpf_api.h:62
size_t raw_data_size
Definition ebpf_api.h:63
size_t offset_in_section
Definition ebpf_api.h:66
_Field_z_ const char * section_name
Definition ebpf_api.h:59
struct _ebpf_api_program_info * next
Definition ebpf_api.h:58
eBPF Map Information
Definition ebpf_core_structs.h:21
Perf event array map producer page.
Definition ebpf_api.h:768
uint64_t pad[7]
Padding to 64 bytes (to place lost_records in next cache line).
Definition ebpf_api.h:770
volatile uint64_t lost_records
Number of lost records.
Definition ebpf_api.h:771
volatile uint64_t producer_offset
Producer(s) have reserved up to this offset.
Definition ebpf_api.h:769
Definition ebpf_program_types.h:50
Ring buffer consumer page definition (public API).
Definition ebpf_api.h:747
volatile uint64_t consumer_offset
Consumer has read up to this offset.
Definition ebpf_api.h:748
Ring buffer producer page definition (public API).
Definition ebpf_api.h:758
volatile uint64_t producer_offset
Producer(s) have reserved up to this offset.
Definition ebpf_api.h:759
Definition ebpf_api.h:50
struct _ebpf_stat * next
Definition ebpf_api.h:51
_Field_z_ const char * key
Definition ebpf_api.h:52
int value
Definition ebpf_api.h:53
Definition ebpf_api.h:571
uint64_t duration
Duration in nanoseconds of the program execution.
Definition ebpf_api.h:582
size_t batch_size
Number of times to repeat the program in a batch.
Definition ebpf_api.h:585
_Readable_bytes_(context_size_in) const uint8_t *context_in
Input context to the program.
_Writable_bytes_(context_size_out) uint8_t *context_out
Output context from the program.
uint64_t return_value
Return value from the program.
Definition ebpf_api.h:580
size_t repeat_count
Number of times to repeat the program.
Definition ebpf_api.h:581
size_t context_size_in
Size of input context.
Definition ebpf_api.h:578
uint32_t cpu
CPU to run the program on.
Definition ebpf_api.h:584
size_t data_size_in
Size of input data.
Definition ebpf_api.h:574
size_t context_size_out
Maximum length of context_out on input and actual length of context_out on output.
Definition ebpf_api.h:579
uint32_t flags
Flags to control the test run.
Definition ebpf_api.h:583
_Readable_bytes_(data_size_in) const uint8_t *data_in
Input data to the program.
_Writable_bytes_(data_size_out) uint8_t *data_out
Output data from the program.
size_t data_size_out
Maximum length of data_out on input and actual length of data_out on output.
Definition ebpf_api.h:575
Per-instruction map annotation from the verifier. For map helper calls where the verifier can prove w...
Definition ebpf_api.h:124
const char * map_name
Map name from ELF (NULL if ambiguous).
Definition ebpf_api.h:127
int32_t helper_id
Helper function ID (e.g., BPF_FUNC_map_lookup_elem).
Definition ebpf_api.h:126
uint32_t max_entries
Map maximum entries.
Definition ebpf_api.h:130
uint32_t value_size
Map value size in bytes.
Definition ebpf_api.h:129
bool is_inner_map_template
True if this map is only an inner map template.
Definition ebpf_api.h:131
uint32_t map_type
Map type (e.g., BPF_MAP_TYPE_ARRAY).
Definition ebpf_api.h:128
uint32_t instruction_offset
BPF program counter of the CALL instruction.
Definition ebpf_api.h:125
Definition ebpf_api.h:112
int total_warnings
Definition ebpf_api.h:114
int total_unreachable
Definition ebpf_api.h:113
int max_loop_count
Definition ebpf_api.h:115
Windows-specific perf buffer options structure.
Definition ebpf_api.h:882
size_t sz
Definition ebpf_api.h:883
uint64_t flags
Definition ebpf_api.h:884
Windows-specific ring buffer options structure.
Definition ebpf_api.h:803
uint64_t flags
Definition ebpf_api.h:805
size_t sz
Definition ebpf_api.h:804