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 A9DE5A0554; Fri, 26 Aug 2022 12:36:53 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EB7204284D; Fri, 26 Aug 2022 12:36:24 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id 4787A4281A for ; Fri, 26 Aug 2022 12:36:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661510183; x=1693046183; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=c5YHVF51WVwQBQOJ5eVbyFRUuGco+5s4B9CoVKSTnjw=; b=RC/6s0BChyncaUhuuy5hMm2zgyKWWy/+X/rip6kPBYGkfIsOQCaLM+VV 5MPaz0RWqaVLJLcGMgtAnl8V/+ikkta7YrZ4Ke5MgC0ZYg9EB4KCkYAt7 reNbgcNLNfpWGA8eUGdzmra4n8//GnA9fUL5Rv3JLZfgXp/JyJxEjqSaV lmc/AgIeDlCxq2V4A/gLXh5aj0ZLxi9XEKbNRopV0qJ/LIW3vgjD31OSj YV2h3UAEZgIMZVNf16Ovoxm7DmJHjAdCMxZDCEHBl3j8d9JbK4nSaU1u6 w/GJFEaKIbcGbSW5W3q+j4ubhbLo09YtxYzMGGdg5ydr78p3tOqAsxBOR Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10450"; a="294482922" X-IronPort-AV: E=Sophos;i="5.93,265,1654585200"; d="scan'208";a="294482922" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2022 03:36:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,265,1654585200"; d="scan'208";a="671414280" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga008.fm.intel.com with ESMTP; 26 Aug 2022 03:36:08 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Subject: [PATCH 3/7] pipeline: add table entry ID read instruction Date: Fri, 26 Aug 2022 10:36:01 +0000 Message-Id: <20220826103605.1579589-4-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220826103605.1579589-1-cristian.dumitrescu@intel.com> References: <20220826103605.1579589-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