P4C
The P4 Compiler
 
Loading...
Searching...
No Matches
target.h
1/*
2Copyright 2019 Orange
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#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
24namespace UBPF {
25
26class UBPFControlBodyTranslator;
27
28class UbpfTarget : public EBPF::Target {
29 public:
30 UbpfTarget() : EBPF::Target("UBPF") {}
31
32 void emitLicense(Util::SourceCodeBuilder *, cstring) const override {};
33 void emitCodeSection(Util::SourceCodeBuilder *, cstring) const override {};
34 void emitIncludes(Util::SourceCodeBuilder *builder) const override;
35 void emitResizeBuffer(Util::SourceCodeBuilder *builder, cstring buffer,
36 cstring offsetVar) const override;
37 void emitTableLookup(Util::SourceCodeBuilder *builder, cstring tblName, cstring key,
38 cstring value) const override;
39 void emitTableUpdate(Util::SourceCodeBuilder *builder, cstring tblName, cstring key,
40 cstring value) const override;
41 void emitGetPacketData(Util::SourceCodeBuilder *builder, cstring ctxVar) const;
42 void emitGetFromStandardMetadata(Util::SourceCodeBuilder *builder, cstring stdMetadataVar,
43 cstring metadataField) const;
44 void emitUserTableUpdate(UNUSED Util::SourceCodeBuilder *builder, UNUSED cstring tblName,
45 UNUSED cstring key, UNUSED cstring value) const override {};
46 void emitTableDecl(Util::SourceCodeBuilder *builder, cstring tblName, EBPF::TableKind tableKind,
47 cstring keyType, cstring valueType, unsigned size) const override;
48 void emitMain(UNUSED Util::SourceCodeBuilder *builder, UNUSED cstring functionName,
49 UNUSED cstring argName) const override {};
50 void emitMain(Util::SourceCodeBuilder *builder, cstring functionName, cstring argName,
51 cstring standardMetadata) const;
52 void emitUbpfHelpers(EBPF::CodeBuilder *builder) const;
53 void emitChecksumHelpers(EBPF::CodeBuilder *builder) const;
54
55 cstring dataOffset(UNUSED cstring base) const override { return cstring(""); }
56 cstring dataEnd(UNUSED cstring base) const override { return cstring(""); }
57 cstring dataLength(UNUSED cstring base) const override { return cstring(""); }
58 cstring dropReturnCode() const override { return "0"; }
59 cstring abortReturnCode() const override { return "1"; }
60 cstring forwardReturnCode() const override { return "1"; }
61 cstring sysMapPath() const override { return ""; }
62 cstring packetDescriptorType() const override { return "void"; }
63};
64
65} // namespace UBPF
66
67#endif /* BACKENDS_UBPF_TARGET_H_ */
Definition codeGen.h:33
Definition target.h:40
Definition target.h:28
Definition sourceCodeBuilder.h:29
Definition cstring.h:72