From: Mohammad Shuab Siddique <mohammad-shuab.siddique@broadcom.com>
To: dev@dpdk.org
Cc: kishore.padmanabha@broadcom.com,
Ajit Khaparde <ajit.khaparde@broadcom.com>,
stable@dpdk.org,
Mohammad Shuab Siddique <mohammad-shuab.siddique@broadcom.com>
Subject: [PATCH 2/4] net/bnxt: pass Rx timestamp in mbuf
Date: Mon, 2 Mar 2026 10:12:34 -0700 [thread overview]
Message-ID: <20260302171236.98625-3-Mohammad-Shuab.Siddique@broadcom.com> (raw)
In-Reply-To: <20260302171236.98625-1-Mohammad-Shuab.Siddique@broadcom.com>
From: Ajit Khaparde <ajit.khaparde@broadcom.com>
Pass Rx timestamp value in the mbuf using dynaflag.
Add ptp_cfg NULL checks to avoid segfault when ptp_cfg is not created.
Cc: stable@dpdk.org
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Signed-off-by: Mohammad Shuab Siddique <mohammad-shuab.siddique@broadcom.com>
---
drivers/net/bnxt/bnxt.h | 4 ++++
drivers/net/bnxt/bnxt_ethdev.c | 9 +++++++++
drivers/net/bnxt/bnxt_rxr.c | 21 +++++++++++++++++----
drivers/net/bnxt/bnxt_rxr.h | 7 +++++++
4 files changed, 37 insertions(+), 4 deletions(-)
diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 83ae151066..92ba475198 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -403,6 +403,10 @@ struct bnxt_ptp_cfg {
/* On P5, the Rx timestamp is present in the Rx completion record */
uint64_t rx_timestamp;
+ /* Dynamic mbuf field for passing Rx timestamp. */
+ int mb_rx_timestamp_offset;
+ /* Dynamic mbuf flag for indicating Rx timestamp. */
+ uint64_t mb_rx_timestamp_flag;
uint64_t current_time;
uint64_t old_time;
rte_spinlock_t ptp_lock;
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 3c618c6e82..c75cd05d99 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -1686,6 +1686,7 @@ static void bnxt_ptp_stop(struct bnxt *bp)
static int bnxt_ptp_start(struct bnxt *bp)
{
+ struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
int rc;
rc = bnxt_schedule_ptp_alarm(bp);
@@ -1694,6 +1695,14 @@ static int bnxt_ptp_start(struct bnxt *bp)
} else {
bp->flags2 |= BNXT_FLAGS2_PTP_TIMESYNC_ENABLED;
bp->flags2 |= BNXT_FLAGS2_PTP_ALARM_SCHEDULED;
+
+ /* extra mbuf field to store timestamp information */
+ if (rte_mbuf_dyn_rx_timestamp_register(&ptp->mb_rx_timestamp_offset,
+ &ptp->mb_rx_timestamp_flag) != 0) {
+ PMD_DRV_LOG_LINE(ERR,
+ "Failed to register mbuf field for Rx timestamp");
+ return -rte_errno;
+ }
}
return rc;
diff --git a/drivers/net/bnxt/bnxt_rxr.c b/drivers/net/bnxt/bnxt_rxr.c
index ac4c61b850..0ccf47cf35 100644
--- a/drivers/net/bnxt/bnxt_rxr.c
+++ b/drivers/net/bnxt/bnxt_rxr.c
@@ -1190,19 +1190,32 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt,
mbuf->data_len = mbuf->pkt_len;
mbuf->port = rxq->port_id;
- if (unlikely((rte_le_to_cpu_16(rxcmp->flags_type) &
+ if (unlikely(((rte_le_to_cpu_16(rxcmp->flags_type) &
RX_PKT_CMPL_FLAGS_MASK) ==
RX_PKT_CMPL_FLAGS_ITYPE_PTP_W_TIMESTAMP) ||
- bp->ptp_all_rx_tstamp)
+ bp->ptp_all_rx_tstamp) && bp->ieee_1588 &&
+ bp->ptp_cfg) {
+ mbuf->ol_flags |= RTE_MBUF_F_RX_IEEE1588_PTP |
+ RTE_MBUF_F_RX_IEEE1588_TMST;
bnxt_get_rx_ts_p5(rxq->bp, rxcmp1->reorder);
-
+#ifndef RTE_IOVA_IN_MBUF
+ bnxt_timestamp_dynfield_set(mbuf,
+ bp->ptp_cfg->mb_rx_timestamp_offset,
+ bp->ptp_cfg->rx_timestamp);
+ mbuf->ol_flags |= bp->ptp_cfg->mb_rx_timestamp_flag;
+#endif
+ }
if (cmp_type == CMPL_BASE_TYPE_RX_L2_V3) {
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)
+ if (mbuf->ol_flags & RTE_MBUF_F_RX_L4_CKSUM_GOOD) {
mbuf->ol_flags &= ~RTE_MBUF_F_RX_IEEE1588_PTP;
+ if (unlikely(bp->ptp_cfg))
+ mbuf->ol_flags &=
+ ~bp->ptp_cfg->mb_rx_timestamp_flag;
+ }
/* If its a PTP frame, ptype cannot be L2_ETHER */
if (mbuf->ol_flags & RTE_MBUF_F_RX_IEEE1588_PTP)
diff --git a/drivers/net/bnxt/bnxt_rxr.h b/drivers/net/bnxt/bnxt_rxr.h
index 5e5496964f..0b7649193f 100644
--- a/drivers/net/bnxt/bnxt_rxr.h
+++ b/drivers/net/bnxt/bnxt_rxr.h
@@ -181,6 +181,13 @@ bnxt_cfa_code_dynfield(struct rte_mbuf *mbuf)
bnxt_cfa_code_dynfield_offset, bnxt_cfa_code_dynfield_t *);
}
+static __rte_always_inline void
+bnxt_timestamp_dynfield_set(struct rte_mbuf *mbuf, int offset,
+ rte_mbuf_timestamp_t ts)
+{
+ *RTE_MBUF_DYNFIELD(mbuf, offset, rte_mbuf_timestamp_t *) = ts;
+}
+
#define BNXT_RX_META_CFA_CODE_SHIFT 19
#define BNXT_CFA_CODE_META_SHIFT 16
#define BNXT_RX_META_CFA_CODE_INT_ACT_REC_BIT 0x8000000
--
2.47.3
next prev parent reply other threads:[~2026-03-02 17:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-02 17:12 [PATCH 0/4] net/bnxt: PTP support series Mohammad Shuab Siddique
2026-03-02 17:12 ` [PATCH 1/4] net/bnxt: support handling PTP frames in Rx Mohammad Shuab Siddique
2026-03-02 17:12 ` Mohammad Shuab Siddique [this message]
2026-03-02 17:12 ` [PATCH 3/4] net/bnxt: support timestamp parsing in Tx Mohammad Shuab Siddique
2026-03-02 17:12 ` [PATCH 4/4] net/bnxt: add ptp_cfg struct support for Thor 2 VFs Mohammad Shuab Siddique
2026-03-02 17:26 ` [PATCH v2 " Mohammad Shuab Siddique
2026-03-11 18:29 ` [PATCH 0/4] net/bnxt: PTP support series Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260302171236.98625-3-Mohammad-Shuab.Siddique@broadcom.com \
--to=mohammad-shuab.siddique@broadcom.com \
--cc=ajit.khaparde@broadcom.com \
--cc=dev@dpdk.org \
--cc=kishore.padmanabha@broadcom.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox