| 195 | } |
| 196 | |
| 197 | static int |
| 198 | stats_mem_populate(struct rte_graph_cluster_stats **stats_in, |
| 199 | struct rte_graph *graph, struct graph_node *graph_node) |
| 200 | { |
| 201 | struct rte_graph_cluster_stats *stats = *stats_in; |
| 202 | rte_node_t id = graph_node->node->id; |
| 203 | struct cluster_node *cluster; |
| 204 | struct rte_node *node; |
| 205 | rte_node_t count; |
| 206 | |
| 207 | cluster = stats->clusters; |
| 208 | |
| 209 | /* Iterate over cluster node array to find node ID match */ |
| 210 | for (count = 0; count < stats->max_nodes; count++) { |
| 211 | /* Found an existing node in the reel */ |
| 212 | if (cluster->stat.id == id) { |
| 213 | node = graph_node_id_to_ptr(graph, id); |
| 214 | if (node == NULL) |
| 215 | SET_ERR_JMP( |
| 216 | ENOENT, err, |
| 217 | "Failed to find node %s in graph %s", |
| 218 | graph_node->node->name, graph->name); |
| 219 | |
| 220 | cluster->nodes[cluster->nb_nodes++] = node; |
| 221 | return 0; |
| 222 | } |
| 223 | cluster = RTE_PTR_ADD(cluster, stats->cluster_node_size); |
| 224 | } |
| 225 | |
| 226 | /* Hey, it is a new node, allocate space for it in the reel */ |
| 227 | stats = realloc(stats, stats->sz + stats->cluster_node_size); |
| 228 | if (stats == NULL) |
| 229 | SET_ERR_JMP(ENOMEM, err, "Realloc failed"); |
| 230 | *stats_in = NULL; |
| 231 | |
| 232 | /* Clear the new struct cluster_node area */ |
| 233 | cluster = RTE_PTR_ADD(stats, stats->sz), |
| 234 | memset(cluster, 0, stats->cluster_node_size); |
| 235 | memcpy(cluster->stat.name, graph_node->node->name, RTE_NODE_NAMESIZE); |
| 236 | cluster->stat.id = graph_node->node->id; |
| 237 | cluster->stat.hz = rte_get_timer_hz(); |
| 238 | node = graph_node_id_to_ptr(graph, id); |
| 239 | if (node == NULL) |
| 240 | SET_ERR_JMP(ENOENT, free, "Failed to find node %s in graph %s", |
| 241 | graph_node->node->name, graph->name); |
| 242 | cluster->nodes[cluster->nb_nodes++] = node; |
| 243 | |
| 244 | stats->sz += stats->cluster_node_size; |
| 245 | stats->max_nodes++; |
| 246 | *stats_in = stats; |
| 247 | |
| 248 | return 0; |
| 249 | free: |
| 250 | free(stats); |
| 251 | err: |
| 252 | return -rte_errno; |
| 253 | } |
| 254 |
no test coverage detected