DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 1/2] net/cnxk: add callback handler to read ptp timestamp
@ 2022-02-24  8:02 Rakesh Kudurumalla
  2022-02-24  8:02 ` [PATCH 2/2] event/cnxk: " Rakesh Kudurumalla
  2022-02-24 11:17 ` [PATCH 1/2] net/cnxk: " Jerin Jacob
  0 siblings, 2 replies; 3+ messages in thread
From: Rakesh Kudurumalla @ 2022-02-24  8:02 UTC (permalink / raw)
  To: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao
  Cc: dev, jerinj, Rakesh Kudurumalla

timestamp resolution for an incoming and outgoing packets
is different for CN10k and CN9K.Added platform specific
callback to retrieve timestamp in correct format when read by
application

Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>
---
 drivers/net/cnxk/cn10k_ethdev.c | 23 +++++++++++++++++++++++
 drivers/net/cnxk/cn10k_rx.h     | 32 +++++++++++++++++++++++++++++++-
 drivers/net/cnxk/cn9k_ethdev.c  | 21 +++++++++++++++++++++
 drivers/net/cnxk/cn9k_rx.h      | 30 +++++++++++++++++++++++++++++-
 4 files changed, 104 insertions(+), 2 deletions(-)

diff --git a/drivers/net/cnxk/cn10k_ethdev.c b/drivers/net/cnxk/cn10k_ethdev.c
index c6890f3699..e57847ef3a 100644
--- a/drivers/net/cnxk/cn10k_ethdev.c
+++ b/drivers/net/cnxk/cn10k_ethdev.c
@@ -428,6 +428,27 @@ cn10k_nix_timesync_disable(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
+static int
+cn10k_nix_timesync_read_tx_timestamp(struct rte_eth_dev *eth_dev,
+				     struct timespec *timestamp)
+{
+	struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
+	struct cnxk_timesync_info *tstamp = &dev->tstamp;
+	uint64_t ns;
+
+	if (*tstamp->tx_tstamp == 0)
+		return -EINVAL;
+
+	*tstamp->tx_tstamp = ((*tstamp->tx_tstamp >> 32) * NSEC_PER_SEC) +
+		(*tstamp->tx_tstamp & 0xFFFFFFFFUL);
+	ns = rte_timecounter_update(&dev->tx_tstamp_tc, *tstamp->tx_tstamp);
+	*timestamp = rte_ns_to_timespec(ns);
+	*tstamp->tx_tstamp = 0;
+	rte_wmb();
+
+	return 0;
+}
+
 static int
 cn10k_nix_dev_start(struct rte_eth_dev *eth_dev)
 {
@@ -499,6 +520,8 @@ nix_eth_dev_ops_override(void)
 	cnxk_eth_dev_ops.timesync_disable = cn10k_nix_timesync_disable;
 	cnxk_eth_dev_ops.rx_metadata_negotiate =
 		cn10k_nix_rx_metadata_negotiate;
+	cnxk_eth_dev_ops.timesync_read_tx_timestamp =
+		cn10k_nix_timesync_read_tx_timestamp;
 }
 
 static void
diff --git a/drivers/net/cnxk/cn10k_rx.h b/drivers/net/cnxk/cn10k_rx.h
index 2083c73879..abf280102b 100644
--- a/drivers/net/cnxk/cn10k_rx.h
+++ b/drivers/net/cnxk/cn10k_rx.h
@@ -432,6 +432,36 @@ nix_rx_nb_pkts(struct cn10k_eth_rxq *rxq, const uint64_t wdata,
 	return RTE_MIN(pkts, available);
 }
 
+static __rte_always_inline void
+cn10k_nix_mbuf_to_tstamp(struct rte_mbuf *mbuf,
+			struct cnxk_timesync_info *tstamp,
+			const uint8_t ts_enable, uint64_t *tstamp_ptr)
+{
+	if (ts_enable) {
+		mbuf->pkt_len -= CNXK_NIX_TIMESYNC_RX_OFFSET;
+		mbuf->data_len -= CNXK_NIX_TIMESYNC_RX_OFFSET;
+
+		/* Reading the rx timestamp inserted by CGX, viz at
+		 * starting of the packet data.
+		 */
+		*tstamp_ptr = ((*tstamp_ptr >> 32) * NSEC_PER_SEC) +
+			(*tstamp_ptr & 0xFFFFFFFFUL);
+		*cnxk_nix_timestamp_dynfield(mbuf, tstamp) =
+			rte_be_to_cpu_64(*tstamp_ptr);
+		/* RTE_MBUF_F_RX_IEEE1588_TMST flag needs to be set only in case
+		 * PTP packets are received.
+		 */
+		if (mbuf->packet_type == RTE_PTYPE_L2_ETHER_TIMESYNC) {
+			tstamp->rx_tstamp =
+				*cnxk_nix_timestamp_dynfield(mbuf, tstamp);
+			tstamp->rx_ready = 1;
+			mbuf->ol_flags |= RTE_MBUF_F_RX_IEEE1588_PTP |
+				RTE_MBUF_F_RX_IEEE1588_TMST |
+				tstamp->rx_tstamp_dynflag;
+		}
+	}
+}
+
 static __rte_always_inline uint16_t
 cn10k_nix_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t pkts,
 		    const uint16_t flags)
