P4C
The P4 Compiler
Loading...
Searching...
No Matches
ebpfPsaChecksum.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_EXTERNS_EBPFPSACHECKSUM_H_
18#define BACKENDS_EBPF_PSA_EXTERNS_EBPFPSACHECKSUM_H_
19
20#include "backends/ebpf/ebpfObject.h"
21#include "ebpfPsaHashAlgorithm.h"
22
23namespace P4::EBPF {
24
26 protected:
28 const IR::Declaration_Instance *declaration;
29
30 void init(const EBPFProgram *program, cstring name, int type);
31
32 public:
33 EBPFChecksumPSA(const EBPFProgram *program, const IR::Declaration_Instance *block,
34 cstring name);
35
36 EBPFChecksumPSA(const EBPFProgram *program, const IR::Declaration_Instance *block, cstring name,
37 int type);
38
39 void emitVariables(CodeBuilder *builder) {
40 if (engine) engine->emitVariables(builder, declaration);
41 }
42
43 virtual void processMethod(CodeBuilder *builder, cstring method,
44 const IR::MethodCallExpression *expr, Visitor *visitor);
45};
46
48 public:
49 EBPFInternetChecksumPSA(const EBPFProgram *program, const IR::Declaration_Instance *block,
50 cstring name)
51 : EBPFChecksumPSA(program, block, name,
52 EBPFHashAlgorithmPSA::HashAlgorithm::ONES_COMPLEMENT16) {}
53
54 void processMethod(CodeBuilder *builder, cstring method, const IR::MethodCallExpression *expr,
55 Visitor *visitor) override;
56};
57
59 public:
60 EBPFHashPSA(const EBPFProgram *program, const IR::Declaration_Instance *block, cstring name)
61 : EBPFChecksumPSA(program, block, name) {}
62
63 void processMethod(CodeBuilder *builder, cstring method, const IR::MethodCallExpression *expr,
64 Visitor *visitor) override;
65
66 void calculateHash(CodeBuilder *builder, const IR::MethodCallExpression *expr,
67 Visitor *visitor);
68
69 void emitGetMethod(CodeBuilder *builder, const IR::MethodCallExpression *expr,
70 Visitor *visitor);
71};
72
73} // namespace P4::EBPF
74
75#endif /* BACKENDS_EBPF_PSA_EXTERNS_EBPFPSACHECKSUM_H_ */
Definition ebpf/codeGen.h:33
Definition ebpfPsaChecksum.h:25
Definition ebpfPsaHashAlgorithm.h:26
virtual void emitVariables(CodeBuilder *builder, const IR::Declaration_Instance *decl)=0
decl might be a null pointer
Definition ebpfPsaChecksum.h:58
void calculateHash(CodeBuilder *builder, const IR::MethodCallExpression *expr, Visitor *visitor)
This method calculates a hash value and saves it to the registerVar.
Definition ebpfPsaChecksum.cpp:100
Definition ebpfPsaChecksum.h:47
Base class for EBPF objects.
Definition ebpfObject.h:31
Definition ebpfProgram.h:39
Definition visitor.h:75
Definition cstring.h:85
Definition codeGen.cpp:25