-
Notifications
You must be signed in to change notification settings - Fork 0
/
simpleSwitch.h
71 lines (55 loc) · 2.82 KB
/
simpleSwitch.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
Copyright 2013-present Barefoot Networks, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef _BACKENDS_BMV2_FLEXSWITCH_H_
#define _BACKENDS_BMV2_FLEXSWITCH_H_
#include <algorithm>
#include <cstring>
#include "frontend_sai_model.h"
#include "sharedActionSelectorCheck.h"
namespace BMV2 {
class Backend;
} // namespace BMV2
namespace P4FLX {
class SimpleSwitch {
BMV2::Backend* backend;
V1Model& v1model;
protected:
void addToFieldList(const IR::Expression* expr, Util::JsonArray* fl);
int createFieldList(const IR::Expression* expr, cstring group,
cstring listName, Util::JsonArray* field_lists);
cstring convertHashAlgorithm(cstring algorithm);
cstring createCalculation(cstring algo, const IR::Expression* fields,
Util::JsonArray* calculations, const IR::Node* node);
void generateUpdate(const IR::BlockStatement *block,
Util::JsonArray* checksums, Util::JsonArray* calculations);
public:
void convertExternObjects(Util::JsonArray *result, const P4::ExternMethod *em,
const IR::MethodCallExpression *mc, const IR::StatOrDecl *s);
void convertExternFunctions(Util::JsonArray *result, const P4::ExternFunction *ef,
const IR::MethodCallExpression *mc, const IR::StatOrDecl* s);
void convertExternInstances(const IR::Declaration *c,
const IR::ExternBlock* eb, Util::JsonArray* action_profiles,
BMV2::SharedActionSelectorCheck& selector_check);
void convertChecksumUpdate(const IR::P4Control* updateControl,
Util::JsonArray* checksums, Util::JsonArray* calculations);
void setPipelineControls(const IR::ToplevelBlock* blk, std::set<cstring>* controls,
std::map<cstring, cstring>* map);
void setNonPipelineControls(const IR::ToplevelBlock* blk, std::set<cstring>* controls);
void setUpdateChecksumControls(const IR::ToplevelBlock* blk, std::set<cstring>* controls);
void setDeparserControls(const IR::ToplevelBlock* blk, std::set<cstring>* controls);
explicit SimpleSwitch(BMV2::Backend* backend) :
backend(backend), v1model(V1Model::instance)
{ CHECK_NULL(backend); }
};
} // namespace P4FLX
#endif /* _BACKENDS_BMV2_SIMPLESWITCH_H_ */