P4C
The P4 Compiler
Loading...
Searching...
No Matches
ebpfPsaParser.h
1/*
2Copyright 2022-present Orange
3Copyright 2022-present Open Networking Foundation
4
5Licensed under the Apache License, Version 2.0 (the "License");
6you may not use this file except in compliance with the License.
7You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11Unless required by applicable law or agreed to in writing, software
12distributed under the License is distributed on an "AS IS" BASIS,
13WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14See the License for the specific language governing permissions and
15limitations under the License.
16*/
17#ifndef BACKENDS_EBPF_PSA_EBPFPSAPARSER_H_
18#define BACKENDS_EBPF_PSA_EBPFPSAPARSER_H_
19
20#include "backends/ebpf/ebpfParser.h"
21#include "backends/ebpf/ebpfType.h"
22#include "backends/ebpf/psa/ebpfPsaTable.h"
23#include "backends/ebpf/psa/externs/ebpfPsaChecksum.h"
24
25namespace P4::EBPF {
26
27class EBPFPsaParser;
28
30 public:
31 EBPFPsaParser *parser;
32
34 EBPFPsaParser *prsr)
35 : StateTranslationVisitor(refMap, typeMap), parser(prsr) {}
36
37 void processMethod(const P4::ExternMethod *ext) override;
38};
39
40class EBPFPsaParser : public EBPFParser {
41 public:
42 std::map<cstring, EBPFChecksumPSA *> checksums;
43 const IR::Parameter *inputMetadata;
44
45 EBPFPsaParser(const EBPFProgram *program, const IR::ParserBlock *block,
46 const P4::TypeMap *typeMap);
47
48 void emit(CodeBuilder *builder) override;
49 void emitParserInputMetadata(CodeBuilder *builder);
50 void emitDeclaration(CodeBuilder *builder, const IR::Declaration *decl) override;
51 void emitRejectState(CodeBuilder *builder) override;
52
53 EBPFChecksumPSA *getChecksum(cstring name) const {
54 auto result = ::P4::get(checksums, name);
55 BUG_CHECK(result != nullptr, "No checksum named %1%", name);
56 return result;
57 }
58
59 DECLARE_TYPEINFO(EBPFPsaParser, EBPFParser);
60};
61
62} // namespace P4::EBPF
63
64#endif /* BACKENDS_EBPF_PSA_EBPFPSAPARSER_H_ */
Definition ebpf/codeGen.h:33
Definition ebpfPsaChecksum.h:25
Definition ebpfParser.h:79
Definition ebpfProgram.h:39
Definition ebpfPsaParser.h:40
Definition ebpfPsaParser.h:29
Definition ebpfParser.h:31
Definition methodInstance.h:168
Class used to encode maps from paths to declarations.
Definition referenceMap.h:66
Definition typeMap.h:41
Definition cstring.h:85
Definition codeGen.cpp:25