From 942402b02096af1c966f10e3e2a3d235787b962e Mon Sep 17 00:00:00 2001 From: Eyal Bari Date: Wed, 26 Jul 2017 11:57:04 +0300 Subject: CLI:add l2 input/outut to "sh int features" Change-Id: If608bbc7f4c8b0d5c3a237098a20279e407c82d3 Signed-off-by: Eyal Bari --- src/vnet/l2/l2_bd.h | 2 +- src/vnet/l2/l2_input.c | 23 +++++++++++++++++++++++ src/vnet/l2/l2_input.h | 2 ++ src/vnet/l2/l2_output.c | 23 +++++++++++++++++++++++ src/vnet/l2/l2_output.h | 2 ++ 5 files changed, 51 insertions(+), 1 deletion(-) (limited to 'src/vnet/l2') diff --git a/src/vnet/l2/l2_bd.h b/src/vnet/l2/l2_bd.h index 93ed1a8532a..0e070651859 100644 --- a/src/vnet/l2/l2_bd.h +++ b/src/vnet/l2/l2_bd.h @@ -34,7 +34,7 @@ typedef struct vnet_main_t *vnet_main; } bd_main_t; -bd_main_t bd_main; +extern bd_main_t bd_main; /* Bridge domain member */ diff --git a/src/vnet/l2/l2_input.c b/src/vnet/l2/l2_input.c index 26c832adfb1..faed7c7fd76 100644 --- a/src/vnet/l2/l2_input.c +++ b/src/vnet/l2/l2_input.c @@ -60,6 +60,29 @@ l2input_get_feat_names (void) return l2input_feat_names; } +u8 * +format_l2_input_features (u8 * s, va_list * args) +{ + static char *display_names[] = { +#define _(sym,name) #sym, + foreach_l2input_feat +#undef _ + }; + u32 feature_bitmap = va_arg (*args, u32); + + if (feature_bitmap == 0) + { + s = format (s, " none configured"); + return s; + } + + feature_bitmap &= ~L2INPUT_FEAT_DROP; /* Not a feature */ + int i; + for (i = L2INPUT_N_FEAT; i >= 0; i--) + if (feature_bitmap & (1 << i)) + s = format (s, "%10s (%s)\n", display_names[i], l2input_feat_names[i]); + return s; +} typedef struct { diff --git a/src/vnet/l2/l2_input.h b/src/vnet/l2/l2_input.h index e6b3bc7f9cd..e8a6c776cef 100644 --- a/src/vnet/l2/l2_input.h +++ b/src/vnet/l2/l2_input.h @@ -148,6 +148,8 @@ STATIC_ASSERT ((u64) L2INPUT_VALID_MASK == (1ull << L2INPUT_N_FEAT) - 1, ""); /** Return an array of strings containing graph node names of each feature */ char **l2input_get_feat_names (void); +/* arg0 - u32 feature_bitmap */ +u8 *format_l2_input_features (u8 * s, va_list * args); static_always_inline u8 bd_feature_flood (l2_bridge_domain_t * bd_config) diff --git a/src/vnet/l2/l2_output.c b/src/vnet/l2/l2_output.c index fbee590c944..500fc5d0e95 100644 --- a/src/vnet/l2/l2_output.c +++ b/src/vnet/l2/l2_output.c @@ -40,6 +40,29 @@ l2output_get_feat_names (void) return l2output_feat_names; } +u8 * +format_l2_output_features (u8 * s, va_list * args) +{ + static char *display_names[] = { +#define _(sym,name) #sym, + foreach_l2output_feat +#undef _ + }; + u32 feature_bitmap = va_arg (*args, u32); + + if (feature_bitmap == 0) + { + s = format (s, " none configured"); + return s; + } + + int i; + for (i = L2OUTPUT_N_FEAT - 1; i >= 0; i--) + if (feature_bitmap & (1 << i)) + s = format (s, "%10s (%s)\n", display_names[i], l2output_feat_names[i]); + return s; +} + l2output_main_t l2output_main; typedef struct diff --git a/src/vnet/l2/l2_output.h b/src/vnet/l2/l2_output.h index a54b8d67c93..1a73fdf9790 100644 --- a/src/vnet/l2/l2_output.h +++ b/src/vnet/l2/l2_output.h @@ -141,6 +141,8 @@ typedef enum /* Return an array of strings containing graph node names of each feature */ char **l2output_get_feat_names (void); +/* arg0 - u32 feature_bitmap */ +u8 *format_l2_output_features (u8 * s, va_list * args); /** * The next set of functions is for use by output feature graph nodes. -- cgit 1.2.3-korg