pipeline: create inline functions for extern instruction
authorCristian Dumitrescu <cristian.dumitrescu@intel.com>
Mon, 13 Sep 2021 16:44:28 +0000 (17:44 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 27 Sep 2021 10:03:10 +0000 (12:03 +0200)
Create inline functions for the extern instruction.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
lib/pipeline/rte_swx_pipeline.c
lib/pipeline/rte_swx_pipeline_internal.h

index ca12f34..c9e2923 100644 (file)
@@ -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);
index 24096a2..14d6d88 100644 (file)
@@ -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