FD.io VPP  v20.05.1-6-gf53edbc3b
Vector Packet Processing
l2_vtr_cmds.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 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 #include "vom/l2_vtr_cmds.hpp"
17 
18 namespace VOM {
19 namespace l2_vtr_cmds {
20 
22  const handle_t& itf,
23  uint16_t tag)
24  : rpc_cmd(item)
25  , m_itf(itf)
26  , m_tag(tag)
27 {
28 }
29 
30 bool
31 set_cmd::operator==(const set_cmd& other) const
32 {
33  return (
34  (m_hw_item.data() == other.m_hw_item.data() && m_itf == other.m_itf) &&
35  (m_tag == other.m_tag));
36 }
37 
38 rc_t
40 {
41  msg_t req(con.ctx(), std::ref(*this));
42 
43  auto& payload = req.get_request().get_payload();
44  payload.sw_if_index = m_itf.value();
45  payload.vtr_op = m_hw_item.data().value();
46  payload.push_dot1q = 1;
47  payload.tag1 = m_tag;
48 
49  VAPI_CALL(req.execute());
50 
51  return (wait());
52 }
53 
54 std::string
56 {
57  std::ostringstream s;
58  s << "L2-vtr-set: " << m_hw_item.to_string() << " itf:" << m_itf.to_string()
59  << " tag:" << m_tag;
60 
61  return (s.str());
62 }
63 
64 }; // namespace vtr_cmds
65 }; // namespace VOM
66 
67 /*
68  * fd.io coding-style-patch-verification: ON
69  *
70  * Local Variables:
71  * eval: (c-set-style "mozilla")
72  * End:
73  */
uint32_t value() const
get the value of the handle
Definition: types.cpp:93
Error codes that VPP will return during a HW write.
Definition: types.hpp:89
int value() const
Return the value of the enum - same as integer conversion.
Definition: enum_base.hpp:88
bool operator==(const set_cmd &i) const
Comparison operator - only used for UT.
Definition: l2_vtr_cmds.cpp:31
T & data()
Return the data read/written.
Definition: hw.hpp:109
std::string to_string() const
convert to string format for debug purposes
Definition: hw.hpp:161
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: l2_vtr_cmds.cpp:39
set_cmd(HW::item< l2_vtr::option_t > &item, const handle_t &itf, uint16_t tag)
Constructor.
Definition: l2_vtr_cmds.cpp:21
A representation of the connection to VPP.
Definition: connection.hpp:33
A base class for all RPC commands to VPP.
Definition: rpc_cmd.hpp:40
#define VAPI_CALL(_stmt)
Convenince wrapper macro for error handling in VAPI sends.
Definition: types.hpp:29
std::string to_string() const
convert to string format for debug purposes
Definition: types.cpp:69
std::string to_string() const
convert to string format for debug purposes
Definition: l2_vtr_cmds.cpp:55
A type declaration of an interface handle in VPP.
Definition: types.hpp:233
A cmd class sets the VTR operation.
Definition: l2_vtr_cmds.hpp:29
vapi::Connection & ctx()
Retrun the VAPI context the commands will use.
Definition: connection.cpp:49
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
HW::item< l2_vtr::option_t > & m_hw_item
A reference to an object&#39;s HW::item that the command will update.
Definition: rpc_cmd.hpp:134
vapi::L2_interface_vlan_tag_rewrite msg_t
convenient typedef
Definition: rpc_cmd.hpp:46