[v1,36/38] net/mvpp2: forward bad packets support

Message ID 20201202101212.4717-37-lironh@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: Jerin Jacob
Headers
Series net/mvpp2: misc updates |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Liron Himi Dec. 2, 2020, 10:12 a.m. UTC
  From: Dana Vardi <danat@marvell.com>

extend the config file with option to forward packets
that were marked as "l2 bad pkts".
by default the driver drop those packets

Signed-off-by: Dana Vardi <danat@marvell.com>
Reviewed-by: Liron Himi <lironh@marvell.com>
---
 drivers/net/mvpp2/mrvl_ethdev.c | 10 ++++++++--
 drivers/net/mvpp2/mrvl_ethdev.h |  2 ++
 drivers/net/mvpp2/mrvl_qos.c    | 17 +++++++++++++++++
 drivers/net/mvpp2/mrvl_qos.h    |  1 +
 4 files changed, 28 insertions(+), 2 deletions(-)
  

Comments

Michael Shamis Dec. 23, 2020, 9:28 a.m. UTC | #1
Reviewed-by: Michael Shamis <michaelsh@marvell.com>

-----Original Message-----
From: dev <dev-bounces@dpdk.org> On Behalf Of lironh@marvell.com
Sent: Wednesday, December 2, 2020 12:12 PM
To: Jerin Jacob Kollanukkaran <jerinj@marvell.com>
Cc: dev@dpdk.org; Dana Vardi <danat@marvell.com>; Liron Himi <lironh@marvell.com>
Subject: [dpdk-dev] [PATCH v1 36/38] net/mvpp2: forward bad packets support

From: Dana Vardi <danat@marvell.com>

extend the config file with option to forward packets that were marked as "l2 bad pkts".
by default the driver drop those packets

Signed-off-by: Dana Vardi <danat@marvell.com>
Reviewed-by: Liron Himi <lironh@marvell.com>
---
 drivers/net/mvpp2/mrvl_ethdev.c | 10 ++++++++--  drivers/net/mvpp2/mrvl_ethdev.h |  2 ++
 drivers/net/mvpp2/mrvl_qos.c    | 17 +++++++++++++++++
 drivers/net/mvpp2/mrvl_qos.h    |  1 +
 4 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c index cb792300b..4b5c4f075 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.c
+++ b/drivers/net/mvpp2/mrvl_ethdev.c
@@ -798,9 +798,14 @@ mrvl_dev_start(struct rte_eth_dev *dev)
 		 priv->pp_id, priv->ppio_id);
 	priv->ppio_params.match = match;
 	priv->ppio_params.eth_start_hdr = PP2_PPIO_HDR_ETH;
-	if (mrvl_cfg)
+	priv->forward_bad_frames = 0;
+
+	if (mrvl_cfg) {
 		priv->ppio_params.eth_start_hdr =
 			mrvl_cfg->port[dev->data->port_id].eth_start_hdr;
+		priv->forward_bad_frames =
+			mrvl_cfg->port[dev->data->port_id].forward_bad_frames;
+	}
 
 	/*
 	 * Calculate the minimum bpool size for refill feature as follows:
@@ -2709,7 +2714,8 @@ mrvl_rx_pkt_burst(void *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 
 		/* drop packet in case of mac, overrun or resource error */
 		status = pp2_ppio_inq_desc_get_l2_pkt_error(&descs[i]);
-		if (unlikely(status != PP2_DESC_ERR_OK)) {
+		if ((unlikely(status != PP2_DESC_ERR_OK)) &&
+			!(q->priv->forward_bad_frames)) {
 			struct pp2_buff_inf binf = {
 				.addr = rte_mbuf_data_iova_default(mbuf),
 				.cookie = (uint64_t)mbuf,
diff --git a/drivers/net/mvpp2/mrvl_ethdev.h b/drivers/net/mvpp2/mrvl_ethdev.h index 148f2acba..2c1c159b9 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.h
+++ b/drivers/net/mvpp2/mrvl_ethdev.h
@@ -182,6 +182,8 @@ struct mrvl_priv {
 	LIST_HEAD(shaper_profiles, mrvl_tm_shaper_profile) shaper_profiles;
 	LIST_HEAD(nodes, mrvl_tm_node) nodes;
 	uint64_t rate_max;
+
+	uint8_t forward_bad_frames;
 };
 
 /** Flow operations forward declaration. */ diff --git a/drivers/net/mvpp2/mrvl_qos.c b/drivers/net/mvpp2/mrvl_qos.c index 10e8636b4..f3936aec4 100644
--- a/drivers/net/mvpp2/mrvl_qos.c
+++ b/drivers/net/mvpp2/mrvl_qos.c
@@ -76,6 +76,8 @@
 #define MRVL_TOK_PARSER_UDF_PROTO_UDP "udp"
 #define MRVL_TOK_PARSER_UDF_FIELD_UDP_DPORT "dport"
 
+/* paser forward bad frames tokens */
+#define MRVL_TOK_FWD_BAD_FRAMES "forward_bad_frames"
 
 /** Number of tokens in range a-b = 2. */  #define MAX_RNG_TOKENS 2 @@ -872,6 +874,21 @@ mrvl_get_cfg(const char *key __rte_unused, const char *path, void *extra_args)
 				return -1;
 			}
 		}
+
+		/* Parse forward bad frames option */
+		entry = rte_cfgfile_get_entry(file, sec_name,
+				MRVL_TOK_FWD_BAD_FRAMES);
+		if (entry) {
+			if (get_val_securely(entry, &val) < 0) {
+				MRVL_LOG(ERR,
+					"Error in parsing %s value (%s)!\n",
+					MRVL_TOK_FWD_BAD_FRAMES, entry);
+				return -1;
+			}
+			(*cfg)->port[n].forward_bad_frames = (uint8_t)val;
+		} else {
+			(*cfg)->port[n].forward_bad_frames = 0;
+		}
 	}
 
 	return 0;
