aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--extras/vom/vom/CMakeLists.txt3
-rw-r--r--extras/vom/vom/gbp_global.cpp155
-rw-r--r--extras/vom/vom/gbp_global.hpp180
-rw-r--r--extras/vom/vom/gbp_global_cmds.cpp64
-rw-r--r--extras/vom/vom/gbp_global_cmds.hpp73
5 files changed, 475 insertions, 0 deletions
diff --git a/extras/vom/vom/CMakeLists.txt b/extras/vom/vom/CMakeLists.txt
index 26dd3e46574..b2f8ec6415d 100644
--- a/extras/vom/vom/CMakeLists.txt
+++ b/extras/vom/vom/CMakeLists.txt
@@ -87,6 +87,8 @@ if(GBP_FILE)
gbp_endpoint_group.cpp
gbp_ext_itf.cpp
gbp_ext_itf_cmds.cpp
+ gbp_global.cpp
+ gbp_global_cmds.cpp
gbp_recirc_cmds.cpp
gbp_recirc.cpp
gbp_route_domain_cmds.cpp
@@ -216,6 +218,7 @@ if(GBP_FILE)
gbp_endpoint.hpp
gbp_endpoint_group.hpp
gbp_ext_itf.hpp
+ gbp_global.hpp
gbp_recirc.hpp
gbp_route_domain.hpp
gbp_rule.hpp
diff --git a/extras/vom/vom/gbp_global.cpp b/extras/vom/vom/gbp_global.cpp
new file mode 100644
index 00000000000..a6cbdd7512c
--- /dev/null
+++ b/extras/vom/vom/gbp_global.cpp
@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 2017 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/gbp_global.hpp"
+#include "vom/gbp_global_cmds.hpp"
+#include "vom/singular_db_funcs.hpp"
+
+namespace VOM {
+/**
+ * A DB of all GBP configs
+ */
+singular_db<std::string, gbp_global> gbp_global::m_db;
+
+gbp_global::event_handler gbp_global::m_evh;
+
+gbp_global::gbp_global(const std::string& system_name,
+ uint32_t remote_ep_retention)
+ : m_system_name(system_name)
+ , m_remote_ep_retention(remote_ep_retention)
+{
+}
+
+gbp_global::gbp_global(const gbp_global& o)
+ : m_system_name(o.m_system_name)
+ , m_remote_ep_retention(o.m_remote_ep_retention)
+{
+}
+
+gbp_global::~gbp_global()
+{
+ sweep();
+ m_db.release(m_system_name, this);
+}
+
+const gbp_global::key_t&
+gbp_global::key() const
+{
+ return (m_system_name);
+}
+
+bool
+gbp_global::operator==(const gbp_global& l) const
+{
+ return ((key() == l.key()) &&
+ (m_remote_ep_retention == l.m_remote_ep_retention));
+}
+
+void
+gbp_global::sweep()
+{
+ // no means to remove this in VPP
+}
+
+void
+gbp_global::dump(std::ostream& os)
+{
+ db_dump(m_db, os);
+}
+
+void
+gbp_global::replay()
+{
+ if (m_binding) {
+ HW::enqueue(
+ new gbp_global_cmds::config_cmd(m_binding, m_remote_ep_retention));
+ }
+}
+
+std::string
+gbp_global::to_string() const
+{
+ std::ostringstream s;
+ s << "GBP-global:"
+ << " remote-EP-retention:" << m_remote_ep_retention;
+
+ return (s.str());
+}
+
+void
+gbp_global::update(const gbp_global& desired)
+{
+ if (!m_binding) {
+ HW::enqueue(
+ new gbp_global_cmds::config_cmd(m_binding, m_remote_ep_retention));
+ }
+}
+
+std::shared_ptr<gbp_global>
+gbp_global::find_or_add(const gbp_global& temp)
+{
+ return (m_db.find_or_add(temp.key(), temp));
+}
+
+std::shared_ptr<gbp_global>
+gbp_global::find(const key_t& k)
+{
+ return (m_db.find(k));
+}
+
+std::shared_ptr<gbp_global>
+gbp_global::singular() const
+{
+ return find_or_add(*this);
+}
+
+gbp_global::event_handler::event_handler()
+{
+ OM::register_listener(this);
+ inspect::register_handler({ "gbp-global" }, "GBP global configurations",
+ this);
+}
+
+void
+gbp_global::event_handler::handle_replay()
+{
+ m_db.replay();
+}
+
+void
+gbp_global::event_handler::handle_populate(const client_db::key_t& key)
+{
+}
+
+dependency_t
+gbp_global::event_handler::order() const
+{
+ return (dependency_t::GLOBAL);
+}
+
+void
+gbp_global::event_handler::show(std::ostream& os)
+{
+ db_dump(m_db, os);
+}
+}
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
diff --git a/extras/vom/vom/gbp_global.hpp b/extras/vom/vom/gbp_global.hpp
new file mode 100644
index 00000000000..7c451cc6270
--- /dev/null
+++ b/extras/vom/vom/gbp_global.hpp
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 2017 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_GBP_GLOBAL_H__
+#define __VOM_GBP_GLOBAL_H__
+
+#include "vom/hw.hpp"
+#include "vom/inspect.hpp"
+#include "vom/object_base.hpp"
+#include "vom/om.hpp"
+#include "vom/singular_db.hpp"
+
+namespace VOM {
+/**
+ * A representation of GBP global configuration
+ */
+class gbp_global : public object_base
+{
+public:
+ /**
+ * The key for the global conifugration is the 'system' namse
+ */
+ typedef std::string key_t;
+
+ /**
+ * Construct a new object matching the desried state
+ */
+ gbp_global(const std::string& system_name, uint32_t remote_ep_retention);
+
+ /**
+ * Copy Constructor
+ */
+ gbp_global(const gbp_global& o);
+
+ /**
+ * Destructor
+ */
+ ~gbp_global();
+
+ /**
+ * Get this objects key
+ */
+ const key_t& key() const;
+
+ /**
+ * Comparison operator
+ */
+ bool operator==(const gbp_global& l) const;
+
+ /**
+ * Return the 'singular' of the GBP global that matches this object
+ */
+ std::shared_ptr<gbp_global> singular() const;
+
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+
+ /**
+ * Dump all GBP globals into the stream provided
+ */
+ static void dump(std::ostream& os);
+
+ /**
+ * Find GBP global config from its key
+ */
+ static std::shared_ptr<gbp_global> find(const key_t& k);
+
+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;
+
+ /**
+ * Enquue commonds to the VPP command Q for the update
+ */
+ void update(const gbp_global& obj);
+
+ /**
+ * Find or add GBP global to the OM
+ */
+ static std::shared_ptr<gbp_global> find_or_add(const gbp_global& temp);
+
+ /*
+ * It's the OM class that calls singular()
+ */
+ friend class OM;
+
+ /**
+ * It's the singular_db class that calls replay()
+ */
+ friend class singular_db<key_t, gbp_global>;
+
+ /**
+ * Sweep/reap the object if still stale
+ */
+ void sweep(void);
+
+ /**
+ * replay the object to create it in hardware
+ */
+ void replay(void);
+
+ /**
+ * The system name
+ */
+ const std::string m_system_name;
+
+ /**
+ * TX timer configs
+ */
+ uint32_t m_remote_ep_retention;
+
+ /**
+ * HW globaluration for the binding. The bool representing the
+ * do/don't bind.
+ */
+ HW::item<bool> m_binding;
+
+ /**
+ * A map of all Gbp globals keyed against the system name.
+ * there needs to be some sort of key, that will do.
+ */
+ static singular_db<key_t, gbp_global> m_db;
+};
+};
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif
diff --git a/extras/vom/vom/gbp_global_cmds.cpp b/extras/vom/vom/gbp_global_cmds.cpp
new file mode 100644
index 00000000000..3ad651b68a3
--- /dev/null
+++ b/extras/vom/vom/gbp_global_cmds.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2017 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/gbp_global_cmds.hpp"
+
+namespace VOM {
+namespace gbp_global_cmds {
+config_cmd::config_cmd(HW::item<bool>& item, uint32_t remote_ep_retention)
+ : rpc_cmd(item)
+ , m_remote_ep_retention(remote_ep_retention)
+{
+}
+
+bool
+config_cmd::operator==(const config_cmd& other) const
+{
+ return (m_remote_ep_retention == other.m_remote_ep_retention);
+}
+
+rc_t
+config_cmd::issue(connection& con)
+{
+ msg_t req(con.ctx(), std::ref(*this));
+
+ auto& payload = req.get_request().get_payload();
+ payload.threshold = m_remote_ep_retention;
+
+ VAPI_CALL(req.execute());
+
+ return (wait());
+}
+
+std::string
+config_cmd::to_string() const
+{
+ std::ostringstream s;
+ s << "Gbp-global-config: " << m_hw_item.to_string()
+ << " remote_ep_retention:" << m_remote_ep_retention;
+
+ return (s.str());
+}
+
+}; // namespace gbp_global_cmds
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
diff --git a/extras/vom/vom/gbp_global_cmds.hpp b/extras/vom/vom/gbp_global_cmds.hpp
new file mode 100644
index 00000000000..377b607c013
--- /dev/null
+++ b/extras/vom/vom/gbp_global_cmds.hpp
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2017 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_GBP_GLOBAL_CMDS_H__
+#define __VOM_GBP_GLOBAL_CMDS_H__
+
+#include "vom/dump_cmd.hpp"
+#include "vom/gbp_global.hpp"
+#include "vom/rpc_cmd.hpp"
+
+#include <vapi/gbp.api.vapi.hpp>
+
+namespace VOM {
+namespace gbp_global_cmds {
+
+/**
+ * A command class that binds the GBP global to the interface
+ */
+class config_cmd
+ : public rpc_cmd<HW::item<bool>,
+ vapi::Gbp_endpoint_learn_set_inactive_threshold>
+{
+public:
+ /**
+ * Constructor
+ */
+ config_cmd(HW::item<bool>& item, uint32_t remote_ep_retention);
+
+ /**
+ * 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 config_cmd& i) const;
+
+private:
+ /**
+ * TX timer configs
+ */
+ uint32_t m_remote_ep_retention;
+};
+
+}; // namespace gbp_global_cmds
+}; // namespace VOM
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif