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 49BB042AA0; Tue, 9 May 2023 08:04:32 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 480F742D37; Tue, 9 May 2023 08:04:10 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id B639942D40 for ; Tue, 9 May 2023 08:04:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683612248; x=1715148248; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Y0p9ycf5KX5Nmp9xu6w3rLj36yHyTpDmklm5oc4pBY8=; b=i3Uc/aIEyb3LTHlOOVsr2sMDEyA3tWoV+yW9JkGEMBOXsThHqSbVwrUv ByGlSP/C7oTt+JTvzfmEfVVZsuqtPPmoDg3NxiefGiiE7Bqy98QgakOl5 Pp6rMmmJKIi1m2KOH2+gvnpXPFMJk2niLRuY5pTM1OrjxjceWCKFUlp93 cSQfaffOWdS7tHf5XTixakIr0AwoGueTmqwlWuwOa3r+QBggsqZGEd8mq aTQ+/5duVHsEG7ZuGDu1s3EFWazwoFZUo4o42JxA5iuouoH00/fkA49KY 4e2gp5siXVAM5fmjtoepklyluoTIcX07fh4+lzbQI69lrtljZyo5LkdKe g==; X-IronPort-AV: E=McAfee;i="6600,9927,10704"; a="351983076" X-IronPort-AV: E=Sophos;i="5.99,261,1677571200"; d="scan'208";a="351983076" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 May 2023 23:04:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10704"; a="701700148" X-IronPort-AV: E=Sophos;i="5.99,261,1677571200"; d="scan'208";a="701700148" Received: from dpdk-zhirun-lmm.sh.intel.com ([10.67.119.94]) by fmsmga007.fm.intel.com with ESMTP; 08 May 2023 23:04:05 -0700 From: Zhirun Yan To: dev@dpdk.org, jerinj@marvell.com, kirankumark@marvell.com, ndabilpuram@marvell.com, stephen@networkplumber.org, pbhagavatula@marvell.com Cc: cunming.liang@intel.com, haiyue.wang@intel.com, Zhirun Yan Subject: [PATCH v6 04/15] graph: add get/set graph worker model APIs Date: Tue, 9 May 2023 15:03:36 +0900 Message-Id: <20230509060347.1237884-5-zhirun.yan@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230509060347.1237884-1-zhirun.yan@intel.com> References: <20230331040306.3143693-1-zhirun.yan@intel.com> <20230509060347.1237884-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 | 54 +++++++++++++++++++++++++++++ lib/graph/rte_graph_worker_common.h | 19 ++++++++++ lib/graph/version.map | 3 ++ 4 files changed, 77 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..cabc101262 --- /dev/null +++ b/lib/graph/rte_graph_worker.c @@ -0,0 +1,54 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2023 Intel Corporation + */ + +#include "rte_graph_worker_common.h" + +RTE_DEFINE_PER_LCORE(enum rte_graph_worker_model, worker_model) = RTE_GRAPH_MODEL_DEFAULT; + +/** + * @warning + * @b EXPERIMENTAL: this API may change, or be removed, without prior notice + * Set the graph worker model + * + * @note This function does not perform any locking, and is only safe to call + * before graph running. + * + * @param name + * Name of the graph worker model. + * + * @return + * 0 on success, -1 otherwise. + */ +int +rte_graph_worker_model_set(enum rte_graph_worker_model model) +{ + if (model >= RTE_GRAPH_MODEL_LIST_END) + goto fail; + + RTE_PER_LCORE(worker_model) = model; + return 0; + +fail: + RTE_PER_LCORE(worker_model) = RTE_GRAPH_MODEL_DEFAULT; + return -1; +} + +/** + * @warning + * @b EXPERIMENTAL: this API may change, or be removed, without prior notice + * + * Get the graph worker model + * + * @param name + * Name of the graph worker model. + * + * @return + * Graph worker model on success. + */ +inline +enum rte_graph_worker_model +rte_graph_worker_model_get(void) +{ + return RTE_PER_LCORE(worker_model); +} diff --git a/lib/graph/rte_graph_worker_common.h b/lib/graph/rte_graph_worker_common.h index e25eabc81f..9bde8856ae 100644 --- a/lib/graph/rte_graph_worker_common.h +++ b/lib/graph/rte_graph_worker_common.h @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -95,6 +96,16 @@ struct rte_node { struct rte_node *nodes[] __rte_cache_min_aligned; /**< Next nodes. */ } __rte_cache_aligned; +/** Graph worker models */ +enum rte_graph_worker_model { + RTE_GRAPH_MODEL_DEFAULT, + RTE_GRAPH_MODEL_RTC = RTE_GRAPH_MODEL_DEFAULT, + RTE_GRAPH_MODEL_MCORE_DISPATCH, + RTE_GRAPH_MODEL_LIST_END +}; + +RTE_DECLARE_PER_LCORE(enum rte_graph_worker_model, worker_model); + /** * @internal * @@ -490,6 +501,14 @@ rte_node_next_stream_move(struct rte_graph *graph, struct rte_node *src, } } +__rte_experimental +enum rte_graph_worker_model +rte_graph_worker_model_get(void); + +__rte_experimental +int +rte_graph_worker_model_set(enum rte_graph_worker_model 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