Branch data Line data Source code
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 pending bitmap and invoke the process function 10 : : * of the nodes and collect the stats. 11 : : * 12 : : * Nodes are visited in topological order (upstream before downstream). 13 : : * Source nodes are seeded into the pending bitmap at the start of each walk. 14 : : * 15 : : * @param graph 16 : : * Graph pointer returned from rte_graph_lookup function. 17 : : * 18 : : * @see rte_graph_lookup() 19 : : */ 20 : : static inline void 21 : 20 : rte_graph_walk_rtc(struct rte_graph *graph) 22 : : { 23 : 20 : const uint16_t nwords = graph->nb_sched_words; 24 : : struct rte_node *node; 25 : : uint16_t word, bit; 26 : : 27 : : /* 28 : : * Nodes are assigned a bit position (sched_idx) sorted by 29 : : * (topo_order, node_id) at graph creation time. Source nodes have 30 : : * topo_order 0, so they always come first. 31 : : * 32 : : * sched_table[] maps bit positions to node offsets: 33 : : * 34 : : * pending[] sched_table[] 35 : : * +----------+ +------------------+ 36 : : * | word 0 | ---> | src_node_0 | bit 0 (depth=0) 37 : : * | 1100...1 | | src_node_1 | bit 1 (depth=0) 38 : : * | | | eth_input | bit 2 (depth=1) 39 : : * | | | mpls_input | bit 3 (depth=2) 40 : : * | | | ipv4_input | bit 4 (depth=3) 41 : : * | | | ... | 42 : : * +----------+ +------------------+ 43 : : * | word 1 | ---> | ip4_rewrite | bit 64 (depth=4) 44 : : * | ... | | ... | 45 : : * +----------+ +------------------+ 46 : : * 47 : : * Walk: for each word, find lowest set bit (rte_ctz64), process 48 : : * that node, clear the bit, re-read the word (processing may 49 : : * have set new bits), repeat. 50 : : */ 51 : : 52 : : /* Seed pending bitmap with source nodes */ 53 [ + + ]: 40 : for (word = 0; word < nwords; word++) 54 : 20 : graph->pending[word] |= graph->src_pending[word]; 55 : : 56 : : for (;;) { 57 : : /* find first word with any pending bit */ 58 [ + + ]: 78 : for (word = 0; word < nwords; word++) 59 [ + + ]: 58 : if (graph->pending[word]) 60 : : break; 61 [ + + ]: 58 : if (word == nwords) 62 : : break; /* no more pending nodes */ 63 : : 64 : 38 : bit = rte_ctz64(graph->pending[word]); 65 : 38 : graph->pending[word] &= ~(1ULL << bit); 66 : : node = __rte_graph_pending_node(graph, word, bit); 67 : : __rte_node_process(graph, node); 68 : : } 69 : 20 : }