Skip to content
Draft
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
874 changes: 434 additions & 440 deletions docs/graph.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 0 additions & 5 deletions modules/infra/api/affinity.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include <gr_api.h>
#include <gr_config.h>
#include <gr_control_output.h>
#include <gr_infra.h>
#include <gr_module.h>
#include <gr_port.h>
Expand Down Expand Up @@ -38,10 +37,6 @@ static struct api_out affinity_set(const void *request, void ** /*response*/) {
if (ret < 0)
goto out;

ret = -control_output_set_affinity(CPU_SETSIZE, &req->control_cpus);
if (ret < 0)
goto out;

gr_config.control_cpus = req->control_cpus;
}
if (CPU_COUNT(&req->datapath_cpus) > 0) {
Expand Down
45 changes: 44 additions & 1 deletion modules/infra/api/stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,17 @@ static struct api_out stats_get(const void *request, void **response) {
continue;
for (unsigned i = 0; i < w_stats->n_stats; i++) {
const struct node_stats *n = &w_stats->stats[i];
const char *name = rte_node_id_to_name(n->node_id);
const struct rte_node_register *nr = gr_node_info_get(n->node_id)
->node;
char name[RTE_NODE_NAMESIZE];
snprintf(
Comment on lines +53 to +56

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

snprintf return value is not checked; truncated node names could be silently dropped—consider handling truncation.

Comment on lines +53 to +56

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return value of snprintf is not checked; truncation of name would be silent.

name,
RTE_NODE_NAMESIZE,
"%s%c",
rte_node_id_to_name(n->node_id),
nr->flags & GR_NODE_FLAG_CONTROL_PLANE ? '*' : '\0'
);

s = find_stat(stats, name);
if (s != NULL) {
s->objs += n->objs;
Expand All @@ -66,6 +76,39 @@ static struct api_out stats_get(const void *request, void **response) {
gr_vec_add(stats, stat);
}
}

if (worker->stats_ctl)
for (unsigned i = 0; i < worker->stats_ctl->n_stats; i++) {
const struct node_stats *n = &w_stats->stats[i];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Critical: Wrong stats array accessed.

Line 82 is accessing the wrong stats array - it should use worker->stats_ctl->stats[i] instead of w_stats->stats[i].

Apply this diff to fix the array access:

-				const struct node_stats *n = &w_stats->stats[i];
+				const struct node_stats *n = &worker->stats_ctl->stats[i];
🤖 Prompt for AI Agents
In modules/infra/api/stats.c at line 82, the code incorrectly accesses the stats
array using w_stats->stats[i]. To fix this, replace w_stats->stats[i] with
worker->stats_ctl->stats[i] to ensure the correct stats array is accessed as
intended.

const struct rte_node_register *nr = gr_node_info_get(
n->node_id
)
->node;
char name[RTE_NODE_NAMESIZE];
snprintf(
name,
RTE_NODE_NAMESIZE,
"%s%c",
rte_node_id_to_name(n->node_id),
nr->flags & GR_NODE_FLAG_CONTROL_PLANE ? '*' : '\0'
);

s = find_stat(stats, name);
if (s != NULL) {
s->objs += n->objs;
s->calls += n->calls;
s->cycles += n->cycles;
} else {
struct stat stat = {
.objs = n->objs,
.calls = n->calls,
.cycles = n->cycles,
};
memccpy(stat.name, name, 0, sizeof(stat.name));
gr_vec_add(stats, stat);
}
}

s = find_stat(stats, "idle");
if (s != NULL) {
s->calls += w_stats->n_sleeps;
Expand Down
117 changes: 0 additions & 117 deletions modules/infra/control/control_output.c

This file was deleted.

4 changes: 4 additions & 0 deletions modules/infra/control/gr_graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#include <sys/queue.h>

#define RTE_GRAPH_MODEL_SELECT RTE_GRAPH_MODEL_MCORE_DISPATCH

#ifdef __GROUT_UNIT_TEST__
#include <gr_cmocka.h>

Expand Down Expand Up @@ -39,6 +41,8 @@ int drop_format(char *buf, size_t buf_len, const void *data, size_t data_len);
typedef void (*gr_node_register_cb_t)(void);

struct gr_node_info {
// Flag used in node->flags to specify that a node is running on a control plane thread
#define GR_NODE_FLAG_CONTROL_PLANE (1 << 31)
struct rte_node_register *node;
gr_node_register_cb_t register_callback;
gr_node_register_cb_t unregister_callback;
Expand Down
1 change: 0 additions & 1 deletion modules/infra/control/gr_loopback.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@

#include <rte_byteorder.h>

void loopback_tx(struct rte_mbuf *m);
control_input_t loopback_get_control_id(void);
void loopback_input_add_type(rte_be16_t eth_type, const char *next_node);
5 changes: 5 additions & 0 deletions modules/infra/control/gr_worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ struct worker {
pthread_t thread;
struct queue_map *rxqs;
struct queue_map *txqs;

struct rte_graph *base[2]; // Base graph, not walked
struct rte_graph *ctl_graph[2]; // graph used to process ctl packets
_Atomic(const struct worker_stats *) stats_ctl;

STAILQ_ENTRY(worker) next;
} __rte_cache_aligned;

Expand Down
Loading