Allow individual stats API and introduce stats.api
- want_interface_simple_stats - want_interface_combined_stats - want_ip4|6_fib|nbr_stats Change-Id: I4e97461def508958b3e429c3fe8859b36fef2d18 Signed-off-by: Keith Burns (alagalah) <alagalah@gmail.com>
This commit is contained in:
Keith Burns (alagalah)
committed by
Dave Wallace
parent
49d66f1f42
commit
8a19f12a0c
1
.gitignore
vendored
1
.gitignore
vendored
@ -55,6 +55,7 @@ test-driver
|
||||
*.iml
|
||||
.bootstrap.ok
|
||||
.settings
|
||||
.autotools
|
||||
# stop autotools ignore
|
||||
|
||||
# OSX and some IDE
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2016 Cisco and/or its affiliates.
|
||||
# Copyright (c) 2017 Cisco and/or its affiliates.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at:
|
||||
@ -58,7 +58,7 @@ vcl_test_server_SOURCES = uri/vcl_test_server.c
|
||||
vcl_test_server_LDADD = libvppcom.la
|
||||
|
||||
vcl_test_client_SOURCES = uri/vcl_test_client.c
|
||||
vcl_test_client_LDADD = libvppcom.la
|
||||
vcl_test_client_LDADD = libvppcom.la
|
||||
|
||||
sock_test_server_SOURCES = uri/sock_test_server.c
|
||||
sock_test_client_SOURCES = uri/sock_test_client.c
|
||||
|
@ -217,7 +217,6 @@ _(from_netconf_client) \
|
||||
_(oam_events) \
|
||||
_(bfd_events)
|
||||
|
||||
/* WARNING: replicated in vpp/stats.h */
|
||||
typedef struct
|
||||
{
|
||||
u32 client_index; /* in memclnt registration pool */
|
||||
|
12
src/vpp.am
12
src/vpp.am
@ -42,9 +42,11 @@ bin_vpp_CFLAGS = @APICLI@
|
||||
nobase_include_HEADERS += \
|
||||
vpp/api/vpe_all_api_h.h \
|
||||
vpp/api/vpe_msg_enum.h \
|
||||
vpp/stats/stats.api.h \
|
||||
vpp/api/vpe.api.h
|
||||
|
||||
API_FILES += vpp/api/vpe.api
|
||||
API_FILES += vpp/stats/stats.api
|
||||
|
||||
BUILT_SOURCES += .version
|
||||
|
||||
@ -116,13 +118,13 @@ endif
|
||||
noinst_PROGRAMS += bin/summary_stats_client
|
||||
|
||||
bin_summary_stats_client_SOURCES = \
|
||||
vpp/api/summary_stats_client.c
|
||||
vpp/api/summary_stats_client.c
|
||||
|
||||
bin_summary_stats_client_LDADD = \
|
||||
libvlibmemoryclient.la \
|
||||
libsvm.la \
|
||||
libvppinfra.la \
|
||||
-lpthread -lm -lrt
|
||||
libvlibmemoryclient.la \
|
||||
libsvm.la \
|
||||
libvppinfra.la \
|
||||
-lpthread -lm -lrt
|
||||
|
||||
bin_PROGRAMS += bin/vpp_get_metrics
|
||||
|
||||
|
@ -110,7 +110,6 @@ _(CREATE_VLAN_SUBIF, create_vlan_subif) \
|
||||
_(CREATE_SUBIF, create_subif) \
|
||||
_(PROXY_ARP_ADD_DEL, proxy_arp_add_del) \
|
||||
_(PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable) \
|
||||
_(VNET_GET_SUMMARY_STATS, vnet_get_summary_stats) \
|
||||
_(RESET_FIB, reset_fib) \
|
||||
_(CREATE_LOOPBACK, create_loopback) \
|
||||
_(CREATE_LOOPBACK_INSTANCE, create_loopback_instance) \
|
||||
@ -745,64 +744,6 @@ vl_api_oam_add_del_t_handler (vl_api_oam_add_del_t * mp)
|
||||
REPLY_MACRO (VL_API_OAM_ADD_DEL_REPLY);
|
||||
}
|
||||
|
||||
static void
|
||||
vl_api_vnet_get_summary_stats_t_handler (vl_api_vnet_get_summary_stats_t * mp)
|
||||
{
|
||||
stats_main_t *sm = &stats_main;
|
||||
vnet_interface_main_t *im = sm->interface_main;
|
||||
vl_api_vnet_get_summary_stats_reply_t *rmp;
|
||||
vlib_combined_counter_main_t *cm;
|
||||
vlib_counter_t v;
|
||||
int i, which;
|
||||
u64 total_pkts[VLIB_N_RX_TX];
|
||||
u64 total_bytes[VLIB_N_RX_TX];
|
||||
|
||||
unix_shared_memory_queue_t *q =
|
||||
vl_api_client_index_to_input_queue (mp->client_index);
|
||||
|
||||
if (!q)
|
||||
return;
|
||||
|
||||
rmp = vl_msg_api_alloc (sizeof (*rmp));
|
||||
rmp->_vl_msg_id = ntohs (VL_API_VNET_GET_SUMMARY_STATS_REPLY);
|
||||
rmp->context = mp->context;
|
||||
rmp->retval = 0;
|
||||
|
||||
memset (total_pkts, 0, sizeof (total_pkts));
|
||||
memset (total_bytes, 0, sizeof (total_bytes));
|
||||
|
||||
vnet_interface_counter_lock (im);
|
||||
|
||||
vec_foreach (cm, im->combined_sw_if_counters)
|
||||
{
|
||||
which = cm - im->combined_sw_if_counters;
|
||||
|
||||
for (i = 0; i < vlib_combined_counter_n_counters (cm); i++)
|
||||
{
|
||||
vlib_get_combined_counter (cm, i, &v);
|
||||
total_pkts[which] += v.packets;
|
||||
total_bytes[which] += v.bytes;
|
||||
}
|
||||
}
|
||||
vnet_interface_counter_unlock (im);
|
||||
|
||||
rmp->total_pkts[VLIB_RX] = clib_host_to_net_u64 (total_pkts[VLIB_RX]);
|
||||
rmp->total_bytes[VLIB_RX] = clib_host_to_net_u64 (total_bytes[VLIB_RX]);
|
||||
rmp->total_pkts[VLIB_TX] = clib_host_to_net_u64 (total_pkts[VLIB_TX]);
|
||||
rmp->total_bytes[VLIB_TX] = clib_host_to_net_u64 (total_bytes[VLIB_TX]);
|
||||
rmp->vector_rate =
|
||||
clib_host_to_net_u64 (vlib_last_vector_length_per_node (sm->vlib_main));
|
||||
|
||||
vl_msg_api_send_shmem (q, (u8 *) & rmp);
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
typedef CLIB_PACKED (struct {
|
||||
ip4_address_t address;
|
||||
u32 address_length: 6;
|
||||
u32 index:26;
|
||||
}) ip4_route_t;
|
||||
/* *INDENT-ON* */
|
||||
|
||||
static int
|
||||
ip4_reset_fib_t_handler (vl_api_reset_fib_t * mp)
|
||||
|
@ -47,6 +47,7 @@
|
||||
* DHCP APIs: see ... /src/vnet/dhcp/{dhcpk.api, dhcp_api.c}
|
||||
* COP APIs: see ... /src/vnet/cop/{cop.api, cop_api.c}
|
||||
* POLICER APIs: see ... /src/vnet/policer/{policer.api, policer_api.c}
|
||||
* STATS APIs: see .../src/vpp/stats/{stats.api, stats.c}
|
||||
*/
|
||||
|
||||
/** \brief Create a new subinterface with the given vlan id
|
||||
@ -136,117 +137,6 @@ autoreply define reset_vrf
|
||||
u32 vrf_id;
|
||||
};
|
||||
|
||||
/** \brief Want Stats, register for stats updates
|
||||
@param client_index - opaque cookie to identify the sender
|
||||
@param context - sender context, to match reply w/ request
|
||||
@param enable_disable - 1 = enable stats, 0 = disable
|
||||
@param pid - pid of process requesting stats updates
|
||||
*/
|
||||
autoreply define want_stats
|
||||
{
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
u32 enable_disable;
|
||||
u32 pid;
|
||||
};
|
||||
|
||||
typeonly manual_print manual_endian define ip4_fib_counter
|
||||
{
|
||||
u32 address;
|
||||
u8 address_length;
|
||||
u64 packets;
|
||||
u64 bytes;
|
||||
};
|
||||
|
||||
manual_print manual_endian define vnet_ip4_fib_counters
|
||||
{
|
||||
u32 vrf_id;
|
||||
u32 count;
|
||||
vl_api_ip4_fib_counter_t c[count];
|
||||
};
|
||||
|
||||
typeonly manual_print manual_endian define ip4_nbr_counter
|
||||
{
|
||||
u32 address;
|
||||
u8 link_type;
|
||||
u64 packets;
|
||||
u64 bytes;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Per-neighbour (i.e. per-adjacency) coutners
|
||||
* @param count The size of the array of counters
|
||||
* @param sw_if_index The interface the adjacency is on
|
||||
* @param begin Flag to indicate this is the first set of stats for this
|
||||
* interface. If this flag is not set the it is a continuation of
|
||||
* stats for this interface
|
||||
* @param c counters
|
||||
*/
|
||||
manual_print manual_endian define vnet_ip4_nbr_counters
|
||||
{
|
||||
u32 count;
|
||||
u32 sw_if_index;
|
||||
u8 begin;
|
||||
vl_api_ip4_nbr_counter_t c[count];
|
||||
};
|
||||
|
||||
typeonly manual_print manual_endian define ip6_fib_counter
|
||||
{
|
||||
u64 address[2];
|
||||
u8 address_length;
|
||||
u64 packets;
|
||||
u64 bytes;
|
||||
};
|
||||
|
||||
manual_print manual_endian define vnet_ip6_fib_counters
|
||||
{
|
||||
u32 vrf_id;
|
||||
u32 count;
|
||||
vl_api_ip6_fib_counter_t c[count];
|
||||
};
|
||||
|
||||
typeonly manual_print manual_endian define ip6_nbr_counter
|
||||
{
|
||||
u64 address[2];
|
||||
u8 link_type;
|
||||
u64 packets;
|
||||
u64 bytes;
|
||||
};
|
||||
|
||||
manual_print manual_endian define vnet_ip6_nbr_counters
|
||||
{
|
||||
u32 count;
|
||||
u32 sw_if_index;
|
||||
u8 begin;
|
||||
vl_api_ip6_nbr_counter_t c[count];
|
||||
};
|
||||
|
||||
/** \brief Request for a single block of summary stats
|
||||
@param client_index - opaque cookie to identify the sender
|
||||
@param context - sender context, to match reply w/ request
|
||||
*/
|
||||
define vnet_get_summary_stats
|
||||
{
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
};
|
||||
|
||||
/** \brief Reply for vnet_get_summary_stats request
|
||||
@param context - sender context, to match reply w/ request
|
||||
@param retval - return code for request
|
||||
@param total_pkts -
|
||||
@param total_bytes -
|
||||
@param vector_rate -
|
||||
*/
|
||||
define vnet_get_summary_stats_reply
|
||||
{
|
||||
u32 context;
|
||||
i32 retval;
|
||||
u64 total_pkts[2];
|
||||
u64 total_bytes[2];
|
||||
f64 vector_rate;
|
||||
};
|
||||
|
||||
/** \brief OAM event structure
|
||||
@param dst_address[] -
|
||||
@param state
|
||||
|
@ -28,6 +28,9 @@
|
||||
/* Include the current layer (third) vpp API definition layer */
|
||||
#include <vpp/api/vpe.api.h>
|
||||
|
||||
/* Include stats APIs */
|
||||
#include <vpp/stats/stats.api.h>
|
||||
|
||||
/*
|
||||
* fd.io coding-style-patch-verification: ON
|
||||
*
|
||||
|
222
src/vpp/stats/stats.api
Normal file
222
src/vpp/stats/stats.api
Normal file
@ -0,0 +1,222 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2016 Cisco and/or its affiliates.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
|
||||
This file defines the stats API
|
||||
*/
|
||||
|
||||
|
||||
/** \brief Want Stats, enable/disable ALL stats updates
|
||||
@param client_index - opaque cookie to identify the sender
|
||||
@param context - sender context, to match reply w/ request
|
||||
@param enable_disable - 1 = enable stats, 0 = disable
|
||||
@param pid - pid of process requesting stats updates
|
||||
*/
|
||||
autoreply define want_stats
|
||||
{
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
u32 enable_disable;
|
||||
u32 pid;
|
||||
};
|
||||
|
||||
/** \brief Want Interface Simple Stats, register for detailed interface stats
|
||||
@param client_index - opaque cookie to identify the sender
|
||||
@param context - sender context, to match reply w/ request
|
||||
@param enable_disable - 1 = enable stats, 0 = disable
|
||||
@param pid - pid of process requesting stats updates
|
||||
*/
|
||||
autoreply define want_interface_simple_stats
|
||||
{
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
u32 enable_disable;
|
||||
u32 pid;
|
||||
};
|
||||
|
||||
/** \brief Want Interface Combined Stats, register for continuous stats
|
||||
@param client_index - opaque cookie to identify the sender
|
||||
@param context - sender context, to match reply w/ request
|
||||
@param enable_disable - 1 = enable stats, 0 = disable
|
||||
@param pid - pid of process requesting stats updates
|
||||
*/
|
||||
autoreply define want_interface_combined_stats
|
||||
{
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
u32 enable_disable;
|
||||
u32 pid;
|
||||
};
|
||||
|
||||
/** \brief Want IP4 FIB Stats, register for continuous stats
|
||||
@param client_index - opaque cookie to identify the sender
|
||||
@param context - sender context, to match reply w/ request
|
||||
@param enable_disable - 1 = enable stats, 0 = disable
|
||||
@param pid - pid of process requesting stats updates
|
||||
*/
|
||||
autoreply define want_ip4_fib_stats
|
||||
{
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
u32 enable_disable;
|
||||
u32 pid;
|
||||
};
|
||||
|
||||
/** \brief Want IP6 FIB Stats, register for continuous stats
|
||||
@param client_index - opaque cookie to identify the sender
|
||||
@param context - sender context, to match reply w/ request
|
||||
@param enable_disable - 1 = enable stats, 0 = disable
|
||||
@param pid - pid of process requesting stats updates
|
||||
*/
|
||||
autoreply define want_ip6_fib_stats
|
||||
{
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
u32 enable_disable;
|
||||
u32 pid;
|
||||
};
|
||||
|
||||
/** \brief Want IP4 NBR Stats, register for continuous stats
|
||||
@param client_index - opaque cookie to identify the sender
|
||||
@param context - sender context, to match reply w/ request
|
||||
@param enable_disable - 1 = enable stats, 0 = disable
|
||||
@param pid - pid of process requesting stats updates
|
||||
*/
|
||||
autoreply define want_ip4_nbr_stats
|
||||
{
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
u32 enable_disable;
|
||||
u32 pid;
|
||||
};
|
||||
|
||||
/** \brief Want IP6 NBR Stats, register for continuous stats
|
||||
@param client_index - opaque cookie to identify the sender
|
||||
@param context - sender context, to match reply w/ request
|
||||
@param enable_disable - 1 = enable stats, 0 = disable
|
||||
@param pid - pid of process requesting stats updates
|
||||
*/
|
||||
autoreply define want_ip6_nbr_stats
|
||||
{
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
u32 enable_disable;
|
||||
u32 pid;
|
||||
};
|
||||
|
||||
typeonly manual_print manual_endian define ip4_fib_counter
|
||||
{
|
||||
u32 address;
|
||||
u8 address_length;
|
||||
u64 packets;
|
||||
u64 bytes;
|
||||
};
|
||||
|
||||
manual_print manual_endian define vnet_ip4_fib_counters
|
||||
{
|
||||
u32 vrf_id;
|
||||
u32 count;
|
||||
vl_api_ip4_fib_counter_t c[count];
|
||||
};
|
||||
|
||||
typeonly manual_print manual_endian define ip4_nbr_counter
|
||||
{
|
||||
u32 address;
|
||||
u8 link_type;
|
||||
u64 packets;
|
||||
u64 bytes;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Per-neighbour (i.e. per-adjacency) coutners
|
||||
* @param count The size of the array of counters
|
||||
* @param sw_if_index The interface the adjacency is on
|
||||
* @param begin Flag to indicate this is the first set of stats for this
|
||||
* interface. If this flag is not set the it is a continuation of
|
||||
* stats for this interface
|
||||
* @param c counters
|
||||
*/
|
||||
manual_print manual_endian define vnet_ip4_nbr_counters
|
||||
{
|
||||
u32 count;
|
||||
u32 sw_if_index;
|
||||
u8 begin;
|
||||
vl_api_ip4_nbr_counter_t c[count];
|
||||
};
|
||||
|
||||
typeonly manual_print manual_endian define ip6_fib_counter
|
||||
{
|
||||
u64 address[2];
|
||||
u8 address_length;
|
||||
u64 packets;
|
||||
u64 bytes;
|
||||
};
|
||||
|
||||
manual_print manual_endian define vnet_ip6_fib_counters
|
||||
{
|
||||
u32 vrf_id;
|
||||
u32 count;
|
||||
vl_api_ip6_fib_counter_t c[count];
|
||||
};
|
||||
|
||||
typeonly manual_print manual_endian define ip6_nbr_counter
|
||||
{
|
||||
u64 address[2];
|
||||
u8 link_type;
|
||||
u64 packets;
|
||||
u64 bytes;
|
||||
};
|
||||
|
||||
manual_print manual_endian define vnet_ip6_nbr_counters
|
||||
{
|
||||
u32 count;
|
||||
u32 sw_if_index;
|
||||
u8 begin;
|
||||
vl_api_ip6_nbr_counter_t c[count];
|
||||
};
|
||||
|
||||
|
||||
/** \brief Request for a single block of summary stats
|
||||
@param client_index - opaque cookie to identify the sender
|
||||
@param context - sender context, to match reply w/ request
|
||||
*/
|
||||
define vnet_get_summary_stats
|
||||
{
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
};
|
||||
|
||||
/** \brief Reply for vnet_get_summary_stats request
|
||||
@param context - sender context, to match reply w/ request
|
||||
@param retval - return code for request
|
||||
@param total_pkts -
|
||||
@param total_bytes -
|
||||
@param vector_rate -
|
||||
*/
|
||||
define vnet_get_summary_stats_reply
|
||||
{
|
||||
u32 context;
|
||||
i32 retval;
|
||||
u64 total_pkts[2];
|
||||
u64 total_bytes[2];
|
||||
f64 vector_rate;
|
||||
};
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* eval: (c-set-style "gnu")
|
||||
* End:
|
||||
*/
|
File diff suppressed because it is too large
Load Diff
@ -21,6 +21,7 @@
|
||||
#include <vnet/interface.h>
|
||||
#include <pthread.h>
|
||||
#include <vlib/threads.h>
|
||||
#include <vnet/fib/fib_table.h>
|
||||
#include <vlib/unix/unix.h>
|
||||
#include <vlibmemory/api.h>
|
||||
#include <vlibmemory/unix_shared_memory_queue.h>
|
||||
@ -35,6 +36,44 @@ typedef struct
|
||||
int tag;
|
||||
} data_structure_lock_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
vpe_client_registration_t client;
|
||||
u8 stats_registrations;
|
||||
#define INTERFACE_SIMPLE_COUNTERS (1 << 0)
|
||||
#define INTERFACE_COMBINED_COUNTERS (1 << 1)
|
||||
#define IP4_FIB_COUNTERS (1 << 2)
|
||||
#define IP4_NBR_COUNTERS (1 << 3)
|
||||
#define IP6_FIB_COUNTERS (1 << 4)
|
||||
#define IP6_NBR_COUNTERS (1 << 5)
|
||||
|
||||
} vpe_client_stats_registration_t;
|
||||
|
||||
/* from .../vnet/vnet/ip/lookup.c. Yuck */
|
||||
typedef CLIB_PACKED (struct
|
||||
{
|
||||
ip4_address_t address;
|
||||
u32 address_length: 6;
|
||||
u32 index: 26;
|
||||
}) ip4_route_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ip6_address_t address;
|
||||
u32 address_length;
|
||||
u32 index;
|
||||
} ip6_route_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ip4_route_t *ip4routes;
|
||||
ip6_route_t *ip6routes;
|
||||
fib_table_t **fibs;
|
||||
hash_pair_t **pvec;
|
||||
uword *results;
|
||||
} do_ip46_fibs_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void *mheap;
|
||||
@ -45,7 +84,8 @@ typedef struct
|
||||
u32 enable_poller;
|
||||
|
||||
uword *stats_registration_hash;
|
||||
vpe_client_registration_t *stats_registrations;
|
||||
vpe_client_stats_registration_t *stats_registrations;
|
||||
vpe_client_stats_registration_t **regs;
|
||||
|
||||
/* control-plane data structure lock */
|
||||
data_structure_lock_t *data_structure_lock;
|
||||
@ -53,6 +93,9 @@ typedef struct
|
||||
/* bail out of FIB walk if set */
|
||||
clib_longjmp_t jmp_buf;
|
||||
|
||||
/* Vectors for Distribution funcs: do_ip4_fibs and do_ip6_fibs. */
|
||||
do_ip46_fibs_t do_ip46_fibs;
|
||||
|
||||
/* convenience */
|
||||
vlib_main_t *vlib_main;
|
||||
vnet_main_t *vnet_main;
|
||||
|
Reference in New Issue
Block a user