> -----Original Message-----
> From: Zhirun Yan <zhirun....@intel.com>
> Sent: Friday, March 31, 2023 9:33 AM
> To: dev@dpdk.org; Jerin Jacob Kollanukkaran <jer...@marvell.com>; Kiran
> Kumar Kokkilagadda <kirankum...@marvell.com>; Nithin Kumar Dabilpuram
> <ndabilpu...@marvell.com>; step...@networkplumber.org
> Cc: cunming.li...@intel.com; haiyue.w...@intel.com; Zhirun Yan
> <zhirun....@intel.com>
> Subject: [EXT] [PATCH v5 02/15] graph: split graph worker into common and
> default model
> 
> External Email
> 
> ----------------------------------------------------------------------
> To support multiple graph worker model, split graph into common
> and default. Naming the current walk function as rte_graph_model_rtc
> cause the default model is RTC(Run-to-completion).
> 
> Signed-off-by: Haiyue Wang <haiyue.w...@intel.com>
> Signed-off-by: Cunming Liang <cunming.li...@intel.com>
> Signed-off-by: Zhirun Yan <zhirun....@intel.com>
> ---
>  lib/graph/graph_pcap.c              |  2 +-
>  lib/graph/graph_private.h           |  2 +-
>  lib/graph/meson.build               |  2 +-
>  lib/graph/rte_graph_model_rtc.h     | 61
> +++++++++++++++++++++++++++++
>  lib/graph/rte_graph_worker.h        | 34 ++++++++++++++++
>  lib/graph/rte_graph_worker_common.h | 57 ---------------------------
>  6 files changed, 98 insertions(+), 60 deletions(-)
>  create mode 100644 lib/graph/rte_graph_model_rtc.h
>  create mode 100644 lib/graph/rte_graph_worker.h
> 
> diff --git a/lib/graph/graph_pcap.c b/lib/graph/graph_pcap.c
> index 8a220370fa..6c43330029 100644
> --- a/lib/graph/graph_pcap.c
> +++ b/lib/graph/graph_pcap.c
> @@ -10,7 +10,7 @@
>  #include <rte_mbuf.h>
>  #include <rte_pcapng.h>
> 
> -#include "rte_graph_worker_common.h"
> +#include "rte_graph_worker.h"
> 
>  #include "graph_pcap_private.h"
> 
> diff --git a/lib/graph/graph_private.h b/lib/graph/graph_private.h
> index f08dbc7e9d..7d1b30b8ac 100644
> --- a/lib/graph/graph_private.h
> +++ b/lib/graph/graph_private.h
> @@ -12,7 +12,7 @@
>  #include <rte_eal.h>
> 
>  #include "rte_graph.h"
> -#include "rte_graph_worker_common.h"
> +#include "rte_graph_worker.h"
> 
>  extern int rte_graph_logtype;
> 
> diff --git a/lib/graph/meson.build b/lib/graph/meson.build
> index 4e2b612ad3..3526d1b5d4 100644
> --- a/lib/graph/meson.build
> +++ b/lib/graph/meson.build
> @@ -16,6 +16,6 @@ sources = files(
>          'graph_populate.c',
>          'graph_pcap.c',
>  )
> -headers = files('rte_graph.h', 'rte_graph_worker_common.h')
> +headers = files('rte_graph.h', 'rte_graph_worker.h')
> 
>  deps += ['eal', 'pcapng']
> diff --git a/lib/graph/rte_graph_model_rtc.h
> b/lib/graph/rte_graph_model_rtc.h
> new file mode 100644
> index 0000000000..665560f831
> --- /dev/null
> +++ b/lib/graph/rte_graph_model_rtc.h
> @@ -0,0 +1,61 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(C) 2023 Intel Corporation
> + */
> +

Please retain Marvell copyright too.

