[v1,34/38] net/mvpp2: consider ptype in cksum info
diff mbox series

Message ID 20201202101212.4717-35-lironh@marvell.com
State Superseded
Delegated to: Jerin Jacob
Headers show
Series
  • net/mvpp2: misc updates
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

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

provide checksum information based on the ptype.

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

Comments

Michael Shamis Dec. 23, 2020, 9:29 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 34/38] net/mvpp2: consider ptype in cksum info

From: Liron Himi <lironh@marvell.com>

provide checksum information based on the ptype.

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

diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c index fe5fd90ef..cb792300b 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.c
+++ b/drivers/net/mvpp2/mrvl_ethdev.c
@@ -2622,23 +2622,27 @@ mrvl_desc_to_packet_type_and_offset(struct pp2_ppio_desc *desc,
  *   Mbuf offload flags.
  */
 static inline uint64_t
-mrvl_desc_to_ol_flags(struct pp2_ppio_desc *desc)
+mrvl_desc_to_ol_flags(struct pp2_ppio_desc *desc, uint64_t packet_type)
 {
-	uint64_t flags;
+	uint64_t flags = 0;
 	enum pp2_inq_desc_status status;
 
-	status = pp2_ppio_inq_desc_get_l3_pkt_error(desc);
-	if (unlikely(status != PP2_DESC_ERR_OK))
-		flags = PKT_RX_IP_CKSUM_BAD;
-	else
-		flags = PKT_RX_IP_CKSUM_GOOD;
-
-	status = pp2_ppio_inq_desc_get_l4_pkt_error(desc);
-	if (unlikely(status != PP2_DESC_ERR_OK))
-		flags |= PKT_RX_L4_CKSUM_BAD;
-	else
-		flags |= PKT_RX_L4_CKSUM_GOOD;
+	if (RTE_ETH_IS_IPV4_HDR(packet_type)) {
+		status = pp2_ppio_inq_desc_get_l3_pkt_error(desc);
+		if (unlikely(status != PP2_DESC_ERR_OK))
+			flags |= PKT_RX_IP_CKSUM_BAD;
+		else
+			flags |= PKT_RX_IP_CKSUM_GOOD;
+	}
 
+	if (((packet_type & RTE_PTYPE_L4_UDP) == RTE_PTYPE_L4_UDP) ||
+	    ((packet_type & RTE_PTYPE_L4_TCP) == RTE_PTYPE_L4_TCP)) {
+		status = pp2_ppio_inq_desc_get_l4_pkt_error(desc);
+		if (unlikely(status != PP2_DESC_ERR_OK))
+			flags |= PKT_RX_L4_CKSUM_BAD;
+		else
+			flags |= PKT_RX_L4_CKSUM_GOOD;
+	}
 	return flags;
 }
 
@@ -2731,7 +2735,9 @@ mrvl_rx_pkt_burst(void *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 
 		mbuf->udata64 = q->port_id;
 		if (likely(q->cksum_enabled))
-			mbuf->ol_flags = mrvl_desc_to_ol_flags(&descs[i]);
+			mbuf->ol_flags =
+				mrvl_desc_to_ol_flags(&descs[i],
+						      mbuf->packet_type);
 
 		rx_pkts[rx_done++] = mbuf;
 		q->bytes_recv += mbuf->pkt_len;
--
2.28.0

Patch
diff mbox series

diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c
index fe5fd90ef..cb792300b 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.c
+++ b/drivers/net/mvpp2/mrvl_ethdev.c
@@ -2622,23 +2622,27 @@  mrvl_desc_to_packet_type_and_offset(struct pp2_ppio_desc *desc,
  *   Mbuf offload flags.
  */
 static inline uint64_t
-mrvl_desc_to_ol_flags(struct pp2_ppio_desc *desc)
+mrvl_desc_to_ol_flags(struct pp2_ppio_desc *desc, uint64_t packet_type)
 {
-	uint64_t flags;
+	uint64_t flags = 0;
 	enum pp2_inq_desc_status status;
 
-	status = pp2_ppio_inq_desc_get_l3_pkt_error(desc);
-	if (unlikely(status != PP2_DESC_ERR_OK))
-		flags = PKT_RX_IP_CKSUM_BAD;
-	else
-		flags = PKT_RX_IP_CKSUM_GOOD;
-
-	status = pp2_ppio_inq_desc_get_l4_pkt_error(desc);
-	if (unlikely(status != PP2_DESC_ERR_OK))
-		flags |= PKT_RX_L4_CKSUM_BAD;
-	else
-		flags |= PKT_RX_L4_CKSUM_GOOD;
+	if (RTE_ETH_IS_IPV4_HDR(packet_type)) {
+		status = pp2_ppio_inq_desc_get_l3_pkt_error(desc);
+		if (unlikely(status != PP2_DESC_ERR_OK))
+			flags |= PKT_RX_IP_CKSUM_BAD;
+		else
+			flags |= PKT_RX_IP_CKSUM_GOOD;
+	}
 
+	if (((packet_type & RTE_PTYPE_L4_UDP) == RTE_PTYPE_L4_UDP) ||
+	    ((packet_type & RTE_PTYPE_L4_TCP) == RTE_PTYPE_L4_TCP)) {
+		status = pp2_ppio_inq_desc_get_l4_pkt_error(desc);
+		if (unlikely(status != PP2_DESC_ERR_OK))
+			flags |= PKT_RX_L4_CKSUM_BAD;
+		else
+			flags |= PKT_RX_L4_CKSUM_GOOD;
+	}
 	return flags;
 }
 
@@ -2731,7 +2735,9 @@  mrvl_rx_pkt_burst(void *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 
 		mbuf->udata64 = q->port_id;
 		if (likely(q->cksum_enabled))
-			mbuf->ol_flags = mrvl_desc_to_ol_flags(&descs[i]);
+			mbuf->ol_flags =
+				mrvl_desc_to_ol_flags(&descs[i],
+						      mbuf->packet_type);
 
 		rx_pkts[rx_done++] = mbuf;
 		q->bytes_recv += mbuf->pkt_len;