diff options
author | Neale Ranns <nranns@cisco.com> | 2019-03-05 04:22:08 -0800 |
---|---|---|
committer | Neale Ranns <nranns@cisco.com> | 2019-03-05 13:51:32 +0000 |
commit | 32f6d8e0ca39483f706dc3a1c28223e9fe028f06 (patch) | |
tree | 4d36a736e12268ca5f4cb937260b3ac037e743c2 /extras | |
parent | 0fce11f23d64eae2f374435b31a77b872d552298 (diff) |
GBP: per-group EP retention policy
Change-Id: I3ed4e2e92f74f15b07fcd3e7fbc3fa8718d5249d
Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'extras')
-rw-r--r-- | extras/vom/vom/CMakeLists.txt | 3 | ||||
-rw-r--r-- | extras/vom/vom/gbp_endpoint_group.cpp | 40 | ||||
-rw-r--r-- | extras/vom/vom/gbp_endpoint_group.hpp | 27 | ||||
-rw-r--r-- | extras/vom/vom/gbp_endpoint_group_cmds.cpp | 6 | ||||
-rw-r--r-- | extras/vom/vom/gbp_endpoint_group_cmds.hpp | 2 | ||||
-rw-r--r-- | extras/vom/vom/gbp_global.cpp | 155 | ||||
-rw-r--r-- | extras/vom/vom/gbp_global.hpp | 180 | ||||
-rw-r--r-- | extras/vom/vom/gbp_global_cmds.cpp | 64 | ||||
-rw-r--r-- | extras/vom/vom/gbp_global_cmds.hpp | 73 |
9 files changed, 71 insertions, 479 deletions
diff --git a/extras/vom/vom/CMakeLists.txt b/extras/vom/vom/CMakeLists.txt index b2f8ec6415d..26dd3e46574 100644 --- a/extras/vom/vom/CMakeLists.txt +++ b/extras/vom/vom/CMakeLists.txt @@ -87,8 +87,6 @@ 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 @@ -218,7 +216,6 @@ 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_endpoint_group.cpp b/extras/vom/vom/gbp_endpoint_group.cpp index 44bdcdb3524..d549a067e67 100644 --- a/extras/vom/vom/gbp_endpoint_group.cpp +++ b/extras/vom/vom/gbp_endpoint_group.cpp @@ -24,6 +24,27 @@ singular_db<gbp_endpoint_group::key_t, gbp_endpoint_group> gbp_endpoint_group::event_handler gbp_endpoint_group::m_evh; +gbp_endpoint_group::retention_t::retention_t() + : remote_ep_timeout(0xffffffff) +{ +} +gbp_endpoint_group::retention_t::retention_t(uint32_t remote_ep_timeout_) + : remote_ep_timeout(remote_ep_timeout_) +{ +} + +bool +gbp_endpoint_group::retention_t::operator==(const retention_t& o) const +{ + return (remote_ep_timeout == o.remote_ep_timeout); +} + +std::string +gbp_endpoint_group::retention_t::to_string() const +{ + return std::to_string(remote_ep_timeout); +} + gbp_endpoint_group::gbp_endpoint_group(epg_id_t epg_id, const interface& itf, const gbp_route_domain& rd, @@ -34,6 +55,7 @@ gbp_endpoint_group::gbp_endpoint_group(epg_id_t epg_id, , m_itf(itf.singular()) , m_rd(rd.singular()) , m_bd(bd.singular()) + , m_retention() { } @@ -46,6 +68,7 @@ gbp_endpoint_group::gbp_endpoint_group(epg_id_t epg_id, , m_itf() , m_rd(rd.singular()) , m_bd(bd.singular()) + , m_retention() { } @@ -60,6 +83,7 @@ gbp_endpoint_group::gbp_endpoint_group(epg_id_t epg_id, , m_itf(itf.singular()) , m_rd(rd.singular()) , m_bd(bd.singular()) + , m_retention() { } @@ -73,6 +97,7 @@ gbp_endpoint_group::gbp_endpoint_group(epg_id_t epg_id, , m_itf() , m_rd(rd.singular()) , m_bd(bd.singular()) + , m_retention() { } @@ -83,6 +108,7 @@ gbp_endpoint_group::gbp_endpoint_group(const gbp_endpoint_group& epg) , m_itf(epg.m_itf) , m_rd(epg.m_rd) , m_bd(epg.m_bd) + , m_retention(epg.m_retention) { } @@ -104,11 +130,18 @@ gbp_endpoint_group::id() const return (m_epg_id); } +void +gbp_endpoint_group::set(const retention_t& retention) +{ + m_retention = retention; +} + bool gbp_endpoint_group::operator==(const gbp_endpoint_group& gg) const { return (key() == gg.key() && (m_sclass == gg.m_sclass) && - (m_itf == gg.m_itf) && (m_rd == gg.m_rd) && (m_bd == gg.m_bd)); + (m_retention == gg.m_retention) && (m_itf == gg.m_itf) && + (m_rd == gg.m_rd) && (m_bd == gg.m_bd)); } void @@ -125,7 +158,7 @@ gbp_endpoint_group::replay() { if (m_hw) { HW::enqueue(new gbp_endpoint_group_cmds::create_cmd( - m_hw, m_epg_id, m_sclass, m_bd->id(), m_rd->id(), + m_hw, m_epg_id, m_sclass, m_bd->id(), m_rd->id(), m_retention, (m_itf ? m_itf->handle() : handle_t::INVALID))); } } @@ -136,6 +169,7 @@ gbp_endpoint_group::to_string() const std::ostringstream s; s << "gbp-endpoint-group:[" << "epg:" << m_epg_id << ", sclass:" << m_sclass << ", " + << "retention:[" << m_retention.to_string() << "], " << (m_itf ? m_itf->to_string() : "NULL") << ", " << m_bd->to_string() << ", " << m_rd->to_string() << "]"; @@ -147,7 +181,7 @@ gbp_endpoint_group::update(const gbp_endpoint_group& r) { if (rc_t::OK != m_hw.rc()) { HW::enqueue(new gbp_endpoint_group_cmds::create_cmd( - m_hw, m_epg_id, m_sclass, m_bd->id(), m_rd->id(), + m_hw, m_epg_id, m_sclass, m_bd->id(), m_rd->id(), m_retention, (m_itf ? m_itf->handle() : handle_t::INVALID))); } } diff --git a/extras/vom/vom/gbp_endpoint_group.hpp b/extras/vom/vom/gbp_endpoint_group.hpp index b60b1553e3f..d6af570b7a9 100644 --- a/extras/vom/vom/gbp_endpoint_group.hpp +++ b/extras/vom/vom/gbp_endpoint_group.hpp @@ -37,6 +37,26 @@ class gbp_endpoint_group : public object_base { public: /** + * Endpoint Retention Policy Settings + */ + struct retention_t + { + retention_t(); + retention_t(uint32_t remote_ep_timeout); + + retention_t(const retention_t&) = default; + retention_t& operator=(const retention_t&) = default; + + bool operator==(const retention_t& o) const; + std::string to_string() const; + + /** + * Remote Endpoint timeout/ageing + */ + uint32_t remote_ep_timeout; + }; + + /** * The key for a GBP endpoint group is its ID */ typedef epg_id_t key_t; @@ -114,6 +134,8 @@ public: const std::shared_ptr<gbp_route_domain> get_route_domain() const; const std::shared_ptr<gbp_bridge_domain> get_bridge_domain() const; + void set(const retention_t& retention); + private: /** * Class definition for listeners to OM events @@ -207,6 +229,11 @@ private: std::shared_ptr<gbp_bridge_domain> m_bd; /** + * The Group's EP retention Policy + */ + retention_t m_retention; + + /** * A map of all bridge_domains */ static singular_db<key_t, gbp_endpoint_group> m_db; diff --git a/extras/vom/vom/gbp_endpoint_group_cmds.cpp b/extras/vom/vom/gbp_endpoint_group_cmds.cpp index 8d0e48e5c2f..a4f86603cb8 100644 --- a/extras/vom/vom/gbp_endpoint_group_cmds.cpp +++ b/extras/vom/vom/gbp_endpoint_group_cmds.cpp @@ -23,6 +23,7 @@ create_cmd::create_cmd(HW::item<bool>& item, uint16_t sclass, uint32_t bd_id, route::table_id_t rd_id, + const gbp_endpoint_group::retention_t& retention, const handle_t& itf) : rpc_cmd(item) , m_epg_id(epg_id) @@ -30,6 +31,7 @@ create_cmd::create_cmd(HW::item<bool>& item, , m_bd_id(bd_id) , m_rd_id(rd_id) , m_itf(itf) + , m_retention(retention) { } @@ -37,7 +39,8 @@ bool create_cmd::operator==(const create_cmd& other) const { return ((m_itf == other.m_itf) && (m_bd_id == other.m_bd_id) && - (m_rd_id == other.m_rd_id) && (m_epg_id == other.m_epg_id)); + (m_rd_id == other.m_rd_id) && (m_epg_id == other.m_epg_id) && + (m_retention == other.m_retention)); } rc_t @@ -51,6 +54,7 @@ create_cmd::issue(connection& con) payload.epg.sclass = m_sclass; payload.epg.bd_id = m_bd_id; payload.epg.rd_id = m_rd_id; + payload.epg.retention.remote_ep_timeout = m_retention.remote_ep_timeout; VAPI_CALL(req.execute()); diff --git a/extras/vom/vom/gbp_endpoint_group_cmds.hpp b/extras/vom/vom/gbp_endpoint_group_cmds.hpp index 2294629ee16..b735b5c132d 100644 --- a/extras/vom/vom/gbp_endpoint_group_cmds.hpp +++ b/extras/vom/vom/gbp_endpoint_group_cmds.hpp @@ -38,6 +38,7 @@ public: uint16_t sclass, uint32_t bd_id, route::table_id_t rd_id, + const gbp_endpoint_group::retention_t& retention, const handle_t& itf); /** @@ -61,6 +62,7 @@ private: const uint32_t m_bd_id; const route::table_id_t m_rd_id; const handle_t m_itf; + const gbp_endpoint_group::retention_t m_retention; }; /** diff --git a/extras/vom/vom/gbp_global.cpp b/extras/vom/vom/gbp_global.cpp deleted file mode 100644 index a6cbdd7512c..00000000000 --- a/extras/vom/vom/gbp_global.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* - * 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 deleted file mode 100644 index 7c451cc6270..00000000000 --- a/extras/vom/vom/gbp_global.hpp +++ /dev/null @@ -1,180 +0,0 @@ -/* - * 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 deleted file mode 100644 index 3ad651b68a3..00000000000 --- a/extras/vom/vom/gbp_global_cmds.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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 deleted file mode 100644 index 377b607c013..00000000000 --- a/extras/vom/vom/gbp_global_cmds.hpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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 |