[v1,15/38] net/mvpp2: only use ol_flags for checksum generation offload

Message ID 20201202101212.4717-16-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 success coding style OK

Commit Message

Liron Himi Dec. 2, 2020, 10:11 a.m. UTC
  From: Liron Himi <lironh@marvell.com>

according to the dpdk spec, only 'ol_flags'
should be used for tx checksum generation

Signed-off-by: Liron Himi <lironh@marvell.com>
Reviewed-by: Liron Himi <lironh@marvell.com>
---
 drivers/net/mvpp2/mrvl_ethdev.c | 60 ++++++++++++++-------------------
 1 file changed, 26 insertions(+), 34 deletions(-)
  

Comments

Michael Shamis Dec. 23, 2020, 9:41 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; Liron Himi <lironh@marvell.com>
Subject: [dpdk-dev] [PATCH v1 15/38] net/mvpp2: only use ol_flags for checksum generation offload

From: Liron Himi <lironh@marvell.com>

according to the dpdk spec, only 'ol_flags'
should be used for tx checksum generation

Signed-off-by: Liron Himi <lironh@marvell.com>
Reviewed-by: Liron Himi <lironh@marvell.com>
---
 drivers/net/mvpp2/mrvl_ethdev.c | 60 ++++++++++++++-------------------
 1 file changed, 26 insertions(+), 34 deletions(-)

diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c index a87336a4c..a03d39aee 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.c
+++ b/drivers/net/mvpp2/mrvl_ethdev.c
@@ -63,11 +63,16 @@
 			  DEV_RX_OFFLOAD_CHECKSUM)
 
 /** Port Tx offloads capabilities */
-#define MRVL_TX_OFFLOADS (DEV_TX_OFFLOAD_IPV4_CKSUM | \
-			  DEV_TX_OFFLOAD_UDP_CKSUM | \
-			  DEV_TX_OFFLOAD_TCP_CKSUM | \
+#define MRVL_TX_OFFLOAD_CHECKSUM (DEV_TX_OFFLOAD_IPV4_CKSUM | \
+				  DEV_TX_OFFLOAD_UDP_CKSUM  | \
+				  DEV_TX_OFFLOAD_TCP_CKSUM)
+#define MRVL_TX_OFFLOADS (MRVL_TX_OFFLOAD_CHECKSUM | \
 			  DEV_TX_OFFLOAD_MULTI_SEGS)
 
