LCOV - code coverage report
Current view: top level - lib/graph - rte_graph_model_mcore_dispatch.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 12 18 66.7 %
Date: 2024-02-14 00:53:57 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 7 18 38.9 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(C) 2023 Intel Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #ifndef _RTE_GRAPH_MODEL_MCORE_DISPATCH_H_
       6                 :            : #define _RTE_GRAPH_MODEL_MCORE_DISPATCH_H_
       7                 :            : 
       8                 :            : /**
       9                 :            :  * @file rte_graph_model_mcore_dispatch.h
      10                 :            :  *
      11                 :            :  * These APIs allow to set core affinity with the node and only used for mcore
      12                 :            :  * dispatch model.
      13                 :            :  */
      14                 :            : 
      15                 :            : #ifdef __cplusplus
      16                 :            : extern "C" {
      17                 :            : #endif
      18                 :            : 
      19                 :            : #include <rte_errno.h>
      20                 :            : #include <rte_mempool.h>
      21                 :            : #include <rte_memzone.h>
      22                 :            : #include <rte_ring.h>
      23                 :            : 
      24                 :            : #include "rte_graph_worker_common.h"
      25                 :            : 
      26                 :            : #define RTE_GRAPH_SCHED_WQ_SIZE_MULTIPLIER  8
      27                 :            : #define RTE_GRAPH_SCHED_WQ_SIZE(nb_nodes)   \
      28                 :            :         ((typeof(nb_nodes))((nb_nodes) * RTE_GRAPH_SCHED_WQ_SIZE_MULTIPLIER))
      29                 :            : 
      30                 :            : /**
      31                 :            :  * @internal
      32                 :            :  *
      33                 :            :  * Schedule the node to the right graph's work queue for mcore dispatch model.
      34                 :            :  *
      35                 :            :  * @param node
      36                 :            :  *   Pointer to the scheduled node object.
      37                 :            :  * @param rq
      38                 :            :  *   Pointer to the scheduled run-queue for all graphs.
      39                 :            :  *
      40                 :            :  * @return
      41                 :            :  *   True on success, false otherwise.
      42                 :            :  *
      43                 :            :  * @note
      44                 :            :  * This implementation is used by mcore dispatch model only and user application
      45                 :            :  * should not call it directly.
      46                 :            :  */
      47                 :            : bool __rte_noinline __rte_graph_mcore_dispatch_sched_node_enqueue(struct rte_node *node,
      48                 :            :                                                                   struct rte_graph_rq_head *rq);
      49                 :            : 
      50                 :            : /**
      51                 :            :  * @internal
      52                 :            :  *
      53                 :            :  * Process all nodes (streams) in the graph's work queue for mcore dispatch model.
      54                 :            :  *
      55                 :            :  * @param graph
      56                 :            :  *   Pointer to the graph object.
      57                 :            :  *
      58                 :            :  * @note
      59                 :            :  * This implementation is used by mcore dispatch model only and user application
      60                 :            :  * should not call it directly.
      61                 :            :  */
      62                 :            : void __rte_graph_mcore_dispatch_sched_wq_process(struct rte_graph *graph);
      63                 :            : 
      64                 :            : /**
      65                 :            :  * Set lcore affinity with the node used for mcore dispatch model.
      66                 :            :  *
      67                 :            :  * @param name
      68                 :            :  *   Valid node name. In the case of the cloned node, the name will be
      69                 :            :  * "parent node name" + "-" + name.
      70                 :            :  * @param lcore_id
      71                 :            :  *   The lcore ID value.
      72                 :            :  *
      73                 :            :  * @return
      74                 :            :  *   0 on success, error otherwise.
      75                 :            :  */
      76                 :            : int rte_graph_model_mcore_dispatch_node_lcore_affinity_set(const char *name,
      77                 :            :                                                            unsigned int lcore_id);
      78                 :            : 
      79                 :            : /**
      80                 :            :  * Perform graph walk on the circular buffer and invoke the process function
      81                 :            :  * of the nodes and collect the stats.
      82                 :            :  *
      83                 :            :  * @param graph
      84                 :            :  *   Graph pointer returned from rte_graph_lookup function.
      85                 :            :  *
      86                 :            :  * @see rte_graph_lookup()
      87                 :            :  */
      88                 :            : static inline void
      89                 :          5 : rte_graph_walk_mcore_dispatch(struct rte_graph *graph)
      90                 :            : {
      91                 :          5 :         const rte_graph_off_t *cir_start = graph->cir_start;
      92                 :          5 :         const rte_node_t mask = graph->cir_mask;
      93                 :          5 :         uint32_t head = graph->head;
      94                 :            :         struct rte_node *node;
      95                 :            : 
      96         [ -  + ]:          5 :         if (graph->dispatch.wq != NULL)
      97                 :          0 :                 __rte_graph_mcore_dispatch_sched_wq_process(graph);
      98                 :            : 
      99         [ +  + ]:         45 :         while (likely(head != graph->tail)) {
     100                 :         40 :                 node = (struct rte_node *)RTE_PTR_ADD(graph, cir_start[(int32_t)head++]);
     101                 :            : 
     102                 :            :                 /* skip the src nodes which not bind with current worker */
     103   [ -  +  -  - ]:         40 :                 if ((int32_t)head < 0 && node->dispatch.lcore_id != graph->dispatch.lcore_id)
     104                 :          0 :                         continue;
     105                 :            : 
     106                 :            :                 /* Schedule the node until all task/objs are done */
     107         [ -  + ]:         40 :                 if (node->dispatch.lcore_id != RTE_MAX_LCORE &&
     108         [ #  # ]:          0 :                     graph->dispatch.lcore_id != node->dispatch.lcore_id &&
     109   [ #  #  #  # ]:          0 :                     graph->dispatch.rq != NULL &&
     110                 :          0 :                     __rte_graph_mcore_dispatch_sched_node_enqueue(node, graph->dispatch.rq))
     111                 :          0 :                         continue;
     112                 :            : 
     113                 :            :                 __rte_node_process(graph, node);
     114                 :            : 
     115         [ +  + ]:         40 :                 head = likely((int32_t)head > 0) ? head & mask : head;
     116                 :            :         }
     117                 :            : 
     118                 :          5 :         graph->tail = 0;
     119                 :          5 : }
     120                 :            : 
     121                 :            : #ifdef __cplusplus
     122                 :            : }
     123                 :            : #endif
     124                 :            : 
     125                 :            : #endif /* _RTE_GRAPH_MODEL_MCORE_DISPATCH_H_ */

Generated by: LCOV version 1.14