VOM: support for pipes
[vpp.git] / extras / vom / vom / l2_binding_cmds.hpp
1 /*
2  * Copyright (c) 2017 Cisco and/or its affiliates.
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 #ifndef __VOM_L2_BINDING_CMDS_H__
17 #define __VOM_L2_BINDING_CMDS_H__
18
19 #include "vom/l2_binding.hpp"
20 #include "vom/rpc_cmd.hpp"
21
22 #include <vapi/l2.api.vapi.hpp>
23 #include <vapi/vpe.api.vapi.hpp>
24
25 namespace VOM {
26 namespace l2_binding_cmds {
27
28 /**
29  * A functor class that binds L2 configuration to an interface
30  */
31 class bind_cmd
32   : public rpc_cmd<HW::item<bool>, vapi::Sw_interface_set_l2_bridge>
33 {
34 public:
35   /**
36    * Constructor
37    */
38   bind_cmd(HW::item<bool>& item, const handle_t& itf, uint32_t bd, bool is_bvi);
39
40   /**
41    * Issue the command to VPP/HW
42    */
43   rc_t issue(connection& con);
44   /**
45    * convert to string format for debug purposes
46    */
47   std::string to_string() const;
48
49   /**
50    * Comparison operator - only used for UT
51    */
52   bool operator==(const bind_cmd& i) const;
53
54 private:
55   /**
56    * The interface to bind
57    */
58   const handle_t m_itf;
59
60   /**
61    * The bridge-domain to bind to
62    */
63   uint32_t m_bd;
64
65   /**
66    * Is it a BVI interface that is being bound
67    */
68   bool m_is_bvi;
69 };
70
71 /**
72  * A cmd class that Unbinds L2 configuration from an interface
73  */
74 class unbind_cmd
75   : public rpc_cmd<HW::item<bool>, vapi::Sw_interface_set_l2_bridge>
76 {
77 public:
78   /**
79    * Constructor
80    */
81   unbind_cmd(HW::item<bool>& item,
82              const handle_t& itf,
83              uint32_t bd,
84              bool is_bvi);
85
86   /**
87    * Issue the command to VPP/HW
88    */
89   rc_t issue(connection& con);
90   /**
91    * convert to string format for debug purposes
92    */
93   std::string to_string() const;
94
95   /**
96    * Comparison operator - only used for UT
97    */
98   bool operator==(const unbind_cmd& i) const;
99
100 private:
101   /**
102    * The interface to bind
103    */
104   const handle_t m_itf;
105
106   /**
107    * The bridge-domain to bind to
108    */
109   uint32_t m_bd;
110
111   /**
112    * Is it a BVI interface that is being bound
113    */
114   bool m_is_bvi;
115 };
116
117 /**
118  * A cmd class sets the VTR operation
119  */
120 class set_vtr_op_cmd : public rpc_cmd<HW::item<l2_binding::l2_vtr_op_t>,
121                                       vapi::L2_interface_vlan_tag_rewrite>
122 {
123 public:
124   /**
125    * Constructor
126    */
127   set_vtr_op_cmd(HW::item<l2_binding::l2_vtr_op_t>& item,
128                  const handle_t& itf,
129                  uint16_t tag);
130
131   /**
132    * Issue the command to VPP/HW
133    */
134   rc_t issue(connection& con);
135
136   /**
137    * convert to string format for debug purposes
138    */
139   std::string to_string() const;
140
141   /**
142    * Comparison operator - only used for UT
143    */
144   bool operator==(const set_vtr_op_cmd& i) const;
145
146 private:
147   /**
148    * The interface to bind
149    */
150   const handle_t m_itf;
151
152   /**
153    * The tag for the operation
154    */
155   uint16_t m_tag;
156 };
157
158 }; // namespace l2_binding_cmds
159 }; // namespace VOM
160
161 /*
162  * fd.io coding-style-patch-verification: ON
163  *
164  * Local Variables:
165  * eval: (c-set-style "mozilla")
166  * End:
167  */
168
169 #endif