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 BD24242C61; Thu, 8 Jun 2023 17:27:23 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5F9D442D30; Thu, 8 Jun 2023 17:26:54 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id B1CB042D3C for ; Thu, 8 Jun 2023 17:26:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686238012; x=1717774012; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GCHvh/8xaurPU393+p5XZALfiUafmxZqkcyAQ1hhiUI=; b=Xjn6gH72MmD24EQBelxk/wTmANkSOt+BfP0z/Y5MhORshJe1LiBqOhWs 9KzzreYW82MU2BCJTa331/BqAqUZ0ui07IZ5knzmYvbFTAeURStz00L+U ZaqryMPO5xocKZm4lLKPVpXkeZxUwLX4ibz9x1rgtr/2zBb+IJA66S1fO PJ1lrWxJ1DiSfSJv1vyFwiGDgpMkIYxdVQMnLQq30y5Jxny3r7KEVSESF 19FGfC1mss2Wf9S/8EmBoelyzqmjhkO6U6mg2S38+FI/yi/9YyQ1FLX3T mwG/K7Y/0YnkEAQcrAm46xcbh7gQ/uqvE36kQdXxP5z5X/kPlb65NNV+Y g==; X-IronPort-AV: E=McAfee;i="6600,9927,10735"; a="385681619" X-IronPort-AV: E=Sophos;i="6.00,227,1681196400"; d="scan'208";a="385681619" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jun 2023 08:26:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10735"; a="834233148" X-IronPort-AV: E=Sophos;i="6.00,227,1681196400"; d="scan'208";a="834233148" Received: from dpdk-zhirun-lmm.sh.intel.com ([10.67.119.94]) by orsmga004.jf.intel.com with ESMTP; 08 Jun 2023 08:26:30 -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 v11 15/16] test/graph: add functional tests for mcore dispatch model Date: Thu, 8 Jun 2023 23:18:43 +0800 Message-Id: <20230608151844.1823783-16-zhirun.yan@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230608151844.1823783-1-zhirun.yan@intel.com> References: <20230608095759.1800617-1-zhirun.yan@intel.com> <20230608151844.1823783-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 Acked-by: Pavan Nikhilesh --- app/test/test_graph.c | 130 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) diff --git a/app/test/test_graph.c b/app/test/test_graph.c index 1a2d1e6fab..8609c0b3a4 100644 --- a/app/test/test_graph.c +++ b/app/test/test_graph.c @@ -660,6 +660,132 @@ 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; + int ret = 0; + + main_graph_id = rte_graph_from_name("worker0"); + if (main_graph_id == RTE_GRAPH_ID_INVALID) { + printf("Must create main graph first\n"); + ret = -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); + ret = -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)); + ret = -1; + } + + rte_graph_destroy(cloned_graph_id); + + return ret; +} + +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 = 0; + + 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"); + ret = -1; + } + + rte_graph_destroy(cloned_graph_id); + + return ret; +} + +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 = 0; + + 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); + ret = -1; + } + + graph = rte_graph_lookup("worker0-cloned-test2"); + + if (graph->dispatch.lcore_id != worker_lcore) { + printf("bind graph %s(id:%d) with lcore %u failed\n", + graph->name, graph->id, worker_lcore); + ret = -1; + } + + rte_graph_model_mcore_dispatch_core_unbind(cloned_graph_id); + if (graph->dispatch.lcore_id != RTE_MAX_LCORE) { + printf("unbind graph %s(id:%d) failed %d\n", + graph->name, graph->id, graph->dispatch.lcore_id); + ret = -1; + } + + rte_graph_destroy(cloned_graph_id); + + return ret; +} + +static int +test_graph_worker_model_set_get(void) +{ + rte_graph_t cloned_graph_id = RTE_GRAPH_ID_INVALID; + struct rte_graph *graph; + int ret = 0; + + cloned_graph_id = rte_graph_clone(graph_id, "cloned-test3", NULL); + ret = rte_graph_worker_model_set(RTE_GRAPH_MODEL_MCORE_DISPATCH); + if (ret != 0) { + printf("Set graph mcore dispatch model failed\n"); + ret = -1; + } + + graph = rte_graph_lookup("worker0-cloned-test3"); + if (rte_graph_worker_model_get(graph) != RTE_GRAPH_MODEL_MCORE_DISPATCH) { + printf("Get graph worker model failed\n"); + ret = -1; + } + + rte_graph_destroy(cloned_graph_id); + + return 0; +} + static int test_graph_walk(void) { @@ -837,6 +963,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