P4C
The P4 Compiler
Loading...
Searching...
No Matches
ebpf_runtime_ubpf.h
1/*
2 * Copyright 2020 Orange
3 * SPDX-FileCopyrightText: 2020 Orange
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8#ifndef P4C_EBPF_RUNTIME_UBPF_H
9#define P4C_EBPF_RUNTIME_UBPF_H
10
11#include <stdint.h>
12#include "../../ebpf/runtime/pcap_util.h"
13#include "../../ebpf/runtime/ebpf_registry.h"
14#include "ubpf_test.h"
15
16struct standard_metadata;
17
18extern uint64_t entry(void *, struct standard_metadata *);
19typedef uint64_t (*packet_filter)(void *dp, struct standard_metadata *std_meta);
20
21void *run_and_record_output(packet_filter entry, const char *pcap_base, pcap_list_t *pkt_list, int debug);
22
23static void inline init_ubpf_table_test(char *name, unsigned int key_size, unsigned int value_size) {
24 struct bpf_table tbl = {
25 .name = name,
26 .type = 0,
27 .key_size = key_size,
28 .value_size = value_size,
29 .bpf_map = NULL
30 };
31 registry_add(&tbl);
32}
33
34
35#define ubpf_printf(fmt, args) \
36 ubpf_printf_test(fmt, args)
37#define ubpf_packet_data(ctx) \
38 ubpf_packet_data_test(ctx)
39#define ubpf_adjust_head(ctx, ofs) \
40 ubpf_adjust_head_test(ctx, ofs)
41#define ubpf_truncate_packet(ctx, maxlen) \
42 ubpf_truncate_packet_test(ctx, maxlen)
43#define ubpf_map_lookup(table, key) \
44 registry_lookup_table_elem(#table, key)
45#define ubpf_map_update(table, key, value) \
46 registry_update_table(#table, key, value, 0)
47
48#define INIT_UBPF_TABLE(name, key_size, value_size) init_ubpf_table_test("&"name, key_size, value_size)
49
50#define RUN(entry, pcap_base, num_pcaps, input_list, debug) \
51 run_and_record_output(entry, pcap_base, input_list, debug)
52#define INIT_EBPF_TABLES(debug)
53#define DELETE_EBPF_TABLES(debug)
54
55
56#endif //P4C_EBPF_RUNTIME_UBPF_H
A helper structure used to describe attributes.
Definition ebpf_registry.h:27