From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 02182A04DD;
	Tue, 20 Oct 2020 11:28:09 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 4E8EAE240;
	Tue, 20 Oct 2020 11:14:54 +0200 (CEST)
Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com
 [148.163.129.52]) by dpdk.org (Postfix) with ESMTP id 018ADC7EC
 for <dev@dpdk.org>; Tue, 20 Oct 2020 11:14:12 +0200 (CEST)
Received: from mx1-us1.ppe-hosted.com (unknown [10.7.65.62])
 by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id
 C61E960050 for <dev@dpdk.org>; Tue, 20 Oct 2020 09:14:11 +0000 (UTC)
Received: from us4-mdac16-35.ut7.mdlocal (unknown [10.7.66.154])
 by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id C56C08009B
 for <dev@dpdk.org>; Tue, 20 Oct 2020 09:14:11 +0000 (UTC)
X-Virus-Scanned: Proofpoint Essentials engine
Received: from mx1-us1.ppe-hosted.com (unknown [10.7.66.34])
 by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 540B528004D
 for <dev@dpdk.org>; Tue, 20 Oct 2020 09:14:11 +0000 (UTC)
Received: from webmail.solarflare.com (uk.solarflare.com [193.34.186.16])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits))
 (No client certificate requested)
 by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 09B7C600061
 for <dev@dpdk.org>; Tue, 20 Oct 2020 09:14:11 +0000 (UTC)
Received: from ukex01.SolarFlarecom.com (10.17.10.4) by
 ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id
 15.0.1497.2; Tue, 20 Oct 2020 10:14:00 +0100
Received: from opal.uk.solarflarecom.com (10.17.10.1) by
 ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server id
 15.0.1497.2 via Frontend Transport; Tue, 20 Oct 2020 10:14:00 +0100
Received: from ukv-loginhost.uk.solarflarecom.com
 (ukv-loginhost.uk.solarflarecom.com [10.17.10.39])
 by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id 09K9E0qi028424;
 Tue, 20 Oct 2020 10:14:00 +0100
Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1])
 by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 617811613AB;
 Tue, 20 Oct 2020 10:14:00 +0100 (BST)
From: Andrew Rybchenko <arybchenko@solarflare.com>
To: <dev@dpdk.org>
CC: Ivan Malov <ivan.malov@oktetlabs.ru>
Date: Tue, 20 Oct 2020 10:13:09 +0100
Message-ID: <1603185222-14831-30-git-send-email-arybchenko@solarflare.com>
X-Mailer: git-send-email 1.8.3.1
In-Reply-To: <1603185222-14831-1-git-send-email-arybchenko@solarflare.com>
References: <1603183709-23420-1-git-send-email-arybchenko@solarflare.com>
 <1603185222-14831-1-git-send-email-arybchenko@solarflare.com>
MIME-Version: 1.0
Content-Type: text/plain
X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.6.1012-25736.003
X-TM-AS-Result: No-2.134200-8.000000-10
X-TMASE-MatchedRID: hOKbrLjOKN5EjiOYrUNIqaofqYgF6NV/x+jrF7TzRS0Ajiw/nJICh+Z5
 Gn23AeDZ8XVI39JCRnRuL3ESIrARlyHhSBQfglfsA9lly13c/gGH0N4NyO41W7vrYEyMiww4q9V
 hOmRpTapMhOK98HsSQD9ZNziQoQkP56XkomU2m5X7gWP0TNHLHGtNZoZ5+7ekBCzD0Dc8iUtPH2
 OEh/+ebHaalVKfJdYjztJEIiMQkV/ecSkNT7l/2YldKbZsGYatfS0Ip2eEHnz3IzXlXlpamPoLR
 4+zsDTtpmd/ehreR4XdibkIw67lEU9bcnLT8dyfbk26O/KUX8Gs4pXz6bFNF1nCmg+eSVSoAejv
 9WP+b9S3LBV+Zzde6VsVzu+vkWoeyNt630cKnsraQLtLC8aUqEPBvsmCWGHWUWQ7Bol0IqAY5tv
 H9Ry2Nw==
X-TM-AS-User-Approved-Sender: Yes
X-TM-AS-User-Blocked-Sender: No
X-TMASE-Result: 10--2.134200-8.000000
X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25736.003
X-MDID: 1603185251-DtLuQXTH0XL0
X-PPE-DISP: 1603185251;DtLuQXTH0XL0
Subject: [dpdk-dev] [PATCH v2 29/62] net/sfc: support VLAN PUSH actions in
	MAE backend
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

From: Ivan Malov <ivan.malov@oktetlabs.ru>

A group of actions (OF_PUSH_VLAN, OF_VLAN_SET_VID and
OF_VLAN_SET_PCP) maps to MAE action VLAN_PUSH.

This action group is supported only for rules which have transfer
attribute, and can be requested once or twice per a rule.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 doc/guides/nics/sfc_efx.rst |  6 ++++
 drivers/net/sfc/sfc_mae.c   | 61 +++++++++++++++++++++++++++++++++++--
 2 files changed, 65 insertions(+), 2 deletions(-)

diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst
index ed9fc9d845..b0caa4edf9 100644
--- a/doc/guides/nics/sfc_efx.rst
+++ b/doc/guides/nics/sfc_efx.rst
@@ -198,6 +198,12 @@ Supported actions (***transfer*** rules):
 
 - OF_POP_VLAN
 
