From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3CA5642C46; Wed, 7 Jun 2023 06:00:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2842442B8E; Wed, 7 Jun 2023 06:00:16 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 78FE341149 for ; Wed, 7 Jun 2023 06:00:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686110414; x=1717646414; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zGmy4M/KmHqnKXj+x7V5VYTe7/K5AqJAn1bfsRAnPYE=; b=fqHcRsAgRM4WNq/W/UJ73xhm3BK1zDUygV/jfeJ14hG8h+Ll4o2SpRjN gu4vv7OFdYTNU5Od072SBgWl/cfkXn0wjiF1La3yg88lJGSeimRF3ysCX Ck6UW2+FOotqNsvWO2SmR1tvwQzVruI0Wo+2X6/WMHL7iq7hnD8NtzivX /qrN2k0iGos9rHOlO6Pk2XOyRsvRVw9r7LCBOYEKCmbplKxs+H6ItlIIf 1KRi+c+xXVTI8kWDLwjddjFrIWDeImhFQHUrMOV92LK/JM3Zj6OtGIpuk ejNtNXXrNKq7U23WJh/69ler9UUeWQENyNO3dHXhspq6hluh+Eg+1YbRb Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10733"; a="359336593" X-IronPort-AV: E=Sophos;i="6.00,222,1681196400"; d="scan'208";a="359336593" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2023 21:00:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10733"; a="686759218" X-IronPort-AV: E=Sophos;i="6.00,222,1681196400"; d="scan'208";a="686759218" Received: from dpdk-zhirun-lmm.sh.intel.com ([10.67.119.94]) by orsmga006.jf.intel.com with ESMTP; 06 Jun 2023 20:59:56 -0700 From: Zhirun Yan To: dev@dpdk.org, jerinj@marvell.com, kirankumark@marvell.com, ndabilpuram@marvell.com, stephen@networkplumber.org, pbhagavatula@marvell.com, jerinjacobk@gmail.com Cc: cunming.liang@intel.com, haiyue.wang@intel.com, mattias.ronnblom@ericsson.com, Zhirun Yan Subject: [PATCH v9 04/17] graph: add get/set graph worker model APIs Date: Wed, 7 Jun 2023 11:51:31 +0800 Message-Id: <20230607035144.1214492-5-zhirun.yan@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230607035144.1214492-1-zhirun.yan@intel.com> References: <20230606144746.708388-1-zhirun.yan@intel.com> <20230607035144.1214492-1-zhirun.yan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add new get/set APIs to configure graph worker model which is used to determine which model will be chosen. Signed-off-by: Haiyue Wang Signed-off-by: Cunming Liang Signed-off-by: Zhirun Yan --- lib/graph/meson.build | 1 + lib/graph/rte_graph_worker.c | 21 ++++++++++ lib/graph/rte_graph_worker_common.h | 61 +++++++++++++++++++++++++++++ lib/graph/version.map | 3 ++ 4 files changed, 86 insertions(+) create mode 100644 lib/graph/rte_graph_worker.c diff --git a/lib/graph/meson.build b/lib/graph/meson.build index 3526d1b5d4..9fab8243da 100644 --- a/lib/graph/meson.build +++ b/lib/graph/meson.build @@ -15,6 +15,7 @@ sources = files( 'graph_stats.c', 'graph_populate.c', 'graph_pcap.c', + 'rte_graph_worker.c', ) headers = files('rte_graph.h', 'rte_graph_worker.h') diff --git a/lib/graph/rte_graph_worker.c b/lib/graph/rte_graph_worker.c new file mode 100644 index 0000000000..b43330bc8d --- /dev/null +++ b/lib/graph/rte_graph_worker.c @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2023 Intel Corporation + */ + +#include "rte_graph_worker_common.h" +#include "graph_private.h" + +int +rte_graph_worker_model_set(uint32_t model) +{ + struct graph_head *graph_head = graph_list_head_get(); + struct graph *graph; + + if (!graph_model_is_valid(model)) + return -EINVAL; + + STAILQ_FOREACH(graph, graph_head, next) + graph->graph->model = model; + + return 0; +} diff --git a/lib/graph/rte_graph_worker_common.h b/lib/graph/rte_graph_worker_common.h index 41428974db..5dba3c0edd 100644 --- a/lib/graph/rte_graph_worker_common.h +++ b/lib/graph/rte_graph_worker_common.h @@ -29,6 +29,13 @@ extern "C" { #endif +/** Graph worker models */ +/* If adding new entry, then update graph_model_is_valid API. */ +#define RTE_GRAPH_MODEL_RTC 0 /**< Run-To-Completion model. It is the default model. */ +#define RTE_GRAPH_MODEL_DEFAULT RTE_GRAPH_MODEL_RTC /**< Default graph model. */ +#define RTE_GRAPH_MODEL_MCORE_DISPATCH 1 +/**< Dispatch model to support cross-core dispatching within core affinity. */ + /** * @internal * @@ -41,6 +48,7 @@ struct rte_graph { rte_node_t nb_nodes; /**< Number of nodes in the graph. */ rte_graph_off_t *cir_start; /**< Pointer to circular buffer. */ rte_graph_off_t nodes_start; /**< Offset at which node memory starts. */ + uint32_t model; /**< graph model */ rte_graph_t id; /**< Graph identifier. */ int socket; /**< Socket ID where memory is allocated. */ char name[RTE_GRAPH_NAMESIZE]; /**< Name of the graph. */ @@ -490,6 +498,59 @@ rte_node_next_stream_move(struct rte_graph *graph, struct rte_node *src, } } +/** + * Test the validity of model. + * + * @param id + * Node id to check. + * + * @return + * true if graph model is valid, false otherwise. + */ +static __rte_always_inline +bool +graph_model_is_valid(uint32_t model) +{ + if (model > RTE_GRAPH_MODEL_MCORE_DISPATCH) + return false; + + return true; +} + +/** + * @note This function does not perform any locking, and is only safe to call + * before graph running. It will set all graphs the same model. + * + * @param model + * Name of the graph worker model. + * + * @return + * 0 on success, -1 otherwise. + */ +__rte_experimental +int rte_graph_worker_model_set(uint32_t model); + +/** + * Get the graph worker model + * + * @note All graph will use the same model and this function will get model from the first one + * + * @param graph + * Graph pointer. + * + * @return + * Graph worker model on success. + */ +__rte_experimental +static inline uint32_t +rte_graph_worker_model_get(struct rte_graph *graph) +{ + if (!graph_model_is_valid(graph->model)) + return -EINVAL; + + return graph->model; +} + #ifdef __cplusplus } #endif diff --git a/lib/graph/version.map b/lib/graph/version.map index 13b838752d..eea73ec9ca 100644 --- a/lib/graph/version.map +++ b/lib/graph/version.map @@ -43,5 +43,8 @@ EXPERIMENTAL { rte_node_next_stream_put; rte_node_next_stream_move; + rte_graph_worker_model_set; + rte_graph_worker_model_get; + local: *; }; -- 2.37.2