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 3345F4286D; Thu, 30 Mar 2023 08:19:25 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C78E142D17; Thu, 30 Mar 2023 08:18:55 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 9D02F42D1D for ; Thu, 30 Mar 2023 08:18:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680157133; x=1711693133; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KvffPVut01BMQ6onAjS4VEulxb5OrYeG76XzuTei3Fs=; b=K1823g3a2wRpohh6Ly1q5oK4STcVPe7rMa3WGTGCEkUXUaxMapq0dnsN NDrSXLsrifJXHLpmEMnLtb9k+ZDc9gxS2bm9E7uS0zvEwyztW0QeqvzBb oJFG3J6ATzrN/g7K4GP29yFAU2FN5dP1kmQcmpNSv9daHIVQLzdPz5ANw K09rIMFdURFK7pGBP5QlxPtNSt5yroflmWhbZzGcdaz6eLFi7w/dsiaX1 pOA92k7BBNyZ85lFL+6V4TV+k9bgY1O9eDG4/lz1ybMGBJYnkWoo6+cDe 8gfF4TKG7FCj5MEQ9x7N5I4pzt+tqgsiv60BHgaDHsRGCSXVOKr7vJ4Eb g==; X-IronPort-AV: E=McAfee;i="6600,9927,10664"; a="343530590" X-IronPort-AV: E=Sophos;i="5.98,303,1673942400"; d="scan'208";a="343530590" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2023 23:18:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10664"; a="828176195" X-IronPort-AV: E=Sophos;i="5.98,303,1673942400"; d="scan'208";a="828176195" Received: from dpdk-zhirun-lmm.sh.intel.com ([10.67.119.68]) by fmsmga001.fm.intel.com with ESMTP; 29 Mar 2023 23:18:51 -0700 From: Zhirun Yan To: dev@dpdk.org, jerinj@marvell.com, kirankumark@marvell.com, ndabilpuram@marvell.com Cc: cunming.liang@intel.com, haiyue.wang@intel.com, Zhirun Yan Subject: [PATCH v4 06/15] graph: introduce graph bind unbind API Date: Thu, 30 Mar 2023 15:18:25 +0900 Message-Id: <20230330061834.3118201-7-zhirun.yan@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230330061834.3118201-1-zhirun.yan@intel.com> References: <20230329064340.2550530-1-zhirun.yan@intel.com> <20230330061834.3118201-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 lcore_id for graph to hold affinity core id where graph would run on. Add bind/unbind API to set/unset graph affinity attribute. lcore_id will be set as MAX by default, it means not enable this attribute. Signed-off-by: Haiyue Wang Signed-off-by: Cunming Liang Signed-off-by: Zhirun Yan --- lib/graph/graph.c | 59 +++++++++++++++++++++++++++++++++++++++ lib/graph/graph_private.h | 2 ++ lib/graph/rte_graph.h | 22 +++++++++++++++ lib/graph/version.map | 2 ++ 4 files changed, 85 insertions(+) diff --git a/lib/graph/graph.c b/lib/graph/graph.c index a839a2803b..b39a99aac6 100644 --- a/lib/graph/graph.c +++ b/lib/graph/graph.c @@ -254,6 +254,64 @@ graph_mem_fixup_secondary(struct rte_graph *graph) return graph_mem_fixup_node_ctx(graph); } +static __rte_always_inline bool +graph_src_node_avail(struct graph *graph) +{ + struct graph_node *graph_node; + + STAILQ_FOREACH(graph_node, &graph->node_list, next) + if ((graph_node->node->flags & RTE_NODE_SOURCE_F) && + (graph_node->node->lcore_id == RTE_MAX_LCORE || + graph->lcore_id == graph_node->node->lcore_id)) + return true; + + return false; +} + +int +rte_graph_model_dispatch_core_bind(rte_graph_t id, int lcore) +{ + struct graph *graph; + + GRAPH_ID_CHECK(id); + if (!rte_lcore_is_enabled(lcore)) + SET_ERR_JMP(ENOLINK, fail, + "lcore %d not enabled\n", + lcore); + + STAILQ_FOREACH(graph, &graph_list, next) + if (graph->id == id) + break; + + graph->lcore_id = lcore; + graph->socket = rte_lcore_to_socket_id(lcore); + + /* check the availability of source node */ + if (!graph_src_node_avail(graph)) + graph->graph->head = 0; + + return 0; + +fail: + return -rte_errno; +} + +void +rte_graph_model_dispatch_core_unbind(rte_graph_t id) +{ + struct graph *graph; + + GRAPH_ID_CHECK(id); + STAILQ_FOREACH(graph, &graph_list, next) + if (graph->id == id) + break; + + graph->lcore_id = RTE_MAX_LCORE; + +fail: + return; +} + struct rte_graph * rte_graph_lookup(const char *name) { @@ -340,6 +398,7 @@ rte_graph_create(const char *name, struct rte_graph_param *prm) graph->src_node_count = src_node_count; graph->node_count = graph_nodes_count(graph); graph->id = graph_id; + graph->lcore_id = RTE_MAX_LCORE; graph->num_pkt_to_capture = prm->num_pkt_to_capture; if (prm->pcap_filename) rte_strscpy(graph->pcap_filename, prm->pcap_filename, RTE_GRAPH_PCAP_FILE_SZ); diff --git a/lib/graph/graph_private.h b/lib/graph/graph_private.h index 409eed3284..ad1d058945 100644 --- a/lib/graph/graph_private.h +++ b/lib/graph/graph_private.h @@ -98,6 +98,8 @@ struct graph { /**< Circular buffer mask for wrap around. */ rte_graph_t id; /**< Graph identifier. */ + unsigned int lcore_id; + /**< Lcore identifier where the graph prefer to run on. */ size_t mem_sz; /**< Memory size of the graph. */ int socket; diff --git a/lib/graph/rte_graph.h b/lib/graph/rte_graph.h index c9a77297fc..c523809d1f 100644 --- a/lib/graph/rte_graph.h +++ b/lib/graph/rte_graph.h @@ -285,6 +285,28 @@ char *rte_graph_id_to_name(rte_graph_t id); __rte_experimental int rte_graph_export(const char *name, FILE *f); +/** + * Bind graph with specific lcore + * + * @param id + * Graph id to get the pointer of graph object + * @param lcore + * The lcore where the graph will run on + * @return + * 0 on success, error otherwise. + */ +__rte_experimental +int rte_graph_model_dispatch_core_bind(rte_graph_t id, int lcore); + +/** + * Unbind graph with lcore + * + * @param id + * Graph id to get the pointer of graph object + */ +__rte_experimental +void rte_graph_model_dispatch_core_unbind(rte_graph_t id); + /** * Get graph object from its name. * diff --git a/lib/graph/version.map b/lib/graph/version.map index 1f090be74e..7de6f08f59 100644 --- a/lib/graph/version.map +++ b/lib/graph/version.map @@ -18,6 +18,8 @@ EXPERIMENTAL { rte_graph_node_get_by_name; rte_graph_obj_dump; rte_graph_walk; + rte_graph_model_dispatch_core_bind; + rte_graph_model_dispatch_core_unbind; rte_graph_cluster_stats_create; rte_graph_cluster_stats_destroy; -- 2.37.2