DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] net/gve: add ptype parsing to DQ format
@ 2024-09-18 20:33 Joshua Washington
  2024-09-22  2:00 ` Ferruh Yigit
  0 siblings, 1 reply; 2+ messages in thread
From: Joshua Washington @ 2024-09-18 20:33 UTC (permalink / raw)
  To: Jeroen de Borst, Rushil Gupta, Joshua Washington; +Cc: dev, Ferruh Yigit

Currently, the packet type is parsed as part of adding the
checksum-related ol_flags for a received packet, but the parsed
information is not added to the mbuf.

This change adds the parsed ptypes to the mbuf and updates the RX
checksum validation to rely on the mbuf instead of re-capturing the
ptype from the descriptor. This helps with compatibility with programs
which rely on the packet type value stored in the mbuf.

Signed-off-by: Joshua Washington <joshwash@google.com>
Reviewed-by: Rushil Gupta <rushilg@google.com>
---
 drivers/net/gve/gve_rx_dqo.c | 62 +++++++++++++++++++++++++-----------
 1 file changed, 44 insertions(+), 18 deletions(-)

diff --git a/drivers/net/gve/gve_rx_dqo.c b/drivers/net/gve/gve_rx_dqo.c
index 5efcce3312..d8e9eee4a8 100644
--- a/drivers/net/gve/gve_rx_dqo.c
+++ b/drivers/net/gve/gve_rx_dqo.c
@@ -6,6 +6,7 @@
 
 #include "gve_ethdev.h"
 #include "base/gve_adminq.h"
+#include "rte_mbuf_ptype.h"
 
 static inline void
 gve_rx_refill_dqo(struct gve_rx_queue *rxq)
@@ -75,38 +76,63 @@ gve_rx_refill_dqo(struct gve_rx_queue *rxq)
 	rxq->bufq_tail = next_avail;
 }
 
-static inline uint16_t
-gve_parse_csum_ol_flags(volatile struct gve_rx_compl_desc_dqo *rx_desc,
-		struct gve_priv *priv) {
-	uint64_t ol_flags = 0;
-	struct gve_ptype ptype =
-		priv->ptype_lut_dqo->ptypes[rx_desc->packet_type];
-
+static inline void
+gve_parse_csum_ol_flags(struct rte_mbuf *rx_mbuf,
+	volatile struct gve_rx_compl_desc_dqo *rx_desc)
+{
 	if (!rx_desc->l3_l4_processed)
-		return ol_flags;
+		return;
 
-	if (ptype.l3_type == GVE_L3_TYPE_IPV4) {
+	if (rx_mbuf->packet_type & RTE_PTYPE_L3_IPV4) {
 		if (rx_desc->csum_ip_err)
-			ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_BAD;
+			rx_mbuf->ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_BAD;
 		else
-			ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_GOOD;
+			rx_mbuf->ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_GOOD;
 	}
 
 	if (rx_desc->csum_l4_err) {
-		ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_BAD;
-		return ol_flags;
+		rx_mbuf->ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_BAD;
+		return;
 	}
+	if (rx_mbuf->packet_type & RTE_PTYPE_L4_MASK)
+		rx_mbuf->ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_GOOD;
+}
+
+static inline void
+gve_rx_set_mbuf_ptype(struct gve_priv *priv, struct rte_mbuf *rx_mbuf,
+		      volatile struct gve_rx_compl_desc_dqo *rx_desc)
+{
+	struct gve_ptype ptype =
+		priv->ptype_lut_dqo->ptypes[rx_desc->packet_type];
+	rx_mbuf->packet_type = 0;
+
+	switch (ptype.l3_type) {
+	case GVE_L3_TYPE_IPV4:
+		rx_mbuf->packet_type |= RTE_PTYPE_L3_IPV4;
+		break;
+	case GVE_L3_TYPE_IPV6:
+		rx_mbuf->packet_type |= RTE_PTYPE_L3_IPV6;
+		break;
+	default:
+		break;
+	}
+
 	switch (ptype.l4_type) {
 	case GVE_L4_TYPE_TCP:
+		rx_mbuf->packet_type |= RTE_PTYPE_L4_TCP;
+		break;
 	case GVE_L4_TYPE_UDP:
+		rx_mbuf->packet_type |= RTE_PTYPE_L4_UDP;
+		break;
 	case GVE_L4_TYPE_ICMP:
+		rx_mbuf->packet_type |= RTE_PTYPE_L4_ICMP;
+		break;
 	case GVE_L4_TYPE_SCTP:
-		ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_GOOD;
+		rx_mbuf->packet_type |= RTE_PTYPE_L4_SCTP;
 		break;
 	default:
 		break;
 	}
-	return ol_flags;
 }
 
 uint16_t
@@ -158,9 +184,9 @@ gve_rx_burst_dqo(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 		rxm->pkt_len = pkt_len;
 		rxm->data_len = pkt_len;
 		rxm->port = rxq->port_id;
-		rxm->ol_flags = 0;
-		rxm->ol_flags |= RTE_MBUF_F_RX_RSS_HASH |
-				gve_parse_csum_ol_flags(rx_desc, rxq->hw);
+		gve_rx_set_mbuf_ptype(rxq->hw, rxm, rx_desc);
+		rxm->ol_flags = RTE_MBUF_F_RX_RSS_HASH;
+		gve_parse_csum_ol_flags(rxm, rx_desc);
 		rxm->hash.rss = rte_le_to_cpu_32(rx_desc->hash);
 
 		rx_pkts[nb_rx++] = rxm;
-- 
2.46.0.662.g92d0881bb0-goog


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-09-22  2:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-18 20:33 [PATCH] net/gve: add ptype parsing to DQ format Joshua Washington
2024-09-22  2:00 ` Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).