> +#include "rte_graph_worker_common.h"
> +
> +/**
> + * Perform graph walk on the circular buffer and invoke the process
> function
> + * of the nodes and collect the stats.
> + *
> + * @param graph
> + *   Graph pointer returned from rte_graph_lookup function.
> + *
> + * @see rte_graph_lookup()
> + */
> +static inline void
> +rte_graph_walk_rtc(struct rte_graph *graph)
> +{
> +     const rte_graph_off_t *cir_start = graph->cir_start;
> +     const rte_node_t mask = graph->cir_mask;
> +     uint32_t head = graph->head;
> +     struct rte_node *node;
> +     uint64_t start;
> +     uint16_t rc;
> +     void **objs;
> +
> +     /*
> +      * Walk on the source node(s) ((cir_start - head) -> cir_start) and
> then
> +      * on the pending streams (cir_start -> (cir_start + mask) -> cir_start)
> +      * in a circular buffer fashion.
> +      *
> +      *      +-----+ <= cir_start - head [number of source nodes]
> +      *      |     |
> +      *      | ... | <= source nodes
> +      *      |     |
> +      *      +-----+ <= cir_start [head = 0] [tail = 0]
> +      *      |     |
> +      *      | ... | <= pending streams
> +      *      |     |
> +      *      +-----+ <= cir_start + mask
> +      */
> +     while (likely(head != graph->tail)) {
> +             node = (struct rte_node *)RTE_PTR_ADD(graph,
> cir_start[(int32_t)head++]);
> +             RTE_ASSERT(node->fence == RTE_GRAPH_FENCE);
> +             objs = node->objs;
> +             rte_prefetch0(objs);
> +
> +             if (rte_graph_has_stats_feature()) {
> +                     start = rte_rdtsc();
> +                     rc = node->process(graph, node, objs, node->idx);
> +                     node->total_cycles += rte_rdtsc() - start;
> +                     node->total_calls++;
> +                     node->total_objs += rc;
> +             } else {
> +                     node->process(graph, node, objs, node->idx);
> +             }
> +                     node->idx = 0;
> +                     head = likely((int32_t)head > 0) ? head & mask :
> head;
> +     }
> +     graph->tail = 0;
> +}
> diff --git a/lib/graph/rte_graph_worker.h b/lib/graph/rte_graph_worker.h
> new file mode 100644
> index 0000000000..7ea18ba80a
> --- /dev/null
> +++ b/lib/graph/rte_graph_worker.h
> @@ -0,0 +1,34 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(C) 2023 Intel Corporation
> + */
> +
> +#ifndef _RTE_GRAPH_WORKER_H_
> +#define _RTE_GRAPH_WORKER_H_
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +#include "rte_graph_model_rtc.h"
> +
> +/**
> + * Perform graph walk on the circular buffer and invoke the process
> function
> + * of the nodes and collect the stats.
> + *
> + * @param graph
> + *   Graph pointer returned from rte_graph_lookup function.
> + *
> + * @see rte_graph_lookup()
> + */
> +__rte_experimental
> +static inline void
> +rte_graph_walk(struct rte_graph *graph)
> +{
> +     rte_graph_walk_rtc(graph);
> +}
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif /* _RTE_GRAPH_WORKER_H_ */
> diff --git a/lib/graph/rte_graph_worker_common.h
> b/lib/graph/rte_graph_worker_common.h
> index 0bad2938f3..b58f8f6947 100644
> --- a/lib/graph/rte_graph_worker_common.h
> +++ b/lib/graph/rte_graph_worker_common.h
> @@ -128,63 +128,6 @@ __rte_experimental
>  void __rte_node_stream_alloc_size(struct rte_graph *graph,
>                                 struct rte_node *node, uint16_t req_size);
> 
> -/**
> - * Perform graph walk on the circular buffer and invoke the process function
> - * of the nodes and collect the stats.
> - *
> - * @param graph
> - *   Graph pointer returned from rte_graph_lookup function.
> - *
> - * @see rte_graph_lookup()
> - */
> -__rte_experimental
> -static inline void
> -rte_graph_walk(struct rte_graph *graph)
> -{
> -     const rte_graph_off_t *cir_start = graph->cir_start;
> -     const rte_node_t mask = graph->cir_mask;
> -     uint32_t head = graph->head;
> -     struct rte_node *node;
> -     uint64_t start;
> -     uint16_t rc;
> -     void **objs;
> -
> -     /*
> -      * Walk on the source node(s) ((cir_start - head) -> cir_start) and
> then
> -      * on the pending streams (cir_start -> (cir_start + mask) -> cir_start)
> -      * in a circular buffer fashion.
> -      *
> -      *      +-----+ <= cir_start - head [number of source nodes]
> -      *      |     |
> -      *      | ... | <= source nodes
> -      *      |     |
> -      *      +-----+ <= cir_start [head = 0] [tail = 0]
> -      *      |     |
> -      *      | ... | <= pending streams
> -      *      |     |
> -      *      +-----+ <= cir_start + mask
> -      */
> -     while (likely(head != graph->tail)) {
> -             node = (struct rte_node *)RTE_PTR_ADD(graph,
> cir_start[(int32_t)head++]);
> -             RTE_ASSERT(node->fence == RTE_GRAPH_FENCE);
> -             objs = node->objs;
> -             rte_prefetch0(objs);
> -
> -             if (rte_graph_has_stats_feature()) {
> -                     start = rte_rdtsc();
> -                     rc = node->process(graph, node, objs, node->idx);
> -                     node->total_cycles += rte_rdtsc() - start;
> -                     node->total_calls++;
> -                     node->total_objs += rc;
> -             } else {
> -                     node->process(graph, node, objs, node->idx);
> -             }
> -             node->idx = 0;
> -             head = likely((int32_t)head > 0) ? head & mask : head;
> -     }
> -     graph->tail = 0;
> -}
> -
>  /* Fast path helper functions */
> 
>  /**
> --
> 2.37.2

Reply via email to