From 5a4f96a178b693ace8e736c30c949ced5928d824 Mon Sep 17 00:00:00 2001 From: Mohsin Kazmi Date: Mon, 20 Nov 2017 10:23:47 +0100 Subject: VOM: stats: Associate stat obj to interface Change-Id: Id8b159dd72b92798538a32fe570fb0038d742ef2 Signed-off-by: Mohsin Kazmi --- src/vpp-api/vom/interface_cmds.cpp | 43 +++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 19 deletions(-) (limited to 'src/vpp-api/vom/interface_cmds.cpp') 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& 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(this))))); - // m_reg->execute(); /* - * then send the request to enable them - */ - msg_t req(con.ctx(), m_swifindex.size(), - std::ref(*(static_cast(this)))); + * then send the request to enable them + */ + msg_t req(con.ctx(), 1, std::ref(*(static_cast(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(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 -- cgit