bmv2
Designing your own switch target with bmv2
primitives.h
1 /* Copyright 2013-present Barefoot Networks, Inc.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /*
17  * Antonin Bas (antonin@barefootnetworks.com)
18  *
19  */
20 
21 #ifndef BM_BM_SIM_CORE_PRIMITIVES_H_
22 #define BM_BM_SIM_CORE_PRIMITIVES_H_
23 
24 #include <bm/bm_sim/actions.h>
25 
26 #include <string>
27 #include <vector>
28 
29 namespace bm {
30 
31 namespace core {
32 
33 struct assign : public ActionPrimitive<Data &, const Data &> {
34  void operator ()(Data &dst, const Data &src) {
35  dst.set(src);
36  }
37 };
38 
39 struct assign_VL : public ActionPrimitive<Field &, const Field &> {
40  void operator ()(Field &dst, const Field &src) {
41  dst.assign_VL(src);
42  }
43 };
44 
45 struct assign_header : public ActionPrimitive<Header &, const Header &> {
46  void operator ()(Header &dst, const Header &src);
47 };
48 
49 struct assign_union
50  : public ActionPrimitive<HeaderUnion &, const HeaderUnion &> {
51  void operator ()(HeaderUnion &dst, const HeaderUnion &src);
52 };
53 
54 struct assign_header_stack
55  : public ActionPrimitive<HeaderStack &, const HeaderStack &> {
56  void operator ()(HeaderStack &dst, const HeaderStack &src);
57 };
58 
59 struct assign_union_stack
60  : public ActionPrimitive<HeaderUnionStack &, const HeaderUnionStack &> {
61  void operator ()(HeaderUnionStack &dst, const HeaderUnionStack &src);
62 };
63 
64 struct push : public ActionPrimitive<StackIface &, const Data &> {
65  void operator ()(StackIface &stack, const Data &num);
66 };
67 
68 struct pop : public ActionPrimitive<StackIface &, const Data &> {
69  void operator ()(StackIface &stack, const Data &num);
70 };
71 
72 struct assert_ : public ActionPrimitive<const Data &> {
73  void operator ()(const Data &src);
74 };
75 
76 struct assume_ : public ActionPrimitive<const Data &> {
77  void operator ()(const Data &src);
78 };
79 
80 class exit_ : public ActionPrimitive<> {
81  void operator ()();
82 };
83 
84 struct log_msg : public ActionPrimitive<const std::string &,
85  const std::vector<Data> > {
86  void operator ()(const std::string &format,
87  const std::vector<Data> data_vector);
88 };
89 
90 } // namespace core
91 
92 } // namespace bm
93 
94 #endif // BM_BM_SIM_CORE_PRIMITIVES_H_
actions.h