From: Ajit Khaparde <[email protected]>

Support handling of PTP frames in the Rx path.
This feature is available in scalar mode data path.
If the Rx completion indicates a PTP timesync packet,
update the mbuf ol_flags accordingly.

This feature is not available in the compressed Rx CQE mode.

Cc: [email protected]

Signed-off-by: Ajit Khaparde <[email protected]>
Signed-off-by: Mohammad Shuab Siddique <[email protected]>
---
 drivers/net/bnxt/bnxt_rxr.c | 11 ++++++++++-
 drivers/net/bnxt/bnxt_rxr.h |  2 +-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_rxr.c b/drivers/net/bnxt/bnxt_rxr.c
index c94abefa01..ac4c61b850 100644
--- a/drivers/net/bnxt/bnxt_rxr.c
+++ b/drivers/net/bnxt/bnxt_rxr.c
@@ -724,7 +724,7 @@ bnxt_set_ol_flags(struct bnxt_rx_ring_info *rxr, struct 
rx_pkt_cmpl *rxcmp,
                     RX_PKT_CMPL_FLAGS_ITYPE_PTP_W_TIMESTAMP))
                ol_flags |= RTE_MBUF_F_RX_IEEE1588_PTP | 
RTE_MBUF_F_RX_IEEE1588_TMST;
 
-       mbuf->ol_flags = ol_flags;
+       mbuf->ol_flags |= ol_flags;
 }
 
 static void
@@ -1182,6 +1182,7 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt,
        if (mbuf == NULL)
                return -EBUSY;
 
+       mbuf->ol_flags = 0;
        mbuf->data_off = RTE_PKTMBUF_HEADROOM;
        mbuf->nb_segs = 1;
        mbuf->next = NULL;
@@ -1199,6 +1200,14 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt,
                bnxt_parse_csum_v3(mbuf, rxcmp1);
                bnxt_parse_pkt_type_v3(mbuf, rxcmp, rxcmp1);
                bnxt_rx_vlan_v3(mbuf, rxcmp, rxcmp1);
+               /* Packet cannot be a PTP ethertype if it is detected as L4 */
+               if (mbuf->ol_flags & RTE_MBUF_F_RX_L4_CKSUM_GOOD)
+                       mbuf->ol_flags &= ~RTE_MBUF_F_RX_IEEE1588_PTP;
+
+               /* If its a PTP frame, ptype cannot be L2_ETHER */
+               if (mbuf->ol_flags & RTE_MBUF_F_RX_IEEE1588_PTP)
+                       mbuf->packet_type = RTE_PTYPE_L2_ETHER_TIMESYNC;
+
                if (BNXT_TRUFLOW_EN(bp))
                        mark_id = bnxt_ulp_set_mark_in_mbuf_v3(rxq->bp, rxcmp1,
                                                               mbuf, &vfr_flag);
diff --git a/drivers/net/bnxt/bnxt_rxr.h b/drivers/net/bnxt/bnxt_rxr.h
index 7357ca4427..5e5496964f 100644
--- a/drivers/net/bnxt/bnxt_rxr.h
+++ b/drivers/net/bnxt/bnxt_rxr.h
@@ -535,6 +535,6 @@ bnxt_parse_csum_v3(struct rte_mbuf *mbuf, struct 
rx_pkt_cmpl_hi *rxcmp1)
        uint16_t error_v2 = rte_le_to_cpu_16(v3_cmp->errors_v2);
        uint32_t flags2 = rte_le_to_cpu_32(v3_cmp->flags2);
 
-       mbuf->ol_flags = bnxt_parse_csum_fields_v3(flags2, error_v2);
+       mbuf->ol_flags |= bnxt_parse_csum_fields_v3(flags2, error_v2);
 }
 #endif /*  _BNXT_RXR_H_ */
-- 
2.47.3

Reply via email to