VOM: fix tests and namespacify l2_vtr 75/17775/2
authorNeale Ranns <nranns@cisco.com>
Fri, 22 Feb 2019 10:48:25 +0000 (02:48 -0800)
committerNeale Ranns <nranns@cisco.com>
Fri, 22 Feb 2019 13:45:38 +0000 (13:45 +0000)
Change-Id: Ie59220a622c3a5195485cd6857b45f57d6eeaf95
Signed-off-by: Neale Ranns <nranns@cisco.com>
extras/vom/vom/interface.cpp
extras/vom/vom/l2_binding.cpp
extras/vom/vom/l2_binding.hpp
extras/vom/vom/l2_vtr.cpp
extras/vom/vom/l2_vtr.hpp
extras/vom/vom/l2_vtr_cmds.cpp
extras/vom/vom/l2_vtr_cmds.hpp
extras/vom/vom/l2_xconnect.cpp
extras/vom/vom/l2_xconnect.hpp
test/ext/vom_test.cpp

index a94be68..ec6204f 100644 (file)
@@ -394,7 +394,7 @@ interface::set(const admin_state_t& state)
 void
 interface::set(const l2_address_t& addr)
 {
-  m_l2_address.update(addr);
+  m_l2_address = { addr, rc_t::NOOP };
 }
 
 void
index 5f0c7a7..37039a0 100644 (file)
@@ -47,7 +47,7 @@ l2_binding::l2_binding(const interface& itf, const bridge_domain& bd)
   , m_bd(bd.singular())
   , m_port_type(l2_port_type_t::L2_PORT_TYPE_NORMAL)
   , m_binding(0)
-  , m_vtr_op(l2_vtr_op_t::L2_VTR_DISABLED, rc_t::UNSET)
+  , m_vtr_op(l2_vtr::option_t::DISABLED, rc_t::UNSET)
   , m_vtr_op_tag(0)
 {
   if (interface::type_t::BVI == m_itf->type())
@@ -64,7 +64,7 @@ l2_binding::l2_binding(const interface& itf,
   , m_bd(bd.singular())
   , m_port_type(port_type)
   , m_binding(0)
-  , m_vtr_op(l2_vtr_op_t::L2_VTR_DISABLED, rc_t::UNSET)
+  , m_vtr_op(l2_vtr::option_t::DISABLED, rc_t::UNSET)
   , m_vtr_op_tag(0)
 {
 }
@@ -119,7 +119,8 @@ l2_binding::replay()
   }
 
   if (m_vtr_op && handle_t::INVALID != m_itf->handle()) {
-    HW::enqueue(new set_vtr_op_cmd(m_vtr_op, m_itf->handle(), m_vtr_op_tag));
+    HW::enqueue(
+      new l2_vtr_cmds::set_cmd(m_vtr_op, m_itf->handle(), m_vtr_op_tag));
   }
 }
 
@@ -142,7 +143,7 @@ l2_binding::to_string() const
 }
 
 void
-l2_binding::set(const l2_vtr_op_t& op, uint16_t tag)
+l2_binding::set(const l2_vtr::option_t& op, uint16_t tag)
 {
   assert(rc_t::UNSET == m_vtr_op.rc());
   m_vtr_op.set(rc_t::NOOP);
@@ -174,7 +175,8 @@ l2_binding::update(const l2_binding& desired)
    * set the VTR operation if request
    */
   if (m_vtr_op.update(desired.m_vtr_op)) {
-    HW::enqueue(new set_vtr_op_cmd(m_vtr_op, m_itf->handle(), m_vtr_op_tag));
+    HW::enqueue(
+      new l2_vtr_cmds::set_cmd(m_vtr_op, m_itf->handle(), m_vtr_op_tag));
   }
 }
 
index 1908289..de3608a 100644 (file)
@@ -98,7 +98,7 @@ public:
   /**
    * Set the VTR operation on the binding/interface
    */
-  void set(const l2_vtr_op_t& op, uint16_t tag);
+  void set(const l2_vtr::option_t& op, uint16_t tag);
 
   /**
    * Static function to find the bridge_domain in the model
@@ -199,7 +199,7 @@ private:
   /**
    * HW configuration for the VTR option
    */
