From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4471245977; Fri, 13 Sep 2024 08:01:04 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 411A942E7D; Fri, 13 Sep 2024 08:00:15 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by mails.dpdk.org (Postfix) with ESMTP id 2802742E0C for ; Fri, 13 Sep 2024 08:00:06 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 07F921A270E; Fri, 13 Sep 2024 08:00:06 +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 A015F1A270D; Fri, 13 Sep 2024 08:00:05 +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 3E52B183DC36; Fri, 13 Sep 2024 14:00:03 +0800 (+08) From: vanshika.shukla@nxp.com To: dev@dpdk.org, Hemant Agrawal , Sachin Saxena Cc: Vanshika Shukla Subject: [v1 07/43] net/dpaa2: dpdmux: add support for CVLAN Date: Fri, 13 Sep 2024 11:29:23 +0530 Message-Id: <20240913055959.3246917-8-vanshika.shukla@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240913055959.3246917-1-vanshika.shukla@nxp.com> References: <20240913055959.3246917-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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Vanshika Shukla 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 --- 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