summaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
Diffstat (limited to 'extras')
-rw-r--r--extras/vom/vom/CMakeLists.txt12
-rw-r--r--extras/vom/vom/qos_map.cpp190
-rw-r--r--extras/vom/vom/qos_map.hpp182
-rw-r--r--extras/vom/vom/qos_map_cmds.cpp142
-rw-r--r--extras/vom/vom/qos_map_cmds.hpp133
-rw-r--r--extras/vom/vom/qos_mark.cpp187
-rw-r--r--extras/vom/vom/qos_mark.hpp179
-rw-r--r--extras/vom/vom/qos_mark_cmds.cpp143
-rw-r--r--extras/vom/vom/qos_mark_cmds.hpp138
-rw-r--r--extras/vom/vom/qos_record.cpp190
-rw-r--r--extras/vom/vom/qos_record.hpp173
-rw-r--r--extras/vom/vom/qos_record_cmds.cpp139
-rw-r--r--extras/vom/vom/qos_record_cmds.hpp136
-rw-r--r--extras/vom/vom/qos_types.cpp39
-rw-r--r--extras/vom/vom/qos_types.hpp58
-rw-r--r--extras/vom/vom/qos_types_api.cpp56
-rw-r--r--extras/vom/vom/qos_types_api.hpp35
17 files changed, 2132 insertions, 0 deletions
diff --git a/extras/vom/vom/CMakeLists.txt b/extras/vom/vom/CMakeLists.txt
index 144749968d5..2ea84d9faa8 100644
--- a/extras/vom/vom/CMakeLists.txt
+++ b/extras/vom/vom/CMakeLists.txt
@@ -167,6 +167,14 @@ list(APPEND VOM_SOURCES
pipe.cpp
pipe_cmds.cpp
prefix.cpp
+ qos_map.cpp
+ qos_map_cmds.cpp
+ qos_mark.cpp
+ qos_mark_cmds.cpp
+ qos_record.cpp
+ qos_record_cmds.cpp
+ qos_types.cpp
+ qos_types_api.cpp
ra_config.cpp
ra_prefix.cpp
route.cpp
@@ -269,6 +277,10 @@ list(APPEND VOM_HEADERS
om.hpp
pipe.hpp
prefix.hpp
+ qos_map.hpp
+ qos_mark.hpp
+ qos_record.hpp
+ qos_types.hpp
ra_config.hpp
ra_prefix.hpp
route.hpp
diff --git a/extras/vom/vom/qos_map.cpp b/extras/vom/vom/qos_map.cpp
new file mode 100644
index 00000000000..9e382ec2f55
--- /dev/null
+++ b/extras/vom/vom/qos_map.cpp
@@ -0,0 +1,190 @@
+/*
+ * Copyright (c) 2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "vom/qos_map.hpp"
+#include "vom/api_types.hpp"
+#include "vom/qos_map_cmds.hpp"
+#include "vom/qos_types_api.hpp"
+#include "vom/singular_db_funcs.hpp"
+
+namespace VOM {
+namespace QoS {
+
+singular_db<map::key_t, map> map::m_db;
+
+map::event_handler map::m_evh;
+
+map::map(uint32_t id, const outputs_t& o)
+ : m_config(false)
+ , m_id(id)
+ , m_outputs(o)
+{
+}
+
+map::map(const map& r)
+ : m_config(r.m_config)
+ , m_id(r.m_id)
+ , m_outputs(r.m_outputs)
+{
+}
+
+map::~map()
+{
+ sweep();
+ m_db.release(key(), this);
+}
+
+const map::key_t
+map::key() const
+{
+ return m_id;
+}
+
+const uint32_t
+map::id() const
+{
+ return m_id;
+}
+
+bool
+map::operator==(const map& m) const
+{
+ return (key() == m.key() && m_outputs == m.m_outputs);
+}
+
+void
+map::sweep()
+{
+ if (m_config) {
+ HW::enqueue(new map_cmds::delete_cmd(m_config, m_id));
+ }
+ HW::write();
+}
+
+void
+map::replay()
+{
+ if (m_config) {
+ HW::enqueue(new map_cmds::create_cmd(m_config, m_id, m_outputs));
+ }
+}
+
+std::string
+map::to_string() const
+{
+ std::ostringstream s;
+ s << "qos-map:" << (int)m_id;
+
+ return (s.str());
+}
+
+void
+map::update(const map& m)
+{
+ m_outputs = m.m_outputs;
+
+ if (rc_t::OK != m_config.rc()) {
+ HW::enqueue(new map_cmds::create_cmd(m_config, m_id, m_outputs));
+ }
+}
+
+std::shared_ptr<map>
+map::find_or_add(const map& temp)
+{
+ return (m_db.find_or_add(temp.key(), temp));
+}
+
+std::shared_ptr<map>
+map::find(const key_t& k)
+{
+ return (m_db.find(k));
+}
+
+std::shared_ptr<map>
+map::singular() const
+{
+ return find_or_add(*this);
+}
+
+void
+map::dump(std::ostream& os)
+{
+ db_dump(m_db, os);
+}
+
+map::event_handler::event_handler()
+{
+ OM::register_listener(this);
+ inspect::register_handler({ "qos-map" }, "QoS Map", this);
+}
+
+void
+map::event_handler::handle_replay()
+{
+ m_db.replay();
+}
+
+static const map::outputs_t
+from_api(vapi_type_qos_egress_map_row rows[4])
+{
+ map::outputs_t o;
+
+ for (uint32_t ii = 0; ii < 4; ii++) {
+ std::copy(std::begin(rows[ii].outputs), std::end(rows[ii].outputs),
+ o[ii].begin());
+ }
+
+ return o;
+}
+
+void
+map::event_handler::handle_populate(const client_db::key_t& key)
+{
+ std::shared_ptr<map_cmds::dump_cmd> cmd =
+ std::make_shared<map_cmds::dump_cmd>();
+
+ HW::enqueue(cmd);
+ HW::write();
+
+ for (auto& rr : *cmd) {
+ auto& payload = rr.get_payload();
+
+ map qr(payload.map.id, from_api(payload.map.rows));
+ OM::commit(key, qr);
+ }
+}
+
+dependency_t
+map::event_handler::order() const
+{
+ return (dependency_t::TABLE);
+}
+
+void
+map::event_handler::show(std::ostream& os)
+{
+ db_dump(m_db, os);
+}
+
+}; // namespace QoS
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
diff --git a/extras/vom/vom/qos_map.hpp b/extras/vom/vom/qos_map.hpp
new file mode 100644
index 00000000000..d722004177b
--- /dev/null
+++ b/extras/vom/vom/qos_map.hpp
@@ -0,0 +1,182 @@
+/*
+ * Copyright (c) 2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __VOM_QOS_MAP_H__
+#define __VOM_QOS_MAP_H__
+
+#include <ostream>
+
+#include "vom/interface.hpp"
+#include "vom/qos_types.hpp"
+#include "vom/singular_db.hpp"
+
+namespace VOM {
+/**
+ * Types belonging to QoS
+ */
+namespace QoS {
+
+/**
+ * A QoS map determines how value from one source are translated to
+ * values of another source
+ */
+class map : public object_base
+{
+public:
+ typedef std::array<std::array<uint8_t, 256>, 4> outputs_t;
+
+ map(uint32_t id, const outputs_t& o);
+ map(const map& r);
+
+ ~map();
+
+ typedef uint32_t key_t;
+
+ /**
+ * Return the object's key
+ */
+ const key_t key() const;
+
+ /**
+ * Return the object's ID
+ */
+ const key_t id() const;
+
+ /**
+ * comparison operator
+ */
+ bool operator==(const map& bdae) const;
+
+ /**
+ * Return the matching 'singular instance'
+ */
+ std::shared_ptr<map> singular() const;
+
+ /**
+ * Find the instnace of the bridge_domain domain in the OM
+ */
+ static std::shared_ptr<map> find(const key_t& k);
+
+ /**
+ * Dump all bridge_domain-doamin into the stream provided
+ */
+ static void dump(std::ostream& os);
+
+ /**
+ * replay the object to create it in hardware
+ */
+ void replay(void);
+
+ /**
+ * Convert to string for debugging
+ */
+ std::string to_string() const;
+
+private:
+ /**
+ * Class definition for listeners to OM events
+ */
+ class event_handler : public OM::listener, public inspect::command_handler
+ {
+ public:
+ event_handler();
+ virtual ~event_handler() = default;
+
+ /**
+ * Handle a populate event
+ */
+ void handle_populate(const client_db::key_t& key);
+
+ /**
+ * Handle a replay event
+ */
+ void handle_replay();
+
+ /**
+ * Show the object in the Singular DB
+ */
+ void show(std::ostream& os);
+
+ /**
+ * Get the sortable Id of the listener
+ */
+ dependency_t order() const;
+ };
+
+ /**
+ * event_handler to register with OM
+ */
+ static event_handler m_evh;
+
+ /**
+ * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
+ */
+ void update(const map& obj);
+
+ /**
+ * Find or add the instnace of the bridge_domain domain in the OM
+ */
+ static std::shared_ptr<map> find_or_add(const map& temp);
+
+ /*
+ * It's the VPPHW class that updates the objects in HW
+ */
+ friend class VOM::OM;
+
+ /**
+ * It's the singular_db class that calls replay()
+ */
+ friend class singular_db<key_t, map>;
+
+ /**
+ * Sweep/reap the object if still stale
+ */
+ void sweep(void);
+
+ /**
+ * HW configuration for the config. The bool representing the
+ * do/don't configured/unconfigured.
+ */
+ HW::item<bool> m_config;
+
+ /**
+ * unique ID of the MAP.
+ */
+ uint32_t m_id;
+
+ /**
+ * outputs from the translation
+ */
+ outputs_t m_outputs;
+
+ /**
+ * A map of all bridge_domains
+ */
+ static singular_db<key_t, map> m_db;
+};
+
+}; // namesapce QoS
+
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/extras/vom/vom/qos_map_cmds.cpp b/extras/vom/vom/qos_map_cmds.cpp
new file mode 100644
index 00000000000..d9054a89fb2
--- /dev/null
+++ b/extras/vom/vom/qos_map_cmds.cpp
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "vom/qos_map_cmds.hpp"
+#include "vom/qos_types_api.hpp"
+
+namespace VOM {
+namespace QoS {
+namespace map_cmds {
+
+static void
+to_api(const map::outputs_t& o, vapi_type_qos_egress_map_row rows[4])
+{
+ for (uint32_t ii = 0; ii < 4; ii++) {
+ std::copy(o[ii].begin(), o[ii].end(), std::begin(rows[ii].outputs));
+ }
+}
+
+create_cmd::create_cmd(HW::item<bool>& item,
+ uint32_t id,
+ const map::outputs_t& o)
+ : rpc_cmd(item)
+ , m_id(id)
+ , m_outputs(o)
+{
+}
+
+bool
+create_cmd::operator==(const create_cmd& other) const
+{
+ return (m_id == other.m_id && m_outputs == other.m_outputs);
+}
+
+rc_t
+create_cmd::issue(connection& con)
+{
+ msg_t req(con.ctx(), std::ref(*this));
+
+ auto& payload = req.get_request().get_payload();
+
+ payload.map.id = m_id;
+ to_api(m_outputs, payload.map.rows);
+
+ VAPI_CALL(req.execute());
+
+ return (wait());
+}
+
+std::string
+create_cmd::to_string() const
+{
+ std::ostringstream s;
+ s << "qos-map-create: " << m_hw_item.to_string() << " map:" << m_id;
+
+ return (s.str());
+}
+
+delete_cmd::delete_cmd(HW::item<bool>& item, uint32_t id)
+ : rpc_cmd(item)
+ , m_id(id)
+{
+}
+
+bool
+delete_cmd::operator==(const delete_cmd& other) const
+{
+ return (m_hw_item == other.m_hw_item && m_id == other.m_id);
+}
+
+rc_t
+delete_cmd::issue(connection& con)
+{
+ msg_t req(con.ctx(), std::ref(*this));
+
+ auto& payload = req.get_request().get_payload();
+ payload.map.id = m_id;
+
+ VAPI_CALL(req.execute());
+
+ return (wait());
+}
+
+std::string
+delete_cmd::to_string() const
+{
+ std::ostringstream s;
+ s << "qos-map-delete: " << m_hw_item.to_string() << " map:" << m_id;
+
+ return (s.str());
+}
+
+dump_cmd::dump_cmd()
+{
+}
+
+bool
+dump_cmd::operator==(const dump_cmd& other) const
+{
+ return (true);
+}
+
+rc_t
+dump_cmd::issue(connection& con)
+{
+ m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
+
+ VAPI_CALL(m_dump->execute());
+
+ wait();
+
+ return rc_t::OK;
+}
+
+std::string
+dump_cmd::to_string() const
+{
+ return ("qos-map-dump");
+}
+
+}; // namespace map_cmds
+}; // namespace QoS
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
diff --git a/extras/vom/vom/qos_map_cmds.hpp b/extras/vom/vom/qos_map_cmds.hpp
new file mode 100644
index 00000000000..8321894d532
--- /dev/null
+++ b/extras/vom/vom/qos_map_cmds.hpp
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __VOM_QOS_MAP_CMDS_H__
+#define __VOM_QOS_MAP_CMDS_H__
+
+#include "vom/dump_cmd.hpp"
+#include "vom/qos_map.hpp"
+
+#include <vapi/qos.api.vapi.hpp>
+
+namespace VOM {
+namespace QoS {
+namespace map_cmds {
+
+/**
+ * A command class that creates or updates the GBP endpoint
+ */
+class create_cmd : public rpc_cmd<HW::item<bool>, vapi::Qos_egress_map_update>
+{
+public:
+ /**
+ * Constructor
+ */
+ create_cmd(HW::item<bool>& item, uint32_t id, const map::outputs_t& o);
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+
+ /**
+ * Comparison operator - only used for UT
+ */
+ bool operator==(const create_cmd& i) const;
+
+private:
+ uint32_t m_id;
+ const map::outputs_t& m_outputs;
+};
+
+/**
+ * A cmd class that deletes a GBP endpoint
+ */
+class delete_cmd : public rpc_cmd<HW::item<bool>, vapi::Qos_egress_map_update>
+{
+public:
+ /**
+ * Constructor
+ */
+ delete_cmd(HW::item<bool>& item, uint32_t id);
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+
+ /**
+ * Comparison operator - only used for UT
+ */
+ bool operator==(const delete_cmd& i) const;
+
+private:
+ uint32_t m_id;
+};
+
+/**
+ * A cmd class that Dumps all the GBP endpoints
+ */
+class dump_cmd : public VOM::dump_cmd<vapi::Qos_egress_map_dump>
+{
+public:
+ /**
+ * Constructor
+ */
+ dump_cmd();
+ dump_cmd(const dump_cmd& d);
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+
+ /**
+ * Comparison operator - only used for UT
+ */
+ bool operator==(const dump_cmd& i) const;
+
+private:
+ /**
+ * HW reutrn code
+ */
+ HW::item<bool> item;
+};
+}; // namespace map_cmds
+}; // namespace Qos
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/extras/vom/vom/qos_mark.cpp b/extras/vom/vom/qos_mark.cpp
new file mode 100644
index 00000000000..feb889380ff
--- /dev/null
+++ b/extras/vom/vom/qos_mark.cpp
@@ -0,0 +1,187 @@
+/*
+ * Copyright (c) 2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "vom/qos_mark.hpp"
+#include "vom/api_types.hpp"
+#include "vom/qos_mark_cmds.hpp"
+#include "vom/qos_types_api.hpp"
+#include "vom/singular_db_funcs.hpp"
+
+namespace VOM {
+namespace QoS {
+
+singular_db<mark::key_t, mark> mark::m_db;
+
+mark::event_handler mark::m_evh;
+
+mark::mark(const interface& itf, const map& m, const source_t& src)
+ : m_config(false)
+ , m_itf(itf.singular())
+ , m_map(m.singular())
+ , m_src(src)
+{
+}
+
+mark::mark(const mark& m)
+ : m_config(m.m_config)
+ , m_itf(m.m_itf)
+ , m_map(m.m_map)
+ , m_src(m.m_src)
+{
+}
+
+mark::~mark()
+{
+ sweep();
+ m_db.release(key(), this);
+}
+
+const mark::key_t
+mark::key() const
+{
+ return (std::make_pair(m_itf->key(), m_src));
+}
+
+bool
+mark::operator==(const mark& m) const
+{
+ return (key() == m.key() && m_map->id() == m.m_map->id());
+}
+
+void
+mark::sweep()
+{
+ if (m_config) {
+ HW::enqueue(new mark_cmds::delete_cmd(m_config, m_itf->handle(), m_src));
+ }
+ HW::write();
+}
+
+void
+mark::replay()
+{
+ if (m_config) {
+ HW::enqueue(
+ new mark_cmds::create_cmd(m_config, m_itf->handle(), m_map->id(), m_src));
+ }
+}
+
+std::string
+mark::to_string() const
+{
+ std::ostringstream s;
+ s << "qos-mark:[" << m_itf->to_string() << ", map:" << m_map->id()
+ << ", src:" << m_src.to_string();
+
+ return (s.str());
+}
+
+void
+mark::update(const mark& r)
+{
+ if (rc_t::OK != m_config.rc()) {
+ HW::enqueue(
+ new mark_cmds::create_cmd(m_config, m_itf->handle(), m_map->id(), m_src));
+ }
+}
+
+std::shared_ptr<mark>
+mark::find_or_add(const mark& temp)
+{
+ return (m_db.find_or_add(temp.key(), temp));
+}
+
+std::shared_ptr<mark>
+mark::find(const key_t& k)
+{
+ return (m_db.find(k));
+}
+
+std::shared_ptr<mark>
+mark::singular() const
+{
+ return find_or_add(*this);
+}
+
+void
+mark::dump(std::ostream& os)
+{
+ db_dump(m_db, os);
+}
+
+mark::event_handler::event_handler()
+{
+ OM::register_listener(this);
+ inspect::register_handler({ "qos-mark" }, "QoS Mark", this);
+}
+
+void
+mark::event_handler::handle_replay()
+{
+ m_db.replay();
+}
+
+void
+mark::event_handler::handle_populate(const client_db::key_t& key)
+{
+ std::shared_ptr<mark_cmds::dump_cmd> cmd =
+ std::make_shared<mark_cmds::dump_cmd>();
+
+ HW::enqueue(cmd);
+ HW::write();
+
+ for (auto& rr : *cmd) {
+ auto& payload = rr.get_payload();
+
+ std::shared_ptr<interface> itf = interface::find(payload.mark.sw_if_index);
+ std::shared_ptr<map> map = map::find(payload.mark.map_id);
+
+ VOM_LOG(log_level_t::DEBUG) << "data: " << payload.mark.sw_if_index;
+
+ if (itf && map) {
+ mark qm(*itf, *map, from_api(payload.mark.output_source));
+ OM::commit(key, qm);
+
+ VOM_LOG(log_level_t::DEBUG) << "read: " << qm.to_string();
+ } else {
+ VOM_LOG(log_level_t::ERROR)
+ << "no interface or map:" << payload.mark.sw_if_index << ", "
+ << payload.mark.map_id;
+ }
+ }
+}
+
+dependency_t
+mark::event_handler::order() const
+{
+ return (dependency_t::ENTRY);
+}
+
+void
+mark::event_handler::show(std::ostream& os)
+{
+ db_dump(m_db, os);
+}
+
+}; // namespace QoS
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
diff --git a/extras/vom/vom/qos_mark.hpp b/extras/vom/vom/qos_mark.hpp
new file mode 100644
index 00000000000..63fec8456fe
--- /dev/null
+++ b/extras/vom/vom/qos_mark.hpp
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __VOM_QOS_MARK_H__
+#define __VOM_QOS_MARK_H__
+
+#include <ostream>
+
+#include "vom/interface.hpp"
+#include "vom/qos_map.hpp"
+#include "vom/qos_types.hpp"
+#include "vom/singular_db.hpp"
+
+namespace VOM {
+namespace QoS {
+
+/**
+ * The marking of packets with QoS bits as they egress an interface
+ */
+class mark : public object_base
+{
+public:
+ mark(const interface& i, const map& m, const source_t& source);
+ mark(const mark& r);
+
+ ~mark();
+
+ typedef std::pair<interface::key_t, source_t> key_t;
+
+ /**
+ * Return the object's key
+ */
+ const key_t key() const;
+
+ /**
+ * comparison operator
+ */
+ bool operator==(const mark& bdae) const;
+
+ /**
+ * Return the matching 'singular instance'
+ */
+ std::shared_ptr<mark> singular() const;
+
+ /**
+ * Find the instnace of the bridge_domain domain in the OM
+ */
+ static std::shared_ptr<mark> find(const key_t& k);
+
+ /**
+ * Dump all bridge_domain-doamin into the stream provided
+ */
+ static void dump(std::ostream& os);
+
+ /**
+ * replay the object to create it in hardware
+ */
+ void replay(void);
+
+ /**
+ * Convert to string for debugging
+ */
+ std::string to_string() const;
+
+private:
+ /**
+ * Class definition for listeners to OM events
+ */
+ class event_handler : public OM::listener, public inspect::command_handler
+ {
+ public:
+ event_handler();
+ virtual ~event_handler() = default;
+
+ /**
+ * Handle a populate event
+ */
+ void handle_populate(const client_db::key_t& key);
+
+ /**
+ * Handle a replay event
+ */
+ void handle_replay();
+
+ /**
+ * Show the object in the Singular DB
+ */
+ void show(std::ostream& os);
+
+ /**
+ * Get the sortable Id of the listener
+ */
+ dependency_t order() const;
+ };
+
+ /**
+ * event_handler to register with OM
+ */
+ static event_handler m_evh;
+
+ /**
+ * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
+ */
+ void update(const mark& obj);
+
+ /**
+ * Find or add the instnace of the bridge_domain domain in the OM
+ */
+ static std::shared_ptr<mark> find_or_add(const mark& temp);
+
+ /*
+ * It's the VPPHW class that updates the objects in HW
+ */
+ friend class VOM::OM;
+
+ /**
+ * It's the singular_db class that calls replay()
+ */
+ friend class singular_db<key_t, mark>;
+
+ /**
+ * Sweep/reap the object if still stale
+ */
+ void sweep(void);
+
+ /**
+ * HW configuration for the config. The bool representing the
+ * do/don't configured/unconfigured.
+ */
+ HW::item<bool> m_config;
+
+ /**
+ * The interface the mark applies to
+ */
+ std::shared_ptr<interface> m_itf;
+
+ /**
+ * The map the marking uses
+ */
+ std::shared_ptr<map> m_map;
+
+ /**
+ * QoS source to mark from
+ */
+ source_t m_src;
+
+ /**
+ * A map of all QoS Markers
+ */
+ static singular_db<key_t, mark> m_db;
+};
+
+}; // namesapce QoS
+
+std::ostream& operator<<(std::ostream& os, const QoS::mark::key_t& key);
+
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/extras/vom/vom/qos_mark_cmds.cpp b/extras/vom/vom/qos_mark_cmds.cpp
new file mode 100644
index 00000000000..50220b33325
--- /dev/null
+++ b/extras/vom/vom/qos_mark_cmds.cpp
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "vom/qos_mark_cmds.hpp"
+#include "vom/qos_types_api.hpp"
+
+namespace VOM {
+namespace QoS {
+namespace mark_cmds {
+
+create_cmd::create_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ uint32_t map_id,
+ const source_t& s)
+ : rpc_cmd(item)
+ , m_itf(itf)
+ , m_map_id(map_id)
+ , m_src(s)
+{
+}
+
+bool
+create_cmd::operator==(const create_cmd& other) const
+{
+ return ((m_itf == other.m_itf) && (m_src == other.m_src) &&
+ (m_map_id == other.m_map_id));
+}
+
+rc_t
+create_cmd::issue(connection& con)
+{
+ msg_t req(con.ctx(), std::ref(*this));
+
+ auto& payload = req.get_request().get_payload();
+ payload.mark.sw_if_index = m_itf.value();
+ payload.mark.map_id = m_map_id;
+ payload.mark.output_source = to_api(m_src);
+
+ VAPI_CALL(req.execute());
+
+ return (wait());
+}
+
+std::string
+create_cmd::to_string() const
+{
+ std::ostringstream s;
+ s << "qos-mark-create: " << m_hw_item.to_string() << " itf:" << m_itf
+ << " src:" << m_src.to_string() << " map-id:" << m_map_id;
+
+ return (s.str());
+}
+
+delete_cmd::delete_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ const source_t& s)
+ : rpc_cmd(item)
+ , m_itf(itf)
+ , m_src(s)
+{
+}
+
+bool
+delete_cmd::operator==(const delete_cmd& other) const
+{
+ return (m_hw_item == other.m_hw_item && m_itf == other.m_itf &&
+ m_src == other.m_src);
+}
+
+rc_t
+delete_cmd::issue(connection& con)
+{
+ msg_t req(con.ctx(), std::ref(*this));
+
+ auto& payload = req.get_request().get_payload();
+ payload.mark.sw_if_index = m_itf.value();
+ payload.mark.output_source = to_api(m_src);
+
+ VAPI_CALL(req.execute());
+
+ return (wait());
+}
+
+std::string
+delete_cmd::to_string() const
+{
+ std::ostringstream s;
+ s << "qos-mark-delete: " << m_hw_item.to_string();
+
+ return (s.str());
+}
+
+dump_cmd::dump_cmd()
+{
+}
+
+bool
+dump_cmd::operator==(const dump_cmd& other) const
+{
+ return (true);
+}
+
+rc_t
+dump_cmd::issue(connection& con)
+{
+ m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
+
+ VAPI_CALL(m_dump->execute());
+
+ wait();
+
+ return rc_t::OK;
+}
+
+std::string
+dump_cmd::to_string() const
+{
+ return ("qos-mark-dump");
+}
+
+}; // namespace mark_cmds
+}; // namespace QoS
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
diff --git a/extras/vom/vom/qos_mark_cmds.hpp b/extras/vom/vom/qos_mark_cmds.hpp
new file mode 100644
index 00000000000..976fddc4ea7
--- /dev/null
+++ b/extras/vom/vom/qos_mark_cmds.hpp
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __VOM_QOS_MARK_CMDS_H__
+#define __VOM_QOS_MARK_CMDS_H__
+
+#include "vom/dump_cmd.hpp"
+#include "vom/qos_mark.hpp"
+
+#include <vapi/qos.api.vapi.hpp>
+
+namespace VOM {
+namespace QoS {
+namespace mark_cmds {
+
+/**
+ * A command class that creates or updates the GBP endpoint
+ */
+class create_cmd : public rpc_cmd<HW::item<bool>, vapi::Qos_mark_enable_disable>
+{
+public:
+ /**
+ * Constructor
+ */
+ create_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ uint32_t map_id,
+ const source_t& src);
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+
+ /**
+ * Comparison operator - only used for UT
+ */
+ bool operator==(const create_cmd& i) const;
+
+private:
+ handle_t m_itf;
+ uint32_t m_map_id;
+ const source_t& m_src;
+};
+
+/**
+ * A cmd class that deletes a GBP endpoint
+ */
+class delete_cmd : public rpc_cmd<HW::item<bool>, vapi::Qos_mark_enable_disable>
+{
+public:
+ /**
+ * Constructor
+ */
+ delete_cmd(HW::item<bool>& item, const handle_t& itf, const source_t& src);
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+
+ /**
+ * Comparison operator - only used for UT
+ */
+ bool operator==(const delete_cmd& i) const;
+
+private:
+ const handle_t m_itf;
+ const source_t& m_src;
+};
+
+/**
+ * A cmd class that Dumps all the GBP endpoints
+ */
+class dump_cmd : public VOM::dump_cmd<vapi::Qos_mark_dump>
+{
+public:
+ /**
+ * Constructor
+ */
+ dump_cmd();
+ dump_cmd(const dump_cmd& d);
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+
+ /**
+ * Comparison operator - only used for UT
+ */
+ bool operator==(const dump_cmd& i) const;
+
+private:
+ /**
+ * HW reutrn code
+ */
+ HW::item<bool> item;
+};
+}; // namespace mark_cmds
+}; // namespace Qos
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/extras/vom/vom/qos_record.cpp b/extras/vom/vom/qos_record.cpp
new file mode 100644
index 00000000000..d56295ca1c4
--- /dev/null
+++ b/extras/vom/vom/qos_record.cpp
@@ -0,0 +1,190 @@
+/*
+ * Copyright (c) 2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "vom/qos_record.hpp"
+#include "vom/api_types.hpp"
+#include "vom/qos_record_cmds.hpp"
+#include "vom/qos_types_api.hpp"
+#include "vom/singular_db_funcs.hpp"
+
+namespace VOM {
+namespace QoS {
+
+singular_db<record::key_t, record> record::m_db;
+
+record::event_handler record::m_evh;
+
+record::record(const interface& itf, const source_t& src)
+ : m_config(false)
+ , m_itf(itf.singular())
+ , m_src(src)
+{
+}
+
+record::record(const record& r)
+ : m_config(r.m_config)
+ , m_itf(r.m_itf)
+ , m_src(r.m_src)
+{
+}
+
+record::~record()
+{
+ sweep();
+ m_db.release(key(), this);
+}
+
+const record::key_t
+record::key() const
+{
+ return (std::make_pair(m_itf->key(), m_src));
+}
+
+bool
+record::operator==(const record& r) const
+{
+ return (key() == r.key());
+}
+
+void
+record::sweep()
+{
+ if (m_config) {
+ HW::enqueue(new record_cmds::delete_cmd(m_config, m_itf->handle(), m_src));
+ }
+ HW::write();
+}
+
+void
+record::replay()
+{
+ if (m_config) {
+ HW::enqueue(new record_cmds::create_cmd(m_config, m_itf->handle(), m_src));
+ }
+}
+
+std::string
+record::to_string() const
+{
+ std::ostringstream s;
+ s << "qos-record:[" << m_itf->to_string() << ", src:" << m_src.to_string();
+
+ return (s.str());
+}
+
+void
+record::update(const record& r)
+{
+ if (rc_t::OK != m_config.rc()) {
+ HW::enqueue(new record_cmds::create_cmd(m_config, m_itf->handle(), m_src));
+ }
+}
+
+std::shared_ptr<record>
+record::find_or_add(const record& temp)
+{
+ return (m_db.find_or_add(temp.key(), temp));
+}
+
+std::shared_ptr<record>
+record::find(const key_t& k)
+{
+ return (m_db.find(k));
+}
+
+std::shared_ptr<record>
+record::singular() const
+{
+ return find_or_add(*this);
+}
+
+void
+record::dump(std::ostream& os)
+{
+ db_dump(m_db, os);
+}
+
+record::event_handler::event_handler()
+{
+ OM::register_listener(this);
+ inspect::register_handler({ "qos-record" }, "QoS Record", this);
+}
+
+void
+record::event_handler::handle_replay()
+{
+ m_db.replay();
+}
+
+void
+record::event_handler::handle_populate(const client_db::key_t& key)
+{
+ std::shared_ptr<record_cmds::dump_cmd> cmd =
+ std::make_shared<record_cmds::dump_cmd>();
+
+ HW::enqueue(cmd);
+ HW::write();
+
+ for (auto& rr : *cmd) {
+ auto& payload = rr.get_payload();
+
+ std::shared_ptr<interface> itf =
+ interface::find(payload.record.sw_if_index);
+
+ VOM_LOG(log_level_t::DEBUG) << "data: " << payload.record.sw_if_index;
+
+ if (itf) {
+ record qr(*itf, from_api(payload.record.input_source));
+ OM::commit(key, qr);
+
+ VOM_LOG(log_level_t::DEBUG) << "read: " << qr.to_string();
+ } else {
+ VOM_LOG(log_level_t::ERROR) << "no interface:"
+ << payload.record.sw_if_index;
+ }
+ }
+}
+
+dependency_t
+record::event_handler::order() const
+{
+ return (dependency_t::ENTRY);
+}
+
+void
+record::event_handler::show(std::ostream& os)
+{
+ db_dump(m_db, os);
+}
+
+}; // namespace QoS
+
+std::ostream&
+operator<<(std::ostream& os, const QoS::record::key_t& key)
+{
+ os << key.first << "," << key.second;
+
+ return os;
+}
+
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
diff --git a/extras/vom/vom/qos_record.hpp b/extras/vom/vom/qos_record.hpp
new file mode 100644
index 00000000000..d74413f9293
--- /dev/null
+++ b/extras/vom/vom/qos_record.hpp
@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __VOM_QOS_RECORD_H__
+#define __VOM_QOS_RECORD_H__
+
+#include <ostream>
+
+#include "vom/interface.hpp"
+#include "vom/qos_types.hpp"
+#include "vom/singular_db.hpp"
+
+namespace VOM {
+/**
+ * Types belonging to QoS
+ */
+namespace QoS {
+
+class record : public object_base
+{
+public:
+ record(const interface& i, const source_t& source);
+ record(const record& r);
+
+ ~record();
+
+ typedef std::pair<interface::key_t, source_t> key_t;
+
+ /**
+ * Return the object's key
+ */
+ const key_t key() const;
+
+ /**
+ * comparison operator
+ */
+ bool operator==(const record& bdae) const;
+
+ /**
+ * Return the matching 'singular instance'
+ */
+ std::shared_ptr<record> singular() const;
+
+ /**
+ * Find the instnace of the bridge_domain domain in the OM
+ */
+ static std::shared_ptr<record> find(const key_t& k);
+
+ /**
+ * Dump all bridge_domain-doamin into the stream provided
+ */
+ static void dump(std::ostream& os);
+
+ /**
+ * replay the object to create it in hardware
+ */
+ void replay(void);
+
+ /**
+ * Convert to string for debugging
+ */
+ std::string to_string() const;
+
+private:
+ /**
+ * Class definition for listeners to OM events
+ */
+ class event_handler : public OM::listener, public inspect::command_handler
+ {
+ public:
+ event_handler();
+ virtual ~event_handler() = default;
+
+ /**
+ * Handle a populate event
+ */
+ void handle_populate(const client_db::key_t& key);
+
+ /**
+ * Handle a replay event
+ */
+ void handle_replay();
+
+ /**
+ * Show the object in the Singular DB
+ */
+ void show(std::ostream& os);
+
+ /**
+ * Get the sortable Id of the listener
+ */
+ dependency_t order() const;
+ };
+
+ /**
+ * event_handler to register with OM
+ */
+ static event_handler m_evh;
+
+ /**
+ * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
+ */
+ void update(const record& obj);
+
+ /**
+ * Find or add the instnace of the bridge_domain domain in the OM
+ */
+ static std::shared_ptr<record> find_or_add(const record& temp);
+
+ /*
+ * It's the VPPHW class that updates the objects in HW
+ */
+ friend class VOM::OM;
+
+ /**
+ * It's the singular_db class that calls replay()
+ */
+ friend class singular_db<key_t, record>;
+
+ /**
+ * Sweep/reap the object if still stale
+ */
+ void sweep(void);
+
+ /**
+ * HW configuration for the config. The bool representing the
+ * do/don't configured/unconfigured.
+ */
+ HW::item<bool> m_config;
+
+ /**
+ * The interface the endpoint is attached to.
+ */
+ std::shared_ptr<interface> m_itf;
+
+ /**
+ * QoS source to record from
+ */
+ source_t m_src;
+
+ /**
+ * A map of all bridge_domains
+ */
+ static singular_db<key_t, record> m_db;
+};
+
+}; // namesapce QoS
+
+std::ostream& operator<<(std::ostream& os, const QoS::record::key_t& key);
+
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/extras/vom/vom/qos_record_cmds.cpp b/extras/vom/vom/qos_record_cmds.cpp
new file mode 100644
index 00000000000..a425187d63c
--- /dev/null
+++ b/extras/vom/vom/qos_record_cmds.cpp
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "vom/qos_record_cmds.hpp"
+#include "vom/qos_types_api.hpp"
+
+namespace VOM {
+namespace QoS {
+namespace record_cmds {
+
+create_cmd::create_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ const source_t& s)
+ : rpc_cmd(item)
+ , m_itf(itf)
+ , m_src(s)
+{
+}
+
+bool
+create_cmd::operator==(const create_cmd& other) const
+{
+ return ((m_itf == other.m_itf) && (m_src == other.m_src));
+}
+
+rc_t
+create_cmd::issue(connection& con)
+{
+ msg_t req(con.ctx(), std::ref(*this));
+
+ auto& payload = req.get_request().get_payload();
+ payload.record.sw_if_index = m_itf.value();
+ payload.record.input_source = to_api(m_src);
+
+ VAPI_CALL(req.execute());
+
+ return (wait());
+}
+
+std::string
+create_cmd::to_string() const
+{
+ std::ostringstream s;
+ s << "qos-record-create: " << m_hw_item.to_string() << " itf:" << m_itf
+ << " src:" << m_src.to_string();
+
+ return (s.str());
+}
+
+delete_cmd::delete_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ const source_t& s)
+ : rpc_cmd(item)
+ , m_itf(itf)
+ , m_src(s)
+{
+}
+
+bool
+delete_cmd::operator==(const delete_cmd& other) const
+{
+ return (m_hw_item == other.m_hw_item && m_itf == other.m_itf &&
+ m_src == other.m_src);
+}
+
+rc_t
+delete_cmd::issue(connection& con)
+{
+ msg_t req(con.ctx(), std::ref(*this));
+
+ auto& payload = req.get_request().get_payload();
+ payload.record.sw_if_index = m_itf.value();
+ payload.record.input_source = to_api(m_src);
+
+ VAPI_CALL(req.execute());
+
+ return (wait());
+}
+
+std::string
+delete_cmd::to_string() const
+{
+ std::ostringstream s;
+ s << "qos-record-delete: " << m_hw_item.to_string();
+
+ return (s.str());
+}
+
+dump_cmd::dump_cmd()
+{
+}
+
+bool
+dump_cmd::operator==(const dump_cmd& other) const
+{
+ return (true);
+}
+
+rc_t
+dump_cmd::issue(connection& con)
+{
+ m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
+
+ VAPI_CALL(m_dump->execute());
+
+ wait();
+
+ return rc_t::OK;
+}
+
+std::string
+dump_cmd::to_string() const
+{
+ return ("qos-record-dump");
+}
+
+}; // namespace record_cmds
+}; // namespace QoS
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
diff --git a/extras/vom/vom/qos_record_cmds.hpp b/extras/vom/vom/qos_record_cmds.hpp
new file mode 100644
index 00000000000..bf98e5da824
--- /dev/null
+++ b/extras/vom/vom/qos_record_cmds.hpp
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __VOM_QOS_RECORD_CMDS_H__
+#define __VOM_QOS_RECORD_CMDS_H__
+
+#include "vom/dump_cmd.hpp"
+#include "vom/qos_record.hpp"
+
+#include <vapi/qos.api.vapi.hpp>
+
+namespace VOM {
+namespace QoS {
+namespace record_cmds {
+
+/**
+ * A command class that creates or updates the GBP endpoint
+ */
+class create_cmd
+ : public rpc_cmd<HW::item<bool>, vapi::Qos_record_enable_disable>
+{
+public:
+ /**
+ * Constructor
+ */
+ create_cmd(HW::item<bool>& item, const handle_t& itf, const source_t& src);
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+
+ /**
+ * Comparison operator - only used for UT
+ */
+ bool operator==(const create_cmd& i) const;
+
+private:
+ const handle_t m_itf;
+ const source_t& m_src;
+};
+
+/**
+ * A cmd class that deletes a GBP endpoint
+ */
+class delete_cmd
+ : public rpc_cmd<HW::item<bool>, vapi::Qos_record_enable_disable>
+{
+public:
+ /**
+ * Constructor
+ */
+ delete_cmd(HW::item<bool>& item, const handle_t& itf, const source_t& src);
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+
+ /**
+ * Comparison operator - only used for UT
+ */
+ bool operator==(const delete_cmd& i) const;
+
+private:
+ const handle_t m_itf;
+ const source_t& m_src;
+};
+
+/**
+ * A cmd class that Dumps all the GBP endpoints
+ */
+class dump_cmd : public VOM::dump_cmd<vapi::Qos_record_dump>
+{
+public:
+ /**
+ * Constructor
+ */
+ dump_cmd();
+ dump_cmd(const dump_cmd& d);
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+
+ /**
+ * Comparison operator - only used for UT
+ */
+ bool operator==(const dump_cmd& i) const;
+
+private:
+ /**
+ * HW reutrn code
+ */
+ HW::item<bool> item;
+};
+}; // namespace record_cmds
+}; // namespace Qos
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/extras/vom/vom/qos_types.cpp b/extras/vom/vom/qos_types.cpp
new file mode 100644
index 00000000000..7d5d77482b0
--- /dev/null
+++ b/extras/vom/vom/qos_types.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "vom/qos_types.hpp"
+
+namespace VOM {
+namespace QoS {
+
+const source_t source_t::EXT(0, "ext");
+const source_t source_t::VLAN(1, "vlan");
+const source_t source_t::MPLS(2, "mpls");
+const source_t source_t::IP(3, "IP");
+
+source_t::source_t(int v, const std::string& s)
+ : enum_base<source_t>(v, s)
+{
+}
+}; // namespace QoS
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
diff --git a/extras/vom/vom/qos_types.hpp b/extras/vom/vom/qos_types.hpp
new file mode 100644
index 00000000000..fea37805baf
--- /dev/null
+++ b/extras/vom/vom/qos_types.hpp
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __VOM_QOS_TYPES_H__
+#define __VOM_QOS_TYPES_H__
+
+#include "vom/enum_base.hpp"
+
+namespace VOM {
+/**
+ * Types belonging to QoS
+ */
+namespace QoS {
+
+/**
+ * The Source of the QoS classification (i.e. which header the bits are
+ * associated with).
+ */
+class source_t : public enum_base<source_t>
+{
+public:
+ const static source_t EXT;
+ const static source_t VLAN;
+ const static source_t MPLS;
+ const static source_t IP;
+
+private:
+ /**
+ * Private constructor taking the value and the string name
+ */
+ source_t(int v, const std::string& s);
+};
+
+}; // namesapce QoS
+
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/extras/vom/vom/qos_types_api.cpp b/extras/vom/vom/qos_types_api.cpp
new file mode 100644
index 00000000000..27cbad7b9b0
--- /dev/null
+++ b/extras/vom/vom/qos_types_api.cpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "vom/qos_types.hpp"
+
+#include <vapi/qos.api.vapi.hpp>
+
+DEFINE_VAPI_MSG_IDS_QOS_API_JSON;
+
+namespace VOM {
+namespace QoS {
+
+const source_t&
+from_api(vapi_enum_qos_source e)
+{
+ switch (e) {
+ case QOS_API_SOURCE_EXT:
+ return source_t::EXT;
+ case QOS_API_SOURCE_VLAN:
+ return source_t::VLAN;
+ case QOS_API_SOURCE_IP:
+ return source_t::IP;
+ case QOS_API_SOURCE_MPLS:
+ return source_t::MPLS;
+ }
+ return source_t::EXT;
+}
+
+vapi_enum_qos_source
+to_api(const source_t& s)
+{
+ return static_cast<vapi_enum_qos_source>((int)s);
+}
+
+}; // namespace QoS
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
diff --git a/extras/vom/vom/qos_types_api.hpp b/extras/vom/vom/qos_types_api.hpp
new file mode 100644
index 00000000000..53cff0d2c69
--- /dev/null
+++ b/extras/vom/vom/qos_types_api.hpp
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "vom/qos_types.hpp"
+
+#include <vapi/qos.api.vapi.hpp>
+
+namespace VOM {
+namespace QoS {
+
+const source_t& from_api(vapi_enum_qos_source e);
+vapi_enum_qos_source to_api(const source_t& s);
+
+}; // namespace QoS
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */