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