P4C
The P4 Compiler
Loading...
Searching...
No Matches
ubpf/target.h
1
/*
2
Copyright 2019 Orange
3
4
Licensed under the Apache License, Version 2.0 (the "License");
5
you may not use this file except in compliance with the License.
6
You may obtain a copy of the License at
7
8
http://www.apache.org/licenses/LICENSE-2.0
9
10
Unless required by applicable law or agreed to in writing, software
11
distributed under the License is distributed on an "AS IS" BASIS,
12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
See the License for the specific language governing permissions and
14
limitations under the License.
15
*/
16
17
#ifndef BACKENDS_UBPF_TARGET_H_
18
#define BACKENDS_UBPF_TARGET_H_
19
20
#include "backends/ebpf/ebpfObject.h"
21
#include "backends/ebpf/target.h"
22
#include "ubpfHelpers.h"
23
24
namespace
P4::UBPF {
25
26
using namespace
P4::literals;
27
28
class
UBPFControlBodyTranslator
;
29
30
class
UbpfTarget :
public
EBPF::Target
{
31
public
:
32
UbpfTarget() :
EBPF::Target
(
"UBPF"
_cs) {}
33
34
void
emitLicense(
Util::SourceCodeBuilder
*,
cstring
)
const override
{};
35
void
emitCodeSection(
Util::SourceCodeBuilder
*,
cstring
)
const override
{};
36
void
emitIncludes(
Util::SourceCodeBuilder
*builder)
const override
;
37
void
emitResizeBuffer(
Util::SourceCodeBuilder
*builder,
cstring
buffer,
38
cstring
offsetVar)
const override
;
39
void
emitTableLookup(
Util::SourceCodeBuilder
*builder,
cstring
tblName,
cstring
key,
40
cstring
value)
const override
;
41
void
emitTableUpdate(
Util::SourceCodeBuilder
*builder,
cstring
tblName,
cstring
key,
42
cstring
value)
const override
;
43
void
emitGetPacketData(
Util::SourceCodeBuilder
*builder,
cstring
ctxVar)
const
;
44
void
emitGetFromStandardMetadata(
Util::SourceCodeBuilder
*builder,
cstring
stdMetadataVar,
45
cstring
metadataField)
const
;
46
void
emitUserTableUpdate(UNUSED
Util::SourceCodeBuilder
*builder, UNUSED
cstring
tblName,
47
UNUSED
cstring
key, UNUSED
cstring
value)
const override
{};
48
void
emitTableDecl(
Util::SourceCodeBuilder
*builder,
cstring
tblName, EBPF::TableKind tableKind,
49
cstring
keyType,
cstring
valueType,
unsigned
size)
const override
;
50
void
emitMain(UNUSED
Util::SourceCodeBuilder
*builder, UNUSED
cstring
functionName,
51
UNUSED
cstring
argName)
const override
{};
52
void
emitMain(
Util::SourceCodeBuilder
*builder,
cstring
functionName,
cstring
argName,
53
cstring
standardMetadata)
const
;
54
void
emitUbpfHelpers(
EBPF::CodeBuilder
*builder)
const
;
55
void
emitChecksumHelpers(
EBPF::CodeBuilder
*builder)
const
;
56
57
cstring
dataOffset(UNUSED
cstring
base)
const override
{
return
""
_cs; }
58
cstring
dataEnd(UNUSED
cstring
base)
const override
{
return
""
_cs; }
59
cstring
dataLength(UNUSED
cstring
base)
const override
{
return
""
_cs; }
60
cstring
dropReturnCode()
const override
{
return
"0"
_cs; }
61
cstring
abortReturnCode()
const override
{
return
"1"
_cs; }
62
cstring
forwardReturnCode()
const override
{
return
"1"
_cs; }
63
cstring
sysMapPath()
const override
{
return
""
_cs; }
64
cstring
packetDescriptorType()
const override
{
return
"void"
_cs; }
65
};
66
67
}
// namespace P4::UBPF
68
69
#endif
/* BACKENDS_UBPF_TARGET_H_ */
P4::EBPF::CodeBuilder
Definition
ebpf/codeGen.h:33
P4::EBPF::Target
Definition
ebpf/target.h:44
P4::UBPF::UBPFControlBodyTranslator
Definition
ubpfControl.h:27
P4::Util::SourceCodeBuilder
Definition
sourceCodeBuilder.h:29
P4::cstring
Definition
cstring.h:85
backends
ubpf
target.h
Generated by
1.13.2