Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 18 additions & 22 deletions zebra/dplane_fpm_nl.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ struct fpm_nl_ctx {

/* Amount of data plane context processed. */
_Atomic uint32_t dplane_contexts;
/* Amount of data plane contexts enqueued. */
_Atomic uint32_t ctxqueue_len;
/* Peak amount of data plane contexts enqueued. */
_Atomic uint32_t ctxqueue_len_peak;

Expand Down Expand Up @@ -399,6 +397,12 @@ DEFUN(fpm_show_counters, fpm_show_counters_cmd,
FPM_STR
"FPM statistic counters\n")
{
uint32_t curr_queue_len;

frr_with_mutex (&gfnc->ctxqueue_mutex) {
curr_queue_len = dplane_ctx_queue_count(&gfnc->ctxqueue);
}

vty_out(vty, "%30s\n%30s\n", "FPM counters", "============");

#define SHOW_COUNTER(label, counter) \
Expand All @@ -412,8 +416,7 @@ DEFUN(fpm_show_counters, fpm_show_counters_cmd,
SHOW_COUNTER("Connection errors", gfnc->counters.connection_errors);
SHOW_COUNTER("Data plane items processed",
gfnc->counters.dplane_contexts);
SHOW_COUNTER("Data plane items enqueued",
gfnc->counters.ctxqueue_len);
SHOW_COUNTER("Data plane items enqueued", curr_queue_len);
SHOW_COUNTER("Data plane items queue peak",
gfnc->counters.ctxqueue_len_peak);
SHOW_COUNTER("Buffer full hits", gfnc->counters.buffer_full);
Expand All @@ -432,6 +435,12 @@ DEFUN(fpm_show_counters_json, fpm_show_counters_json_cmd,
"FPM statistic counters\n"
JSON_STR)
{
uint32_t curr_queue_len;

frr_with_mutex (&gfnc->ctxqueue_mutex) {
curr_queue_len = dplane_ctx_queue_count(&gfnc->ctxqueue);
}

struct json_object *jo;

jo = json_object_new_object();
Expand All @@ -445,8 +454,7 @@ DEFUN(fpm_show_counters_json, fpm_show_counters_json_cmd,
gfnc->counters.connection_errors);
json_object_int_add(jo, "data-plane-contexts",
gfnc->counters.dplane_contexts);
json_object_int_add(jo, "data-plane-contexts-queue",
gfnc->counters.ctxqueue_len);
json_object_int_add(jo, "data-plane-contexts-queue", curr_queue_len);
json_object_int_add(jo, "data-plane-contexts-queue-peak",
gfnc->counters.ctxqueue_len_peak);
json_object_int_add(jo, "buffer-full-hits", gfnc->counters.buffer_full);
Expand Down Expand Up @@ -1495,8 +1503,6 @@ static void fpm_process_queue(struct event *t)

/* Account the processed entries. */
processed_contexts++;
atomic_fetch_sub_explicit(&fnc->counters.ctxqueue_len, 1,
memory_order_relaxed);

dplane_ctx_set_status(ctx, ZEBRA_DPLANE_REQUEST_SUCCESS);
dplane_provider_enqueue_out_ctx(fnc->prov, ctx);
Expand Down Expand Up @@ -1670,7 +1676,7 @@ static int fpm_nl_process(struct zebra_dplane_provider *prov)
struct zebra_dplane_ctx *ctx;
struct fpm_nl_ctx *fnc;
int counter, limit;
uint64_t cur_queue, peak_queue = 0, stored_peak_queue;
uint64_t cur_queue = 0, peak_queue = 0, stored_peak_queue;

fnc = dplane_provider_get_data(prov);
limit = dplane_provider_get_work_limit(prov);
Expand All @@ -1684,20 +1690,12 @@ static int fpm_nl_process(struct zebra_dplane_provider *prov)
* anyway.
*/
if (fnc->socket != -1 && fnc->connecting == false) {
/*
* Update the number of queued contexts *before*
* enqueueing, to ensure counter consistency.
*/
atomic_fetch_add_explicit(&fnc->counters.ctxqueue_len,
1, memory_order_relaxed);

frr_with_mutex (&fnc->ctxqueue_mutex) {
dplane_ctx_enqueue_tail(&fnc->ctxqueue, ctx);
cur_queue =
dplane_ctx_queue_count(&fnc->ctxqueue);
}

cur_queue = atomic_load_explicit(
&fnc->counters.ctxqueue_len,
memory_order_relaxed);
if (peak_queue < cur_queue)
peak_queue = cur_queue;
continue;
Expand All @@ -1714,9 +1712,7 @@ static int fpm_nl_process(struct zebra_dplane_provider *prov)
atomic_store_explicit(&fnc->counters.ctxqueue_len_peak,
peak_queue, memory_order_relaxed);

if (atomic_load_explicit(&fnc->counters.ctxqueue_len,
memory_order_relaxed)
> 0)
if (cur_queue > 0)
event_add_event(fnc->fthread->master, fpm_process_queue, fnc, 0,
&fnc->t_dequeue);

Expand Down
5 changes: 5 additions & 0 deletions zebra/zebra_dplane.c
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,11 @@ struct zebra_dplane_ctx *dplane_ctx_dequeue(struct dplane_ctx_list_head *q)
return ctx;
}

uint32_t dplane_ctx_queue_count(struct dplane_ctx_list_head *q)
{
return dplane_ctx_list_count(q);
}

/*
* Accessors for information from the context object
*/
Expand Down
2 changes: 2 additions & 0 deletions zebra/zebra_dplane.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ struct zebra_dplane_ctx *dplane_ctx_get_head(struct dplane_ctx_list_head *q);
/* Init a list of contexts */
void dplane_ctx_q_init(struct dplane_ctx_list_head *q);

uint32_t dplane_ctx_queue_count(struct dplane_ctx_list_head *q);

/*
* Accessors for information from the context object
*/
Expand Down