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 44AB542BCF; Mon, 5 Jun 2023 13:28:06 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 372EF42D3E; Mon, 5 Jun 2023 13:27:08 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 1D19A42DBA for ; Mon, 5 Jun 2023 13:27:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685964426; x=1717500426; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2feDbESPZg/LmMcaAMrdEs1xzOtshMANT0zJsErXdHs=; b=PjdjlTfAv3nuTjeKm9ZF1MQ06g53ifFyQSmQLT1ApxraR/nPPv1SAQZ9 8u6dhCLP2VcFKiDj8k5kBGNIyJyOp9sJ3kOy4pcKoShsUk4PXfv7gFnSY +KoUdRMuZcvUjomxF4QWtbpKVR8mbLPpkSbh4uHPyU2TKMyLM0x5teetz Jxua57HyGxfkkxnWkEFprNtKiUtEnLDqL9iAqVP7Z8tDSFse5XlrdrQTA CcoBvyruGWplwuaZ/FD2B33PHCcoVymPxuLK4pUbOz8XdX6U9Vh/KmFFX UP5AqQdSWazNJ0M883yyMtxrk6q530wVP8xAO5+PwBTKR/01JrQsvga0c g==; X-IronPort-AV: E=McAfee;i="6600,9927,10731"; a="422168677" X-IronPort-AV: E=Sophos;i="6.00,217,1681196400"; d="scan'208";a="422168677" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2023 04:27:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10731"; a="832779001" X-IronPort-AV: E=Sophos;i="6.00,217,1681196400"; d="scan'208";a="832779001" Received: from dpdk-zhirun-lmm.sh.intel.com ([10.67.119.94]) by orsmga004.jf.intel.com with ESMTP; 05 Jun 2023 04:27:02 -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 v7 16/17] test/graph: add functional tests for mcore dispatch model Date: Mon, 5 Jun 2023 20:19:22 +0900 Message-Id: <20230605111923.3772260-17-zhirun.yan@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230605111923.3772260-1-zhirun.yan@intel.com> References: <20230509060347.1237884-1-zhirun.yan@intel.com> <20230605111923.3772260-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 functional test for mcore dispatch model including graph clone, graph model set/get, node worker affinity, graph worker binding/unbinding. Signed-off-by: Haiyue Wang Signed-off-by: Cunming Liang Signed-off-by: Zhirun Yan --- app/test/test_graph.c | 113 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/app/test/test_graph.c b/app/test/test_graph.c index 1a2d1e6fab..d711b7deb9 100644 --- a/app/test/test_graph.c +++ b/app/test/test_graph.c @@ -660,6 +660,115 @@ test_create_graph(void) return 0; } +static int +test_graph_clone(void) +{ + rte_graph_t cloned_graph_id = RTE_GRAPH_ID_INVALID; + rte_graph_t main_graph_id = RTE_GRAPH_ID_INVALID; + struct rte_graph_param graph_conf; + + main_graph_id = rte_graph_from_name("worker0"); + if (main_graph_id == RTE_GRAPH_ID_INVALID) { + printf("Must create main graph first\n"); + return -1; + } + + graph_conf.dispatch.mp_capacity = 1024; + graph_conf.dispatch.wq_size_max = 32; + + cloned_graph_id = rte_graph_clone(main_graph_id, "cloned-test0", &graph_conf); + + if (cloned_graph_id == RTE_GRAPH_ID_INVALID) { + printf("Graph creation failed with error = %d\n", rte_errno); + return -1; + } + + if (strcmp(rte_graph_id_to_name(cloned_graph_id), "worker0-cloned-test0")) { + printf("Cloned graph should name as %s but get %s\n", "worker0-cloned-test", + rte_graph_id_to_name(cloned_graph_id)); + return -1; + } + return 0; +} + +static int +test_graph_model_mcore_dispatch_node_lcore_affinity_set(void) +{ + rte_graph_t cloned_graph_id = RTE_GRAPH_ID_INVALID; + unsigned int worker_lcore = RTE_MAX_LCORE; + rte_node_t nid = RTE_NODE_ID_INVALID; + char node_name[64] = "test_node00"; + struct rte_node *node; + int ret; + + worker_lcore = rte_get_next_lcore(worker_lcore, true, 1); + ret = rte_graph_model_mcore_dispatch_node_lcore_affinity_set(node_name, worker_lcore); + if (ret == 0) + printf("Set node %s affinity to lcore %u\n", node_name, worker_lcore); + + nid = rte_node_from_name(node_name); + cloned_graph_id = rte_graph_clone(graph_id, "cloned-test1", NULL); + node = rte_graph_node_get(cloned_graph_id, nid); + + if (node->dispatch.lcore_id != worker_lcore) { + printf("set node affinity failed\n"); + return -1; + } + return 0; +} + +static int +test_graph_model_mcore_dispatch_core_bind_unbind(void) +{ + rte_graph_t cloned_graph_id = RTE_GRAPH_ID_INVALID; + unsigned int worker_lcore = RTE_MAX_LCORE; + struct rte_graph *graph; + int ret; + + worker_lcore = rte_get_next_lcore(worker_lcore, true, 1); + cloned_graph_id = rte_graph_clone(graph_id, "cloned-test2", NULL); + + ret = rte_graph_model_mcore_dispatch_core_bind(cloned_graph_id, worker_lcore); + if (ret != 0) { + printf("bind graph %d to lcore %u failed\n", graph_id, worker_lcore); + return -1; + } + + graph = rte_graph_lookup("worker0-cloned-test2"); + + if (graph->lcore_id != worker_lcore) { + printf("bind graph %s(id:%d) with lcore %u failed\n", + graph->name, graph->id, worker_lcore); + return -1; + } + + rte_graph_model_mcore_dispatch_core_unbind(cloned_graph_id); + if (graph->lcore_id != RTE_MAX_LCORE) { + printf("unbind graph %s(id:%d) failed %d\n", + graph->name, graph->id, graph->lcore_id); + return -1; + } + return 0; +} + +static int +test_graph_worker_model_set_get(void) +{ + int ret; + + ret = rte_graph_worker_model_set(RTE_GRAPH_MODEL_MCORE_DISPATCH); + if (ret != 0) { + printf("Set graph mcore dispatch model failed\n"); + return -1; + } + + if (rte_graph_worker_model_get() != RTE_GRAPH_MODEL_MCORE_DISPATCH) { + printf("Get graph worker model failed\n"); + return -1; + } + return 0; +} + static int test_graph_walk(void) { @@ -837,6 +946,10 @@ static struct unit_test_suite graph_testsuite = { TEST_CASE(test_update_edges), TEST_CASE(test_lookup_functions), TEST_CASE(test_create_graph), + TEST_CASE(test_graph_clone), + TEST_CASE(test_graph_model_mcore_dispatch_node_lcore_affinity_set), + TEST_CASE(test_graph_model_mcore_dispatch_core_bind_unbind), + TEST_CASE(test_graph_worker_model_set_get), TEST_CASE(test_graph_lookup_functions), TEST_CASE(test_graph_walk), TEST_CASE(test_print_stats), -- 2.37.2