diff options
author | Neale Ranns <neale.ranns@cisco.com> | 2017-11-14 08:40:43 -0800 |
---|---|---|
committer | Neale Ranns <nranns@cisco.com> | 2017-11-14 19:25:54 +0000 |
commit | 10e7a9f8d8c8572be16f9b3f0395da6f8eff22ec (patch) | |
tree | 76cad881f5bd9a2c1c3ec664a880c3d0ba299961 /src/vpp-api | |
parent | a161a6dedb1aa3aba00109d325d2909051a3c987 (diff) |
VOM: bridge-domain learning mode and route help commands
Change-Id: I2fa219d6530f1e7a3b8ae32d35a0c60ba57c5129
Signed-off-by: Neale Ranns <neale.ranns@cisco.com>
Diffstat (limited to 'src/vpp-api')
-rw-r--r-- | src/vpp-api/vom/bridge_domain.cpp | 19 | ||||
-rw-r--r-- | src/vpp-api/vom/bridge_domain.hpp | 25 | ||||
-rw-r--r-- | src/vpp-api/vom/bridge_domain_cmds.cpp | 6 | ||||
-rw-r--r-- | src/vpp-api/vom/bridge_domain_cmds.hpp | 9 | ||||
-rw-r--r-- | src/vpp-api/vom/inspect.hpp | 2 | ||||
-rw-r--r-- | src/vpp-api/vom/route.cpp | 1 | ||||
-rw-r--r-- | src/vpp-api/vom/route_domain.cpp | 34 | ||||
-rw-r--r-- | src/vpp-api/vom/route_domain.hpp | 36 |
8 files changed, 125 insertions, 7 deletions
diff --git a/src/vpp-api/vom/bridge_domain.cpp b/src/vpp-api/vom/bridge_domain.cpp index 8e012b5d951..81d83621212 100644 --- a/src/vpp-api/vom/bridge_domain.cpp +++ b/src/vpp-api/vom/bridge_domain.cpp @@ -19,6 +19,17 @@ #include "vom/l2_binding.hpp" namespace VOM { + +const bridge_domain::learning_mode_t bridge_domain::learning_mode_t::ON(1, + "on"); +const bridge_domain::learning_mode_t bridge_domain::learning_mode_t::OFF(0, + "off"); + +bridge_domain::learning_mode_t::learning_mode_t(int v, const std::string& s) + : enum_base<bridge_domain::learning_mode_t>(v, s) +{ +} + /** * A DB of al the interfaces, key on the name */ @@ -29,13 +40,15 @@ bridge_domain::event_handler bridge_domain::m_evh; /** * Construct a new object matching the desried state */ -bridge_domain::bridge_domain(uint32_t id) +bridge_domain::bridge_domain(uint32_t id, const learning_mode_t& lmode) : m_id(id) + , m_learning_mode(lmode) { } bridge_domain::bridge_domain(const bridge_domain& o) : m_id(o.m_id) + , m_learning_mode(o.m_learning_mode) { } @@ -58,7 +71,7 @@ void bridge_domain::replay() { if (rc_t::OK == m_id.rc()) { - HW::enqueue(new bridge_domain_cmds::create_cmd(m_id)); + HW::enqueue(new bridge_domain_cmds::create_cmd(m_id, m_learning_mode)); } } @@ -116,7 +129,7 @@ bridge_domain::update(const bridge_domain& desired) * the desired state is always that the interface should be created */ if (rc_t::OK != m_id.rc()) { - HW::enqueue(new bridge_domain_cmds::create_cmd(m_id)); + HW::enqueue(new bridge_domain_cmds::create_cmd(m_id, m_learning_mode)); } } diff --git a/src/vpp-api/vom/bridge_domain.hpp b/src/vpp-api/vom/bridge_domain.hpp index b42f53fce7b..2c134f0740b 100644 --- a/src/vpp-api/vom/bridge_domain.hpp +++ b/src/vpp-api/vom/bridge_domain.hpp @@ -32,6 +32,21 @@ class bridge_domain : public object_base { public: /** + * Bridge Domain Learning mode + */ + struct learning_mode_t : enum_base<learning_mode_t> + { + const static learning_mode_t ON; + const static learning_mode_t OFF; + + private: + /** + * Private constructor taking the value and the string name + */ + learning_mode_t(int v, const std::string& s); + }; + + /** * The value of the defaultbridge domain */ const static uint32_t DEFAULT_TABLE = 0; @@ -39,11 +54,14 @@ public: /** * Construct a new object matching the desried state */ - bridge_domain(uint32_t id); + bridge_domain(uint32_t id, + const learning_mode_t& lmode = learning_mode_t::ON); + /** * Copy Constructor */ bridge_domain(const bridge_domain& o); + /** * Destructor */ @@ -146,6 +164,11 @@ private: HW::item<uint32_t> m_id; /** + * The leanring mode of the bridge + */ + learning_mode_t m_learning_mode; + + /** * A map of all interfaces key against the interface's name */ static singular_db<uint32_t, bridge_domain> m_db; diff --git a/src/vpp-api/vom/bridge_domain_cmds.cpp b/src/vpp-api/vom/bridge_domain_cmds.cpp index 1b9dc1cff99..498569f9fab 100644 --- a/src/vpp-api/vom/bridge_domain_cmds.cpp +++ b/src/vpp-api/vom/bridge_domain_cmds.cpp @@ -19,8 +19,10 @@ DEFINE_VAPI_MSG_IDS_L2_API_JSON; namespace VOM { namespace bridge_domain_cmds { -create_cmd::create_cmd(HW::item<uint32_t>& item) +create_cmd::create_cmd(HW::item<uint32_t>& item, + const bridge_domain::learning_mode_t& lmode) : rpc_cmd(item) + , m_learning_mode(lmode) { } @@ -40,7 +42,7 @@ create_cmd::issue(connection& con) payload.flood = 1; payload.uu_flood = 1; payload.forward = 1; - payload.learn = 1; + payload.learn = m_learning_mode.value(); payload.arp_term = 1; payload.mac_age = 0; payload.is_add = 1; diff --git a/src/vpp-api/vom/bridge_domain_cmds.hpp b/src/vpp-api/vom/bridge_domain_cmds.hpp index c6226fd339b..f263b323e41 100644 --- a/src/vpp-api/vom/bridge_domain_cmds.hpp +++ b/src/vpp-api/vom/bridge_domain_cmds.hpp @@ -34,7 +34,8 @@ public: /** * Constructor */ - create_cmd(HW::item<uint32_t>& item); + create_cmd(HW::item<uint32_t>& item, + const bridge_domain::learning_mode_t& lmode); /** * Issue the command to VPP/HW @@ -49,6 +50,12 @@ public: * Comparison operator - only used for UT */ bool operator==(const create_cmd& i) const; + +private: + /** + * the learning mode for the bridge + */ + bridge_domain::learning_mode_t m_learning_mode; }; /** diff --git a/src/vpp-api/vom/inspect.hpp b/src/vpp-api/vom/inspect.hpp index fb9528decc0..d5bca3040d2 100644 --- a/src/vpp-api/vom/inspect.hpp +++ b/src/vpp-api/vom/inspect.hpp @@ -18,8 +18,10 @@ #include <deque> #include <map> +#include <memory> #include <ostream> #include <string> +#include <vector> namespace VOM { /** diff --git a/src/vpp-api/vom/route.cpp b/src/vpp-api/vom/route.cpp index ece0768e634..e59bfbaaf8c 100644 --- a/src/vpp-api/vom/route.cpp +++ b/src/vpp-api/vom/route.cpp @@ -19,6 +19,7 @@ namespace VOM { namespace route { +ip_route::event_handler ip_route::m_evh; singular_db<ip_route::key_t, ip_route> ip_route::m_db; const path::special_t path::special_t::STANDARD(0, "standard"); diff --git a/src/vpp-api/vom/route_domain.cpp b/src/vpp-api/vom/route_domain.cpp index f173fd7a250..08357faa6c5 100644 --- a/src/vpp-api/vom/route_domain.cpp +++ b/src/vpp-api/vom/route_domain.cpp @@ -18,6 +18,9 @@ #include "vom/route_domain_cmds.hpp" namespace VOM { + +route_domain::event_handler route_domain::m_evh; + /** * A DB of al the interfaces, key on the name */ @@ -164,7 +167,38 @@ route_domain::dump(std::ostream& os) { m_db.dump(os); } + +void +route_domain::event_handler::handle_populate(const client_db::key_t& key) +{ +} + +route_domain::event_handler::event_handler() +{ + OM::register_listener(this); + inspect::register_handler({ "rd", "route-domain" }, "Route Domains", this); +} + +void +route_domain::event_handler::handle_replay() +{ + m_db.replay(); +} + +dependency_t +route_domain::event_handler::order() const +{ + return (dependency_t::TABLE); } + +void +route_domain::event_handler::show(std::ostream& os) +{ + m_db.dump(os); +} + +}; // namespace VOPM + /* * fd.io coding-style-patch-verification: ON * diff --git a/src/vpp-api/vom/route_domain.hpp b/src/vpp-api/vom/route_domain.hpp index 0639fb95925..516271f7f66 100644 --- a/src/vpp-api/vom/route_domain.hpp +++ b/src/vpp-api/vom/route_domain.hpp @@ -16,6 +16,7 @@ #ifndef __VOM_ROUTE_DOMAIN_H__ #define __VOM_ROUTE_DOMAIN_H__ +#include "vom/inspect.hpp" #include "vom/object_base.hpp" #include "vom/om.hpp" #include "vom/prefix.hpp" @@ -94,6 +95,41 @@ public: 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; + }; + + /** + * Instance of the 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 route_domain& obj); |