P4C
The P4 Compiler
 
Loading...
Searching...
No Matches
ebpf_registry.h
1/*
2Copyright 2018 VMware, Inc.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17/*
18 * This file defines a shared registry. It is required by the p4c-ebpf test framework
19 * and acts as an interface between the emulated control and data plane. It provides
20 * a mechanism to access shared tables by name or id and is intended to approximate the
21 * kernel ebpf object API as closely as possible. This library is currently not thread-safe.
22 */
23
24#ifndef BACKENDS_EBPF_RUNTIME_EBPF_REGISTRY_H_
25#define BACKENDS_EBPF_RUNTIME_EBPF_REGISTRY_H_
26
27#include "ebpf_map.h"
28
29#define MAX_TABLE_NAME_LENGTH 256 // maximum length of the table name
30
41struct bpf_table {
42 char *name; // table name longer than VAR_SIZE is not accessed
43 unsigned int type; // currently only hashmap is supported
44 unsigned int key_size; // size of the key structure
45 unsigned int value_size; // size of the value structure
46 unsigned int max_entries; // Maximum of possible entries
47 struct bpf_map *bpf_map; // Pointer to the actual hash map
48};
49
56int registry_add(struct bpf_table *tbl);
57
64int registry_delete_tbl(const char *name);
65
72void registry_delete();
73
80struct bpf_table *registry_lookup_table(const char *name);
81
88struct bpf_table *registry_lookup_table_id(int tbl_id);
89
96int registry_get_id(const char *name);
97
106int registry_update_table(const char *name, void *key, void *value, unsigned long long flags);
107
116int registry_update_table_id(int tbl_id, void *key, void *value, unsigned long long flags);
117
127int registry_delete_table_elem(const char *name, void *key);
128
138int registry_delete_table_elem_id(int tbl_id, void *key);
139
149void *registry_lookup_table_elem(const char *name, void *key);
150
160void *registry_lookup_table_elem_id(int tbl_id, void *key);
161
162#endif // BACKENDS_EBPF_RUNTIME_EBPF_REGISTRY_H_
Definition ebpf_map.h:27
A helper structure used to describe attributes.
Definition ebpf_registry.h:41