diff options
author | Neale Ranns <nranns@cisco.com> | 2018-03-16 16:26:21 -0700 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2018-03-19 15:56:23 +0000 |
commit | 6f4a6be8f222dd8caa94d19a7e4d87cb864ba7f4 (patch) | |
tree | cadc511a5926926133b3bbb4ca9c7b4239d3b2eb /src | |
parent | 7b867a8e491357058d37838091ed67a2e77bce2c (diff) |
Interface Unicast, Multicast and Broadcast stats on the API
Change-Id: I7c75da358aff1bd0216a602a49f2909cef5d920d
Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/vnet/interface.api | 44 | ||||
-rw-r--r-- | src/vnet/interface.c | 66 | ||||
-rw-r--r-- | src/vnet/interface.h | 36 | ||||
-rw-r--r-- | src/vnet/interface_api.c | 22 |
4 files changed, 162 insertions, 6 deletions
diff --git a/src/vnet/interface.api b/src/vnet/interface.api index 9dfb0c3257f..4d1b5ac06de 100644 --- a/src/vnet/interface.api +++ b/src/vnet/interface.api @@ -238,17 +238,41 @@ typeonly manual_print manual_endian define vlib_counter @param sw_if_index - interface indexes for counters @param rx_packets - received packet count @param rx_bytes - received byte count + @param rx_unicast_packets - received unicast packet count + @param rx_unicast_bytes - received unicast byte count + @param rx_multicast_packets - received multicast packet count + @param rx_multicast_bytes - received multicast byte count + @param rx_broadcast_packets - received broadcast packet count + @param rx_broadcast_bytes - received broadcast byte count @param tx_packets - transmitted packet count @param tx_bytes - transmitted byte count + @param tx_unicast_packets - transmitted unicast packet count + @param tx_unicast_bytes - transmitted unicast byte count + @param tx_multicast_packets - transmitted multicast packet count + @param tx_multicast_bytes - transmitted multicast byte count + @param tx_broadcast_packets - transmitted broadcast packet count + @param tx_broadcast_bytes - transmitted broadcast byte count */ typeonly manual_print manual_endian define vnet_combined_counter { u32 sw_if_index; - u64 rx_packets; /**< packet counter */ - u64 rx_bytes; /**< byte counter */ - u64 tx_packets; /**< packet counter */ - u64 tx_bytes; /**< byte counter */ + u64 rx_packets; /**< packet counter */ + u64 rx_bytes; /**< byte counter */ + u64 rx_unicast_packets; /**< packet counter */ + u64 rx_unicast_bytes; /**< byte counter */ + u64 rx_multicast_packets; /**< packet counter */ + u64 rx_multicast_bytes; /**< byte counter */ + u64 rx_broadcast_packets; /**< packet counter */ + u64 rx_broadcast_bytes; /**< byte counter */ + u64 tx_packets; /**< packet counter */ + u64 tx_bytes; /**< byte counter */ + u64 tx_unicast_packets; /**< packet counter */ + u64 tx_unicast_bytes; /**< byte counter */ + u64 tx_multicast_packets; /**< packet counter */ + u64 tx_multicast_bytes; /**< byte counter */ + u64 tx_broadcast_packets; /**< packet counter */ + u64 tx_broadcast_bytes; /**< byte counter */ }; /** \brief Simple interface counter data type for vnet_interface_simple_counters @@ -517,6 +541,18 @@ autoreply define delete_loopback u32 sw_if_index; }; +/** \brief Enable or disable detailed interface stats + @param client_index - opaque cookie to identify the sender + @param context - sender context, to match reply w/ request + @param enable_disable - set to 1 to enable, 0 to disable detailed stats +*/ +autoreply define collect_detailed_interface_stats +{ + u32 client_index; + u32 context; + u8 enable_disable; +}; + /* * Local Variables: * eval: (c-set-style "gnu") diff --git a/src/vnet/interface.c b/src/vnet/interface.c index 122ae065ad0..ba342d49c9e 100644 --- a/src/vnet/interface.c +++ b/src/vnet/interface.c @@ -1237,7 +1237,19 @@ vnet_interface_init (vlib_main_t * vm) vec_validate (im->combined_sw_if_counters, VNET_N_COMBINED_INTERFACE_COUNTER - 1); im->combined_sw_if_counters[VNET_INTERFACE_COUNTER_RX].name = "rx"; + im->combined_sw_if_counters[VNET_INTERFACE_COUNTER_RX_UNICAST].name = + "rx-unicast"; + im->combined_sw_if_counters[VNET_INTERFACE_COUNTER_RX_MULTICAST].name = + "rx-multicast"; + im->combined_sw_if_counters[VNET_INTERFACE_COUNTER_RX_BROADCAST].name = + "rx-broadcast"; im->combined_sw_if_counters[VNET_INTERFACE_COUNTER_TX].name = "tx"; + im->combined_sw_if_counters[VNET_INTERFACE_COUNTER_TX_UNICAST].name = + "tx-unicast"; + im->combined_sw_if_counters[VNET_INTERFACE_COUNTER_TX_MULTICAST].name = + "tx-multicast"; + im->combined_sw_if_counters[VNET_INTERFACE_COUNTER_TX_BROADCAST].name = + "tx-broadcast"; im->sw_if_counter_lock[0] = 0; @@ -1537,6 +1549,60 @@ default_update_adjacency (vnet_main_t * vnm, u32 sw_if_index, u32 ai) } } +int collect_detailed_interface_stats_flag = 0; + +void +collect_detailed_interface_stats_flag_set () +{ + collect_detailed_interface_stats_flag = 1; +} + +void +collect_detailed_interface_stats_flag_clear () +{ + collect_detailed_interface_stats_flag = 0; +} + +static clib_error_t * +collect_detailed_interface_stats_cli (vlib_main_t * vm, + unformat_input_t * input, + vlib_cli_command_t * cmd) +{ + unformat_input_t _line_input, *line_input = &_line_input; + clib_error_t *error = NULL; + + /* Get a line of input. */ + if (!unformat_user (input, unformat_line_input, line_input)) + return clib_error_return (0, "expected enable | disable"); + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (line_input, "enable") || unformat (line_input, "on")) + collect_detailed_interface_stats_flag_set (); + else if (unformat (line_input, "disable") + || unformat (line_input, "off")) + collect_detailed_interface_stats_flag_clear (); + else + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; + } + } + +done: + unformat_free (line_input); + return error; +} + +/* *INDENT-OFF* */ +VLIB_CLI_COMMAND (collect_detailed_interface_stats_command, static) = { + .path = "interface collect detailed-stats", + .short_help = "interface collect detailed-stats <enable|disable>", + .function = collect_detailed_interface_stats_cli, +}; +/* *INDENT-ON* */ + /* * fd.io coding-style-patch-verification: ON * diff --git a/src/vnet/interface.h b/src/vnet/interface.h index 8988eb0e8aa..73f1895b74f 100644 --- a/src/vnet/interface.h +++ b/src/vnet/interface.h @@ -634,9 +634,43 @@ typedef enum /* Combined counters. */ VNET_INTERFACE_COUNTER_RX = 0, VNET_INTERFACE_COUNTER_TX = 1, - VNET_N_COMBINED_INTERFACE_COUNTER = 2, + VNET_INTERFACE_COUNTER_RX_UNICAST = 2, + VNET_INTERFACE_COUNTER_TX_UNICAST = 3, + VNET_INTERFACE_COUNTER_RX_MULTICAST = 4, + VNET_INTERFACE_COUNTER_TX_MULTICAST = 5, + VNET_INTERFACE_COUNTER_RX_BROADCAST = 6, + VNET_INTERFACE_COUNTER_TX_BROADCAST = 7, + VNET_N_COMBINED_INTERFACE_COUNTER = 8, } vnet_interface_counter_type_t; +#define foreach_combined_interface_counter(X) \ + X(VNET_INTERFACE_COUNTER_RX, rx) \ + X(VNET_INTERFACE_COUNTER_TX, tx) \ + X(VNET_INTERFACE_COUNTER_RX_UNICAST, rx_unicast) \ + X(VNET_INTERFACE_COUNTER_TX_UNICAST, tx_unicast) \ + X(VNET_INTERFACE_COUNTER_RX_MULTICAST, rx_multicast) \ + X(VNET_INTERFACE_COUNTER_TX_MULTICAST, tx_multicast) \ + X(VNET_INTERFACE_COUNTER_RX_BROADCAST, rx_broadcast) \ + X(VNET_INTERFACE_COUNTER_TX_BROADCAST, tx_broadcast) + +typedef enum +{ + COLLECT_SIMPLE_STATS = 0, + COLLECT_DETAILED_STATS = 1, +} vnet_interface_stats_collection_mode_e; + +extern int collect_detailed_interface_stats_flag; + +static inline int +collect_detailed_interface_stats () +{ + return collect_detailed_interface_stats_flag; +} + +void collect_detailed_interface_stats_flag_set (); +void collect_detailed_interface_stats_flag_clear (); + + typedef struct { u32 output_node_index; diff --git a/src/vnet/interface_api.c b/src/vnet/interface_api.c index b22cadd871e..3d9bb30f142 100644 --- a/src/vnet/interface_api.c +++ b/src/vnet/interface_api.c @@ -68,7 +68,8 @@ _(DELETE_SUBIF, delete_subif) \ _(CREATE_LOOPBACK, create_loopback) \ _(CREATE_LOOPBACK_INSTANCE, create_loopback_instance) \ _(DELETE_LOOPBACK, delete_loopback) \ -_(INTERFACE_NAME_RENUMBER, interface_name_renumber) +_(INTERFACE_NAME_RENUMBER, interface_name_renumber) \ +_(COLLECT_DETAILED_INTERFACE_STATS, collect_detailed_interface_stats) static void vl_api_sw_interface_set_flags_t_handler (vl_api_sw_interface_set_flags_t * mp) @@ -1169,6 +1170,25 @@ vl_api_delete_loopback_t_handler (vl_api_delete_loopback_t * mp) REPLY_MACRO (VL_API_DELETE_LOOPBACK_REPLY); } +static void + vl_api_collect_detailed_interface_stats_t_handler + (vl_api_collect_detailed_interface_stats_t * mp) +{ + vl_api_collect_detailed_interface_stats_reply_t *rmp; + int rv = 0; + + if (mp->enable_disable) + { + collect_detailed_interface_stats_flag_set (); + } + else + { + collect_detailed_interface_stats_flag_clear (); + } + + REPLY_MACRO (VL_API_COLLECT_DETAILED_INTERFACE_STATS_REPLY); +} + /* * vpe_api_hookup * Add vpe's API message handlers to the table. |