xref: /openbmc/qemu/ebpf/ebpf_rss.h (revision 646b5378)
1 /*
2  * eBPF RSS header
3  *
4  * Developed by Daynix Computing LTD (http://www.daynix.com)
5  *
6  * Authors:
7  *  Andrew Melnychenko <andrew@daynix.com>
8  *  Yuri Benditovich <yuri.benditovich@daynix.com>
9  *
10  * This work is licensed under the terms of the GNU GPL, version 2.  See
11  * the COPYING file in the top-level directory.
12  */
13 
14 #ifndef QEMU_EBPF_RSS_H
15 #define QEMU_EBPF_RSS_H
16 
17 #include "qapi/error.h"
18 
19 #define EBPF_RSS_MAX_FDS 4
20 
21 struct EBPFRSSContext {
22     void *obj;
23     int program_fd;
24     int map_configuration;
25     int map_toeplitz_key;
26     int map_indirections_table;
27 
28     /* mapped eBPF maps for direct access to omit bpf_map_update_elem() */
29     void *mmap_configuration;
30     void *mmap_toeplitz_key;
31     void *mmap_indirections_table;
32 };
33 
34 struct EBPFRSSConfig {
35     uint8_t redirect;
36     uint8_t populate_hash;
37     uint32_t hash_types;
38     uint16_t indirections_len;
39     uint16_t default_queue;
40 } __attribute__((packed));
41 
42 void ebpf_rss_init(struct EBPFRSSContext *ctx);
43 
44 bool ebpf_rss_is_loaded(struct EBPFRSSContext *ctx);
45 
46 bool ebpf_rss_load(struct EBPFRSSContext *ctx, Error **errp);
47 
48 bool ebpf_rss_load_fds(struct EBPFRSSContext *ctx, int program_fd,
49                        int config_fd, int toeplitz_fd, int table_fd,
50                        Error **errp);
51 
52 bool ebpf_rss_set_all(struct EBPFRSSContext *ctx, struct EBPFRSSConfig *config,
53                       uint16_t *indirections_table, uint8_t *toeplitz_key,
54                       Error **errp);
55 
56 void ebpf_rss_unload(struct EBPFRSSContext *ctx);
57 
58 #endif /* QEMU_EBPF_RSS_H */
59