diff --git a/drivers/net/mvpp2/mrvl_qos.h b/drivers/net/mvpp2/mrvl_qos.h index daf4776ec..f2e341c37 100644
--- a/drivers/net/mvpp2/mrvl_qos.h
+++ b/drivers/net/mvpp2/mrvl_qos.h
@@ -48,6 +48,7 @@ struct mrvl_cfg {
 		uint8_t use_global_defaults;
 		struct pp2_cls_plcr_params policer_params;
 		uint8_t setup_policer;
+		uint8_t forward_bad_frames;
 	} port[RTE_MAX_ETHPORTS];
 };
 
--
2.28.0
  

Patch

diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c
index cb792300b..4b5c4f075 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.c
+++ b/drivers/net/mvpp2/mrvl_ethdev.c
@@ -798,9 +798,14 @@  mrvl_dev_start(struct rte_eth_dev *dev)
 		 priv->pp_id, priv->ppio_id);
 	priv->ppio_params.match = match;
 	priv->ppio_params.eth_start_hdr = PP2_PPIO_HDR_ETH;
-	if (mrvl_cfg)
+	priv->forward_bad_frames = 0;
+
+	if (mrvl_cfg) {
 		priv->ppio_params.eth_start_hdr =
 			mrvl_cfg->port[dev->data->port_id].eth_start_hdr;
+		priv->forward_bad_frames =
+			mrvl_cfg->port[dev->data->port_id].forward_bad_frames;
+	}
 
 	/*
 	 * Calculate the minimum bpool size for refill feature as follows:
@@ -2709,7 +2714,8 @@  mrvl_rx_pkt_burst(void *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 
 		/* drop packet in case of mac, overrun or resource error */
 		status = pp2_ppio_inq_desc_get_l2_pkt_error(&descs[i]);
-		if (unlikely(status != PP2_DESC_ERR_OK)) {
+		if ((unlikely(status != PP2_DESC_ERR_OK)) &&
+			!(q->priv->forward_bad_frames)) {
 			struct pp2_buff_inf binf = {
 				.addr = rte_mbuf_data_iova_default(mbuf),
 				.cookie = (uint64_t)mbuf,
diff --git a/drivers/net/mvpp2/mrvl_ethdev.h b/drivers/net/mvpp2/mrvl_ethdev.h
index 148f2acba..2c1c159b9 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.h
+++ b/drivers/net/mvpp2/mrvl_ethdev.h
@@ -182,6 +182,8 @@  struct mrvl_priv {
 	LIST_HEAD(shaper_profiles, mrvl_tm_shaper_profile) shaper_profiles;
 	LIST_HEAD(nodes, mrvl_tm_node) nodes;
 	uint64_t rate_max;
+
+	uint8_t forward_bad_frames;
 };
 
 /** Flow operations forward declaration. */
diff --git a/drivers/net/mvpp2/mrvl_qos.c b/drivers/net/mvpp2/mrvl_qos.c
index 10e8636b4..f3936aec4 100644
--- a/drivers/net/mvpp2/mrvl_qos.c
+++ b/drivers/net/mvpp2/mrvl_qos.c
@@ -76,6 +76,8 @@ 
 #define MRVL_TOK_PARSER_UDF_PROTO_UDP "udp"
 #define MRVL_TOK_PARSER_UDF_FIELD_UDP_DPORT "dport"
 
+/* paser forward bad frames tokens */
+#define MRVL_TOK_FWD_BAD_FRAMES "forward_bad_frames"
 
 /** Number of tokens in range a-b = 2. */
 #define MAX_RNG_TOKENS 2
@@ -872,6 +874,21 @@  mrvl_get_cfg(const char *key __rte_unused, const char *path, void *extra_args)
 				return -1;
 			}
 		}
+
+		/* Parse forward bad frames option */
+		entry = rte_cfgfile_get_entry(file, sec_name,
+				MRVL_TOK_FWD_BAD_FRAMES);
+		if (entry) {
+			if (get_val_securely(entry, &val) < 0) {
+				MRVL_LOG(ERR,
+					"Error in parsing %s value (%s)!\n",
+					MRVL_TOK_FWD_BAD_FRAMES, entry);
+				return -1;
+			}
+			(*cfg)->port[n].forward_bad_frames = (uint8_t)val;
+		} else {
+			(*cfg)->port[n].forward_bad_frames = 0;
+		}
 	}
 
 	return 0;
diff --git a/drivers/net/mvpp2/mrvl_qos.h b/drivers/net/mvpp2/mrvl_qos.h
index daf4776ec..f2e341c37 100644
--- a/drivers/net/mvpp2/mrvl_qos.h
+++ b/drivers/net/mvpp2/mrvl_qos.h
@@ -48,6 +48,7 @@  struct mrvl_cfg {
 		uint8_t use_global_defaults;
 		struct pp2_cls_plcr_params policer_params;
 		uint8_t setup_policer;
+		uint8_t forward_bad_frames;
 	} port[RTE_MAX_ETHPORTS];
 };