From ed76ee24dfe76fb9400470a4efb3871acd37cad9 Mon Sep 17 00:00:00 2001 From: Mohsin Kazmi Date: Fri, 2 Mar 2018 12:31:37 +0100 Subject: VOM: bond: Add support for LACP Change-Id: I0245263b212142858d3305b0f365d8342912dbb9 Signed-off-by: Mohsin Kazmi --- src/vpp-api/vom/interface.cpp | 65 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 4 deletions(-) (limited to 'src/vpp-api/vom/interface.cpp') diff --git a/src/vpp-api/vom/interface.cpp b/src/vpp-api/vom/interface.cpp index f943bf4a616..f323727b052 100644 --- a/src/vpp-api/vom/interface.cpp +++ b/src/vpp-api/vom/interface.cpp @@ -14,6 +14,9 @@ */ #include "vom/interface.hpp" +#include "vom/bond_group_binding.hpp" +#include "vom/bond_group_binding_cmds.hpp" +#include "vom/bond_interface_cmds.hpp" #include "vom/interface_cmds.hpp" #include "vom/interface_factory.hpp" #include "vom/l3_binding_cmds.hpp" @@ -464,6 +467,9 @@ interface::dump(std::ostream& os) void interface::event_handler::handle_populate(const client_db::key_t& key) { + /* + * dump VPP current states + */ std::shared_ptr vcmd = std::make_shared(); @@ -474,13 +480,10 @@ interface::event_handler::handle_populate(const client_db::key_t& key) std::shared_ptr vitf = interface_factory::new_vhost_user_interface( vhost_itf_record.get_payload()); - VOM_LOG(log_level_t::DEBUG) << "dump: " << vitf->to_string(); + VOM_LOG(log_level_t::DEBUG) << " vhost-dump: " << vitf->to_string(); OM::commit(key, *vitf); } - /* - * dump VPP current states - */ std::shared_ptr cmd = std::make_shared(); @@ -522,6 +525,60 @@ interface::event_handler::handle_populate(const client_db::key_t& key) } } } + + std::shared_ptr bcmd = + std::make_shared(); + + HW::enqueue(bcmd); + HW::write(); + + for (auto& bond_itf_record : *bcmd) { + std::shared_ptr bond_itf = + interface_factory::new_bond_interface(bond_itf_record.get_payload()); + + VOM_LOG(log_level_t::DEBUG) << " bond-dump:" << bond_itf->to_string(); + + /* + * Write each of the discovered interfaces into the OM, + * but disable the HW Command q whilst we do, so that no + * commands are sent to VPP + */ + OM::commit(key, *bond_itf); + + std::shared_ptr scmd = + std::make_shared( + bond_group_binding_cmds::dump_cmd(bond_itf->handle())); + + HW::enqueue(scmd); + HW::write(); + + bond_group_binding::enslaved_itf_t enslaved_itfs; + + for (auto& slave_itf_record : *scmd) { + bond_member slave_itf = interface_factory::new_bond_member_interface( + slave_itf_record.get_payload()); + + VOM_LOG(log_level_t::DEBUG) << " slave-dump:" << slave_itf.to_string(); + + /* + * Write each of the discovered interfaces into the OM, + * but disable the HW Command q whilst we do, so that no + * commands are sent to VPP + */ + // OM::commit(slave_itf->key(), *slave_itf); + enslaved_itfs.insert(slave_itf); + } + + if (!enslaved_itfs.empty()) { + bond_group_binding bid(*bond_itf, enslaved_itfs); + /* + * Write each of the discovered interfaces into the OM, + * but disable the HW Command q whilst we do, so that no + * commands are sent to VPP + */ + OM::commit(key, bid); + } + } } interface::event_handler::event_handler() -- cgit 1.2.3-korg