From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id BA993A0548;
	Fri, 10 Sep 2021 15:38:12 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 55B454116F;
	Fri, 10 Sep 2021 15:37:28 +0200 (CEST)
Received: from mga09.intel.com (mga09.intel.com [134.134.136.24])
 by mails.dpdk.org (Postfix) with ESMTP id E577F4114E
 for <dev@dpdk.org>; Fri, 10 Sep 2021 15:37:22 +0200 (CEST)
X-IronPort-AV: E=McAfee;i="6200,9189,10102"; a="221113280"
X-IronPort-AV: E=Sophos;i="5.85,283,1624345200"; d="scan'208";a="221113280"
Received: from fmsmga002.fm.intel.com ([10.253.24.26])
 by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 10 Sep 2021 06:37:22 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.85,283,1624345200"; d="scan'208";a="549328536"
Received: from silpixa00400573.ir.intel.com (HELO
 silpixa00400573.ger.corp.intel.com) ([10.237.223.107])
 by fmsmga002.fm.intel.com with ESMTP; 10 Sep 2021 06:37:21 -0700
From: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
To: dev@dpdk.org
Date: Fri, 10 Sep 2021 14:36:58 +0100
Message-Id: <20210910133713.93103-9-cristian.dumitrescu@intel.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20210910133713.93103-1-cristian.dumitrescu@intel.com>
References: <20210910123003.85448-1-cristian.dumitrescu@intel.com>
 <20210910133713.93103-1-cristian.dumitrescu@intel.com>
Subject: [dpdk-dev] [PATCH V2 09/24] pipeline: create inline functions for
 extern instruction
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

Create inline functions for the extern instruction.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
 lib/pipeline/rte_swx_pipeline.c          | 22 +++---------
 lib/pipeline/rte_swx_pipeline_internal.h | 43 ++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 18 deletions(-)

diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c
index ca12f34b01..c9e29230c2 100644
--- a/lib/pipeline/rte_swx_pipeline.c
+++ b/lib/pipeline/rte_swx_pipeline.c
@@ -2317,18 +2317,10 @@ instr_extern_obj_exec(struct rte_swx_pipeline *p)
 {
 	struct thread *t = &p->threads[p->thread_id];
 	struct instruction *ip = t->ip;
-	uint32_t obj_id = ip->ext_obj.ext_obj_id;
-	uint32_t func_id = ip->ext_obj.func_id;
-	struct extern_obj_runtime *obj = &t->extern_objs[obj_id];
-	rte_swx_extern_type_member_func_t func = obj->funcs[func_id];
-
-	TRACE("[Thread %2u] extern obj %u member func %u\n",
-	      p->thread_id,
-	      obj_id,
-	      func_id);
+	uint32_t done;
 
 	/* Extern object member function execute. */
-	uint32_t done = func(obj->obj, obj->mailbox);
+	done = __instr_extern_obj_exec(p, t, ip);
 
 	/* Thread. */
 	thread_ip_inc_cond(t, done);
@@ -2340,16 +2332,10 @@ instr_extern_func_exec(struct rte_swx_pipeline *p)
 {
 	struct thread *t = &p->threads[p->thread_id];
 	struct instruction *ip = t->ip;
-	uint32_t ext_func_id = ip->ext_func.ext_func_id;
-	struct extern_func_runtime *ext_func = &t->extern_funcs[ext_func_id];
-	rte_swx_extern_func_t func = ext_func->func;
-
-	TRACE("[Thread %2u] extern func %u\n",
-	      p->thread_id,
-	      ext_func_id);
+	uint32_t done;
 
 	/* Extern function execute. */
-	uint32_t done = func(ext_func->mailbox);
+	done = __instr_extern_func_exec(p, t, ip);
 
 	/* Thread. */
 	thread_ip_inc_cond(t, done);
diff --git a/lib/pipeline/rte_swx_pipeline_internal.h b/lib/pipeline/rte_swx_pipeline_internal.h
index 24096a23b6..14d6d88344 100644
--- a/lib/pipeline/rte_swx_pipeline_internal.h
+++ b/lib/pipeline/rte_swx_pipeline_internal.h
@@ -2015,4 +2015,47 @@ __instr_forget_exec(struct rte_swx_pipeline *p,
 	stats->n_pkts_forget += 1;
 }
 
+/*
+ * extern.
+ */
+static inline uint32_t
+__instr_extern_obj_exec(struct rte_swx_pipeline *p __rte_unused,
+			struct thread *t,
+			const struct instruction *ip)
+{
+	uint32_t obj_id = ip->ext_obj.ext_obj_id;
+	uint32_t func_id = ip->ext_obj.func_id;
+	struct extern_obj_runtime *obj = &t->extern_objs[obj_id];
+	rte_swx_extern_type_member_func_t func = obj->funcs[func_id];
+	uint32_t done;
+
+	TRACE("[Thread %2u] extern obj %u member func %u\n",
+	      p->thread_id,
+	      obj_id,
+	      func_id);
+
+	done = func(obj->obj, obj->mailbox);
+
+	return done;
+}
+
+static inline uint32_t
+__instr_extern_func_exec(struct rte_swx_pipeline *p __rte_unused,
+			 struct thread *t,
+			 const struct instruction *ip)
+{
+	uint32_t ext_func_id = ip->ext_func.ext_func_id;
+	struct extern_func_runtime *ext_func = &t->extern_funcs[ext_func_id];
+	rte_swx_extern_func_t func = ext_func->func;
+	uint32_t done;
+
+	TRACE("[Thread %2u] extern func %u\n",
+	      p->thread_id,
+	      ext_func_id);
+
+	done = func(ext_func->mailbox);
+
+	return done;
+}
+
 #endif
-- 
2.17.1