aboutsummaryrefslogtreecommitdiffstats
path: root/extras/vom
diff options
context:
space:
mode:
Diffstat (limited to 'extras/vom')
-rw-r--r--extras/vom/vom/interface.cpp10
-rw-r--r--extras/vom/vom/interface_cmds.cpp66
-rw-r--r--extras/vom/vom/interface_cmds.hpp46
3 files changed, 120 insertions, 2 deletions
diff --git a/extras/vom/vom/interface.cpp b/extras/vom/vom/interface.cpp
index ec6204f1e0c..40f960730d7 100644
--- a/extras/vom/vom/interface.cpp
+++ b/extras/vom/vom/interface.cpp
@@ -275,13 +275,17 @@ interface::key() const
std::queue<cmd*>&
interface::mk_create_cmd(std::queue<cmd*>& q)
{
- if ((type_t::LOOPBACK == m_type) || (type_t::BVI == m_type)) {
+ if (type_t::LOOPBACK == m_type) {
q.push(new interface_cmds::loopback_create_cmd(m_hdl, m_name));
q.push(new interface_cmds::set_tag(m_hdl, m_name));
/*
* set the m_tag for pretty-print
*/
m_tag = m_name;
+ } else if (type_t::BVI == m_type) {
+ q.push(new interface_cmds::bvi_create_cmd(m_hdl, m_name));
+ q.push(new interface_cmds::set_tag(m_hdl, m_name));
+ m_tag = m_name;
} else if (type_t::AFPACKET == m_type) {
q.push(new interface_cmds::af_packet_create_cmd(m_hdl, m_name));
if (!m_tag.empty())
@@ -301,8 +305,10 @@ interface::mk_create_cmd(std::queue<cmd*>& q)
std::queue<cmd*>&
interface::mk_delete_cmd(std::queue<cmd*>& q)
{
- if ((type_t::LOOPBACK == m_type) || (type_t::BVI == m_type)) {
+ if (type_t::LOOPBACK == m_type) {
q.push(new interface_cmds::loopback_delete_cmd(m_hdl));
+ } else if (type_t::BVI == m_type) {
+ q.push(new interface_cmds::bvi_delete_cmd(m_hdl));
} else if (type_t::AFPACKET == m_type) {
q.push(new interface_cmds::af_packet_delete_cmd(m_hdl, m_name));
} else if (type_t::VHOST == m_type) {
diff --git a/extras/vom/vom/interface_cmds.cpp b/extras/vom/vom/interface_cmds.cpp
index 3a7fb50f64b..b72c2ad69e5 100644
--- a/extras/vom/vom/interface_cmds.cpp
+++ b/extras/vom/vom/interface_cmds.cpp
@@ -23,6 +23,41 @@ DEFINE_VAPI_MSG_IDS_VHOST_USER_API_JSON;
namespace VOM {
namespace interface_cmds {
+
+bvi_create_cmd::bvi_create_cmd(HW::item<handle_t>& item,
+ const std::string& name)
+ : create_cmd(item, name)
+{
+}
+
+rc_t
+bvi_create_cmd::issue(connection& con)
+{
+ msg_t req(con.ctx(), std::ref(*this));
+
+ auto& payload = req.get_request().get_payload();
+
+ payload.user_instance = ~0;
+
+ VAPI_CALL(req.execute());
+
+ wait();
+
+ if (m_hw_item.rc() == rc_t::OK) {
+ insert_interface();
+ }
+
+ return rc_t::OK;
+}
+std::string
+bvi_create_cmd::to_string() const
+{
+ std::ostringstream s;
+ s << "bvi-itf-create: " << m_hw_item.to_string() << " name:" << m_name;
+
+ return (s.str());
+}
+
loopback_create_cmd::loopback_create_cmd(HW::item<handle_t>& item,
const std::string& name)
: create_cmd(item, name)
@@ -138,6 +173,37 @@ vhost_create_cmd::to_string() const
return (s.str());
}
+bvi_delete_cmd::bvi_delete_cmd(HW::item<handle_t>& item)
+ : delete_cmd(item)
+{
+}
+
+rc_t
+bvi_delete_cmd::issue(connection& con)
+{
+ msg_t req(con.ctx(), std::ref(*this));
+
+ auto& payload = req.get_request().get_payload();
+ payload.sw_if_index = m_hw_item.data().value();
+
+ VAPI_CALL(req.execute());
+
+ wait();
+ m_hw_item.set(rc_t::NOOP);
+
+ remove_interface();
+ return rc_t::OK;
+}
+
+std::string
+bvi_delete_cmd::to_string() const
+{
+ std::ostringstream s;
+ s << "bvi-itf-delete: " << m_hw_item.to_string();
+
+ return (s.str());
+}
+
loopback_delete_cmd::loopback_delete_cmd(HW::item<handle_t>& item)
: delete_cmd(item)
{
diff --git a/extras/vom/vom/interface_cmds.hpp b/extras/vom/vom/interface_cmds.hpp
index 218d4b083d1..2ee892fc0f8 100644
--- a/extras/vom/vom/interface_cmds.hpp
+++ b/extras/vom/vom/interface_cmds.hpp
@@ -25,6 +25,7 @@
#include <vapi/af_packet.api.vapi.hpp>
#include <vapi/interface.api.vapi.hpp>
+#include <vapi/l2.api.vapi.hpp>
#include <vapi/vhost_user.api.vapi.hpp>
#include <vapi/vpe.api.vapi.hpp>
@@ -38,6 +39,30 @@ std::unique_ptr<interface> new_interface(
const vapi_payload_sw_interface_details& vd);
/**
+ * A command class to create bvi interfaces in VPP
+ */
+class bvi_create_cmd : public interface::create_cmd<vapi::Bvi_create>
+{
+public:
+ /**
+ * Constructor taking the HW::item to update
+ * and the name of the interface to create
+ */
+ bvi_create_cmd(HW::item<handle_t>& item, const std::string& name);
+ ~bvi_create_cmd() = default;
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+};
+
+/**
* A command class to create Loopback interfaces in VPP
*/
class loopback_create_cmd : public interface::create_cmd<vapi::Create_loopback>
@@ -109,6 +134,27 @@ private:
};
/**
+ * A command class to delete bvi interfaces in VPP
+ */
+class bvi_delete_cmd : public interface::delete_cmd<vapi::Bvi_delete>
+{
+public:
+ /**
+ * Constructor taking the HW::item to update
+ */
+ bvi_delete_cmd(HW::item<handle_t>& item);
+
+ /**
+ * Issue the command to VPP/HW
+ */
+ rc_t issue(connection& con);
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+};
+
+/**
* A command class to delete loopback interfaces in VPP
*/
class loopback_delete_cmd : public interface::delete_cmd<vapi::Delete_loopback>