-  HW::item<l2_vtr_op_t> m_vtr_op;
+  HW::item<l2_vtr::option_t> m_vtr_op;
 
   /**
    * The Dot1q tag for the VTR operation
index 707a223..61505f6 100644 (file)
 #include "vom/l2_vtr.hpp"
 
 namespace VOM {
+namespace l2_vtr {
 
 /*
  * Make sure these are in sync with the smae enum in VPP
  */
-const l2_vtr_op_t l2_vtr_op_t::L2_VTR_DISABLED(0, "disabled");
-const l2_vtr_op_t l2_vtr_op_t::L2_VTR_PUSH_1(1, "push-1");
-const l2_vtr_op_t l2_vtr_op_t::L2_VTR_PUSH_2(2, "push-2");
-const l2_vtr_op_t l2_vtr_op_t::L2_VTR_POP_1(3, "pop-1");
-const l2_vtr_op_t l2_vtr_op_t::L2_VTR_POP_2(4, "pop-2");
-const l2_vtr_op_t l2_vtr_op_t::L2_VTR_TRANSLATE_1_1(5, "translate-1-1");
-const l2_vtr_op_t l2_vtr_op_t::L2_VTR_TRANSLATE_1_2(6, "translate-1-2");
-const l2_vtr_op_t l2_vtr_op_t::L2_VTR_TRANSLATE_2_1(7, "translate-2-1");
-const l2_vtr_op_t l2_vtr_op_t::L2_VTR_TRANSLATE_2_2(5, "translate-2-2");
+const option_t option_t::DISABLED(0, "disabled");
+const option_t option_t::PUSH_1(1, "push-1");
+const option_t option_t::PUSH_2(2, "push-2");
+const option_t option_t::POP_1(3, "pop-1");
+const option_t option_t::POP_2(4, "pop-2");
+const option_t option_t::TRANSLATE_1_1(5, "translate-1-1");
+const option_t option_t::TRANSLATE_1_2(6, "translate-1-2");
+const option_t option_t::TRANSLATE_2_1(7, "translate-2-1");
+const option_t option_t::TRANSLATE_2_2(5, "translate-2-2");
 
-l2_vtr_op_t::l2_vtr_op_t(int v, const std::string s)
-  : enum_base<l2_vtr_op_t>(v, s)
+option_t::option_t(int v, const std::string s)
+  : enum_base<option_t>(v, s)
 {
 }