@@ -486,7 +516,7 @@ cn10k_nix_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t pkts,
 
 		cn10k_nix_cqe_to_mbuf(cq, cq->tag, mbuf, lookup_mem, mbuf_init,
 				      flags);
-		cnxk_nix_mbuf_to_tstamp(mbuf, rxq->tstamp,
+		cn10k_nix_mbuf_to_tstamp(mbuf, rxq->tstamp,
 					(flags & NIX_RX_OFFLOAD_TSTAMP_F),
 					(uint64_t *)((uint8_t *)mbuf
 								+ data_off));
diff --git a/drivers/net/cnxk/cn9k_ethdev.c b/drivers/net/cnxk/cn9k_ethdev.c
index d81f9ac80f..6b049b2897 100644
--- a/drivers/net/cnxk/cn9k_ethdev.c
+++ b/drivers/net/cnxk/cn9k_ethdev.c
@@ -450,6 +450,25 @@ cn9k_nix_dev_start(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
+static int
+cn9k_nix_timesync_read_tx_timestamp(struct rte_eth_dev *eth_dev,
+				    struct timespec *timestamp)
+{
+	struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
+	struct cnxk_timesync_info *tstamp = &dev->tstamp;
+	uint64_t ns;
+
+	if (*tstamp->tx_tstamp == 0)
+		return -EINVAL;
+
+	ns = rte_timecounter_update(&dev->tx_tstamp_tc, *tstamp->tx_tstamp);
+	*timestamp = rte_ns_to_timespec(ns);
+	*tstamp->tx_tstamp = 0;
+	rte_wmb();
+
+	return 0;
+}
+
 static int
 cn9k_nix_rx_metadata_negotiate(struct rte_eth_dev *eth_dev, uint64_t *features)
 {
@@ -492,6 +511,8 @@ nix_eth_dev_ops_override(void)
 	cnxk_eth_dev_ops.timesync_disable = cn9k_nix_timesync_disable;
 	cnxk_eth_dev_ops.mtr_ops_get = NULL;
 	cnxk_eth_dev_ops.rx_metadata_negotiate = cn9k_nix_rx_metadata_negotiate;
+	cnxk_eth_dev_ops.timesync_read_tx_timestamp =
+		cn9k_nix_timesync_read_tx_timestamp;
 }
 
 static void
diff --git a/drivers/net/cnxk/cn9k_rx.h b/drivers/net/cnxk/cn9k_rx.h
index 6b6c5bfbc2..25a4927a33 100644
--- a/drivers/net/cnxk/cn9k_rx.h
+++ b/drivers/net/cnxk/cn9k_rx.h
@@ -435,6 +435,34 @@ nix_rx_nb_pkts(struct cn9k_eth_rxq *rxq, const uint64_t wdata,
 	return RTE_MIN(pkts, available);
 }
 
+static __rte_always_inline void
+cn9k_nix_mbuf_to_tstamp(struct rte_mbuf *mbuf,
+			struct cnxk_timesync_info *tstamp,
+			const uint8_t ts_enable, uint64_t *tstamp_ptr)
+{
+	if (ts_enable) {
+		mbuf->pkt_len -= CNXK_NIX_TIMESYNC_RX_OFFSET;
+		mbuf->data_len -= CNXK_NIX_TIMESYNC_RX_OFFSET;
+
+		/* Reading the rx timestamp inserted by CGX, viz at
+		 * starting of the packet data.
+		 */
+		*cnxk_nix_timestamp_dynfield(mbuf, tstamp) =
+			rte_be_to_cpu_64(*tstamp_ptr);
+		/* RTE_MBUF_F_RX_IEEE1588_TMST flag needs to be set only in case
+		 * PTP packets are received.
+		 */
+		if (mbuf->packet_type == RTE_PTYPE_L2_ETHER_TIMESYNC) {
+			tstamp->rx_tstamp =
+				*cnxk_nix_timestamp_dynfield(mbuf, tstamp);
+			tstamp->rx_ready = 1;
+			mbuf->ol_flags |= RTE_MBUF_F_RX_IEEE1588_PTP |
+					  RTE_MBUF_F_RX_IEEE1588_TMST |
+					  tstamp->rx_tstamp_dynflag;
+		}
+	}
+}
+
 static __rte_always_inline uint16_t
 cn9k_nix_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t pkts,
 		   const uint16_t flags)
@@ -463,7 +491,7 @@ cn9k_nix_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t pkts,
 
 		cn9k_nix_cqe_to_mbuf(cq, cq->tag, mbuf, lookup_mem, mbuf_init,
 				     flags);
-		cnxk_nix_mbuf_to_tstamp(mbuf, rxq->tstamp,
+		cn9k_nix_mbuf_to_tstamp(mbuf, rxq->tstamp,
 					(flags & NIX_RX_OFFLOAD_TSTAMP_F),
 					(uint64_t *)((uint8_t *)mbuf
 								+ data_off));
-- 
2.25.1


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

* [PATCH 2/2] event/cnxk: add callback handler to read ptp timestamp
  2022-02-24  8:02 [PATCH 1/2] net/cnxk: add callback handler to read ptp timestamp Rakesh Kudurumalla
@ 2022-02-24  8:02 ` Rakesh Kudurumalla
  2022-02-24 11:17 ` [PATCH 1/2] net/cnxk: " Jerin Jacob
  1 sibling, 0 replies; 3+ messages in thread
From: Rakesh Kudurumalla @ 2022-02-24  8:02 UTC (permalink / raw)
  To: Pavan Nikhilesh, Shijith Thotton, Nithin Dabilpuram,
	Kiran Kumar K, Sunil Kumar Kori, Satha Rao
  Cc: dev, jerinj, Rakesh Kudurumalla

timestamp resolution for an incoming and outgoing packets
is different for CN10k and CN9K.Added platform specific
callback to retrieve timestamp in correct format when read by
application

Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>
---
 drivers/event/cnxk/cn10k_worker.h |  4 ++--
 drivers/event/cnxk/cn9k_worker.h  |  4 ++--
 drivers/net/cnxk/cnxk_ethdev.h    | 28 ----------------------------
 3 files changed, 4 insertions(+), 32 deletions(-)

diff --git a/drivers/event/cnxk/cn10k_worker.h b/drivers/event/cnxk/cn10k_worker.h
index e8255eaca2..d288c66cac 100644
--- a/drivers/event/cnxk/cn10k_worker.h
+++ b/drivers/event/cnxk/cn10k_worker.h
@@ -179,7 +179,7 @@ cn10k_process_vwqe(uintptr_t vwqe, uint16_t port_id, const uint32_t flags,
 		/* Extracting tstamp, if PTP enabled*/
 		tstamp_ptr = *(uint64_t *)(((struct nix_wqe_hdr_s *)cqe) +
 					   CNXK_SSO_WQE_SG_PTR);
-		cnxk_nix_mbuf_to_tstamp((struct rte_mbuf *)mbuf, tstamp,
+		cn10k_nix_mbuf_to_tstamp((struct rte_mbuf *)mbuf, tstamp,
 					flags & NIX_RX_OFFLOAD_TSTAMP_F,
 					(uint64_t *)tstamp_ptr);
 		wqe[0] = (uint64_t *)mbuf;
@@ -269,7 +269,7 @@ cn10k_sso_hws_get_work(struct cn10k_sso_hws *ws, struct rte_event *ev,
 			tstamp_ptr = *(uint64_t *)(((struct nix_wqe_hdr_s *)
 							    gw.u64[1]) +
 						   CNXK_SSO_WQE_SG_PTR);
-			cnxk_nix_mbuf_to_tstamp((struct rte_mbuf *)mbuf,
+			cn10k_nix_mbuf_to_tstamp((struct rte_mbuf *)mbuf,
 						ws->tstamp,
 						flags & NIX_RX_OFFLOAD_TSTAMP_F,
 						(uint64_t *)tstamp_ptr);
diff --git a/drivers/event/cnxk/cn9k_worker.h b/drivers/event/cnxk/cn9k_worker.h
index 2107ff7b16..c03b49323d 100644
--- a/drivers/event/cnxk/cn9k_worker.h
+++ b/drivers/event/cnxk/cn9k_worker.h
@@ -205,7 +205,7 @@ cn9k_sso_hws_dual_get_work(uint64_t base, uint64_t pair_base,
 			tstamp_ptr = *(uint64_t *)(((struct nix_wqe_hdr_s *)
 							    gw.u64[1]) +
 						   CNXK_SSO_WQE_SG_PTR);
-			cnxk_nix_mbuf_to_tstamp((struct rte_mbuf *)mbuf,
+			cn9k_nix_mbuf_to_tstamp((struct rte_mbuf *)mbuf,
 						dws->tstamp,
 						flags & NIX_RX_OFFLOAD_TSTAMP_F,
 						(uint64_t *)tstamp_ptr);
@@ -281,7 +281,7 @@ cn9k_sso_hws_get_work(struct cn9k_sso_hws *ws, struct rte_event *ev,
 			tstamp_ptr = *(uint64_t *)(((struct nix_wqe_hdr_s *)
 							    gw.u64[1]) +
 						   CNXK_SSO_WQE_SG_PTR);
-			cnxk_nix_mbuf_to_tstamp((struct rte_mbuf *)mbuf,
+			cn9k_nix_mbuf_to_tstamp((struct rte_mbuf *)mbuf,
 						ws->tstamp,
 						flags & NIX_RX_OFFLOAD_TSTAMP_F,
 						(uint64_t *)tstamp_ptr);
diff --git a/drivers/net/cnxk/cnxk_ethdev.h b/drivers/net/cnxk/cnxk_ethdev.h
index ce42b8625a..351b9f8fcf 100644
--- a/drivers/net/cnxk/cnxk_ethdev.h
+++ b/drivers/net/cnxk/cnxk_ethdev.h
@@ -714,34 +714,6 @@ cnxk_nix_timestamp_dynfield(struct rte_mbuf *mbuf,
 				 rte_mbuf_timestamp_t *);
 }
 
-static __rte_always_inline void
-cnxk_nix_mbuf_to_tstamp(struct rte_mbuf *mbuf,
-			struct cnxk_timesync_info *tstamp,
-			const uint8_t ts_enable, uint64_t *tstamp_ptr)
-{
-	if (ts_enable) {
-		mbuf->pkt_len -= CNXK_NIX_TIMESYNC_RX_OFFSET;
-		mbuf->data_len -= CNXK_NIX_TIMESYNC_RX_OFFSET;
-
-		/* Reading the rx timestamp inserted by CGX, viz at
-		 * starting of the packet data.
-		 */
-		*cnxk_nix_timestamp_dynfield(mbuf, tstamp) =
-			rte_be_to_cpu_64(*tstamp_ptr);
-		/* RTE_MBUF_F_RX_IEEE1588_TMST flag needs to be set only in case
-		 * PTP packets are received.
-		 */
-		if (mbuf->packet_type == RTE_PTYPE_L2_ETHER_TIMESYNC) {
-			tstamp->rx_tstamp =
-				*cnxk_nix_timestamp_dynfield(mbuf, tstamp);
-			tstamp->rx_ready = 1;
-			mbuf->ol_flags |= RTE_MBUF_F_RX_IEEE1588_PTP |
-					  RTE_MBUF_F_RX_IEEE1588_TMST |
-					  tstamp->rx_tstamp_dynflag;
-		}
-	}
-}
-
 static __rte_always_inline uintptr_t
 cnxk_nix_sa_base_get(uint16_t port, const void *lookup_mem)
 {
-- 
2.25.1


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

* Re: [PATCH 1/2] net/cnxk: add callback handler to read ptp timestamp
  2022-02-24  8:02 [PATCH 1/2] net/cnxk: add callback handler to read ptp timestamp Rakesh Kudurumalla
  2022-02-24  8:02 ` [PATCH 2/2] event/cnxk: " Rakesh Kudurumalla
@ 2022-02-24 11:17 ` Jerin Jacob
  1 sibling, 0 replies; 3+ messages in thread
From: Jerin Jacob @ 2022-02-24 11:17 UTC (permalink / raw)
  To: Rakesh Kudurumalla, Ferruh Yigit
  Cc: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao,
	dpdk-dev, Jerin Jacob

On Thu, Feb 24, 2022 at 1:32 PM Rakesh Kudurumalla
<rkudurumalla@marvell.com> wrote:
>
> timestamp resolution for an incoming and outgoing packets
> is different for CN10k and CN9K.Added platform specific
> callback to retrieve timestamp in correct format when read by
> application
>
> Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>

Squashed 2/2 into 1/2.


Acked-by: Jerin Jacob <jerinj@marvell.com>

Updated git commit as follows and Applied to
dpdk-next-net-mrvl/for-next-net. Thanks

    net/cnxk: add SoC specific PTP timestamp read

    Timestamp resolution for an incoming and outgoing packets
    is different for CN10k and CN9K. Added SoC specific
    callback to retrieve timestamp in correct format
    when read by application.

    Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>
    Acked-by: Jerin Jacob <jerinj@marvell.com>

> ---
>  drivers/net/cnxk/cn10k_ethdev.c | 23 +++++++++++++++++++++++
>  drivers/net/cnxk/cn10k_rx.h     | 32 +++++++++++++++++++++++++++++++-
>  drivers/net/cnxk/cn9k_ethdev.c  | 21 +++++++++++++++++++++
>  drivers/net/cnxk/cn9k_rx.h      | 30 +++++++++++++++++++++++++++++-
>  4 files changed, 104 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/cnxk/cn10k_ethdev.c b/drivers/net/cnxk/cn10k_ethdev.c
> index c6890f3699..e57847ef3a 100644
> --- a/drivers/net/cnxk/cn10k_ethdev.c
> +++ b/drivers/net/cnxk/cn10k_ethdev.c
> @@ -428,6 +428,27 @@ cn10k_nix_timesync_disable(struct rte_eth_dev *eth_dev)
>         return 0;
>  }
>
> +static int
> +cn10k_nix_timesync_read_tx_timestamp(struct rte_eth_dev *eth_dev,
> +                                    struct timespec *timestamp)
> +{
> +       struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
> +       struct cnxk_timesync_info *tstamp = &dev->tstamp;
> +       uint64_t ns;
> +
> +       if (*tstamp->tx_tstamp == 0)
> +               return -EINVAL;
> +
> +       *tstamp->tx_tstamp = ((*tstamp->tx_tstamp >> 32) * NSEC_PER_SEC) +
> +               (*tstamp->tx_tstamp & 0xFFFFFFFFUL);
> +       ns = rte_timecounter_update(&dev->tx_tstamp_tc, *tstamp->tx_tstamp);
> +       *timestamp = rte_ns_to_timespec(ns);
> +       *tstamp->tx_tstamp = 0;
> +       rte_wmb();
> +
> +       return 0;
> +}
> +
>  static int
>  cn10k_nix_dev_start(struct rte_eth_dev *eth_dev)
>  {
> @@ -499,6 +520,8 @@ nix_eth_dev_ops_override(void)
>         cnxk_eth_dev_ops.timesync_disable = cn10k_nix_timesync_disable;
>         cnxk_eth_dev_ops.rx_metadata_negotiate =
>                 cn10k_nix_rx_metadata_negotiate;
> +       cnxk_eth_dev_ops.timesync_read_tx_timestamp =
> +               cn10k_nix_timesync_read_tx_timestamp;
>  }
>
>  static void
> diff --git a/drivers/net/cnxk/cn10k_rx.h b/drivers/net/cnxk/cn10k_rx.h
> index 2083c73879..abf280102b 100644
> --- a/drivers/net/cnxk/cn10k_rx.h
> +++ b/drivers/net/cnxk/cn10k_rx.h
> @@ -432,6 +432,36 @@ nix_rx_nb_pkts(struct cn10k_eth_rxq *rxq, const uint64_t wdata,
>         return RTE_MIN(pkts, available);
>  }
>
> +static __rte_always_inline void
> +cn10k_nix_mbuf_to_tstamp(struct rte_mbuf *mbuf,
> +                       struct cnxk_timesync_info *tstamp,
> +                       const uint8_t ts_enable, uint64_t *tstamp_ptr)
> +{
> +       if (ts_enable) {
> +               mbuf->pkt_len -= CNXK_NIX_TIMESYNC_RX_OFFSET;
> +               mbuf->data_len -= CNXK_NIX_TIMESYNC_RX_OFFSET;
> +
> +               /* Reading the rx timestamp inserted by CGX, viz at
> +                * starting of the packet data.
> +                */
> +               *tstamp_ptr = ((*tstamp_ptr >> 32) * NSEC_PER_SEC) +
> +                       (*tstamp_ptr & 0xFFFFFFFFUL);
> +               *cnxk_nix_timestamp_dynfield(mbuf, tstamp) =
> +                       rte_be_to_cpu_64(*tstamp_ptr);
> +               /* RTE_MBUF_F_RX_IEEE1588_TMST flag needs to be set only in case
> +                * PTP packets are received.
> +                */
> +               if (mbuf->packet_type == RTE_PTYPE_L2_ETHER_TIMESYNC) {
> +                       tstamp->rx_tstamp =
> +                               *cnxk_nix_timestamp_dynfield(mbuf, tstamp);
> +                       tstamp->rx_ready = 1;
> +                       mbuf->ol_flags |= RTE_MBUF_F_RX_IEEE1588_PTP |
> +                               RTE_MBUF_F_RX_IEEE1588_TMST |
> +                               tstamp->rx_tstamp_dynflag;
> +               }
> +       }
> +}
> +
>  static __rte_always_inline uint16_t
>  cn10k_nix_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t pkts,
>                     const uint16_t flags)
> @@ -486,7 +516,7 @@ cn10k_nix_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t pkts,
>
>                 cn10k_nix_cqe_to_mbuf(cq, cq->tag, mbuf, lookup_mem, mbuf_init,
>                                       flags);
> -               cnxk_nix_mbuf_to_tstamp(mbuf, rxq->tstamp,
> +               cn10k_nix_mbuf_to_tstamp(mbuf, rxq->tstamp,
>                                         (flags & NIX_RX_OFFLOAD_TSTAMP_F),
>                                         (uint64_t *)((uint8_t *)mbuf
>                                                                 + data_off));
> diff --git a/drivers/net/cnxk/cn9k_ethdev.c b/drivers/net/cnxk/cn9k_ethdev.c
> index d81f9ac80f..6b049b2897 100644
> --- a/drivers/net/cnxk/cn9k_ethdev.c
> +++ b/drivers/net/cnxk/cn9k_ethdev.c
> @@ -450,6 +450,25 @@ cn9k_nix_dev_start(struct rte_eth_dev *eth_dev)
>         return 0;
>  }
>
> +static int
> +cn9k_nix_timesync_read_tx_timestamp(struct rte_eth_dev *eth_dev,
> +                                   struct timespec *timestamp)
> +{
> +       struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
> +       struct cnxk_timesync_info *tstamp = &dev->tstamp;
> +       uint64_t ns;
> +
> +       if (*tstamp->tx_tstamp == 0)
> +               return -EINVAL;
> +
> +       ns = rte_timecounter_update(&dev->tx_tstamp_tc, *tstamp->tx_tstamp);
> +       *timestamp = rte_ns_to_timespec(ns);
> +       *tstamp->tx_tstamp = 0;
> +       rte_wmb();
> +
> +       return 0;
> +}
> +
>  static int
>  cn9k_nix_rx_metadata_negotiate(struct rte_eth_dev *eth_dev, uint64_t *features)
>  {
> @@ -492,6 +511,8 @@ nix_eth_dev_ops_override(void)
>         cnxk_eth_dev_ops.timesync_disable = cn9k_nix_timesync_disable;
>         cnxk_eth_dev_ops.mtr_ops_get = NULL;
>         cnxk_eth_dev_ops.rx_metadata_negotiate = cn9k_nix_rx_metadata_negotiate;
> +       cnxk_eth_dev_ops.timesync_read_tx_timestamp =
> +               cn9k_nix_timesync_read_tx_timestamp;
>  }
>
>  static void
> diff --git a/drivers/net/cnxk/cn9k_rx.h b/drivers/net/cnxk/cn9k_rx.h
> index 6b6c5bfbc2..25a4927a33 100644
> --- a/drivers/net/cnxk/cn9k_rx.h
> +++ b/drivers/net/cnxk/cn9k_rx.h
> @@ -435,6 +435,34 @@ nix_rx_nb_pkts(struct cn9k_eth_rxq *rxq, const uint64_t wdata,
>         return RTE_MIN(pkts, available);
>  }
>
> +static __rte_always_inline void
> +cn9k_nix_mbuf_to_tstamp(struct rte_mbuf *mbuf,
> +                       struct cnxk_timesync_info *tstamp,
> +                       const uint8_t ts_enable, uint64_t *tstamp_ptr)
> +{
> +       if (ts_enable) {
> +               mbuf->pkt_len -= CNXK_NIX_TIMESYNC_RX_OFFSET;
> +               mbuf->data_len -= CNXK_NIX_TIMESYNC_RX_OFFSET;
> +
> +               /* Reading the rx timestamp inserted by CGX, viz at
> +                * starting of the packet data.
> +                */
> +               *cnxk_nix_timestamp_dynfield(mbuf, tstamp) =
> +                       rte_be_to_cpu_64(*tstamp_ptr);
> +               /* RTE_MBUF_F_RX_IEEE1588_TMST flag needs to be set only in case
> +                * PTP packets are received.
> +                */
> +               if (mbuf->packet_type == RTE_PTYPE_L2_ETHER_TIMESYNC) {
> +                       tstamp->rx_tstamp =
> +                               *cnxk_nix_timestamp_dynfield(mbuf, tstamp);
> +                       tstamp->rx_ready = 1;
> +                       mbuf->ol_flags |= RTE_MBUF_F_RX_IEEE1588_PTP |
> +                                         RTE_MBUF_F_RX_IEEE1588_TMST |
> +                                         tstamp->rx_tstamp_dynflag;
> +               }
> +       }
> +}
> +
>  static __rte_always_inline uint16_t
>  cn9k_nix_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t pkts,
>                    const uint16_t flags)
> @@ -463,7 +491,7 @@ cn9k_nix_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t pkts,
>
>                 cn9k_nix_cqe_to_mbuf(cq, cq->tag, mbuf, lookup_mem, mbuf_init,
>                                      flags);
> -               cnxk_nix_mbuf_to_tstamp(mbuf, rxq->tstamp,
> +               cn9k_nix_mbuf_to_tstamp(mbuf, rxq->tstamp,
>                                         (flags & NIX_RX_OFFLOAD_TSTAMP_F),
>                                         (uint64_t *)((uint8_t *)mbuf
>                                                                 + data_off));
> --
> 2.25.1
>

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

end of thread, other threads:[~2022-02-24 11:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-24  8:02 [PATCH 1/2] net/cnxk: add callback handler to read ptp timestamp Rakesh Kudurumalla
2022-02-24  8:02 ` [PATCH 2/2] event/cnxk: " Rakesh Kudurumalla
2022-02-24 11:17 ` [PATCH 1/2] net/cnxk: " Jerin Jacob

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).