aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vpp-api/vom/interface.cpp18
-rw-r--r--src/vpp-api/vom/interface.hpp15
-rw-r--r--src/vpp-api/vom/interface_cmds.cpp43
-rw-r--r--src/vpp-api/vom/interface_cmds.hpp9
-rw-r--r--src/vpp-api/vom/rpc_cmd.hpp11
5 files changed, 71 insertions, 25 deletions
diff --git a/src/vpp-api/vom/interface.cpp b/src/vpp-api/vom/interface.cpp
index 8f1023d2273..39ca074920f 100644
--- a/src/vpp-api/vom/interface.cpp
+++ b/src/vpp-api/vom/interface.cpp
@@ -163,11 +163,15 @@ interface::sweep()
new interface_cmds::set_table_cmd(m_table_id, l3_proto_t::IPV6, m_hdl));
}
+ if (m_stats)
+ HW::dequeue(m_stats);
+
// If the interface is up, bring it down
if (m_state && interface::admin_state_t::UP == m_state.data()) {
m_state.data() = interface::admin_state_t::DOWN;
HW::enqueue(new interface_cmds::state_change_cmd(m_state, m_hdl));
}
+
if (m_hdl) {
std::queue<cmd*> cmds;
HW::enqueue(mk_delete_cmd(cmds));
@@ -356,6 +360,20 @@ interface::set(const oper_state_t& state)
m_oper = state;
}
+void
+interface::enable_stats_i(interface::stat_listener& el)
+{
+ m_stats.reset(new interface_cmds::stats_cmd(el, handle_i()));
+ HW::enqueue(m_stats);
+ HW::write();
+}
+
+void
+interface::enable_stats(interface::stat_listener& el)
+{
+ singular()->enable_stats_i(el);
+}
+
std::shared_ptr<interface>
interface::singular_i() const
{
diff --git a/src/vpp-api/vom/interface.hpp b/src/vpp-api/vom/interface.hpp
index 181e76dad69..76ecf8af0a0 100644
--- a/src/vpp-api/vom/interface.hpp
+++ b/src/vpp-api/vom/interface.hpp
@@ -421,6 +421,11 @@ public:
*/
static void dump(std::ostream& os);
+ /**
+ * Enable stats for this interface
+ */
+ void enable_stats(stat_listener& el);
+
protected:
/**
* Construct an interface object with a handle and a HW address
@@ -513,6 +518,11 @@ private:
static event_handler m_evh;
/**
+ * enable the interface stats in the singular instance
+ */
+ void enable_stats_i(stat_listener& el);
+
+ /**
* Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
*/
void update(const interface& obj);
@@ -550,6 +560,11 @@ private:
std::shared_ptr<route_domain> m_rd;
/**
+ * shared pointer to the stats object for this interface.
+ */
+ std::shared_ptr<interface_cmds::stats_cmd> m_stats;
+
+ /**
* The state of the interface
*/
HW::item<admin_state_t> m_state;
diff --git a/src/vpp-api/vom/interface_cmds.cpp b/src/vpp-api/vom/interface_cmds.cpp
index 4f6286f7bef..750ad1f8881 100644
--- a/src/vpp-api/vom/interface_cmds.cpp
+++ b/src/vpp-api/vom/interface_cmds.cpp
@@ -401,11 +401,10 @@ events_cmd::to_string() const
/**
* Interface statistics
*/
-stats_cmd::stats_cmd(interface::stat_listener& el,
- const std::vector<handle_t>& interfaces)
+stats_cmd::stats_cmd(interface::stat_listener& el, const handle_t& handle)
: event_cmd(el.status())
, m_listener(el)
- , m_swifindex(interfaces)
+ , m_swifindex(handle)
{
}
@@ -419,29 +418,21 @@ rc_t
stats_cmd::issue(connection& con)
{
/*
- * First set the clal back to handle the interface stats
- */
+ * First set the call back to handle the interface stats
+ */
m_reg.reset(new reg_t(con.ctx(), std::ref(*(static_cast<event_cmd*>(this)))));
- // m_reg->execute();
/*
- * then send the request to enable them
- */
- msg_t req(con.ctx(), m_swifindex.size(),
- std::ref(*(static_cast<rpc_cmd*>(this))));
+ * then send the request to enable them
+ */
+ msg_t req(con.ctx(), 1, std::ref(*(static_cast<rpc_cmd*>(this))));
auto& payload = req.get_request().get_payload();
payload.enable_disable = 1;
payload.pid = getpid();
- payload.num = m_swifindex.size();
-
- auto it = m_swifindex.cbegin();
- uint32_t ii = 0;
- while (it != m_swifindex.cend()) {
- payload.sw_ifs[ii] = it->value();
- ++it;
- ++ii;
- }
+ payload.num = 1;
+
+ payload.sw_ifs[0] = m_swifindex.value();
VAPI_CALL(req.execute());
@@ -453,6 +444,20 @@ stats_cmd::issue(connection& con)
void
stats_cmd::retire(connection& con)
{
+ /*
+ * disable interface stats.
+ */
+ msg_t req(con.ctx(), 1, std::ref(*(static_cast<rpc_cmd*>(this))));
+
+ auto& payload = req.get_request().get_payload();
+ payload.enable_disable = 0;
+ payload.pid = getpid();
+ payload.num = 1;
+ payload.sw_ifs[0] = m_swifindex.value();
+
+ VAPI_CALL(req.execute());
+
+ wait();
}
void
diff --git a/src/vpp-api/vom/interface_cmds.hpp b/src/vpp-api/vom/interface_cmds.hpp
index 4178be38e04..c86df92a4aa 100644
--- a/src/vpp-api/vom/interface_cmds.hpp
+++ b/src/vpp-api/vom/interface_cmds.hpp
@@ -364,7 +364,7 @@ private:
/**
* The listeners to notify when data/events arrive
*/
- interface::interface::event_listener& m_listener;
+ interface::event_listener& m_listener;
};
/**
@@ -377,8 +377,7 @@ public:
/**
* Constructor taking the listner to notify
*/
- stats_cmd(interface::stat_listener& el,
- const std::vector<handle_t>& interfaces);
+ stats_cmd(interface::stat_listener& el, const handle_t& handle);
/**
* Issue the command to VPP/HW
@@ -409,9 +408,9 @@ private:
/**
* The listeners to notify when data/stats arrive
*/
- interface::interface::stat_listener& m_listener;
+ interface::stat_listener& m_listener;
- std::vector<handle_t> m_swifindex;
+ handle_t m_swifindex;
};
/**
diff --git a/src/vpp-api/vom/rpc_cmd.hpp b/src/vpp-api/vom/rpc_cmd.hpp
index 60dbd47c8b3..ae3c6753d24 100644
--- a/src/vpp-api/vom/rpc_cmd.hpp
+++ b/src/vpp-api/vom/rpc_cmd.hpp
@@ -71,7 +71,16 @@ public:
/**
* Fulfill the commands promise. Called from the RX thread
*/
- void fulfill(const DATA& d) { m_promise.set_value(d); }
+ void fulfill(const DATA& d)
+ {
+ m_promise.set_value(d);
+
+ /*
+ * we reset the promise after setting the value to reuse it
+ * when we run the retire command from the same cmd object
+ */
+ m_promise = std::promise<DATA>();
+ }
/**
* Wait on the commands promise. i.e. block on the completion