From patchwork Wed Sep 23 18:06:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 78604 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3C44FA04B1; Wed, 23 Sep 2020 20:10:46 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B33351DD16; Wed, 23 Sep 2020 20:08:12 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 0B8681DB61 for ; Wed, 23 Sep 2020 20:07:15 +0200 (CEST) IronPort-SDR: 3RumlEnqYBOCgE6Y3mOxf36YxV4aJKVTAn/lAsk0E+Zq2HMyQ55uvGTWstbxotRvHebpBi+HDZ H/XuVgxCdZyQ== X-IronPort-AV: E=McAfee;i="6000,8403,9753"; a="245809554" X-IronPort-AV: E=Sophos;i="5.77,293,1596524400"; d="scan'208";a="245809554" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Sep 2020 11:07:15 -0700 IronPort-SDR: CJtqCciEZFG8anSWXft6NJC7zm/iZMs/faWzBEnLZZmSgcTQ0PEuflhsRFQYKzUoKtj+Rv3Jag ay+FQeRMwVYQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,293,1596524400"; d="scan'208";a="305477919" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com) ([10.237.223.107]) by orsmga003.jf.intel.com with ESMTP; 23 Sep 2020 11:07:14 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: thomas@monjalon.net, david.marchand@redhat.com Date: Wed, 23 Sep 2020 19:06:27 +0100 Message-Id: <20200923180645.55852-24-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200923180645.55852-1-cristian.dumitrescu@intel.com> References: <20200910152645.9342-2-cristian.dumitrescu@intel.com> <20200923180645.55852-1-cristian.dumitrescu@intel.com> Subject: [dpdk-dev] [PATCH v5 23/41] pipeline: introduce SWX table instruction X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The table instruction looks up the input key into the table and then it triggers the execution of the action found in the table entry. On lookup miss, the default table action is executed. Signed-off-by: Cristian Dumitrescu --- lib/librte_pipeline/rte_swx_pipeline.c | 100 +++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/lib/librte_pipeline/rte_swx_pipeline.c b/lib/librte_pipeline/rte_swx_pipeline.c index 2098f44c1..887668481 100644 --- a/lib/librte_pipeline/rte_swx_pipeline.c +++ b/lib/librte_pipeline/rte_swx_pipeline.c @@ -349,6 +349,9 @@ enum instruction_type { INSTR_ALU_SHR_HH, /* dst = H, src = H */ INSTR_ALU_SHR_MI, /* dst = MEF, src = I */ INSTR_ALU_SHR_HI, /* dst = H, src = I */ + + /* table TABLE */ + INSTR_TABLE, }; struct instr_operand { @@ -376,6 +379,10 @@ struct instr_hdr_validity { uint8_t header_id; }; +struct instr_table { + uint8_t table_id; +}; + struct instr_dst_src { struct instr_operand dst; union { @@ -405,6 +412,7 @@ struct instruction { struct instr_dst_src mov; struct instr_dma dma; struct instr_dst_src alu; + struct instr_table table; }; }; @@ -2057,6 +2065,15 @@ thread_ip_reset(struct rte_swx_pipeline *p, struct thread *t) t->ip = p->instructions; } +static inline void +thread_ip_action_call(struct rte_swx_pipeline *p, + struct thread *t, + uint32_t action_id) +{ + t->ret = t->ip + 1; + t->ip = p->action_instructions[action_id]; +} + static inline void thread_ip_inc(struct rte_swx_pipeline *p); @@ -2670,6 +2687,79 @@ instr_hdr_invalidate_exec(struct rte_swx_pipeline *p) thread_ip_inc(p); } +/* + * table. + */ +static struct table * +table_find(struct rte_swx_pipeline *p, const char *name); + +static int +instr_table_translate(struct rte_swx_pipeline *p, + struct action *action, + char **tokens, + int n_tokens, + struct instruction *instr, + struct instruction_data *data __rte_unused) +{ + struct table *t; + + CHECK(!action, EINVAL); + CHECK(n_tokens == 2, EINVAL); + + t = table_find(p, tokens[1]); + CHECK(t, EINVAL); + + instr->type = INSTR_TABLE; + instr->table.table_id = t->id; + return 0; +} + +static inline void +instr_table_exec(struct rte_swx_pipeline *p) +{ + struct thread *t = &p->threads[p->thread_id]; + struct instruction *ip = t->ip; + uint32_t table_id = ip->table.table_id; + struct rte_swx_table_state *ts = &t->table_state[table_id]; + struct table_runtime *table = &t->tables[table_id]; + uint64_t action_id; + uint8_t *action_data; + int done, hit; + + /* Table. */ + done = table->func(ts->obj, + table->mailbox, + table->key, + &action_id, + &action_data, + &hit); + if (!done) { + /* Thread. */ + TRACE("[Thread %2u] table %u (not finalized)\n", + p->thread_id, + table_id); + + thread_yield(p); + return; + } + + action_id = hit ? action_id : ts->default_action_id; + action_data = hit ? action_data : ts->default_action_data; + + TRACE("[Thread %2u] table %u (%s, action %u)\n", + p->thread_id, + table_id, + hit ? "hit" : "miss", + (uint32_t)action_id); + + t->action_id = action_id; + t->structs[0] = action_data; + t->hit = hit; + + /* Thread. */ + thread_ip_action_call(p, t, action_id); +} + /* * mov. */ @@ -4269,6 +4359,14 @@ instr_translate(struct rte_swx_pipeline *p, instr, data); + if (!strcmp(tokens[tpos], "table")) + return instr_table_translate(p, + action, + &tokens[tpos], + n_tokens - tpos, + instr, + data); + CHECK(0, EINVAL); } @@ -4471,6 +4569,8 @@ static instr_exec_t instruction_table[] = { [INSTR_ALU_SHR_HH] = instr_alu_shr_hh_exec, [INSTR_ALU_SHR_MI] = instr_alu_shr_mi_exec, [INSTR_ALU_SHR_HI] = instr_alu_shr_hi_exec, + + [INSTR_TABLE] = instr_table_exec, }; static inline void