FD.io VPP  v21.01.1
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  */
bool operator==(const dump_cmd &i) const
Comparison operator - only used for UT.
const char *const string
Definition: cJSON.h:172
Error codes that VPP will return during a HW write.
Definition: types.hpp:89
create_cmd(HW::item< bool > &item, uint32_t id, const map::outputs_t &o)
Constructor.
std::string to_string() const
convert to string format for debug purposes
delete_cmd(HW::item< bool > &item, uint32_t id)
Constructor.
vl_api_qos_egress_map_row_t rows[4]
Definition: qos.api:153
std::string to_string() const
convert to string format for debug purposes
Definition: hw.hpp:161
static void to_api(const map::outputs_t &o, vapi_type_qos_egress_map_row rows[4])
std::string to_string() const
convert to string format for debug purposes
A cmd class that deletes a GBP endpoint.
A representation of the connection to VPP.
Definition: connection.hpp:33
bool operator==(const create_cmd &i) const
Comparison operator - only used for UT.
A base class for all RPC commands to VPP.
Definition: rpc_cmd.hpp:40
A cmd class that Dumps all the GBP endpoints.
#define VAPI_CALL(_stmt)
Convenince wrapper macro for error handling in VAPI sends.
Definition: types.hpp:29
std::array< std::array< bits_t, 256 >, 4 > outputs_t
Definition: qos_map.hpp:38
std::string to_string() const
convert to string format for debug purposes
cJSON * item
Definition: cJSON.h:222
static const rc_t OK
The HW write was successfull.
Definition: types.hpp:109
A command class that creates or updates the GBP endpoint.
bool operator==(const delete_cmd &i) const
Comparison operator - only used for UT.
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
f64 end
end of the time range
Definition: mactime.api:44
rc_t issue(connection &con)
Issue the command to VPP/HW.
rc_t issue(connection &con)
Issue the command to VPP/HW.
HW::item< bool > & m_hw_item
A reference to an object&#39;s HW::item that the command will update.
Definition: rpc_cmd.hpp:134
rc_t issue(connection &con)
Issue the command to VPP/HW.
HW::item< bool > & item()
return the HW item the command updates
Definition: rpc_cmd.hpp:66
vapi::Qos_egress_map_update msg_t
convenient typedef
Definition: rpc_cmd.hpp:46