1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(C) 2020 Marvell International Ltd. 3 * Copyright(C) 2023 Intel Corporation 4 */ 5 6 #include "rte_graph_worker_common.h" 7 8 /** 9 * Perform graph walk on the circular buffer and invoke the process function 10 * of the nodes and collect the stats. 11 * 12 * @param graph 13 * Graph pointer returned from rte_graph_lookup function. 14 * 15 * @see rte_graph_lookup() 16 */ 17 static inline void rte_graph_walk_rtc(struct rte_graph * graph)18rte_graph_walk_rtc(struct rte_graph *graph) 19 { 20 const rte_graph_off_t *cir_start = graph->cir_start; 21 const rte_node_t mask = graph->cir_mask; 22 uint32_t head = graph->head; 23 struct rte_node *node; 24 25 /* 26 * Walk on the source node(s) ((cir_start - head) -> cir_start) and then 27 * on the pending streams (cir_start -> (cir_start + mask) -> cir_start) 28 * in a circular buffer fashion. 29 * 30 * +-----+ <= cir_start - head [number of source nodes] 31 * | | 32 * | ... | <= source nodes 33 * | | 34 * +-----+ <= cir_start [head = 0] [tail = 0] 35 * | | 36 * | ... | <= pending streams 37 * | | 38 * +-----+ <= cir_start + mask 39 */ 40 while (likely(head != graph->tail)) { 41 node = (struct rte_node *)RTE_PTR_ADD(graph, cir_start[(int32_t)head++]); 42 __rte_node_process(graph, node); 43 head = likely((int32_t)head > 0) ? head & mask : head; 44 } 45 graph->tail = 0; 46 } 47