summaryrefslogtreecommitdiffstats
path: root/hicn-plugin/src/hicn_api.c
diff options
context:
space:
mode:
authorAlberto Compagno <acompagn+fdio@cisco.com>2019-03-23 20:25:28 +0100
committerAlberto Compagno <acompagn+fdio@cisco.com>2019-03-23 20:25:28 +0100
commit8aac03e30ed3fc291542de23e5c02d2c4e05a66f (patch)
treef466277c13559a470e9bd9fb045bcbf377713f78 /hicn-plugin/src/hicn_api.c
parent43562f9f02d35e5d540ab4028a0326c0c7cd4898 (diff)
[HICN-139] Exporting per-face statistics through the binary api.
Change-Id: I253fb788fec527360876064b22ab54620eb2c615 Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com>
Diffstat (limited to 'hicn-plugin/src/hicn_api.c')
-rw-r--r--hicn-plugin/src/hicn_api.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/hicn-plugin/src/hicn_api.c b/hicn-plugin/src/hicn_api.c
index c532118b3..6249d6e5e 100644
--- a/hicn-plugin/src/hicn_api.c
+++ b/hicn-plugin/src/hicn_api.c
@@ -68,6 +68,7 @@
_(HICN_API_FACE_IP_ADD, hicn_api_face_ip_add) \
_(HICN_API_FACE_IP_DEL, hicn_api_face_ip_del) \
_(HICN_API_FACE_IP_PARAMS_GET, hicn_api_face_ip_params_get) \
+ _(HICN_API_FACE_STATS_DUMP, hicn_api_face_stats_dump) \
_(HICN_API_ROUTE_GET, hicn_api_route_get) \
_(HICN_API_ROUTE_NHOPS_ADD, hicn_api_route_nhops_add) \
_(HICN_API_ROUTE_DEL, hicn_api_route_del) \
@@ -255,6 +256,68 @@ static void
/* *INDENT-ON* */
}
+static void
+send_face_stats_details (vl_api_registration_t * reg,
+ hicn_face_t * face, u32 context)
+{
+ vl_api_hicn_api_face_stats_details_t *mp;
+ hicn_main_t *hm = &hicn_main;
+ mp = vl_msg_api_alloc (sizeof (*mp));
+ memset (mp, 0, sizeof (*mp));
+
+ mp->_vl_msg_id =
+ htons (VL_API_HICN_API_FACE_STATS_DETAILS + hm->msg_id_base);
+ mp->context = context;
+
+ mp->faceid = htonl (hicn_dpoi_get_index (face));
+ vlib_counter_t v;
+ vlib_get_combined_counter (&counters
+ [hicn_dpoi_get_index (face) * HICN_N_COUNTER],
+ HICN_FACE_COUNTERS_INTEREST_RX, &v);
+ mp->irx_packets = clib_net_to_host_u64 (v.packets);
+ mp->irx_bytes = clib_net_to_host_u64 (v.bytes);
+
+ vlib_get_combined_counter (&counters
+ [hicn_dpoi_get_index (face) * HICN_N_COUNTER],
+ HICN_FACE_COUNTERS_INTEREST_TX, &v);
+ mp->itx_packets = clib_net_to_host_u64 (v.packets);
+ mp->itx_bytes = clib_net_to_host_u64 (v.bytes);
+
+ vlib_get_combined_counter (&counters
+ [hicn_dpoi_get_index (face) * HICN_N_COUNTER],
+ HICN_FACE_COUNTERS_DATA_RX, &v);
+ mp->drx_packets = clib_net_to_host_u64 (v.packets);
+ mp->drx_bytes = clib_net_to_host_u64 (v.bytes);
+
+ vlib_get_combined_counter (&counters
+ [hicn_dpoi_get_index (face) * HICN_N_COUNTER],
+ HICN_FACE_COUNTERS_DATA_TX, &v);
+ mp->dtx_packets = clib_net_to_host_u64 (v.packets);
+ mp->dtx_bytes = clib_net_to_host_u64 (v.bytes);
+
+ vl_api_send_msg (reg, (u8 *) mp);
+}
+
+static void
+ vl_api_hicn_api_face_stats_dump_t_handler
+ (vl_api_hicn_api_face_stats_dump_t * mp)
+{
+ hicn_face_t *face;
+ vl_api_registration_t *reg;
+
+ reg = vl_api_client_index_to_registration (mp->client_index);
+ if (!reg)
+ return;
+
+ /* *INDENT-OFF* */
+ pool_foreach (face, hicn_dpoi_face_pool,
+ ({
+ send_face_stats_details (reg, face, mp->context);
+ }));
+ /* *INDENT-ON* */
+}
+
+
/****** ROUTE *******/
static void