xref: /openbmc/qemu/ebpf/ebpf_rss.h (revision ed75658a)
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 #define EBPF_RSS_MAX_FDS 4
18 
19 struct EBPFRSSContext {
20     void *obj;
21     int program_fd;
22     int map_configuration;
23     int map_toeplitz_key;
24     int map_indirections_table;
25 
26     /* mapped eBPF maps for direct access to omit bpf_map_update_elem() */
27     void *mmap_configuration;
28     void *mmap_toeplitz_key;
29     void *mmap_indirections_table;
30 };
31 
32 struct EBPFRSSConfig {
33     uint8_t redirect;
34     uint8_t populate_hash;
35     uint32_t hash_types;
36     uint16_t indirections_len;
37     uint16_t default_queue;
38 } __attribute__((packed));
39 
40 void ebpf_rss_init(struct EBPFRSSContext *ctx);
41 
42 bool ebpf_rss_is_loaded(struct EBPFRSSContext *ctx);
43 
44 bool ebpf_rss_load(struct EBPFRSSContext *ctx);
45 
46 bool ebpf_rss_load_fds(struct EBPFRSSContext *ctx, int program_fd,
47                        int config_fd, int toeplitz_fd, int table_fd);
48 
49 bool ebpf_rss_set_all(struct EBPFRSSContext *ctx, struct EBPFRSSConfig *config,
50                       uint16_t *indirections_table, uint8_t *toeplitz_key);
51 
52 void ebpf_rss_unload(struct EBPFRSSContext *ctx);
53 
54 #endif /* QEMU_EBPF_RSS_H */
55