From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 3AB6D459C6;
	Wed, 18 Sep 2024 09:52:03 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id E933242ED8;
	Wed, 18 Sep 2024 09:51:12 +0200 (CEST)
Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13])
 by mails.dpdk.org (Postfix) with ESMTP id 66ACE42E8B
 for <dev@dpdk.org>; Wed, 18 Sep 2024 09:51:01 +0200 (CEST)
Received: from inva020.nxp.com (localhost [127.0.0.1])
 by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 4BC9A1A13B8;
 Wed, 18 Sep 2024 09:51:01 +0200 (CEST)
Received: from aprdc01srsp001v.ap-rdc01.nxp.com
 (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16])
 by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 121D71A0343;
 Wed, 18 Sep 2024 09:51:01 +0200 (CEST)
Received: from lsv03379.swis.in-blr01.nxp.com (lsv03379.swis.in-blr01.nxp.com
 [92.120.147.188])
 by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id 29B32183C481;
 Wed, 18 Sep 2024 15:51:00 +0800 (+08)
From: vanshika.shukla@nxp.com
To: dev@dpdk.org, Hemant Agrawal <hemant.agrawal@nxp.com>,
 Sachin Saxena <sachin.saxena@nxp.com>
Cc: Vanshika Shukla <vanshika.shukla@nxp.com>
Subject: [v2 07/43] net/dpaa2: dpdmux: add support for CVLAN
Date: Wed, 18 Sep 2024 13:20:20 +0530
Message-Id: <20240918075056.1838654-8-vanshika.shukla@nxp.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20240918075056.1838654-1-vanshika.shukla@nxp.com>
References: <20240913055959.3246917-1-vanshika.shukla@nxp.com>
 <20240918075056.1838654-1-vanshika.shukla@nxp.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Virus-Scanned: ClamAV using ClamSMTP
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
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

From: Vanshika Shukla <vanshika.shukla@nxp.com>

This patch adds the support for DPDMUX_METHOD_C_VLAN_MAC method
which implements DPDMUX based on C-VLAN and MAC address.

Signed-off-by: Vanshika Shukla <vanshika.shukla@nxp.com>
---
 drivers/net/dpaa2/dpaa2_mux.c     | 59 +++++++++++++++++++++++++------
 drivers/net/dpaa2/mc/fsl_dpdmux.h | 18 +++++++++-
 drivers/net/dpaa2/rte_pmd_dpaa2.h |  3 ++
 3 files changed, 68 insertions(+), 12 deletions(-)

diff --git a/drivers/net/dpaa2/dpaa2_mux.c b/drivers/net/dpaa2/dpaa2_mux.c
index fa3659e452..53020e9302 100644
--- a/drivers/net/dpaa2/dpaa2_mux.c
+++ b/drivers/net/dpaa2/dpaa2_mux.c
@@ -233,6 +233,35 @@ rte_pmd_dpaa2_mux_flow_create(uint32_t dpdmux_id,
 	return NULL;
 }
 
