FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
qos_map_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/qos_map_cmds.hpp"
17 #include "vom/qos_types_api.hpp"
18 
19 namespace VOM {
20 namespace QoS {
21 namespace map_cmds {
22 
23 static void
24 to_api(const map::outputs_t& o, vapi_type_qos_egress_map_row rows[4])
25 {
26  for (uint32_t ii = 0; ii < 4; ii++) {
27  std::copy(o[ii].begin(), o[ii].end(), std::begin(rows[ii].outputs));
28  }
29 }
30 
32  uint32_t id,
33  const map::outputs_t& o)
34  : rpc_cmd(item)
35  , m_id(id)
36  , m_outputs(o)
37 {
38 }
39 
40 bool
42 {
43  return (m_id == other.m_id && m_outputs == other.m_outputs);
44 }
45 
46 rc_t
48 {
49  msg_t req(con.ctx(), std::ref(*this));
50 
51  auto& payload = req.get_request().get_payload();
52 
53  payload.map.id = m_id;
54  to_api(m_outputs, payload.map.rows);
55 
56  VAPI_CALL(req.execute());
57 
58  return (wait());
59 }
60 
63 {
64  std::ostringstream s;
65  s << "qos-map-create: " << m_hw_item.to_string() << " map:" << m_id;
66 
67  return (s.str());
68 }
69 
71  : rpc_cmd(item)
72  , m_id(id)
73 {
74 }
75 
76 bool
78 {
79  return (m_hw_item == other.m_hw_item && m_id == other.m_id);
80 }
81 
82 rc_t
84 {
85  msg_t req(con.ctx(), std::ref(*this));
86 
87  auto& payload = req.get_request().get_payload();
88  payload.map.id = m_id;
89 
90  VAPI_CALL(req.execute());
91 
92  return (wait());
93 }
94 
97 {
98  std::ostringstream s;
99  s << "qos-map-delete: " << m_hw_item.to_string() << " map:" << m_id;
100 
101  return (s.str());
102 }
103 
105 {
106 }
107 
108 bool
109 dump_cmd::operator==(const dump_cmd& other) const
110 {
111  return (true);
112 }
113 
114 rc_t
116 {
117  m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
118 
119  VAPI_CALL(m_dump->execute());
120 
121  wait();
122 
123  return rc_t::OK;
124 }
125 
128 {
129  return ("qos-map-dump");
130 }
131 
132 }; // namespace map_cmds
133 }; // namespace QoS
134 }; // namespace VOM
135 
136 /*
137  * fd.io coding-style-patch-verification: OFF
138  *
139  * Local Variables:
140  * eval: (c-set-style "mozilla")
141  * End:
142  */
VOM::HW::item< bool >
VOM::QoS::map_cmds::to_api
static void to_api(const map::outputs_t &o, vapi_type_qos_egress_map_row rows[4])
Definition: qos_map_cmds.cpp:24
VOM::dump_cmd< vapi::Qos_egress_map_dump >::msg_t
vapi::Qos_egress_map_dump msg_t
Definition: dump_cmd.hpp:46
VOM::rpc_cmd< HW::item< bool >, vapi::Qos_egress_map_update >::wait
rc_t wait()
Wait on the commands promise.
Definition: rpc_cmd.hpp:82
VOM
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
VOM::rc_t::OK
const static rc_t OK
The HW write was successfull.
Definition: types.hpp:109
VOM::QoS::map_cmds::create_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: qos_map_cmds.cpp:47
VOM::QoS::map_cmds::dump_cmd::operator==
bool operator==(const dump_cmd &i) const
Comparison operator - only used for UT.
Definition: qos_map_cmds.cpp:109
VOM::rpc_cmd
A base class for all RPC commands to VPP.
Definition: rpc_cmd.hpp:40
qos_types_api.hpp
con
Connection con
Definition: vapi_cpp_test.cpp:56
VOM::QoS::map::outputs_t
std::array< std::array< bits_t, 256 >, 4 > outputs_t
Definition: qos_map.hpp:38
VOM::rpc_cmd< HW::item< bool >, vapi::Qos_egress_map_update >::m_hw_item
HW::item< bool > & m_hw_item
A reference to an object's HW::item that the command will update.
Definition: rpc_cmd.hpp:134
VOM::dump_cmd< vapi::Qos_egress_map_dump >::m_dump
std::unique_ptr< vapi::Qos_egress_map_dump > m_dump
The VAPI event registration.
Definition: dump_cmd.hpp:143
VOM::QoS::map_cmds::delete_cmd::operator==
bool operator==(const delete_cmd &i) const
Comparison operator - only used for UT.
Definition: qos_map_cmds.cpp:77
VOM::QoS::map_cmds::dump_cmd
A cmd class that Dumps all the GBP endpoints.
Definition: qos_map_cmds.hpp:92
VOM::QoS::map_cmds::create_cmd
A command class that creates or updates the GBP endpoint.
Definition: qos_map_cmds.hpp:31
VOM::QoS::map_cmds::delete_cmd
A cmd class that deletes a GBP endpoint.
Definition: qos_map_cmds.hpp:62
VOM::QoS::map_cmds::create_cmd::operator==
bool operator==(const create_cmd &i) const
Comparison operator - only used for UT.
Definition: qos_map_cmds.cpp:41
VAPI_CALL
#define VAPI_CALL(_stmt)
Convenince wrapper macro for error handling in VAPI sends.
Definition: types.hpp:29
VOM::connection
A representation of the connection to VPP.
Definition: connection.hpp:33
end
f64 end
end of the time range
Definition: mactime.api:44
VOM::dump_cmd< vapi::Qos_egress_map_dump >::wait
rc_t wait()
Wait for the issue of the command to complete.
Definition: dump_cmd.hpp:93
rows
vl_api_qos_egress_map_row_t rows[4]
Definition: qos.api:153
VOM::QoS::map_cmds::create_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: qos_map_cmds.cpp:62
VOM::HW::item::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: hw.hpp:161
id
u8 id[64]
Definition: dhcp.api:160
VOM::rpc_cmd< HW::item< bool >, vapi::Qos_egress_map_update >::msg_t
vapi::Qos_egress_map_update msg_t
convenient typedef
Definition: rpc_cmd.hpp:46
VOM::QoS::map_cmds::dump_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: qos_map_cmds.cpp:127
VOM::QoS::map_cmds::create_cmd::create_cmd
create_cmd(HW::item< bool > &item, uint32_t id, const map::outputs_t &o)
Constructor.
Definition: qos_map_cmds.cpp:31
qos_map_cmds.hpp
VOM::QoS::map_cmds::delete_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: qos_map_cmds.cpp:83
VOM::QoS::map_cmds::delete_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: qos_map_cmds.cpp:96
item
cJSON * item
Definition: cJSON.h:222
VOM::QoS::map_cmds::dump_cmd::dump_cmd
dump_cmd()
Constructor.
Definition: qos_map_cmds.cpp:104
VOM::rc_t
Error codes that VPP will return during a HW write.
Definition: types.hpp:89
VOM::QoS::map_cmds::dump_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: qos_map_cmds.cpp:115
VOM::QoS::map_cmds::delete_cmd::delete_cmd
delete_cmd(HW::item< bool > &item, uint32_t id)
Constructor.
Definition: qos_map_cmds.cpp:70
string
const char *const string
Definition: cJSON.h:172