+#define MRVL_TX_PKT_OFFLOADS (PKT_TX_IP_CKSUM | \
+			      PKT_TX_TCP_CKSUM | \
+			      PKT_TX_UDP_CKSUM)
+
 static const char * const valid_args[] = {
 	MRVL_IFACE_NAME_ARG,
 	MRVL_CFG_ARG,
@@ -2596,8 +2601,6 @@ mrvl_rx_pkt_burst(void *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
  *
  * @param ol_flags
  *   Offload flags.
- * @param packet_type
- *   Packet type bitfield.
  * @param l3_type
  *   Pointer to the pp2_ouq_l3_type structure.
  * @param l4_type
@@ -2606,12 +2609,9 @@ mrvl_rx_pkt_burst(void *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
  *   Will be set to 1 in case l3 checksum is computed.
  * @param l4_cksum
  *   Will be set to 1 in case l4 checksum is computed.
- *
- * @return
- *   0 on success, negative error value otherwise.
  */
-static inline int
-mrvl_prepare_proto_info(uint64_t ol_flags, uint32_t packet_type,
+static inline void
+mrvl_prepare_proto_info(uint64_t ol_flags,
 			enum pp2_outq_l3_type *l3_type,
 			enum pp2_outq_l4_type *l4_type,
 			int *gen_l3_cksum,
@@ -2621,26 +2621,22 @@ mrvl_prepare_proto_info(uint64_t ol_flags, uint32_t packet_type,
 	 * Based on ol_flags prepare information
 	 * for pp2_ppio_outq_desc_set_proto_info() which setups descriptor
 	 * for offloading.
+	 * in most of the checksum cases ipv4 must be set, so this is the
+	 * default value
 	 */
-	if (ol_flags & PKT_TX_IPV4) {
-		*l3_type = PP2_OUTQ_L3_TYPE_IPV4;
-		*gen_l3_cksum = ol_flags & PKT_TX_IP_CKSUM ? 1 : 0;
-	} else if (ol_flags & PKT_TX_IPV6) {
+	*l3_type = PP2_OUTQ_L3_TYPE_IPV4;
+	*gen_l3_cksum = ol_flags & PKT_TX_IP_CKSUM ? 1 : 0;
+
+	if (ol_flags & PKT_TX_IPV6) {
 		*l3_type = PP2_OUTQ_L3_TYPE_IPV6;
 		/* no checksum for ipv6 header */
 		*gen_l3_cksum = 0;
-	} else {
-		/* if something different then stop processing */
-		return -1;
 	}
 
-	ol_flags &= PKT_TX_L4_MASK;
-	if ((packet_type & RTE_PTYPE_L4_TCP) &&
-	    ol_flags == PKT_TX_TCP_CKSUM) {
+	if ((ol_flags & PKT_TX_L4_MASK) == PKT_TX_TCP_CKSUM) {
 		*l4_type = PP2_OUTQ_L4_TYPE_TCP;
 		*gen_l4_cksum = 1;
-	} else if ((packet_type & RTE_PTYPE_L4_UDP) &&
-		   ol_flags == PKT_TX_UDP_CKSUM) {
+	} else if ((ol_flags & PKT_TX_L4_MASK) ==  PKT_TX_UDP_CKSUM) {
 		*l4_type = PP2_OUTQ_L4_TYPE_UDP;
 		*gen_l4_cksum = 1;
 	} else {
@@ -2648,8 +2644,6 @@ mrvl_prepare_proto_info(uint64_t ol_flags, uint32_t packet_type,
 		/* no checksum for other type */
 		*gen_l4_cksum = 0;
 	}
-
-	return 0;
 }
 
 /**
@@ -2750,7 +2744,7 @@ mrvl_tx_pkt_burst(void *txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 	struct pp2_hif *hif;
 	struct pp2_ppio_desc descs[nb_pkts];
 	unsigned int core_id = rte_lcore_id();
-	int i, ret, bytes_sent = 0;
+	int i, bytes_sent = 0;
 	uint16_t num, sq_free_size;
 	uint64_t addr;
 
@@ -2794,11 +2788,10 @@ mrvl_tx_pkt_burst(void *txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 		 * in case unsupported ol_flags were passed
 		 * do not update descriptor offload information
 		 */
-		ret = mrvl_prepare_proto_info(mbuf->ol_flags, mbuf->packet_type,
-					      &l3_type, &l4_type, &gen_l3_cksum,
-					      &gen_l4_cksum);
-		if (unlikely(ret))
+		if (!(mbuf->ol_flags & MRVL_TX_PKT_OFFLOADS))
 			continue;
+		mrvl_prepare_proto_info(mbuf->ol_flags, &l3_type, &l4_type,
+					&gen_l3_cksum, &gen_l4_cksum);
 
 		pp2_ppio_outq_desc_set_proto_info(&descs[i], l3_type, l4_type,
 						  mbuf->l2_len,
@@ -2848,7 +2841,7 @@ mrvl_tx_sg_pkt_burst(void *txq, struct rte_mbuf **tx_pkts,
 	struct pp2_ppio_sg_pkts pkts;
 	uint8_t frags[nb_pkts];
 	unsigned int core_id = rte_lcore_id();
-	int i, j, ret, bytes_sent = 0;
+	int i, j, bytes_sent = 0;
 	int tail, tail_first;
 	uint16_t num, sq_free_size;
 	uint16_t nb_segs, total_descs = 0;
@@ -2935,11 +2928,10 @@ mrvl_tx_sg_pkt_burst(void *txq, struct rte_mbuf **tx_pkts,
 		/* In case unsupported ol_flags were passed
 		 * do not update descriptor offload information
 		 */
-		ret = mrvl_prepare_proto_info(mbuf->ol_flags, mbuf->packet_type,
-					      &l3_type, &l4_type, &gen_l3_cksum,
-					      &gen_l4_cksum);
-		if (unlikely(ret))
+		if (!(mbuf->ol_flags & MRVL_TX_PKT_OFFLOADS))
 			continue;
+		mrvl_prepare_proto_info(mbuf->ol_flags, &l3_type, &l4_type,
+					&gen_l3_cksum, &gen_l4_cksum);
 
 		pp2_ppio_outq_desc_set_proto_info(&descs[tail_first], l3_type,
 						  l4_type, mbuf->l2_len,
--
2.28.0
  

Patch

diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c
index a87336a4c..a03d39aee 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.c
+++ b/drivers/net/mvpp2/mrvl_ethdev.c
@@ -63,11 +63,16 @@ 
 			  DEV_RX_OFFLOAD_CHECKSUM)
 
 /** Port Tx offloads capabilities */
-#define MRVL_TX_OFFLOADS (DEV_TX_OFFLOAD_IPV4_CKSUM | \
-			  DEV_TX_OFFLOAD_UDP_CKSUM | \
-			  DEV_TX_OFFLOAD_TCP_CKSUM | \
+#define MRVL_TX_OFFLOAD_CHECKSUM (DEV_TX_OFFLOAD_IPV4_CKSUM | \
+				  DEV_TX_OFFLOAD_UDP_CKSUM  | \
+				  DEV_TX_OFFLOAD_TCP_CKSUM)
+#define MRVL_TX_OFFLOADS (MRVL_TX_OFFLOAD_CHECKSUM | \
 			  DEV_TX_OFFLOAD_MULTI_SEGS)
 
+#define MRVL_TX_PKT_OFFLOADS (PKT_TX_IP_CKSUM | \
+			      PKT_TX_TCP_CKSUM | \
+			      PKT_TX_UDP_CKSUM)
+
 static const char * const valid_args[] = {
 	MRVL_IFACE_NAME_ARG,
 	MRVL_CFG_ARG,
@@ -2596,8 +2601,6 @@  mrvl_rx_pkt_burst(void *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
  *
  * @param ol_flags
  *   Offload flags.
- * @param packet_type
- *   Packet type bitfield.
  * @param l3_type
  *   Pointer to the pp2_ouq_l3_type structure.
  * @param l4_type
@@ -2606,12 +2609,9 @@  mrvl_rx_pkt_burst(void *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
  *   Will be set to 1 in case l3 checksum is computed.
  * @param l4_cksum
  *   Will be set to 1 in case l4 checksum is computed.
- *
- * @return
- *   0 on success, negative error value otherwise.
  */
-static inline int
-mrvl_prepare_proto_info(uint64_t ol_flags, uint32_t packet_type,
+static inline void
+mrvl_prepare_proto_info(uint64_t ol_flags,
 			enum pp2_outq_l3_type *l3_type,
 			enum pp2_outq_l4_type *l4_type,
 			int *gen_l3_cksum,
@@ -2621,26 +2621,22 @@  mrvl_prepare_proto_info(uint64_t ol_flags, uint32_t packet_type,
 	 * Based on ol_flags prepare information
 	 * for pp2_ppio_outq_desc_set_proto_info() which setups descriptor
 	 * for offloading.
+	 * in most of the checksum cases ipv4 must be set, so this is the
+	 * default value
 	 */
-	if (ol_flags & PKT_TX_IPV4) {
-		*l3_type = PP2_OUTQ_L3_TYPE_IPV4;
-		*gen_l3_cksum = ol_flags & PKT_TX_IP_CKSUM ? 1 : 0;
-	} else if (ol_flags & PKT_TX_IPV6) {
+	*l3_type = PP2_OUTQ_L3_TYPE_IPV4;
+	*gen_l3_cksum = ol_flags & PKT_TX_IP_CKSUM ? 1 : 0;
+
+	if (ol_flags & PKT_TX_IPV6) {
 		*l3_type = PP2_OUTQ_L3_TYPE_IPV6;
 		/* no checksum for ipv6 header */
 		*gen_l3_cksum = 0;
-	} else {
-		/* if something different then stop processing */
-		return -1;
 	}
 
-	ol_flags &= PKT_TX_L4_MASK;
-	if ((packet_type & RTE_PTYPE_L4_TCP) &&
-	    ol_flags == PKT_TX_TCP_CKSUM) {
+	if ((ol_flags & PKT_TX_L4_MASK) == PKT_TX_TCP_CKSUM) {
 		*l4_type = PP2_OUTQ_L4_TYPE_TCP;
 		*gen_l4_cksum = 1;
-	} else if ((packet_type & RTE_PTYPE_L4_UDP) &&
-		   ol_flags == PKT_TX_UDP_CKSUM) {
+	} else if ((ol_flags & PKT_TX_L4_MASK) ==  PKT_TX_UDP_CKSUM) {
 		*l4_type = PP2_OUTQ_L4_TYPE_UDP;
 		*gen_l4_cksum = 1;
 	} else {
@@ -2648,8 +2644,6 @@  mrvl_prepare_proto_info(uint64_t ol_flags, uint32_t packet_type,
 		/* no checksum for other type */
 		*gen_l4_cksum = 0;
 	}
-
-	return 0;
 }
 
 /**
@@ -2750,7 +2744,7 @@  mrvl_tx_pkt_burst(void *txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 	struct pp2_hif *hif;
 	struct pp2_ppio_desc descs[nb_pkts];
 	unsigned int core_id = rte_lcore_id();
-	int i, ret, bytes_sent = 0;
+	int i, bytes_sent = 0;
 	uint16_t num, sq_free_size;
 	uint64_t addr;
 
@@ -2794,11 +2788,10 @@  mrvl_tx_pkt_burst(void *txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 		 * in case unsupported ol_flags were passed
 		 * do not update descriptor offload information
 		 */
-		ret = mrvl_prepare_proto_info(mbuf->ol_flags, mbuf->packet_type,
-					      &l3_type, &l4_type, &gen_l3_cksum,
-					      &gen_l4_cksum);
-		if (unlikely(ret))
+		if (!(mbuf->ol_flags & MRVL_TX_PKT_OFFLOADS))
 			continue;
+		mrvl_prepare_proto_info(mbuf->ol_flags, &l3_type, &l4_type,
+					&gen_l3_cksum, &gen_l4_cksum);
 
 		pp2_ppio_outq_desc_set_proto_info(&descs[i], l3_type, l4_type,
 						  mbuf->l2_len,
@@ -2848,7 +2841,7 @@  mrvl_tx_sg_pkt_burst(void *txq, struct rte_mbuf **tx_pkts,
 	struct pp2_ppio_sg_pkts pkts;
 	uint8_t frags[nb_pkts];
 	unsigned int core_id = rte_lcore_id();
-	int i, j, ret, bytes_sent = 0;
+	int i, j, bytes_sent = 0;
 	int tail, tail_first;
 	uint16_t num, sq_free_size;
 	uint16_t nb_segs, total_descs = 0;
@@ -2935,11 +2928,10 @@  mrvl_tx_sg_pkt_burst(void *txq, struct rte_mbuf **tx_pkts,
 		/* In case unsupported ol_flags were passed
 		 * do not update descriptor offload information
 		 */
-		ret = mrvl_prepare_proto_info(mbuf->ol_flags, mbuf->packet_type,
-					      &l3_type, &l4_type, &gen_l3_cksum,
-					      &gen_l4_cksum);
-		if (unlikely(ret))
+		if (!(mbuf->ol_flags & MRVL_TX_PKT_OFFLOADS))
 			continue;
+		mrvl_prepare_proto_info(mbuf->ol_flags, &l3_type, &l4_type,
+					&gen_l3_cksum, &gen_l4_cksum);
 
 		pp2_ppio_outq_desc_set_proto_info(&descs[tail_first], l3_type,
 						  l4_type, mbuf->l2_len,