P4C
The P4 Compiler
Loading...
Searching...
No Matches
backends/tc/options.h
1/*
2 * Copyright (C) 2023 Intel Corporation
3 * SPDX-FileCopyrightText: 2023 Intel Corporation
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8#ifndef BACKENDS_TC_OPTIONS_H_
9#define BACKENDS_TC_OPTIONS_H_
10
11#include "backends/ebpf/ebpfOptions.h"
12#include "frontends/common/options.h"
13
14namespace P4::TC {
15
16class TCOptions : public CompilerOptions {
17 public:
18 // file to output to
19 std::filesystem::path outputFolder;
20 bool DebugOn = false;
21 // tracing eBPF code execution
22 bool emitTraceMessages = false;
23 // XDP2TC mode for PSA-eBPF
24 enum XDP2TC xdp2tcMode = XDP2TC_META;
25 unsigned timerProfiles = 4;
26
27 TCOptions() {
28 registerOption(
29 "-o", "output Directory",
30 [this](const char *arg) {
31 outputFolder = arg;
32 return true;
33 },
34 "Write pipeline template, introspection json and C output to given directory");
35 registerOption(
36 "-g", nullptr,
37 [this](const char *) {
38 DebugOn = true;
39 return true;
40 },
41 "Generates debug information");
42 registerOption(
43 "--trace", nullptr,
44 [this](const char *) {
45 emitTraceMessages = true;
46 return true;
47 },
48 "Generate tracing messages of packet processing");
49 registerOption(
50 "--xdp2tc", "MODE",
51 [this](const char *arg) {
52 if (!strcmp(arg, "meta")) {
53 xdp2tcMode = XDP2TC_META;
54 } else if (!strcmp(arg, "head")) {
55 xdp2tcMode = XDP2TC_HEAD;
56 } else if (!strcmp(arg, "cpumap")) {
57 xdp2tcMode = XDP2TC_CPUMAP;
58 }
59 return true;
60 },
61 "Select the mode used to pass metadata from XDP to TC "
62 "(possible values: meta, head, cpumap).");
63 registerOption(
64 "--num-timer-profiles", "profiles",
65 [this](const char *arg) {
66 timerProfiles = std::atoi(arg);
67 return true;
68 },
69 "Defines the number of timer profiles. Default is 4.");
70 }
71};
72
73using TCContext = P4CContextWithOptions<TCOptions>;
74
75} // namespace P4::TC
76
77#endif /* BACKENDS_TC_OPTIONS_H_ */
Definition parser_options.h:170
This file defines functions for the pass to generate the introspection file.
Definition tc/backend.cpp:17