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 85232A0555; Fri, 26 Aug 2022 13:21:48 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 92AE840146; Fri, 26 Aug 2022 13:21:36 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 847BF40A80 for ; Fri, 26 Aug 2022 13:21:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661512892; x=1693048892; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=c5YHVF51WVwQBQOJ5eVbyFRUuGco+5s4B9CoVKSTnjw=; b=PJQG7i1+2MlR1c24d7w0xh3tGfcB+gr/S+QRHlVarbtuac9KKhfnz19/ ntl4LRFZxVEVYs5erDk+MgXMmuaMR0Ugkuk+j56hh+K5JQ24YVAwefQNp FOrgNn9/tBImcPpuCBDgBax2QRU7y5HE1osx46RvxWaI3WHyNh/H5EkQD 4R+onji/mvKcYbUgGUAlGgewrgLg7cza2/ym3iM9+Ia0+WHaW1xz7/c5c M57dbjSe3Ksn941mw9zmc1VV9thf8wPORB4Wjq7ZdQWizlfIlXXNiqgbi +CYlaA25d9lUvaYhfIPuTDkxpIcLpujibboJfpXd72MIUgHuHF71iKpxv w==; X-IronPort-AV: E=McAfee;i="6500,9779,10450"; a="295264077" X-IronPort-AV: E=Sophos;i="5.93,265,1654585200"; d="scan'208";a="295264077" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2022 04:21:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,265,1654585200"; d="scan'208";a="678834800" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga004.fm.intel.com with ESMTP; 26 Aug 2022 04:21:31 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Subject: [PATCH V2 3/7] pipeline: add table entry ID read instruction Date: Fri, 26 Aug 2022 11:21:23 +0000 Message-Id: <20220826112127.1580044-4-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220826112127.1580044-1-cristian.dumitrescu@intel.com> References: <20220826103605.1579589-1-cristian.dumitrescu@intel.com> <20220826112127.1580044-1-cristian.dumitrescu@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 the entry ID instruction that reads the entry ID of the latest table lookup operation from the pipeline into the meta-data. The entry ID is then used by the register and meter instructions as the index into the register or meter array. Signed-off-by: Cristian Dumitrescu --- lib/pipeline/rte_swx_pipeline.c | 68 ++++++++++++++++++++++++ lib/pipeline/rte_swx_pipeline_internal.h | 20 +++++++ 2 files changed, 88 insertions(+) diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c index 80108b8916..ec8268b7f8 100644 --- a/lib/pipeline/rte_swx_pipeline.c +++ b/lib/pipeline/rte_swx_pipeline.c @@ -2834,6 +2834,43 @@ instr_forget_exec(struct rte_swx_pipeline *p) thread_ip_inc(p); } +/* + * entryid. + */ +static int +instr_entryid_translate(struct rte_swx_pipeline *p, + struct action *action __rte_unused, + char **tokens, + int n_tokens, + struct instruction *instr, + struct instruction_data *data __rte_unused) +{ + struct field *f; + + CHECK(n_tokens == 2, EINVAL); + + f = metadata_field_parse(p, tokens[1]); + CHECK(f, EINVAL); + CHECK(f->n_bits <= 64, EINVAL); + + instr->type = INSTR_ENTRYID; + instr->mov.dst.n_bits = f->n_bits; + instr->mov.dst.offset = f->offset / 8; + return 0; +} + +static inline void +instr_entryid_exec(struct rte_swx_pipeline *p) +{ + struct thread *t = &p->threads[p->thread_id]; + struct instruction *ip = t->ip; + + __instr_entryid_exec(p, t, ip); + + /* Thread. */ + thread_ip_inc(p); +} + /* * extern. */ @@ -6336,6 +6373,14 @@ instr_translate(struct rte_swx_pipeline *p, instr, data); + if (!strcmp(tokens[tpos], "entryid")) + return instr_entryid_translate(p, + action, + &tokens[tpos], + n_tokens - tpos, + instr, + data); + if (!strcmp(tokens[tpos], "extern")) return instr_extern_translate(p, action, @@ -7321,6 +7366,8 @@ static instr_exec_t instruction_table[] = { [INSTR_LEARNER_REARM] = instr_rearm_exec, [INSTR_LEARNER_REARM_NEW] = instr_rearm_new_exec, [INSTR_LEARNER_FORGET] = instr_forget_exec, + [INSTR_ENTRYID] = instr_entryid_exec, + [INSTR_EXTERN_OBJ] = instr_extern_obj_exec, [INSTR_EXTERN_FUNC] = instr_extern_func_exec, [INSTR_HASH_FUNC] = instr_hash_func_exec, @@ -11222,6 +11269,7 @@ instr_type_to_name(struct instruction *instr) case INSTR_LEARNER_REARM: return "INSTR_LEARNER_REARM"; case INSTR_LEARNER_REARM_NEW: return "INSTR_LEARNER_REARM_NEW"; case INSTR_LEARNER_FORGET: return "INSTR_LEARNER_FORGET"; + case INSTR_ENTRYID: return "INSTR_ENTRYID"; case INSTR_EXTERN_OBJ: return "INSTR_EXTERN_OBJ"; case INSTR_EXTERN_FUNC: return "INSTR_EXTERN_FUNC"; @@ -11922,6 +11970,24 @@ instr_forget_export(struct instruction *instr, FILE *f) instr_type_to_name(instr)); } +static void +instr_entryid_export(struct instruction *instr, FILE *f) +{ + fprintf(f, + "\t{\n" + "\t\t.type = %s,\n" + "\t\t.mov = {\n" + "\t\t\t.dst = {\n" + "\t\t\t\t.n_bits = %u,\n" + "\t\t\t\t.offset = %u,\n" + "\t\t\t},\n" + "\t\t},\n" + "\t},\n", + instr_type_to_name(instr), + instr->mov.dst.n_bits, + instr->mov.dst.offset); +} + static void instr_extern_export(struct instruction *instr, FILE *f) { @@ -12212,6 +12278,7 @@ static instruction_export_t export_table[] = { [INSTR_LEARNER_REARM] = instr_rearm_export, [INSTR_LEARNER_REARM_NEW] = instr_rearm_export, [INSTR_LEARNER_FORGET] = instr_forget_export, + [INSTR_ENTRYID] = instr_entryid_export, [INSTR_EXTERN_OBJ] = instr_extern_export, [INSTR_EXTERN_FUNC] = instr_extern_export, @@ -12438,6 +12505,7 @@ instr_type_to_func(struct instruction *instr) case INSTR_LEARNER_REARM: return "__instr_rearm_exec"; case INSTR_LEARNER_REARM_NEW: return "__instr_rearm_new_exec"; case INSTR_LEARNER_FORGET: return "__instr_forget_exec"; + case INSTR_ENTRYID: return "__instr_entryid_exec"; case INSTR_EXTERN_OBJ: return NULL; case INSTR_EXTERN_FUNC: return NULL; diff --git a/lib/pipeline/rte_swx_pipeline_internal.h b/lib/pipeline/rte_swx_pipeline_internal.h index 8f96b67d76..335506039b 100644 --- a/lib/pipeline/rte_swx_pipeline_internal.h +++ b/lib/pipeline/rte_swx_pipeline_internal.h @@ -504,6 +504,11 @@ enum instruction_type { /* forget */ INSTR_LEARNER_FORGET, + /* entryid m.table_entry_id + * Read the internal table entry ID into the specified meta-data field. + */ + INSTR_ENTRYID, + /* extern e.obj.func */ INSTR_EXTERN_OBJ, @@ -2377,6 +2382,21 @@ __instr_forget_exec(struct rte_swx_pipeline *p, stats->n_pkts_forget += 1; } +/* + * entryid. + */ +static inline void +__instr_entryid_exec(struct rte_swx_pipeline *p __rte_unused, + struct thread *t, + const struct instruction *ip) +{ + TRACE("[Thread %2u]: entryid\n", + p->thread_id); + + /* Meta-data. */ + METADATA_WRITE(t, ip->mov.dst.offset, ip->mov.dst.n_bits, t->entry_id); +} + /* * extern. */ -- 2.34.1