summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeale Ranns <neale.ranns@cisco.com>2018-06-07 02:08:07 -0700
committerFlorin Coras <florin.coras@gmail.com>2018-06-21 07:44:37 +0000
commit586479a73162426a02b2bbc8ab724e0dfb9921e0 (patch)
tree05701dd882dbc218ffb1bd28f20fce50bbcda61c
parent0c58ad4045c03552a6c6100e8e8441558aaea972 (diff)
BIER neighbor stats
Change-Id: I2f638f1932b4aeddf2408c06d1b8393551675b72 Signed-off-by: Neale Ranns <neale.ranns@cisco.com>
-rw-r--r--src/vnet/bier/bier_fmask.c64
-rw-r--r--src/vnet/bier/bier_fmask.h4
-rw-r--r--src/vnet/bier/bier_fmask_db.c35
-rw-r--r--src/vnet/bier/bier_fmask_db.h40
-rw-r--r--src/vnet/bier/bier_output.c10
-rw-r--r--src/vnet/udp/udp_encap.c2
-rw-r--r--src/vnet/udp/udp_encap.h2
-rw-r--r--src/vpp/stats/stats.api41
-rw-r--r--src/vpp/stats/stats.c212
-rw-r--r--src/vpp/stats/stats.reg1
10 files changed, 333 insertions, 78 deletions
diff --git a/src/vnet/bier/bier_fmask.c b/src/vnet/bier/bier_fmask.c
index 3d7cc838ab0..73f719460aa 100644
--- a/src/vnet/bier/bier_fmask.c
+++ b/src/vnet/bier/bier_fmask.c
@@ -37,6 +37,11 @@ static const char *const bier_fmask_attr_names[] = BIER_FMASK_ATTR_NAMES;
*/
bier_fmask_t *bier_fmask_pool;
+/**
+ * Stats for each BIER fmask object
+ */
+vlib_combined_counter_main_t bier_fmask_counters;
+
static inline index_t
bier_fmask_get_index (const bier_fmask_t *bfm)
{
@@ -165,6 +170,12 @@ bier_fmask_init (bier_fmask_t *bfm,
const bier_table_id_t *btid;
mpls_label_t olabel;
+ ASSERT(1 == vec_len(rpaths));
+ memset(bfm, 0, sizeof(*bfm));
+
+ bfm->bfm_id = clib_mem_alloc(sizeof(*bfm->bfm_id));
+
+ fib_node_init(&bfm->bfm_node, FIB_NODE_TYPE_BIER_FMASK);
*bfm->bfm_id = *fmid;
dpo_reset(&bfm->bfm_dpo);
btid = bier_table_get_id(bfm->bfm_id->bfmi_bti);
@@ -268,20 +279,19 @@ bier_fmask_create_and_lock (const bier_fmask_id_t *fmid,
const fib_route_path_t *rpaths)
{
bier_fmask_t *bfm;
+ index_t bfmi;
pool_get_aligned(bier_fmask_pool, bfm, CLIB_CACHE_LINE_BYTES);
+ bfmi = bier_fmask_get_index(bfm);
- memset(bfm, 0, sizeof(*bfm));
-
- bfm->bfm_id = clib_mem_alloc(sizeof(*bfm->bfm_id));
+ vlib_validate_combined_counter (&(bier_fmask_counters), bfmi);
+ vlib_zero_combined_counter (&(bier_fmask_counters), bfmi);
- ASSERT(1 == vec_len(rpaths));
- fib_node_init(&bfm->bfm_node, FIB_NODE_TYPE_BIER_FMASK);
bier_fmask_init(bfm, fmid, rpaths);
- bier_fmask_lock(bier_fmask_get_index(bfm));
+ bier_fmask_lock(bfmi);
- return (bier_fmask_get_index(bfm));
+ return (bfmi);
}
void
@@ -331,6 +341,7 @@ format_bier_fmask (u8 *s, va_list *ap)
u32 indent = va_arg(*ap, u32);
bier_fmask_attributes_t attr;
bier_fmask_t *bfm;
+ vlib_counter_t to;
if (pool_is_free_index(bier_fmask_pool, bfmi))
{
@@ -349,6 +360,8 @@ format_bier_fmask (u8 *s, va_list *ap)
s = format (s, "%s,", bier_fmask_attr_names[attr]);
}
}
+ vlib_get_combined_counter (&(bier_fmask_counters), bfmi, &to);
+ s = format (s, " to:[%Ld:%Ld]]", to.packets, to.bytes);
s = format(s, "\n");
s = fib_path_list_format(bfm->bfm_pl, s);
@@ -371,6 +384,43 @@ format_bier_fmask (u8 *s, va_list *ap)
return (s);
}
+void
+bier_fmask_get_stats (index_t bfmi, u64 * packets, u64 * bytes)
+{
+ vlib_counter_t to;
+
+ vlib_get_combined_counter (&(bier_fmask_counters), bfmi, &to);
+
+ *packets = to.packets;
+ *bytes = to.bytes;
+}
+
+void
+bier_fmask_encode (index_t bfmi,
+ bier_table_id_t *btid,
+ fib_route_path_encode_t *rpath)
+{
+ bier_fmask_t *bfm;
+
+ bfm = bier_fmask_get(bfmi);
+ *btid = *bier_table_get_id(bfm->bfm_id->bfmi_bti);
+
+ memset(rpath, 0, sizeof(*rpath));
+
+ rpath->rpath.frp_sw_if_index = ~0;
+
+ switch (bfm->bfm_id->bfmi_nh_type)
+ {
+ case BIER_NH_UDP:
+ rpath->rpath.frp_flags = FIB_ROUTE_PATH_UDP_ENCAP;
+ rpath->rpath.frp_udp_encap_id = bfm->bfm_id->bfmi_id;
+ break;
+ case BIER_NH_IP:
+ memcpy(&rpath->rpath.frp_addr, &bfm->bfm_id->bfmi_nh,
+ sizeof(rpath->rpath.frp_addr));
+ break;
+ }
+}
static fib_node_t *
bier_fmask_get_node (fib_node_index_t index)
diff --git a/src/vnet/bier/bier_fmask.h b/src/vnet/bier/bier_fmask.h
index 56930f6cd44..0666605c23f 100644
--- a/src/vnet/bier/bier_fmask.h
+++ b/src/vnet/bier/bier_fmask.h
@@ -163,6 +163,10 @@ extern u32 bier_fmask_child_add (fib_node_index_t fib_entry_index,
fib_node_index_t child_index);
extern void bier_fmask_child_remove (fib_node_index_t fib_entry_index,
u32 sibling_index);
+extern void bier_fmask_get_stats (index_t bfmi, u64 * packets, u64 * bytes);
+extern void bier_fmask_encode (index_t bfmi,
+ bier_table_id_t *btid,
+ fib_route_path_encode_t *rpath);
/*
* provided for fast data-path access
diff --git a/src/vnet/bier/bier_fmask_db.c b/src/vnet/bier/bier_fmask_db.c
index 67d3bd1cf85..59e2973b589 100644
--- a/src/vnet/bier/bier_fmask_db.c
+++ b/src/vnet/bier/bier_fmask_db.c
@@ -31,7 +31,7 @@ typedef struct bier_fmask_db_t_ {
/**
* hash table for underlying storage
*/
- mhash_t bfdb_hash;
+ uword *bfdb_hash;
/**
* Pool for memory
@@ -68,11 +68,12 @@ bier_fmask_db_mk_key (index_t bti,
if (FIB_ROUTE_PATH_UDP_ENCAP & rpath->frp_flags)
{
key->bfmi_id = rpath->frp_udp_encap_id;
+ key->bfmi_nh_type = BIER_NH_UDP;
}
else
{
- key->bfmi_sw_if_index = rpath->frp_sw_if_index;
memcpy(&key->bfmi_nh, &rpath->frp_addr, sizeof(rpath->frp_addr));
+ key->bfmi_nh_type = BIER_NH_IP;
}
if (NULL == rpath->frp_label_stack)
{
@@ -82,6 +83,7 @@ bier_fmask_db_mk_key (index_t bti,
{
key->bfmi_hdr_type = BIER_HDR_O_MPLS;
}
+ key->bfmi_bti = bti;
}
u32
@@ -92,7 +94,7 @@ bier_fmask_db_find (index_t bti,
uword *p;
bier_fmask_db_mk_key(bti, rpath, &fmid);
- p = mhash_get(&bier_fmask_db.bfdb_hash, &fmid);
+ p = hash_get_mem(bier_fmask_db.bfdb_hash, &fmid);
if (NULL != p)
{
@@ -111,7 +113,7 @@ bier_fmask_db_find_or_create_and_lock (index_t bti,
uword *p;
bier_fmask_db_mk_key(bti, rpath, &fmid);
- p = mhash_get(&bier_fmask_db.bfdb_hash, &fmid);
+ p = hash_get_mem(bier_fmask_db.bfdb_hash, &fmid);
if (NULL == p)
{
@@ -121,7 +123,7 @@ bier_fmask_db_find_or_create_and_lock (index_t bti,
*/
index = bier_fmask_create_and_lock(&fmid, rpath);
bfm = bier_fmask_get(index);
- mhash_set(&bier_fmask_db.bfdb_hash, bfm->bfm_id, index, 0);
+ hash_set_mem(bier_fmask_db.bfdb_hash, bfm->bfm_id, index);
}
else
{
@@ -137,7 +139,7 @@ bier_fmask_db_remove (const bier_fmask_id_t *fmid)
{
uword *p;
- p = mhash_get(&bier_fmask_db.bfdb_hash, fmid);
+ p = hash_get_mem(bier_fmask_db.bfdb_hash, fmid);
if (NULL == p) {
/*
@@ -145,16 +147,29 @@ bier_fmask_db_remove (const bier_fmask_id_t *fmid)
*/
ASSERT (!"remove non-existant fmask");
} else {
- mhash_unset(&(bier_fmask_db.bfdb_hash), (void*)fmid, 0);
+ hash_unset(bier_fmask_db.bfdb_hash, fmid);
}
}
+void
+bier_fmask_db_walk (bier_fmask_walk_fn_t fn, void *ctx)
+{
+ CLIB_UNUSED (bier_fmask_id_t *fmid);
+ uword *bfmi;
+
+ hash_foreach(fmid, bfmi, bier_fmask_db.bfdb_hash,
+ ({
+ if (WALK_STOP == fn(*bfmi, ctx))
+ break;
+ }));
+}
+
clib_error_t *
bier_fmask_db_module_init (vlib_main_t *vm)
{
- mhash_init(&bier_fmask_db.bfdb_hash,
- sizeof(index_t),
- sizeof(bier_fmask_id_t));
+ bier_fmask_db.bfdb_hash = hash_create_mem(0,
+ sizeof(bier_fmask_id_t),
+ sizeof(index_t));
return (NULL);
}
diff --git a/src/vnet/bier/bier_fmask_db.h b/src/vnet/bier/bier_fmask_db.h
index a7f29c2b6a6..36e555f8680 100644
--- a/src/vnet/bier/bier_fmask_db.h
+++ b/src/vnet/bier/bier_fmask_db.h
@@ -36,23 +36,28 @@ typedef enum bier_hdr_type_t_ {
* BIER header in non-MPLS networks
*/
BIER_HDR_O_OTHER,
-} bier_hdr_type_t;
+} __attribute__((packed)) bier_hdr_type_t;
/**
- * A key/ID for a BIER forwarding Mas (FMask).
- * This is a simplified version of a fib_route_path_t.
+ * BIER next-hop type
*/
-typedef struct bier_fmask_id_t_ {
+typedef enum bier_nh_type_t_ {
/**
- * Type of BIER header this fmask supports
+ * BIER Header in MPLS networks
*/
- bier_hdr_type_t bfmi_hdr_type;
+ BIER_NH_IP,
/**
- * The BIER table this fmask is in
+ * BIER header in non-MPLS networks
*/
- index_t bfmi_bti;
+ BIER_NH_UDP,
+} __attribute__((packed)) bier_nh_type_t;
+/**
+ * A key/ID for a BIER forwarding Mas (FMask).
+ * This is a simplified version of a fib_route_path_t.
+ */
+typedef struct bier_fmask_id_t_ {
union {
/**
* next-hop of the peer
@@ -64,11 +69,20 @@ typedef struct bier_fmask_id_t_ {
*/
u32 bfmi_id;
};
+ /**
+ * The BIER table this fmask is in
+ */
+ index_t bfmi_bti;
/**
- * Software interface index
+ * Type of BIER header this fmask supports
*/
- u32 bfmi_sw_if_index;
+ bier_hdr_type_t bfmi_hdr_type;
+
+ /**
+ * Union discriminatrr
+ */
+ bier_nh_type_t bfmi_nh_type;
} __attribute__((packed)) bier_fmask_id_t;
extern index_t
@@ -79,5 +93,11 @@ extern index_t bier_fmask_db_find (index_t bti,
extern void bier_fmask_db_remove (const bier_fmask_id_t *fmid);
+/**
+ * Walk all the BIER fmasks
+ */
+typedef walk_rc_t (*bier_fmask_walk_fn_t) (index_t bfmi, void *ctx);
+
+extern void bier_fmask_db_walk(bier_fmask_walk_fn_t fn, void *ctx);
#endif
diff --git a/src/vnet/bier/bier_output.c b/src/vnet/bier/bier_output.c
index 01eeffe475c..7f513fc7b48 100644
--- a/src/vnet/bier/bier_output.c
+++ b/src/vnet/bier/bier_output.c
@@ -49,6 +49,7 @@ typedef enum {
* Forward declaration
*/
vlib_node_registration_t bier_output_node;
+extern vlib_combined_counter_main_t bier_fmask_counters;
/**
* @brief Packet trace recoed for a BIER output
@@ -64,13 +65,14 @@ bier_output (vlib_main_t * vm,
vlib_node_runtime_t * node,
vlib_frame_t * from_frame)
{
+ vlib_combined_counter_main_t *cm = &bier_fmask_counters;
u32 n_left_from, next_index, * from, * to_next;
+ u32 thread_index;
+ thread_index = vlib_get_thread_index ();
from = vlib_frame_vector_args (from_frame);
n_left_from = from_frame->n_vectors;
- // vnet_buffer(b0)->sw_if_index[VLIB_TX] = d0->tx_fib_index;
-
/*
* objection your honour! speculation!
*/
@@ -112,6 +114,10 @@ bier_output (vlib_main_t * vm,
bfmi0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX];
bfm0 = bier_fmask_get(bfmi0);
+ vlib_increment_combined_counter(
+ cm, thread_index, bfmi0, 1,
+ vlib_buffer_length_in_chain (vm, b0));
+
/*
* perform the logical AND of the packet's mask with
* that of the fmask objects, to reset the bits that
diff --git a/src/vnet/udp/udp_encap.c b/src/vnet/udp/udp_encap.c
index 4b4d5412ca7..914680f98a2 100644
--- a/src/vnet/udp/udp_encap.c
+++ b/src/vnet/udp/udp_encap.c
@@ -599,7 +599,7 @@ udp_encap_walk (udp_encap_walk_cb_t cb, void *ctx)
/* *INDENT-OFF* */
pool_foreach_index(uei, udp_encap_pool,
({
- if (!cb(uei, ctx))
+ if (WALK_STOP == cb(uei, ctx))
break;
}));
/* *INDENT-ON* */
diff --git a/src/vnet/udp/udp_encap.h b/src/vnet/udp/udp_encap.h
index 185d5e7f7f9..e20edec7be5 100644
--- a/src/vnet/udp/udp_encap.h
+++ b/src/vnet/udp/udp_encap.h
@@ -131,7 +131,7 @@ extern void udp_encap_get_stats (index_t uei, u64 * packets, u64 * bytes);
* Callback function invoked when walking all encap objects.
* Return non-zero to continue the walk.
*/
-typedef int (*udp_encap_walk_cb_t) (index_t uei, void *ctx);
+typedef walk_rc_t (*udp_encap_walk_cb_t) (index_t uei, void *ctx);
/**
* Walk each of the encap objects
diff --git a/src/vpp/stats/stats.api b/src/vpp/stats/stats.api
index 72e03b0b40c..5d00908cca6 100644
--- a/src/vpp/stats/stats.api
+++ b/src/vpp/stats/stats.api
@@ -18,9 +18,10 @@
This file defines the stats API
*/
-option version = "1.0.0";
+option version = "1.0.1";
import "vnet/interface.api";
+import "vnet/bier/bier.api";
service {
rpc want_stats
@@ -58,6 +59,9 @@ service {
rpc want_udp_encap_stats
returns want_udp_encap_stats_reply
events vnet_udp_encap_counters;
+ rpc want_bier_neighbor_stats
+ returns want_bier_neighbor_stats_reply
+ events vnet_bier_neighbor_counters;
};
/** \brief Want Stats, enable/disable ALL stats updates
@@ -472,6 +476,41 @@ manual_print manual_endian define vnet_udp_encap_counters
vl_api_udp_encap_counter_t c[count];
};
+/** \brief Want BIER neighbor 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 - 1 = enable stats, 0 = disable
+ @param pid - pid of process requesting stats updates
+*/
+autoreply define want_bier_neighbor_stats
+{
+ u32 client_index;
+ u32 context;
+ u32 enable;
+ u32 pid;
+};
+
+/** \brief Stat for one BIER neighbor object
+ @param tbl_id - The BIER Table ID the neighbour belongs to.
+ @param path - The path describing the negihbor (this is the data
+ given during a BIER route add)
+ @param packets - number of packets sent
+ @param bytes - number of bytes sent
+*/
+typeonly manual_print manual_endian define bier_neighbor_counter
+{
+ vl_api_bier_table_id_t tbl_id;
+ vl_api_fib_path_t path;
+ u64 packets;
+ u64 bytes;
+};
+
+manual_print manual_endian define vnet_bier_neighbor_counters
+{
+ u32 timestamp;
+ u32 count;
+ vl_api_bier_neighbor_counter_t c[count];
+};
/*
* Local Variables:
diff --git a/src/vpp/stats/stats.c b/src/vpp/stats/stats.c
index 452871febdc..9f912109e6e 100644
--- a/src/vpp/stats/stats.c
+++ b/src/vpp/stats/stats.c
@@ -19,6 +19,9 @@
#include <vnet/mfib/mfib_entry.h>
#include <vnet/dpo/load_balance.h>
#include <vnet/udp/udp_encap.h>
+#include <vnet/bier/bier_fmask.h>
+#include <vnet/bier/bier_table.h>
+#include <vnet/fib/fib_api.h>
#define STATS_DEBUG 0
@@ -65,7 +68,8 @@ _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
_(WANT_IP6_NBR_STATS, want_ip6_nbr_stats) \
_(VNET_GET_SUMMARY_STATS, vnet_get_summary_stats) \
_(STATS_GET_POLLER_DELAY, stats_get_poller_delay) \
-_(WANT_UDP_ENCAP_STATS, want_udp_encap_stats)
+_(WANT_UDP_ENCAP_STATS, want_udp_encap_stats) \
+_(WANT_BIER_NEIGHBOR_STATS, want_bier_neighbor_stats)
#define vl_msg_name_crc_list
#include <vpp/stats/stats.api.h>
@@ -88,6 +92,7 @@ setup_message_id_table (api_main_t * am)
#define IP4_MFIB_COUNTER_BATCH_SIZE 24
#define IP6_MFIB_COUNTER_BATCH_SIZE 15
#define UDP_ENCAP_COUNTER_BATCH_SIZE (1024 / sizeof(vl_api_udp_encap_counter_t))
+#define BIER_NEIGHBOR_COUNTER_BATCH_SIZE (1024 / sizeof(vl_api_bier_neighbor_counter_t))
/* 5ms */
#define STATS_RELEASE_DELAY_NS (1000 * 1000 * 5)
@@ -1224,6 +1229,23 @@ ip4_nbr_stats_cb (adj_index_t ai, void *arg)
#define MIN(x,y) (((x)<(y))?(x):(y))
static void
+send_and_pause (stats_main_t * sm, svm_queue_t * q, u8 * mp)
+{
+ u8 pause = 0;
+
+ svm_queue_lock (q);
+ pause = svm_queue_is_full (q);
+
+ vl_msg_api_send_shmem_nolock (q, (u8 *) & mp);
+ svm_queue_unlock (q);
+ dsunlock (sm);
+
+ if (pause)
+ ip46_fib_stats_delay (sm, 0 /* sec */ ,
+ STATS_RELEASE_DELAY_NS);
+}
+
+static void
ip4_nbr_ship (stats_main_t * sm, ip4_nbr_stats_ctx_t * ctx)
{
api_main_t *am = sm->api_main;
@@ -1268,16 +1290,7 @@ ip4_nbr_ship (stats_main_t * sm, ip4_nbr_stats_ctx_t * ctx)
/*
* send to the shm q
*/
- svm_queue_lock (q);
- pause = svm_queue_is_full (q);
-
- vl_msg_api_send_shmem_nolock (q, (u8 *) & mp);
- svm_queue_unlock (q);
- dsunlock (sm);
-
- if (pause)
- ip46_fib_stats_delay (sm, 0 /* sec */ ,
- STATS_RELEASE_DELAY_NS);
+ send_and_pause (sm, q, (u8 *) & mp);
}
}
@@ -1423,16 +1436,7 @@ ip6_nbr_ship (stats_main_t * sm,
/*
* send to the shm q
*/
- svm_queue_lock (q);
- pause = svm_queue_is_full (q);
-
- vl_msg_api_send_shmem_nolock (q, (u8 *) & mp);
- svm_queue_unlock (q);
- dsunlock (sm);
-
- if (pause)
- ip46_fib_stats_delay (sm, 0 /* sec */ ,
- STATS_RELEASE_DELAY_NS);
+ send_and_pause(sm, q, (u8 *) & mp);
}
}
@@ -2138,31 +2142,25 @@ again:
vl_msg_api_free (mp);
}
-typedef struct udp_encap_stat_t_
-{
- u32 ue_id;
- u64 stats[2];
-} udp_encap_stat_t;
-
typedef struct udp_encap_stats_walk_t_
{
- udp_encap_stat_t *stats;
+ vl_api_udp_encap_counter_t *stats;
} udp_encap_stats_walk_t;
-static int
+static walk_rc_t
udp_encap_stats_walk_cb (index_t uei, void *arg)
{
udp_encap_stats_walk_t *ctx = arg;
- udp_encap_stat_t *stat;
+ vl_api_udp_encap_counter_t *stat;
udp_encap_t *ue;
ue = udp_encap_get (uei);
vec_add2 (ctx->stats, stat, 1);
- stat->ue_id = uei;
- udp_encap_get_stats (ue->ue_id, &stat->stats[0], &stat->stats[1]);
+ stat->id = ue->ue_id;
+ udp_encap_get_stats (ue->ue_id, &stat->packets, &stat->bytes);
- return (1);
+ return (WALK_CONTINUE);
}
static void
@@ -2213,23 +2211,14 @@ udp_encap_ship (udp_encap_stats_walk_t * ctx)
/*
* send to the shm q
*/
- svm_queue_lock (q);
- pause = svm_queue_is_full (q);
-
- vl_msg_api_send_shmem_nolock (q, (u8 *) & mp);
- svm_queue_unlock (q);
- dsunlock (sm);
-
- if (pause)
- ip46_fib_stats_delay (sm, 0 /* sec */ ,
- STATS_RELEASE_DELAY_NS);
+ send_and_pause (sm, q, (u8 *) & mp);
}
}
static void
do_udp_encap_counters (stats_main_t * sm)
{
- udp_encap_stat_t *stat;
+ vl_api_udp_encap_counter_t *stat;
udp_encap_stats_walk_t ctx = {
.stats = NULL,
@@ -2242,6 +2231,100 @@ do_udp_encap_counters (stats_main_t * sm)
udp_encap_ship (&ctx);
}
+typedef struct bier_neighbor_stats_walk_t_
+{
+ vl_api_bier_neighbor_counter_t *stats;
+} bier_neighbor_stats_walk_t;
+
+static walk_rc_t
+bier_neighbor_stats_walk_cb (index_t bfmi, void *arg)
+{
+ bier_neighbor_stats_walk_t *ctx = arg;
+ vl_api_bier_neighbor_counter_t *stat;
+ fib_route_path_encode_t rpath;
+ bier_table_id_t btid;
+
+ vec_add2 (ctx->stats, stat, 1);
+
+ bier_fmask_encode (bfmi, &btid, &rpath);
+
+ stat->tbl_id.bt_set = btid.bti_set;
+ stat->tbl_id.bt_sub_domain = btid.bti_sub_domain;
+ stat->tbl_id.bt_hdr_len_id = btid.bti_hdr_len;
+ fib_api_path_encode (&rpath, &stat->path);
+ bier_fmask_get_stats (bfmi, &stat->packets, &stat->bytes);
+
+ return (WALK_CONTINUE);
+}
+
+static void
+bier_neighbor_ship (bier_neighbor_stats_walk_t * ctx)
+{
+ vl_api_vnet_bier_neighbor_counters_t *mp;
+ vl_shmem_hdr_t *shmem_hdr;
+ stats_main_t *sm;
+ api_main_t *am;
+ svm_queue_t *q;
+
+ mp = NULL;
+ sm = &stats_main;
+ am = sm->api_main;
+ shmem_hdr = am->shmem_hdr;
+ q = shmem_hdr->vl_input_queue;
+
+ /*
+ * If the walk context has counters, which may be left over from the last
+ * suspend, then we continue from there.
+ */
+ while (0 != vec_len (ctx->stats))
+ {
+ u32 n_items = MIN (vec_len (ctx->stats),
+ BIER_NEIGHBOR_COUNTER_BATCH_SIZE);
+ u8 pause = 0;
+
+ dslock (sm, 0 /* release hint */ , 1 /* tag */ );
+
+ mp = vl_msg_api_alloc_as_if_client (sizeof (*mp) +
+ (n_items *
+ sizeof
+ (vl_api_bier_neighbor_counter_t)));
+ mp->_vl_msg_id = ntohs (VL_API_VNET_BIER_NEIGHBOR_COUNTERS);
+ mp->count = ntohl (n_items);
+
+ /*
+ * copy the counters from the back of the context, then we can easily
+ * 'erase' them by resetting the vector length.
+ * The order we push the stats to the caller is not important.
+ */
+ clib_memcpy (mp->c,
+ &ctx->stats[vec_len (ctx->stats) - n_items],
+ n_items * sizeof (*ctx->stats));
+
+ _vec_len (ctx->stats) = vec_len (ctx->stats) - n_items;
+
+ /*
+ * send to the shm q
+ */
+ send_and_pause (sm, q, (u8 *) & mp);
+ }
+}
+
+static void
+do_bier_neighbor_counters (stats_main_t * sm)
+{
+ vl_api_bier_neighbor_counter_t *stat;
+
+ bier_neighbor_stats_walk_t ctx = {
+ .stats = NULL,
+ };
+
+ dslock (sm, 0 /* release hint */ , 1 /* tag */ );
+ bier_fmask_db_walk (bier_neighbor_stats_walk_cb, &ctx);
+ dsunlock (sm);
+
+ bier_neighbor_ship (&ctx);
+}
+
int
stats_set_poller_delay (u32 poller_delay_sec)
{
@@ -2434,8 +2517,8 @@ stats_thread_fn (void *arg)
if (pool_elts (sm->stats_registrations[IDX_IP6_NBR_COUNTERS]))
do_ip6_nbr_counters (sm);
- if (pool_elts (sm->stats_registrations[IDX_UDP_ENCAP_COUNTERS]))
- do_udp_encap_counters (sm);
+ if (pool_elts (sm->stats_registrations[IDX_BIER_NEIGHBOR_COUNTERS]))
+ do_bier_neighbor_counters (sm);
}
}
@@ -2734,6 +2817,43 @@ reply:
}
static void
+vl_api_want_bier_neighbor_stats_t_handler (vl_api_want_bier_neighbor_stats_t *
+ mp)
+{
+ stats_main_t *sm = &stats_main;
+ vpe_client_registration_t rp;
+ vl_api_want_bier_neighbor_stats_reply_t *rmp;
+ uword *p;
+ i32 retval = 0;
+ vl_api_registration_t *reg;
+ u32 fib;
+
+ fib = ~0; //Using same mechanism as _per_interface_
+ rp.client_index = mp->client_index;
+ rp.client_pid = mp->pid;
+
+ handle_client_registration (&rp, IDX_BIER_NEIGHBOR_COUNTERS, fib,
+ mp->enable);
+
+reply:
+ reg = vl_api_client_index_to_registration (mp->client_index);
+
+ if (!reg)
+ {
+ sm->enable_poller = clear_client_for_stat (IDX_BIER_NEIGHBOR_COUNTERS,
+ fib, mp->client_index);
+ return;
+ }
+
+ rmp = vl_msg_api_alloc (sizeof (*rmp));
+ rmp->_vl_msg_id = ntohs (VL_API_WANT_BIER_NEIGHBOR_STATS_REPLY);
+ rmp->context = mp->context;
+ rmp->retval = retval;
+
+ vl_api_send_msg (reg, (u8 *) rmp);
+}
+
+static void
vl_api_want_stats_t_handler (vl_api_want_stats_t * mp)
{
stats_main_t *sm = &stats_main;
diff --git a/src/vpp/stats/stats.reg b/src/vpp/stats/stats.reg
index dbec8c912f9..8983e3960d8 100644
--- a/src/vpp/stats/stats.reg
+++ b/src/vpp/stats/stats.reg
@@ -42,3 +42,4 @@ stats_reg (PER_INTERFACE_SIMPLE_COUNTERS)
stats_reg (IP4_MFIB_COUNTERS)
stats_reg (IP6_MFIB_COUNTERS)
stats_reg (UDP_ENCAP_COUNTERS)
+stats_reg (BIER_NEIGHBOR_COUNTERS)