VOM: Add support bridge domain arp entry dump 38/14438/3
authorMohsin Kazmi <sykazmi@cisco.com>
Thu, 23 Aug 2018 13:25:47 +0000 (15:25 +0200)
committerDamjan Marion <dmarion@me.com>
Mon, 27 Aug 2018 17:50:24 +0000 (17:50 +0000)
Change-Id: I5d563e1ebc3bd0a40e9347eaf0d00cad1f86a382
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
extras/vom/vom/bridge_domain_arp_entry.cpp
extras/vom/vom/bridge_domain_arp_entry_cmds.cpp
extras/vom/vom/bridge_domain_arp_entry_cmds.hpp

index a203a76..7221c3f 100644 (file)
@@ -162,6 +162,32 @@ void
 bridge_domain_arp_entry::event_handler::handle_populate(
   const client_db::key_t& key)
 {
+  /*
+   * dump VPP Bridge domains
+   */
+  std::shared_ptr<bridge_domain_arp_entry_cmds::dump_cmd> cmd =
+    std::make_shared<bridge_domain_arp_entry_cmds::dump_cmd>(~0);
+
+  HW::enqueue(cmd);
+  HW::write();
+
+  for (auto& record : *cmd) {
+    auto& payload = record.get_payload();
+
+    std::shared_ptr<bridge_domain> bd = bridge_domain::find(payload.bd_id);
+    bridge_domain_arp_entry bd_ae(
+      *bd, from_bytes(payload.is_ipv6, payload.ip_address),
+      mac_address_t(payload.mac_address));
+
+    VOM_LOG(log_level_t::DEBUG) << "dump: " << bd_ae.to_string();
+
+    /*
+     * Write each of the discovered bridge-domain arp entry into the OM,
+     * but disable the HW Command q whilst we do, so that no
+     * commands are sent to VPP
+     */
+    OM::commit(key, bd_ae);
+  }
 }
 
 dependency_t
index d404d5d..188d773 100644 (file)
@@ -111,6 +111,43 @@ delete_cmd::to_string() const
   return (s.str());
 }
 
+dump_cmd::dump_cmd(uint32_t bd_id)
+  : m_bd(bd_id)
+{
+}
+
+dump_cmd::dump_cmd(const dump_cmd& d)
+  : m_bd(d.m_bd)
+{
+}
+
+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)));
+
+  auto& payload = m_dump->get_request().get_payload();
+  payload.bd_id = m_bd;
+
+  VAPI_CALL(m_dump->execute());
+
+  wait();
+
+  return rc_t::OK;
+}
+
+std::string
+dump_cmd::to_string() const
+{
+  return ("bridge-domain-arp-entry-dump");
+}
+
 }; // namespace bridge_domain_arp_entry
 }; // namespace VOM
 
index 9637e37..490fc4b 100644 (file)
@@ -17,6 +17,7 @@
 #define __VOM_BRIDGE_DOMAIN_ARP_ENTRY_CMDS_H__
 
 #include "vom/bridge_domain_arp_entry.hpp"
+#include "vom/dump_cmd.hpp"
 
 #include <vapi/l2.api.vapi.hpp>
 #include <vapi/vpe.api.vapi.hpp>
@@ -93,6 +94,44 @@ private:
   mac_address_t m_mac;
   boost::asio::ip::address m_ip_addr;
 };
+
+/**
+ * A cmd class that Dumps all arp termination tables
+ */
+class dump_cmd : public VOM::dump_cmd<vapi::Bd_ip_mac_dump>
+{
+public:
+  /**
+   * Constructor
+   */
+  dump_cmd(uint32_t bd_id);
+  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;
+
+  /**
+   * The bd_id to get the arp termination table for
+   */
+  uint32_t m_bd;
+};
 };
 };