summaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2019-07-31 02:48:02 -0700
committerNeale Ranns <nranns@cisco.com>2019-07-31 16:17:36 +0000
commit83832e7ced8be8b7de394415feaba70c32e3c38d (patch)
treeb9269e9f5cff694fa39cc26b5c25cb81828e1435 /extras
parentb504777e7f1c9728e65b874284b4dfd39359c8a8 (diff)
qos: Store function
Type: feature store: write a QoS value into the buffer meta-data record: Extract a QoS value from a packet header and store it. mark: Make a change to the content of a packet header by writing a stored QoS value Change-Id: I07d1e87dd1ca90d40ac1ae1774fee1b272cab83f Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'extras')
-rw-r--r--extras/vom/vom/CMakeLists.txt3
-rw-r--r--extras/vom/vom/qos_map.hpp2
-rw-r--r--extras/vom/vom/qos_store.cpp186
-rw-r--r--extras/vom/vom/qos_store.hpp178
-rw-r--r--extras/vom/vom/qos_store_cmds.cpp143
-rw-r--r--extras/vom/vom/qos_store_cmds.hpp140
-rw-r--r--extras/vom/vom/qos_types.hpp2
7 files changed, 653 insertions, 1 deletions
diff --git a/extras/vom/vom/CMakeLists.txt b/extras/vom/vom/CMakeLists.txt
index 2ea84d9faa8..ad5a66e3521 100644
--- a/extras/vom/vom/CMakeLists.txt
+++ b/extras/vom/vom/CMakeLists.txt
@@ -173,6 +173,8 @@ list(APPEND VOM_SOURCES
qos_mark_cmds.cpp
qos_record.cpp
qos_record_cmds.cpp
+ qos_store.cpp
+ qos_store_cmds.cpp
qos_types.cpp
qos_types_api.cpp
ra_config.cpp
@@ -280,6 +282,7 @@ list(APPEND VOM_HEADERS
qos_map.hpp
qos_mark.hpp
qos_record.hpp
+ qos_store.hpp
qos_types.hpp
ra_config.hpp
ra_prefix.hpp
diff --git a/extras/vom/vom/qos_map.hpp b/extras/vom/vom/qos_map.hpp
index d722004177b..8d235c4994b 100644
--- a/extras/vom/vom/qos_map.hpp
+++ b/extras/vom/vom/qos_map.hpp
@@ -35,7 +35,7 @@ namespace QoS {
class map : public object_base
{
public:
- typedef std::array<std::array<uint8_t, 256>, 4> outputs_t;
+ typedef std::array<std::array<bits_t, 256>, 4> outputs_t;
map(uint32_t id, const outputs_t& o);
map(const map& r);
diff --git a/extras/vom/vom/qos_store.cpp b/extras/vom/vom/qos_store.cpp
new file mode 100644
index 00000000000..08c2586557d
--- /dev/null
+++ b/extras/vom/vom/qos_store.cpp
@@ -0,0 +1,186 @@
+/*
+ * 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_store.hpp"
+#include "vom/api_types.hpp"
+#include "vom/qos_store_cmds.hpp"
+#include "vom/qos_types_api.hpp"
+#include "vom/singular_db_funcs.hpp"
+
+namespace VOM {
+namespace QoS {
+
+singular_db<store::key_t, store> store::m_db;
+
+store::event_handler store::m_evh;
+
+store::store(const interface& itf, const source_t& src, bits_t value)
+ : m_config(false)
+ , m_itf(itf.singular())
+ , m_src(src)
+ , m_value(value)
+{
+}
+
+store::store(const store& s)
+ : m_config(s.m_config)
+ , m_itf(s.m_itf)
+ , m_src(s.m_src)
+ , m_value(s.m_value)
+{
+}
+
+store::~store()
+{
+ sweep();
+ m_db.release(key(), this);
+}
+
+const store::key_t
+store::key() const
+{
+ return (std::make_pair(m_itf->key(), m_src));
+}
+
+bool
+store::operator==(const store& r) const
+{
+ return (key() == r.key());
+}
+
+void
+store::sweep()
+{
+ if (m_config) {
+ HW::enqueue(new store_cmds::delete_cmd(m_config, m_itf->handle(), m_src));
+ }
+ HW::write();
+}
+
+void
+store::replay()
+{
+ if (m_config) {
+ HW::enqueue(
+ new store_cmds::create_cmd(m_config, m_itf->handle(), m_src, m_value));
+ }
+}
+
+std::string
+store::to_string() const
+{
+ std::ostringstream s;
+ s << "qos-store:[" << m_itf->to_string() << ", src:" << m_src.to_string()
+ << ", value:" << static_cast<int>(m_value);
+
+ return (s.str());
+}
+
+void
+store::update(const store& r)
+{
+ if (rc_t::OK != m_config.rc()) {
+ HW::enqueue(
+ new store_cmds::create_cmd(m_config, m_itf->handle(), m_src, m_value));
+ }
+}
+
+std::shared_ptr<store>
+store::find_or_add(const store& temp)
+{
+ return (m_db.find_or_add(temp.key(), temp));
+}
+
+std::shared_ptr<store>
+store::find(const key_t& k)
+{
+ return (m_db.find(k));
+}
+
+std::shared_ptr<store>
+store::singular() const
+{
+ return find_or_add(*this);
+}
+
+void
+store::dump(std::ostream& os)
+{
+ db_dump(m_db, os);
+}
+
+store::event_handler::event_handler()
+{
+ OM::register_listener(this);
+ inspect::register_handler({ "qos-store" }, "QoS Store", this);
+}
+
+void
+store::event_handler::handle_replay()
+{
+ m_db.replay();
+}
+
+void
+store::event_handler::handle_populate(const client_db::key_t& key)
+{
+ std::shared_ptr<store_cmds::dump_cmd> cmd =
+ std::make_shared<store_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.store.sw_if_index);
+
+ VOM_LOG(log_level_t::DEBUG) << "data: " << payload.store.sw_if_index;
+
+ if (itf) {
+ store qr(*itf, from_api(payload.store.input_source), payload.store.value);
+ OM::commit(key, qr);
+
+ VOM_LOG(log_level_t::DEBUG) << "read: " << qr.to_string();
+ } else {
+ VOM_LOG(log_level_t::ERROR) << "no interface:"
+ << payload.store.sw_if_index;
+ }
+ }
+}
+
+dependency_t
+store::event_handler::order() const
+{
+ return (dependency_t::ENTRY);
+}
+
+void
+store::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_store.hpp b/extras/vom/vom/qos_store.hpp
new file mode 100644
index 00000000000..b68831497ab
--- /dev/null
+++ b/extras/vom/vom/qos_store.hpp
@@ -0,0 +1,178 @@
+/*
+ * 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_STORE_H__
+#define __VOM_QOS_STORE_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 store : public object_base
+{
+public:
+ store(const interface& i, const source_t& source, bits_t value);
+ store(const store& r);
+
+ ~store();
+
+ 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 store& bdae) const;
+
+ /**
+ * Return the matching 'singular instance'
+ */
+ std::shared_ptr<store> singular() const;
+
+ /**
+ * Find the instnace of the bridge_domain domain in the OM
+ */
+ static std::shared_ptr<store> 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 store& obj);
+
+ /**
+ * Find or add the instnace of the bridge_domain domain in the OM
+ */
+ static std::shared_ptr<store> find_or_add(const store& 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, store>;
+
+ /**
+ * 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 store from
+ */
+ source_t m_src;
+
+ /**
+ * QoS Value to store in the buffer
+ */
+ bits_t m_value;
+
+ /**
+ * A map of all bridge_domains
+ */
+ static singular_db<key_t, store> m_db;
+};
+
+}; // namesapce QoS
+
+std::ostream& operator<<(std::ostream& os, const QoS::store::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_store_cmds.cpp b/extras/vom/vom/qos_store_cmds.cpp
new file mode 100644
index 00000000000..2718c7a66e4
--- /dev/null
+++ b/extras/vom/vom/qos_store_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_store_cmds.hpp"
+#include "vom/qos_types_api.hpp"
+
+namespace VOM {
+namespace QoS {
+namespace store_cmds {
+
+create_cmd::create_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ const source_t& s,
+ bits_t value)
+ : rpc_cmd(item)
+ , m_itf(itf)
+ , m_src(s)
+ , m_value(value)
+{
+}
+
+bool
+create_cmd::operator==(const create_cmd& other) const
+{
+ return ((m_itf == other.m_itf) && (m_src == other.m_src) &&
+ (m_value == other.m_value));
+}
+
+rc_t
+create_cmd::issue(connection& con)
+{
+ msg_t req(con.ctx(), std::ref(*this));
+
+ auto& payload = req.get_request().get_payload();
+ payload.store.sw_if_index = m_itf.value();
+ payload.store.input_source = to_api(m_src);
+ payload.store.value = m_value;
+
+ VAPI_CALL(req.execute());
+
+ return (wait());
+}
+
+std::string
+create_cmd::to_string() const
+{
+ std::ostringstream s;
+ s << "qos-store-create: " << m_hw_item.to_string() << " itf:" << m_itf
+ << " src:" << m_src.to_string() << " value:" << static_cast<int>(m_value);
+
+ 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.store.sw_if_index = m_itf.value();
+ payload.store.input_source = to_api(m_src);
+
+ VAPI_CALL(req.execute());
+
+ return (wait());
+}
+
+std::string
+delete_cmd::to_string() const
+{
+ std::ostringstream s;
+ s << "qos-store-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-store-dump");
+}
+
+}; // namespace store_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_store_cmds.hpp b/extras/vom/vom/qos_store_cmds.hpp
new file mode 100644
index 00000000000..35671088a72
--- /dev/null
+++ b/extras/vom/vom/qos_store_cmds.hpp
@@ -0,0 +1,140 @@
+/*
+ * 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_STORE_CMDS_H__
+#define __VOM_QOS_STORE_CMDS_H__
+
+#include "vom/dump_cmd.hpp"
+#include "vom/qos_store.hpp"
+
+#include <vapi/qos.api.vapi.hpp>
+
+namespace VOM {
+namespace QoS {
+namespace store_cmds {
+
+/**
+ * A command class that creates or updates the GBP endpoint
+ */
+class create_cmd
+ : public rpc_cmd<HW::item<bool>, vapi::Qos_store_enable_disable>
+{
+public:
+ /**
+ * Constructor
+ */
+ create_cmd(HW::item<bool>& item,
+ const handle_t& itf,
+ const source_t& src,
+ bits_t value);
+
+ /**
+ * 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;
+ const source_t& m_src;
+ bits_t m_value;
+};
+
+/**
+ * A cmd class that deletes a GBP endpoint
+ */
+class delete_cmd
+ : public rpc_cmd<HW::item<bool>, vapi::Qos_store_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_store_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 store_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.hpp b/extras/vom/vom/qos_types.hpp
index fea37805baf..e3c6a169c60 100644
--- a/extras/vom/vom/qos_types.hpp
+++ b/extras/vom/vom/qos_types.hpp
@@ -24,6 +24,8 @@ namespace VOM {
*/
namespace QoS {
+typedef uint8_t bits_t;
+
/**
* The Source of the QoS classification (i.e. which header the bits are
* associated with).