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 5FE7342CAB; Tue, 13 Jun 2023 16:12:29 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EFFE242D13; Tue, 13 Jun 2023 16:12:12 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 9190542D12 for ; Tue, 13 Jun 2023 16:12:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686665530; x=1718201530; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ERhwuJLn0yryRw8xvHlvjydjD6kplI7pY0bp3ltMxec=; b=kQu3G6aX1z4OGq6BGlNiR1LVtFOe6SB1MTB8y8GYd2KCIDo2231tNUV8 jQ2Q/OW05/iKed3AqBSQ64xyiz9qeZolIPvr38VZCnCTR7QKpuU16psgr +eHlZ60UmzXE3hMYJRKwYpiy/JlY5qHxVwitCOt8PW7DWN8CrhF216EME 9beYp2KUnwPlGj+x0n8VM71/n4+vjgyawJUqBMFKlHZgSXEzNGDwztwUe EJFUvDSsYFG6FRlimy0ppeHQ4LYktTHLKubtp47mxMyj7LgrDCBa7iCB+ FgVE8+KjjjliuwKS6gdwB0v0oHGO1bXo4lJA4P+HcBgltxn/9I3C3i7F2 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10740"; a="355839694" X-IronPort-AV: E=Sophos;i="6.00,239,1681196400"; d="scan'208";a="355839694" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jun 2023 07:12:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10740"; a="741439308" X-IronPort-AV: E=Sophos;i="6.00,239,1681196400"; d="scan'208";a="741439308" Received: from dpdk-zhirun-lmm.sh.intel.com ([10.67.119.94]) by orsmga008.jf.intel.com with ESMTP; 13 Jun 2023 07:12:06 -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, david.marchand@redhat.com Cc: cunming.liang@intel.com, haiyue.wang@intel.com, mattias.ronnblom@ericsson.com, Zhirun Yan Subject: [PATCH v14 04/16] graph: add get/set graph worker model APIs Date: Tue, 13 Jun 2023 22:04:33 +0800 Message-Id: <20230613140445.2155542-5-zhirun.yan@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230613140445.2155542-1-zhirun.yan@intel.com> References: <20230613101404.1787790-1-zhirun.yan@intel.com> <20230613140445.2155542-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 Acked-by: Jerin Jacob --- lib/graph/meson.build | 1 + lib/graph/rte_graph_worker.c | 39 ++++++++++++++++ lib/graph/rte_graph_worker_common.h | 70 +++++++++++++++++++++++++++++ lib/graph/version.map | 5 +++ 4 files changed, 115 insertions(+) create mode 100644 lib/graph/rte_graph_worker.c diff --git a/lib/graph/meson.build b/lib/graph/meson.build index 31d78a1dc2..5661dd855b 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') indirect_headers += files( diff --git a/lib/graph/rte_graph_worker.c b/lib/graph/rte_graph_worker.c new file mode 100644 index 0000000000..7e2a918fae --- /dev/null +++ b/lib/graph/rte_graph_worker.c @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2023 Intel Corporation + */ + +#include "rte_graph_worker_common.h" +#include "graph_private.h" + +bool +rte_graph_model_is_valid(uint8_t model) +{ + if (model > RTE_GRAPH_MODEL_MCORE_DISPATCH) + return false; + + return true; +} + +int +rte_graph_worker_model_set(uint8_t model) +{ + struct graph_head *graph_head = graph_list_head_get(); + struct graph *graph; + + if (!rte_graph_model_is_valid(model)) + return -EINVAL; + + STAILQ_FOREACH(graph, graph_head, next) + graph->graph->model = model; + + return 0; +} + +uint8_t +rte_graph_worker_model_get(struct rte_graph *graph) +{ + if (!rte_graph_model_is_valid(graph->model)) + return -EINVAL; + + return graph->model; +} diff --git a/lib/graph/rte_graph_worker_common.h b/lib/graph/rte_graph_worker_common.h index a90addb172..123600f939 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 */ +/* When adding a new graph model entry, update rte_graph_model_is_valid() implementation. */ +#define RTE_GRAPH_MODEL_RTC 0 /**< Run-To-Completion model. It is the default model. */ +#define RTE_GRAPH_MODEL_MCORE_DISPATCH 1 +/**< Dispatch model to support cross-core dispatching within core affinity. */ +#define RTE_GRAPH_MODEL_DEFAULT RTE_GRAPH_MODEL_RTC /**< Default graph model. */ + /** * @internal * @@ -41,6 +48,9 @@ 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. */ + uint8_t model; /**< graph model */ + uint8_t reserved1; /**< Reserved for future use. */ + uint16_t reserved2; /**< Reserved for future use. */ 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 +500,66 @@ rte_node_next_stream_move(struct rte_graph *graph, struct rte_node *src, } } +/** + * Test the validity of model. + * + * @param model + * Model to check. + * + * @return + * True if graph model is valid, false otherwise. + */ +__rte_experimental +bool +rte_graph_model_is_valid(uint8_t model); + +/** + * @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(uint8_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. + * Used for slow path. + * + * @param graph + * Graph pointer. + * + * @return + * Graph worker model on success. + */ +__rte_experimental +uint8_t rte_graph_worker_model_get(struct rte_graph *graph); + +/** + * Get the graph worker model without check + * + * @note All graph will use the same model and this function will get model from the first one. + * Used for fast path. + * + * @param graph + * Graph pointer. + * + * @return + * Graph worker model on success. + */ +__rte_experimental +static __rte_always_inline +uint8_t rte_graph_worker_model_no_check_get(struct rte_graph *graph) +{ + return graph->model; +} + #ifdef __cplusplus } #endif diff --git a/lib/graph/version.map b/lib/graph/version.map index 13b838752d..e9a680a45e 100644 --- a/lib/graph/version.map +++ b/lib/graph/version.map @@ -14,10 +14,15 @@ EXPERIMENTAL { rte_graph_lookup; rte_graph_list_dump; rte_graph_max_count; + rte_graph_model_is_valid; rte_graph_node_get; rte_graph_node_get_by_name; rte_graph_obj_dump; rte_graph_walk; + rte_graph_worker_model_get; + rte_graph_worker_model_no_check_get; + rte_graph_worker_model_set; + rte_graph_cluster_stats_create; rte_graph_cluster_stats_destroy; -- 2.37.2