summaryrefslogtreecommitdiffstats
path: root/hicn-plugin/src/faces/face_cli.c
diff options
context:
space:
mode:
authorAlberto Compagno <acompagn+fdio@cisco.com>2019-03-23 14:46:14 +0100
committerAlberto Compagno <acompagn+fdio@cisco.com>2019-03-23 16:05:19 +0100
commit2ba7f1f0bef4ecb20af57283d456e66e31fa667a (patch)
tree5c29f03e3259bc9def5623152ae9e3eff771f39f /hicn-plugin/src/faces/face_cli.c
parenta2bdc00ea25f89185c1095a48a8f51cb2c1a20e6 (diff)
[HICN-138] Added number of received/transmitted bytes and packets on each face
Change-Id: Icfe9cd84bdc72afef3d714064e695d1abef368f5 Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com>
Diffstat (limited to 'hicn-plugin/src/faces/face_cli.c')
-rw-r--r--hicn-plugin/src/faces/face_cli.c71
1 files changed, 69 insertions, 2 deletions
diff --git a/hicn-plugin/src/faces/face_cli.c b/hicn-plugin/src/faces/face_cli.c
index 3ddf96beb..b0ed7ddae 100644
--- a/hicn-plugin/src/faces/face_cli.c
+++ b/hicn-plugin/src/faces/face_cli.c
@@ -28,7 +28,9 @@ hicn_face_cli_show_command_fn (vlib_main_t * vm,
char *face_type_name = NULL;
int found = ~0;
int deleted = 0;
-
+ u8 *n = 0;
+ u8 *s = 0;
+ vlib_counter_t v;
/* Get a line of input. */
unformat_input_t _line_input, *line_input = &_line_input;
@@ -74,6 +76,31 @@ hicn_face_cli_show_command_fn (vlib_main_t * vm,
hicn_face_t *face = hicn_dpoi_get_from_idx (face_id);
hicn_face_vft_t *vft = hicn_face_get_vft (face->shared.face_type);
vlib_cli_output (vm, "%U\n", vft->format_face, face_id, 0 /*indent */ );
+
+ u32 indent = 3;
+
+ for (int i = 0; i < HICN_N_COUNTER; i++)
+ {
+ vlib_get_combined_counter (&counters
+ [hicn_dpoi_get_index (face) *
+ HICN_N_COUNTER], i, &v);
+ s =
+ format (s, "%U%s", format_white_space, indent,
+ HICN_FACE_CTRX_STRING[i]);
+
+ if (n)
+ _vec_len (n) = 0;
+ n = format (n, "packets");
+ s =
+ format (s, "%U%-16v%16Ld", format_white_space,
+ 30 - strlen (HICN_FACE_CTRX_STRING[i]), n, v.packets);
+
+ _vec_len (n) = 0;
+ n = format (n, "bytes");
+ s = format (s, "\n%U%-16v%16Ld\n",
+ format_white_space, indent + 30, n, v.bytes);
+ }
+ vlib_cli_output (vm, "%s\n", s);
}
else
{
@@ -88,7 +115,28 @@ hicn_face_cli_show_command_fn (vlib_main_t * vm,
if (!((face->shared.flags & HICN_FACE_FLAGS_DELETED) && !deleted))
{
if ((face->shared.face_type == type) && (face->shared.flags))
- vlib_cli_output(vm, "%U\n", vft->format_face, hicn_dpoi_get_index(face), 0);
+ {
+ vlib_cli_output(vm, "%U\n", vft->format_face, hicn_dpoi_get_index(face), 0);
+ u8 * s = 0;
+ u32 indent = 3;
+
+ for (int i = 0; i < HICN_N_COUNTER; i++)
+ {
+ vlib_get_combined_counter (&counters[hicn_dpoi_get_index(face) * HICN_N_COUNTER], i, &v);
+ s = format (s, "%U%s",format_white_space, indent, HICN_FACE_CTRX_STRING[i]);
+
+ if (n)
+ _vec_len (n) = 0;
+ n = format (n, "packets");
+ s = format (s, "%U%-16v%16Ld", format_white_space, 30-strlen(HICN_FACE_CTRX_STRING[i]), n, v.packets);
+
+ _vec_len (n) = 0;
+ n = format (n, "bytes");
+ s = format (s, "\n%U%-16v%16Ld\n",
+ format_white_space, indent+30, n, v.bytes);
+ }
+ vlib_cli_output (vm, "%s\n", s);
+ }
}
});
/* *INDENT-ON* */
@@ -103,6 +151,25 @@ hicn_face_cli_show_command_fn (vlib_main_t * vm,
{
hicn_face_vft_t * vft = hicn_face_get_vft(face->shared.face_type);
vlib_cli_output(vm, "%U\n", vft->format_face, hicn_dpoi_get_index(face), 0);
+ u32 indent = 3;
+ u8 * s = 0;
+
+ for (int i = 0; i < HICN_N_COUNTER; i++)
+ {
+ vlib_get_combined_counter (&counters[hicn_dpoi_get_index(face) * HICN_N_COUNTER], i, &v);
+ s = format (s, "%U%s",format_white_space, indent, HICN_FACE_CTRX_STRING[i]);
+
+ if (n)
+ _vec_len (n) = 0;
+ n = format (n, "packets");
+ s = format (s, "%U%-16v%16Ld", format_white_space, 30-strlen(HICN_FACE_CTRX_STRING[i]), n, v.packets);
+
+ _vec_len (n) = 0;
+ n = format (n, "bytes");
+ s = format (s, "\n%U%-16v%16Ld\n",
+ format_white_space, indent+30, n, v.bytes);
+ }
+ vlib_cli_output (vm, "%s\n", s);
}
});
/* *INDENT-ON* */