+- OF_PUSH_VLAN
+
+- OF_VLAN_SET_VID
+
+- OF_VLAN_SET_PCP
+
 - PHY_PORT
 
 Validating flow rules depends on the firmware variant.
diff --git a/drivers/net/sfc/sfc_mae.c b/drivers/net/sfc/sfc_mae.c
index 5fbf627f0a..98808ac3f0 100644
--- a/drivers/net/sfc/sfc_mae.c
+++ b/drivers/net/sfc/sfc_mae.c
@@ -463,6 +463,7 @@ sfc_mae_rule_parse_pattern(struct sfc_adapter *sa,
 
 enum sfc_mae_actions_bundle_type {
 	SFC_MAE_ACTIONS_BUNDLE_EMPTY = 0,
+	SFC_MAE_ACTIONS_BUNDLE_VLAN_PUSH,
 };
 
 struct sfc_mae_actions_bundle {
@@ -470,6 +471,10 @@ struct sfc_mae_actions_bundle {
 
 	/* Indicates actions already tracked by the current bundle */
 	uint64_t				actions_mask;
+
+	/* Parameters used by SFC_MAE_ACTIONS_BUNDLE_VLAN_PUSH */
+	rte_be16_t				vlan_push_tpid;
+	rte_be16_t				vlan_push_tci;
 };
 
 /*
@@ -479,13 +484,17 @@ struct sfc_mae_actions_bundle {
  */
 static int
 sfc_mae_actions_bundle_submit(const struct sfc_mae_actions_bundle *bundle,
-			      __rte_unused efx_mae_actions_t *spec)
+			      efx_mae_actions_t *spec)
 {
 	int rc = 0;
 
 	switch (bundle->type) {
 	case SFC_MAE_ACTIONS_BUNDLE_EMPTY:
 		break;
+	case SFC_MAE_ACTIONS_BUNDLE_VLAN_PUSH:
+		rc = efx_mae_action_set_populate_vlan_push(
+			spec, bundle->vlan_push_tpid, bundle->vlan_push_tci);
+		break;
 	default:
 		SFC_ASSERT(B_FALSE);
 		break;
@@ -509,6 +518,11 @@ sfc_mae_actions_bundle_sync(const struct rte_flow_action *action,
 	int rc;
 
 	switch (action->type) {
+	case RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN:
+	case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID:
+	case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP:
+		bundle_type_new = SFC_MAE_ACTIONS_BUNDLE_VLAN_PUSH;
+		break;
 	default:
 		/*
 		 * Self-sufficient actions, including END, are handled in this
@@ -538,6 +552,34 @@ sfc_mae_actions_bundle_sync(const struct rte_flow_action *action,
 			"Failed to request the (group of) action(s)");
 }
 
+static void
+sfc_mae_rule_parse_action_of_push_vlan(
+			    const struct rte_flow_action_of_push_vlan *conf,
+			    struct sfc_mae_actions_bundle *bundle)
+{
+	bundle->vlan_push_tpid = conf->ethertype;
+}
+
+static void
+sfc_mae_rule_parse_action_of_set_vlan_vid(
+			    const struct rte_flow_action_of_set_vlan_vid *conf,
+			    struct sfc_mae_actions_bundle *bundle)
+{
+	bundle->vlan_push_tci |= (conf->vlan_vid &
+				  rte_cpu_to_be_16(RTE_LEN2MASK(12, uint16_t)));
+}
+
+static void
+sfc_mae_rule_parse_action_of_set_vlan_pcp(
+			    const struct rte_flow_action_of_set_vlan_pcp *conf,
+			    struct sfc_mae_actions_bundle *bundle)
+{
+	uint16_t vlan_tci_pcp = (uint16_t)(conf->vlan_pcp &
+					   RTE_LEN2MASK(3, uint8_t)) << 13;
+
+	bundle->vlan_push_tci |= rte_cpu_to_be_16(vlan_tci_pcp);
+}
+
 static int
 sfc_mae_rule_parse_action_phy_port(struct sfc_adapter *sa,
 				   const struct rte_flow_action_phy_port *conf,
@@ -566,7 +608,7 @@ sfc_mae_rule_parse_action(struct sfc_adapter *sa,
 			  efx_mae_actions_t *spec,
 			  struct rte_flow_error *error)
 {
-	int rc;
+	int rc = 0;
 
 	switch (action->type) {
 	case RTE_FLOW_ACTION_TYPE_OF_POP_VLAN:
@@ -574,6 +616,21 @@ sfc_mae_rule_parse_action(struct sfc_adapter *sa,
 				       bundle->actions_mask);
 		rc = efx_mae_action_set_populate_vlan_pop(spec);
 		break;
+	case RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN:
+		SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
+				       bundle->actions_mask);
+		sfc_mae_rule_parse_action_of_push_vlan(action->conf, bundle);
+		break;
+	case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID:
+		SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
+				       bundle->actions_mask);
+		sfc_mae_rule_parse_action_of_set_vlan_vid(action->conf, bundle);
+		break;
+	case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP:
+		SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
+				       bundle->actions_mask);
+		sfc_mae_rule_parse_action_of_set_vlan_pcp(action->conf, bundle);
+		break;
 	case RTE_FLOW_ACTION_TYPE_PHY_PORT:
 		SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_PHY_PORT,
 				       bundle->actions_mask);
-- 
2.17.1