From patchwork Thu Oct 11 11:41:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 46604 X-Patchwork-Delegate: cristian.dumitrescu@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 98D6F1B544; Thu, 11 Oct 2018 13:41:48 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 4291E1B515 for ; Thu, 11 Oct 2018 13:41:46 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Oct 2018 04:41:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,368,1534834800"; d="scan'208";a="94289032" Received: from silpixa00382658.ir.intel.com ([10.237.223.29]) by fmsmga002.fm.intel.com with ESMTP; 11 Oct 2018 04:41:36 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Date: Thu, 11 Oct 2018 12:41:12 +0100 Message-Id: <1539258078-85906-2-git-send-email-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1539258078-85906-1-git-send-email-cristian.dumitrescu@intel.com> References: <1539258078-85906-1-git-send-email-cristian.dumitrescu@intel.com> Subject: [dpdk-dev] [PATCH v4 2/8] examples/ip_pipeline: add support for packet tag table action 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" Add support for the packet tag table action. Signed-off-by: Cristian Dumitrescu --- examples/ip_pipeline/action.c | 11 +++++++++++ examples/ip_pipeline/cli.c | 38 +++++++++++++++++++++++++++++++++++++- examples/ip_pipeline/pipeline.h | 1 + examples/ip_pipeline/thread.c | 10 ++++++++++ 4 files changed, 59 insertions(+), 1 deletion(-) diff --git a/examples/ip_pipeline/action.c b/examples/ip_pipeline/action.c index a0f97be..3f825a0 100644 --- a/examples/ip_pipeline/action.c +++ b/examples/ip_pipeline/action.c @@ -344,6 +344,17 @@ table_action_profile_create(const char *name, } } + if (params->action_mask & (1LLU << RTE_TABLE_ACTION_TAG)) { + status = rte_table_action_profile_action_register(ap, + RTE_TABLE_ACTION_TAG, + NULL); + + if (status) { + rte_table_action_profile_free(ap); + return NULL; + } + } + status = rte_table_action_profile_freeze(ap); if (status) { rte_table_action_profile_free(ap); diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c index 3ff7caa..a85d04c 100644 --- a/examples/ip_pipeline/cli.c +++ b/examples/ip_pipeline/cli.c @@ -1032,7 +1032,8 @@ static const char cmd_table_action_profile_help[] = " [time]\n" " [sym_crypto dev offset " " mempool_create \n" -" mempool_init ]\n"; +" mempool_init ]\n" +" [tag]\n"; static void cmd_table_action_profile(char **tokens, @@ -1451,6 +1452,11 @@ cmd_table_action_profile(char **tokens, t0 += 9; } /* sym_crypto */ + if ((t0 < n_tokens) && (strcmp(tokens[t0], "tag") == 0)) { + p.action_mask |= 1LLU << RTE_TABLE_ACTION_TAG; + t0 += 1; + } /* tag */ + if (t0 < n_tokens) { snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); return; @@ -3107,6 +3113,7 @@ parse_match(char **tokens, * aead_algo aead_key aead_iv aead_aad * digest_size * data_offset ] + * [tag ] * * where: * ::= g | y | r | drop @@ -4068,6 +4075,22 @@ parse_table_action_sym_crypto(char **tokens, } static uint32_t +parse_table_action_tag(char **tokens, + uint32_t n_tokens, + struct table_rule_action *a) +{ + if ((n_tokens < 2) || + strcmp(tokens[0], "tag")) + return 0; + + if (parser_read_uint32(&a->tag.tag, tokens[1])) + return 0; + + a->action_mask |= 1 << RTE_TABLE_ACTION_TAG; + return 2; +} + +static uint32_t parse_table_action(char **tokens, uint32_t n_tokens, char *out, @@ -4218,6 +4241,19 @@ parse_table_action(char **tokens, if (n == 0) { snprintf(out, out_size, MSG_ARG_INVALID, "action sym_crypto"); + } + + tokens += n; + n_tokens -= n; + } + + if (n_tokens && (strcmp(tokens[0], "tag") == 0)) { + uint32_t n; + + n = parse_table_action_tag(tokens, n_tokens, a); + if (n == 0) { + snprintf(out, out_size, MSG_ARG_INVALID, + "action tag"); return 0; } diff --git a/examples/ip_pipeline/pipeline.h b/examples/ip_pipeline/pipeline.h index b6b9dc0..73485f6 100644 --- a/examples/ip_pipeline/pipeline.h +++ b/examples/ip_pipeline/pipeline.h @@ -282,6 +282,7 @@ struct table_rule_action { struct rte_table_action_stats_params stats; struct rte_table_action_time_params time; struct rte_table_action_sym_crypto_params sym_crypto; + struct rte_table_action_tag_params tag; }; int diff --git a/examples/ip_pipeline/thread.c b/examples/ip_pipeline/thread.c index 3ec44c9..41891f4 100644 --- a/examples/ip_pipeline/thread.c +++ b/examples/ip_pipeline/thread.c @@ -2494,6 +2494,16 @@ action_convert(struct rte_table_action *a, return status; } + if (action->action_mask & (1LLU << RTE_TABLE_ACTION_TAG)) { + status = rte_table_action_apply(a, + data, + RTE_TABLE_ACTION_TAG, + &action->tag); + + if (status) + return status; + } + return 0; }