| 156 | }; |
| 157 | |
| 158 | static struct rte_graph_cluster_stats * |
| 159 | stats_mem_init(struct cluster *cluster, |
| 160 | const struct rte_graph_cluster_stats_param *prm) |
| 161 | { |
| 162 | size_t sz = sizeof(struct rte_graph_cluster_stats); |
| 163 | struct rte_graph_cluster_stats *stats; |
| 164 | rte_graph_cluster_stats_cb_t fn; |
| 165 | int socket_id = prm->socket_id; |
| 166 | uint32_t cluster_node_size; |
| 167 | |
| 168 | /* Fix up callback */ |
| 169 | fn = prm->fn; |
| 170 | if (fn == NULL) { |
| 171 | const struct rte_graph *graph = cluster->graphs[0]->graph; |
| 172 | if (graph->model == RTE_GRAPH_MODEL_MCORE_DISPATCH) |
| 173 | fn = graph_cluster_stats_cb_dispatch; |
| 174 | else |
| 175 | fn = graph_cluster_stats_cb_rtc; |
| 176 | } |
| 177 | |
| 178 | cluster_node_size = sizeof(struct cluster_node); |
| 179 | /* For a given cluster, max nodes will be the max number of graphs */ |
| 180 | cluster_node_size += cluster->nb_graphs * sizeof(struct rte_node *); |
| 181 | cluster_node_size = RTE_ALIGN(cluster_node_size, RTE_CACHE_LINE_SIZE); |
| 182 | |
| 183 | stats = realloc(NULL, sz); |
| 184 | if (stats) { |
| 185 | memset(stats, 0, sz); |
| 186 | stats->fn = fn; |
| 187 | stats->cluster_node_size = cluster_node_size; |
| 188 | stats->max_nodes = 0; |
| 189 | stats->socket_id = socket_id; |
| 190 | stats->cookie = prm->cookie; |
| 191 | stats->sz = sz; |
| 192 | } |
| 193 | |
| 194 | return stats; |
| 195 | } |
| 196 | |
| 197 | static int |
| 198 | stats_mem_populate(struct rte_graph_cluster_stats **stats_in, |
no test coverage detected