+int
+rte_pmd_dpaa2_mux_flow_l2(uint32_t dpdmux_id,
+	uint8_t mac_addr[6], uint16_t vlan_id, int dest_if)
+{
+	struct dpaa2_dpdmux_dev *dpdmux_dev;
+	struct dpdmux_l2_rule rule;
+	int ret, i;
+
+	/* Find the DPDMUX from dpdmux_id in our list */
+	dpdmux_dev = get_dpdmux_from_id(dpdmux_id);
+	if (!dpdmux_dev) {
+		DPAA2_PMD_ERR("Invalid dpdmux_id: %d", dpdmux_id);
+		return -ENODEV;
+	}
+
+	for (i = 0; i < 6; i++)
+		rule.mac_addr[i] = mac_addr[i];
+	rule.vlan_id = vlan_id;
+
+	ret = dpdmux_if_add_l2_rule(&dpdmux_dev->dpdmux, CMD_PRI_LOW,
+			dpdmux_dev->token, dest_if, &rule);
+	if (ret) {
+		DPAA2_PMD_ERR("dpdmux_if_add_l2_rule failed:err(%d)", ret);
+		return ret;
+	}
+
+	return 0;
+}
+
 int
 rte_pmd_dpaa2_mux_rx_frame_len(uint32_t dpdmux_id, uint16_t max_rx_frame_len)
 {
@@ -353,6 +382,7 @@ dpaa2_create_dpdmux_device(int vdev_fd __rte_unused,
 	int ret;
 	uint16_t maj_ver;
 	uint16_t min_ver;
+	uint8_t skip_reset_flags;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -379,12 +409,18 @@ dpaa2_create_dpdmux_device(int vdev_fd __rte_unused,
 		goto init_err;
 	}
 
-	ret = dpdmux_if_set_default(&dpdmux_dev->dpdmux, CMD_PRI_LOW,
-				    dpdmux_dev->token, attr.default_if);
-	if (ret) {
-		DPAA2_PMD_ERR("setting default interface failed in %s",
-			      __func__);
-		goto init_err;
+	if (attr.method != DPDMUX_METHOD_C_VLAN_MAC) {
+		ret = dpdmux_if_set_default(&dpdmux_dev->dpdmux, CMD_PRI_LOW,
+				dpdmux_dev->token, attr.default_if);
+		if (ret) {
+			DPAA2_PMD_ERR("setting default interface failed in %s",
+				      __func__);
+			goto init_err;
+		}
+		skip_reset_flags = DPDMUX_SKIP_DEFAULT_INTERFACE
+			| DPDMUX_SKIP_UNICAST_RULES | DPDMUX_SKIP_MULTICAST_RULES;
+	} else {
+		skip_reset_flags = DPDMUX_SKIP_DEFAULT_INTERFACE;
 	}
 
 	ret = dpdmux_get_api_version(&dpdmux_dev->dpdmux, CMD_PRI_LOW,
@@ -400,10 +436,7 @@ dpaa2_create_dpdmux_device(int vdev_fd __rte_unused,
 	 */
 	if (maj_ver >= 6 && min_ver >= 6) {
 		ret = dpdmux_set_resetable(&dpdmux_dev->dpdmux, CMD_PRI_LOW,
-				dpdmux_dev->token,
-				DPDMUX_SKIP_DEFAULT_INTERFACE |
-				DPDMUX_SKIP_UNICAST_RULES |
-				DPDMUX_SKIP_MULTICAST_RULES);
+				dpdmux_dev->token, skip_reset_flags);
 		if (ret) {
 			DPAA2_PMD_ERR("setting default interface failed in %s",
 				      __func__);
@@ -416,7 +449,11 @@ dpaa2_create_dpdmux_device(int vdev_fd __rte_unused,
 
 		memset(&mux_err_cfg, 0, sizeof(mux_err_cfg));
 		mux_err_cfg.error_action = DPDMUX_ERROR_ACTION_CONTINUE;
-		mux_err_cfg.errors = DPDMUX_ERROR_DISC;
+
+		if (attr.method != DPDMUX_METHOD_C_VLAN_MAC)
+			mux_err_cfg.errors = DPDMUX_ERROR_DISC;
+		else
+			mux_err_cfg.errors = DPDMUX_ALL_ERRORS;
 
 		ret = dpdmux_if_set_errors_behavior(&dpdmux_dev->dpdmux,
 				CMD_PRI_LOW,
diff --git a/drivers/net/dpaa2/mc/fsl_dpdmux.h b/drivers/net/dpaa2/mc/fsl_dpdmux.h
index 4600ea94d4..9bbac44219 100644
--- a/drivers/net/dpaa2/mc/fsl_dpdmux.h
+++ b/drivers/net/dpaa2/mc/fsl_dpdmux.h
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
  *
  * Copyright 2013-2016 Freescale Semiconductor Inc.
- * Copyright 2018-2021 NXP
+ * Copyright 2018-2022 NXP
  *
  */
 #ifndef __FSL_DPDMUX_H
@@ -549,6 +549,22 @@ int dpdmux_get_api_version(struct fsl_mc_io *mc_io,
  */
 #define DPDMUX__ERROR_L4CE			0x00000001
 
+#define DPDMUX_ALL_ERRORS	(DPDMUX__ERROR_L4CE | \
+				 DPDMUX__ERROR_L4CV | \
+				 DPDMUX__ERROR_L3CE | \
+				 DPDMUX__ERROR_L3CV | \
+				 DPDMUX_ERROR_BLE | \
+				 DPDMUX_ERROR_PHE | \
+				 DPDMUX_ERROR_ISP | \
+				 DPDMUX_ERROR_PTE | \
+				 DPDMUX_ERROR_FPE | \
+				 DPDMUX_ERROR_FLE | \
+				 DPDMUX_ERROR_PIEE | \
+				 DPDMUX_ERROR_TIDE | \
+				 DPDMUX_ERROR_MNLE | \
+				 DPDMUX_ERROR_EOFHE | \
+				 DPDMUX_ERROR_KSE)
+
 enum dpdmux_error_action {
 	DPDMUX_ERROR_ACTION_DISCARD = 0,
 	DPDMUX_ERROR_ACTION_CONTINUE = 1
diff --git a/drivers/net/dpaa2/rte_pmd_dpaa2.h b/drivers/net/dpaa2/rte_pmd_dpaa2.h
index 80e5e3298b..bebebcacdc 100644
--- a/drivers/net/dpaa2/rte_pmd_dpaa2.h
+++ b/drivers/net/dpaa2/rte_pmd_dpaa2.h
@@ -35,6 +35,9 @@ rte_pmd_dpaa2_mux_flow_create(uint32_t dpdmux_id,
 int
 rte_pmd_dpaa2_mux_flow_destroy(uint32_t dpdmux_id,
 	uint16_t entry_index);
+int
+rte_pmd_dpaa2_mux_flow_l2(uint32_t dpdmux_id,
+	uint8_t mac_addr[6], uint16_t vlan_id, int dest_if);
 
 /**
  * @warning
-- 
2.25.1