From patchwork Thu Oct 11 11:41:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 46609 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 8DAAD1B57E; Thu, 11 Oct 2018 13:41:58 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id C98431B53E for ; Thu, 11 Oct 2018 13:41:47 +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 fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Oct 2018 04:41:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,368,1534834800"; d="scan'208";a="94289076" Received: from silpixa00382658.ir.intel.com ([10.237.223.29]) by fmsmga002.fm.intel.com with ESMTP; 11 Oct 2018 04:41:39 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Date: Thu, 11 Oct 2018 12:41:17 +0100 Message-Id: <1539258078-85906-7-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 7/8] net/softnic: add support for packet decap 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 packet decap table action. Signed-off-by: Cristian Dumitrescu --- drivers/net/softnic/rte_eth_softnic_action.c | 11 +++++++ drivers/net/softnic/rte_eth_softnic_cli.c | 38 +++++++++++++++++++++++++ drivers/net/softnic/rte_eth_softnic_internals.h | 1 + drivers/net/softnic/rte_eth_softnic_thread.c | 10 +++++++ 4 files changed, 60 insertions(+) diff --git a/drivers/net/softnic/rte_eth_softnic_action.c b/drivers/net/softnic/rte_eth_softnic_action.c index 133dd06..2b74848 100644 --- a/drivers/net/softnic/rte_eth_softnic_action.c +++ b/drivers/net/softnic/rte_eth_softnic_action.c @@ -375,6 +375,17 @@ softnic_table_action_profile_create(struct pmd_internals *p, } } + if (params->action_mask & (1LLU << RTE_TABLE_ACTION_DECAP)) { + status = rte_table_action_profile_action_register(ap, + RTE_TABLE_ACTION_DECAP, + 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/drivers/net/softnic/rte_eth_softnic_cli.c b/drivers/net/softnic/rte_eth_softnic_cli.c index 31c37da..2ddd936 100644 --- a/drivers/net/softnic/rte_eth_softnic_cli.c +++ b/drivers/net/softnic/rte_eth_softnic_cli.c @@ -1280,6 +1280,7 @@ cmd_port_in_action_profile(struct pmd_internals *softnic, * [stats pkts | bytes | both] * [time] * [tag] + * [decap] */ static void cmd_table_action_profile(struct pmd_internals *softnic, @@ -1617,6 +1618,12 @@ cmd_table_action_profile(struct pmd_internals *softnic, t0 += 1; } /* tag */ + if (t0 < n_tokens && + (strcmp(tokens[t0], "decap") == 0)) { + p.action_mask |= 1LLU << RTE_TABLE_ACTION_DECAP; + t0 += 1; + } /* decap */ + if (t0 < n_tokens) { snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); return; @@ -3184,6 +3191,7 @@ parse_match(char **tokens, * [stats] * [time] * [tag ] + * [decap ] * * where: * ::= g | y | r | drop @@ -3690,6 +3698,22 @@ parse_table_action_tag(char **tokens, } static uint32_t +parse_table_action_decap(char **tokens, + uint32_t n_tokens, + struct softnic_table_rule_action *a) +{ + if (n_tokens < 2 || + strcmp(tokens[0], "decap")) + return 0; + + if (softnic_parser_read_uint16(&a->decap.n, tokens[1])) + return 0; + + a->action_mask |= 1 << RTE_TABLE_ACTION_DECAP; + return 2; +} + +static uint32_t parse_table_action(char **tokens, uint32_t n_tokens, char *out, @@ -3847,6 +3871,20 @@ parse_table_action(char **tokens, n_tokens -= n; } + if (n_tokens && (strcmp(tokens[0], "decap") == 0)) { + uint32_t n; + + n = parse_table_action_decap(tokens, n_tokens, a); + if (n == 0) { + snprintf(out, out_size, MSG_ARG_INVALID, + "action decap"); + return 0; + } + + tokens += n; + n_tokens -= n; + } + if (n_tokens0 - n_tokens == 1) { snprintf(out, out_size, MSG_ARG_INVALID, "action"); return 0; diff --git a/drivers/net/softnic/rte_eth_softnic_internals.h b/drivers/net/softnic/rte_eth_softnic_internals.h index 1623ff8..9aa19a9 100644 --- a/drivers/net/softnic/rte_eth_softnic_internals.h +++ b/drivers/net/softnic/rte_eth_softnic_internals.h @@ -898,6 +898,7 @@ struct softnic_table_rule_action { struct rte_table_action_stats_params stats; struct rte_table_action_time_params time; struct rte_table_action_tag_params tag; + struct rte_table_action_decap_params decap; }; struct rte_flow { diff --git a/drivers/net/softnic/rte_eth_softnic_thread.c b/drivers/net/softnic/rte_eth_softnic_thread.c index e1d002e..c8a8d23 100644 --- a/drivers/net/softnic/rte_eth_softnic_thread.c +++ b/drivers/net/softnic/rte_eth_softnic_thread.c @@ -2488,6 +2488,16 @@ action_convert(struct rte_table_action *a, return status; } + if (action->action_mask & (1LLU << RTE_TABLE_ACTION_DECAP)) { + status = rte_table_action_apply(a, + data, + RTE_TABLE_ACTION_DECAP, + &action->decap); + + if (status) + return status; + } + return 0; }