-}
+
+}; // namespace l2_vtr
+}; // namespace VOM
 
 /*
  * fd.io coding-style-patch-verification: ON
index 540cc83..688e87a 100644 (file)
 #include "vom/om.hpp"
 
 namespace VOM {
-struct l2_vtr_op_t : public enum_base<l2_vtr_op_t>
+namespace l2_vtr {
+struct option_t : public enum_base<option_t>
 {
-  l2_vtr_op_t(const l2_vtr_op_t& l) = default;
-  ~l2_vtr_op_t() = default;
+  option_t(const option_t& l) = default;
+  ~option_t() = default;
 
-  const static l2_vtr_op_t L2_VTR_DISABLED;
-  const static l2_vtr_op_t L2_VTR_PUSH_1;
-  const static l2_vtr_op_t L2_VTR_PUSH_2;
-  const static l2_vtr_op_t L2_VTR_POP_1;
-  const static l2_vtr_op_t L2_VTR_POP_2;
-  const static l2_vtr_op_t L2_VTR_TRANSLATE_1_1;
-  const static l2_vtr_op_t L2_VTR_TRANSLATE_1_2;
-  const static l2_vtr_op_t L2_VTR_TRANSLATE_2_1;
-  const static l2_vtr_op_t L2_VTR_TRANSLATE_2_2;
+  const static option_t DISABLED;
+  const static option_t PUSH_1;
+  const static option_t PUSH_2;
+  const static option_t POP_1;
+  const static option_t POP_2;
+  const static option_t TRANSLATE_1_1;
+  const static option_t TRANSLATE_1_2;
+  const static option_t TRANSLATE_2_1;
+  const static option_t TRANSLATE_2_2;
 
 private:
-  l2_vtr_op_t(int v, const std::string s);
-};
+  option_t(int v, const std::string s);
 };
+}; // namespace l2_vtr
+}; // namesapce VOM
 
 /*
  * fd.io coding-style-patch-verification: ON
index df50ae4..1c76cf0 100644 (file)
 #include "vom/l2_vtr_cmds.hpp"
 
 namespace VOM {
+namespace l2_vtr_cmds {
 
-set_vtr_op_cmd::set_vtr_op_cmd(HW::item<l2_vtr_op_t>& item,
-                               const handle_t& itf,
-                               uint16_t tag)
+set_cmd::set_cmd(HW::item<l2_vtr::option_t>& item,
+                 const handle_t& itf,
+                 uint16_t tag)
   : rpc_cmd(item)
   , m_itf(itf)
   , m_tag(tag)
@@ -27,7 +28,7 @@ set_vtr_op_cmd::set_vtr_op_cmd(HW::item<l2_vtr_op_t>& item,
 }
 
 bool
-set_vtr_op_cmd::operator==(const set_vtr_op_cmd& other) const
+set_cmd::operator==(const set_cmd& other) const
 {
   return (
     (m_hw_item.data() == other.m_hw_item.data() && m_itf == other.m_itf) &&
@@ -35,7 +36,7 @@ set_vtr_op_cmd::operator==(const set_vtr_op_cmd& other) const
 }
 
 rc_t
-set_vtr_op_cmd::issue(connection& con)
+set_cmd::issue(connection& con)
 {
   msg_t req(con.ctx(), std::ref(*this));
 
@@ -51,15 +52,16 @@ set_vtr_op_cmd::issue(connection& con)
 }
 
 std::string
-set_vtr_op_cmd::to_string() const
+set_cmd::to_string() const
 {
   std::ostringstream s;
-  s << "L2-set-vtr-op: " << m_hw_item.to_string()
-    << " itf:" << m_itf.to_string() << " tag:" << m_tag;
+  s << "L2-vtr-set: " << m_hw_item.to_string() << " itf:" << m_itf.to_string()
+    << " tag:" << m_tag;
 
   return (s.str());
 }
 
+}; // namespace vtr_cmds
 }; // namespace VOM
 
 /*
index d26b719..14477fd 100644 (file)
 #include "vom/rpc_cmd.hpp"
 
 #include <vapi/l2.api.vapi.hpp>
-#include <vapi/vpe.api.vapi.hpp>
 
 namespace VOM {
-
+namespace l2_vtr_cmds {
 /**
  * A cmd class sets the VTR operation
  */
-class set_vtr_op_cmd
-  : public rpc_cmd<HW::item<l2_vtr_op_t>, vapi::L2_interface_vlan_tag_rewrite>
+class set_cmd : public rpc_cmd<HW::item<l2_vtr::option_t>,
+                               vapi::L2_interface_vlan_tag_rewrite>
 {
 public:
   /**
    * Constructor
    */
-  set_vtr_op_cmd(HW::item<l2_vtr_op_t>& item,
-                 const handle_t& itf,
-                 uint16_t tag);
+  set_cmd(HW::item<l2_vtr::option_t>& item, const handle_t& itf, uint16_t tag);
 
   /**
    * Issue the command to VPP/HW
@@ -51,7 +48,7 @@ public:
   /**
    * Comparison operator - only used for UT
    */
-  bool operator==(const set_vtr_op_cmd& i) const;
+  bool operator==(const set_cmd& i) const;
 
 private:
   /**
@@ -65,6 +62,7 @@ private:
   uint16_t m_tag;
 };
 
+}; // namespace vtr_cmds
 }; // namespace VOM
 
 /*
index 1bdb651..f54da6c 100644 (file)
@@ -34,7 +34,7 @@ l2_xconnect::l2_xconnect(const interface& east_itf, const interface& west_itf)
   , m_west_itf(west_itf.singular())
   , m_xconnect_east(0)
   , m_xconnect_west(0)
-  , m_vtr_op(l2_vtr_op_t::L2_VTR_DISABLED, rc_t::UNSET)
+  , m_vtr_op(l2_vtr::option_t::DISABLED, rc_t::UNSET)
   , m_vtr_op_tag(0)
 {
 }
@@ -98,7 +98,7 @@ l2_xconnect::replay()
 
   if (m_vtr_op && handle_t::INVALID != m_east_itf->handle()) {
     HW::enqueue(
-      new set_vtr_op_cmd(m_vtr_op, m_east_itf->handle(), m_vtr_op_tag));
+      new l2_vtr_cmds::set_cmd(m_vtr_op, m_east_itf->handle(), m_vtr_op_tag));
   }
 }
 
@@ -122,7 +122,7 @@ l2_xconnect::to_string() const
 }
 
 void
-l2_xconnect::set(const l2_vtr_op_t& op, uint16_t tag)
+l2_xconnect::set(const l2_vtr::option_t& op, uint16_t tag)
 {
   assert(rc_t::UNSET == m_vtr_op.rc());
   m_vtr_op.set(rc_t::NOOP);
@@ -148,7 +148,7 @@ l2_xconnect::update(const l2_xconnect& desired)
    */
   if (m_vtr_op.update(desired.m_vtr_op)) {
     HW::enqueue(
-      new set_vtr_op_cmd(m_vtr_op, m_east_itf->handle(), m_vtr_op_tag));
+      new l2_vtr_cmds::set_cmd(m_vtr_op, m_east_itf->handle(), m_vtr_op_tag));
   }
 }
 
