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 B93C8A04DD;
	Tue, 20 Oct 2020 11:09:28 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 275D3CACC;
	Tue, 20 Oct 2020 10:50:28 +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 E1590BBB0
 for <dev@dpdk.org>; Tue, 20 Oct 2020 10:49:07 +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
 2E8C360086 for <dev@dpdk.org>; Tue, 20 Oct 2020 08:49:06 +0000 (UTC)
Received: from us4-mdac16-69.ut7.mdlocal (unknown [10.7.64.188])
 by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 2F4708009B
 for <dev@dpdk.org>; Tue, 20 Oct 2020 08:49:06 +0000 (UTC)
X-Virus-Scanned: Proofpoint Essentials engine
Received: from mx1-us1.ppe-hosted.com (unknown [10.7.66.33])
 by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 4187C280059
 for <dev@dpdk.org>; Tue, 20 Oct 2020 08:49:01 +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 EAB20A80061
 for <dev@dpdk.org>; Tue, 20 Oct 2020 08:49:00 +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 09:48:50 +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 09:48:50 +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 09K8mn1U030804;
 Tue, 20 Oct 2020 09:48:50 +0100
Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1])
 by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 69A631626E1;
 Tue, 20 Oct 2020 09:48:49 +0100 (BST)
From: Andrew Rybchenko <arybchenko@solarflare.com>
To: <y@solarflare.com>
CC: <dev@dpdk.org>, Ivan Malov <ivan.malov@oktetlabs.ru>
Date: Tue, 20 Oct 2020 09:47:59 +0100
Message-ID: <1603183709-23420-33-git-send-email-arybchenko@solarflare.com>
X-Mailer: git-send-email 1.8.3.1
In-Reply-To: <1603183709-23420-1-git-send-email-arybchenko@solarflare.com>
References: <1603183709-23420-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.082000-8.000000-10
X-TMASE-MatchedRID: pX1c04mAgVEZ7Z5t6RByKcbr3d9/yP1kaeMaKzvXUpljLp8Cm8vwF12O
 RX0B8+qTT1fsjZmF+qzm9S/0eIQUb+ox2xGkyLxhPwKTD1v8YV5SDnPEI8clbdjMMV3eZDNhrWm
 yq7PauHmer62Ni/rU6K1TSd3U5mjSWELDcKwGO24Pe5gzF3TVt1xo0H+7nJCrijbNm22YqDBnj1
 T6aiJbiTxOxTEbgyTygDLqnrRlXrZ8nn9tnqel2MZW5ai5WKlyLI9Rj5e/2rM7mylLNWg91tRwX
 o/6srg5M3VnBiT32oTeccuulHjnOrASsnG6FVMG3uJICNR8ChGK5URknflp4R5N9Xn7Fnyp8Oyc
 cFNBL2TKhETi2//sjuP9Cb59K8ACZrS+A8PszW/U9h9N881NSQ==
X-TM-AS-User-Approved-Sender: Yes
X-TM-AS-User-Blocked-Sender: No
X-TMASE-Result: 10--2.082000-8.000000
X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25736.003
X-MDID: 1603183741-MLHalgAcbAwB
X-PPE-DISP: 1603183741;MLHalgAcbAwB
Subject: [dpdk-dev] [PATCH 32/62] common/sfc_efx/base: support adding MARK
	action to a set
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>

This action can be added at any point before DELIVER.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/common/sfc_efx/base/efx.h             |  6 ++
 drivers/common/sfc_efx/base/efx_impl.h        |  2 +
 drivers/common/sfc_efx/base/efx_mae.c         | 58 ++++++++++++++++++-
 .../sfc_efx/rte_common_sfc_efx_version.map    |  1 +
 4 files changed, 65 insertions(+), 2 deletions(-)

diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h
index e03da22c3b..1d2987653b 100644
--- a/drivers/common/sfc_efx/base/efx.h
+++ b/drivers/common/sfc_efx/base/efx.h
@@ -4183,6 +4183,12 @@ extern	__checkReturn			efx_rc_t
 efx_mae_action_set_populate_flag(
 	__in				efx_mae_actions_t *spec);
 
+LIBEFX_API
+extern	__checkReturn			efx_rc_t
+efx_mae_action_set_populate_mark(
+	__in				efx_mae_actions_t *spec,
+	__in				uint32_t mark_value);
+
 LIBEFX_API
 extern	__checkReturn			efx_rc_t
 efx_mae_action_set_populate_deliver(
diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h
index bffd4c6ce8..db68cc7b24 100644
--- a/drivers/common/sfc_efx/base/efx_impl.h
+++ b/drivers/common/sfc_efx/base/efx_impl.h
@@ -1711,6 +1711,7 @@ typedef enum efx_mae_action_e {
 	 * in the end of the enumeration (before DELIVER).
 	 */
 	EFX_MAE_ACTION_FLAG,
+	EFX_MAE_ACTION_MARK,
 
 	/* DELIVER is always the last action. */
 	EFX_MAE_ACTION_DELIVER,
@@ -1737,6 +1738,7 @@ typedef struct efx_mae_actions_s {
 	unsigned int			emass_n_vlan_tags_to_push;
 	efx_mae_action_vlan_push_t	emass_vlan_push_descs[
 	    EFX_MAE_VLAN_PUSH_MAX_NTAGS];
+	uint32_t			emass_mark_value;
 	efx_mport_sel_t			emass_deliver_mport;
 } efx_mae_actions_t;
 
diff --git a/drivers/common/sfc_efx/base/efx_mae.c b/drivers/common/sfc_efx/base/efx_mae.c
index 93fd02f6d2..880336a7d9 100644
--- a/drivers/common/sfc_efx/base/efx_mae.c
+++ b/drivers/common/sfc_efx/base/efx_mae.c
@@ -746,6 +746,35 @@ efx_mae_action_set_add_flag(
 	return (rc);
 }
 
+static	__checkReturn			efx_rc_t
+efx_mae_action_set_add_mark(
+	__in				efx_mae_actions_t *spec,
+	__in				size_t arg_size,
+	__in_bcount(arg_size)		const uint8_t *arg)
+{
+	efx_rc_t rc;
+
+	if (arg_size != sizeof (spec->emass_mark_value)) {
+		rc = EINVAL;
+		goto fail1;
+	}
+
+	if (arg == NULL) {
+		rc = EINVAL;
+		goto fail2;
+	}
+
+	memcpy(&spec->emass_mark_value, arg, arg_size);
+
+	return (0);
+
+fail2:
+	EFSYS_PROBE(fail2);
+fail1:
+	EFSYS_PROBE1(fail1, efx_rc_t, rc);
+	return (rc);
+}
+
 static	__checkReturn			efx_rc_t
 efx_mae_action_set_add_deliver(
 	__in				efx_mae_actions_t *spec,
@@ -791,6 +820,9 @@ static const efx_mae_action_desc_t efx_mae_actions[EFX_MAE_NACTIONS] = {
 	[EFX_MAE_ACTION_FLAG] = {
 		.emad_add = efx_mae_action_set_add_flag
 	},
+	[EFX_MAE_ACTION_MARK] = {
+		.emad_add = efx_mae_action_set_add_mark
+	},
 	[EFX_MAE_ACTION_DELIVER] = {
 		.emad_add = efx_mae_action_set_add_deliver
 	}
@@ -800,6 +832,7 @@ static const uint32_t efx_mae_action_ordered_map =
 	(1U << EFX_MAE_ACTION_VLAN_POP) |
 	(1U << EFX_MAE_ACTION_VLAN_PUSH) |
 	(1U << EFX_MAE_ACTION_FLAG) |
+	(1U << EFX_MAE_ACTION_MARK) |
 	(1U << EFX_MAE_ACTION_DELIVER);
 
 /*
@@ -808,7 +841,8 @@ static const uint32_t efx_mae_action_ordered_map =
  * strictly ordered actions.
  */
 static const uint32_t efx_mae_action_nonstrict_map =
-	(1U << EFX_MAE_ACTION_FLAG);
+	(1U << EFX_MAE_ACTION_FLAG) |
+	(1U << EFX_MAE_ACTION_MARK);
 
 static const uint32_t efx_mae_action_repeat_map =
 	(1U << EFX_MAE_ACTION_VLAN_POP) |
@@ -836,7 +870,8 @@ efx_mae_action_set_spec_populate(
 	    (sizeof (efx_mae_action_repeat_map) * 8));
 
 	EFX_STATIC_ASSERT(EFX_MAE_ACTION_DELIVER + 1 == EFX_MAE_NACTIONS);
-	EFX_STATIC_ASSERT(EFX_MAE_ACTION_FLAG + 1 == EFX_MAE_ACTION_DELIVER);
+	EFX_STATIC_ASSERT(EFX_MAE_ACTION_FLAG + 1 == EFX_MAE_ACTION_MARK);
+	EFX_STATIC_ASSERT(EFX_MAE_ACTION_MARK + 1 == EFX_MAE_ACTION_DELIVER);
 
 	if (type >= EFX_ARRAY_SIZE(efx_mae_actions)) {
 		rc = EINVAL;
@@ -920,6 +955,17 @@ efx_mae_action_set_populate_flag(
 	    EFX_MAE_ACTION_FLAG, 0, NULL));
 }
 
+	__checkReturn			efx_rc_t
+efx_mae_action_set_populate_mark(
+	__in				efx_mae_actions_t *spec,
+	__in				uint32_t mark_value)
+{
+	const uint8_t *arg = (const uint8_t *)&mark_value;
+
+	return (efx_mae_action_set_spec_populate(spec,
+	    EFX_MAE_ACTION_MARK, sizeof (mark_value), arg));
+}
+
 	__checkReturn			efx_rc_t
 efx_mae_action_set_populate_deliver(
 	__in				efx_mae_actions_t *spec,
@@ -1117,6 +1163,14 @@ efx_mae_action_set_alloc(
 		    MAE_ACTION_SET_ALLOC_IN_FLAG, 1);
 	}
 
+	if ((spec->emass_actions & (1U << EFX_MAE_ACTION_MARK)) != 0) {
+		MCDI_IN_SET_DWORD_FIELD(req, MAE_ACTION_SET_ALLOC_IN_FLAGS,
+		    MAE_ACTION_SET_ALLOC_IN_MARK, 1);
+
+		MCDI_IN_SET_DWORD(req,
+		    MAE_ACTION_SET_ALLOC_IN_MARK_VALUE, spec->emass_mark_value);
+	}
+
 	MCDI_IN_SET_DWORD(req,
 	    MAE_ACTION_SET_ALLOC_IN_DELIVER, spec->emass_deliver_mport.sel);
 
diff --git a/drivers/common/sfc_efx/rte_common_sfc_efx_version.map b/drivers/common/sfc_efx/rte_common_sfc_efx_version.map
index f57f4a3a8f..6ed412ee39 100644
--- a/drivers/common/sfc_efx/rte_common_sfc_efx_version.map
+++ b/drivers/common/sfc_efx/rte_common_sfc_efx_version.map
@@ -91,6 +91,7 @@ INTERNAL {
 	efx_mae_action_set_free;
 	efx_mae_action_set_populate_deliver;
 	efx_mae_action_set_populate_flag;
+	efx_mae_action_set_populate_mark;
 	efx_mae_action_set_populate_vlan_pop;
 	efx_mae_action_set_populate_vlan_push;
 	efx_mae_action_set_spec_fini;
-- 
2.17.1