index 32acd61..89acc1c 100644 (file)
@@ -81,7 +81,7 @@ public:
   /**
    * Set the VTR operation on the binding/interface
    */
-  void set(const l2_vtr_op_t& op, uint16_t tag);
+  void set(const l2_vtr::option_t& op, uint16_t tag);
 
   /**
    * Static function to find the bridge_domain in the model
@@ -183,7 +183,7 @@ private:
   /**
    * HW configuration for the VTR option
    */
-  HW::item<l2_vtr_op_t> m_vtr_op;
+  HW::item<l2_vtr::option_t> m_vtr_op;
 
   /**
    * The Dot1q tag for the VTR operation
index c259bb0..2665394 100644 (file)
@@ -25,6 +25,7 @@
 #include "vom/bond_group_binding_cmds.hpp"
 #include "vom/l2_binding.hpp"
 #include "vom/l2_binding_cmds.hpp"
+#include "vom/l2_vtr_cmds.hpp"
 #include "vom/l2_xconnect.hpp"
 #include "vom/l2_xconnect_cmds.hpp"
 #include "vom/l3_binding.hpp"
@@ -308,9 +309,9 @@ public:
                     {
                         rc = handle_derived<l2_binding_cmds::unbind_cmd>(f_exp, f_act);
                     }
-                    else if (typeid(*f_exp) == typeid(l2_binding_cmds::set_vtr_op_cmd))
+                    else if (typeid(*f_exp) == typeid(l2_vtr_cmds::set_cmd))
                     {
-                        rc = handle_derived<l2_binding_cmds::set_vtr_op_cmd>(f_exp, f_act);
+                        rc = handle_derived<l2_vtr_cmds::set_cmd>(f_exp, f_act);
                     }
                     else if (typeid(*f_exp) == typeid(l2_xconnect_cmds::bind_cmd))
                     {
@@ -988,14 +989,14 @@ BOOST_AUTO_TEST_CASE(test_bridge) {
     TRY_CHECK_RC(OM::write(dante, bd1));
 
     l2_binding *l2itf2 = new l2_binding(itf2, bd1);
-    HW::item<l2_binding::l2_vtr_op_t> hw_set_vtr(l2_binding::l2_vtr_op_t::L2_VTR_POP_1, rc_t::OK);
-    l2itf2->set(l2_binding::l2_vtr_op_t::L2_VTR_POP_1, 68);
+    HW::item<l2_vtr::option_t> hw_set_vtr(l2_vtr::option_t::POP_1, rc_t::OK);
+    l2itf2->set(l2_vtr::option_t::POP_1, 68);
 
     ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind,
                                          hw_ifh2.data(),
                                          hw_bd.data(),
                                          l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
-    ADD_EXPECT(l2_binding_cmds::set_vtr_op_cmd(hw_set_vtr, hw_ifh2.data(), 68));
+    ADD_EXPECT(l2_vtr_cmds::set_cmd(hw_set_vtr, hw_ifh2.data(), 68));
     TRY_CHECK_RC(OM::write(dante, *l2itf2));
 
     // Add some static entries to the bridge-domain