From: Thomas Monjalon Date: Thu, 29 Oct 2020 06:48:48 +0000 (+0100) Subject: net/octeontx2: switch Rx timestamp to dynamic mbuf field X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=af50731085f5057df92813c362d31f0ad1b9efaf;hp=f6800feb3ea3169fdd924bc2fd89ce208e68906c;p=dpdk.git net/octeontx2: switch Rx timestamp to dynamic mbuf field The mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced. The registration of field and flag is done in both otx2_nix_dev_start() and otx2_nix_timesync_enable(). The dynamic offset and flag are stored in struct otx2_timesync_info to favor cache locality. Signed-off-by: Thomas Monjalon Acked-by: David Marchand Acked-by: Olivier Matz --- diff --git a/drivers/net/octeontx2/otx2_ethdev.c b/drivers/net/octeontx2/otx2_ethdev.c index cfb733a4b5..6cebbe677d 100644 --- a/drivers/net/octeontx2/otx2_ethdev.c +++ b/drivers/net/octeontx2/otx2_ethdev.c @@ -2225,6 +2225,16 @@ otx2_nix_dev_start(struct rte_eth_dev *eth_dev) if (otx2_ethdev_is_ptp_en(dev) && otx2_dev_is_vf(dev)) otx2_nix_ptp_enable_vf(eth_dev); + if (dev->rx_offload_flags & NIX_RX_OFFLOAD_TSTAMP_F) { + rc = rte_mbuf_dyn_rx_timestamp_register( + &dev->tstamp.tstamp_dynfield_offset, + &dev->tstamp.rx_tstamp_dynflag); + if (rc != 0) { + otx2_err("Failed to register Rx timestamp field/flag"); + return -rte_errno; + } + } + rc = npc_rx_enable(dev); if (rc) { otx2_err("Failed to enable NPC rx %d", rc); diff --git a/drivers/net/octeontx2/otx2_ptp.c b/drivers/net/octeontx2/otx2_ptp.c index ae5a2b7cd1..b8ef4c181d 100644 --- a/drivers/net/octeontx2/otx2_ptp.c +++ b/drivers/net/octeontx2/otx2_ptp.c @@ -239,6 +239,14 @@ otx2_nix_timesync_enable(struct rte_eth_dev *eth_dev) dev->tstamp.tx_tstamp_iova = ts->iova; dev->tstamp.tx_tstamp = ts->addr; + rc = rte_mbuf_dyn_rx_timestamp_register( + &dev->tstamp.tstamp_dynfield_offset, + &dev->tstamp.rx_tstamp_dynflag); + if (rc != 0) { + otx2_err("Failed to register Rx timestamp field/flag"); + return -rte_errno; + } + /* System time should be already on by default */ nix_start_timecounters(eth_dev); diff --git a/drivers/net/octeontx2/otx2_rx.h b/drivers/net/octeontx2/otx2_rx.h index 61a5c436dd..926f614a4e 100644 --- a/drivers/net/octeontx2/otx2_rx.h +++ b/drivers/net/octeontx2/otx2_rx.h @@ -49,6 +49,8 @@ struct otx2_timesync_info { uint64_t rx_tstamp; rte_iova_t tx_tstamp_iova; uint64_t *tx_tstamp; + uint64_t rx_tstamp_dynflag; + int tstamp_dynfield_offset; uint8_t tx_ready; uint8_t rx_ready; } __rte_cache_aligned; @@ -63,6 +65,14 @@ union mbuf_initializer { uint64_t value; }; +static inline rte_mbuf_timestamp_t * +otx2_timestamp_dynfield(struct rte_mbuf *mbuf, + struct otx2_timesync_info *info) +{ + return RTE_MBUF_DYNFIELD(mbuf, + info->tstamp_dynfield_offset, rte_mbuf_timestamp_t *); +} + static __rte_always_inline void otx2_nix_mbuf_to_tstamp(struct rte_mbuf *mbuf, struct otx2_timesync_info *tstamp, const uint16_t flag, @@ -77,15 +87,18 @@ otx2_nix_mbuf_to_tstamp(struct rte_mbuf *mbuf, /* Reading the rx timestamp inserted by CGX, viz at * starting of the packet data. */ - mbuf->timestamp = rte_be_to_cpu_64(*tstamp_ptr); + *otx2_timestamp_dynfield(mbuf, tstamp) = + rte_be_to_cpu_64(*tstamp_ptr); /* PKT_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 = mbuf->timestamp; + tstamp->rx_tstamp = + *otx2_timestamp_dynfield(mbuf, tstamp); tstamp->rx_ready = 1; mbuf->ol_flags |= PKT_RX_IEEE1588_PTP | - PKT_RX_IEEE1588_TMST | PKT_RX_TIMESTAMP; + PKT_RX_IEEE1588_TMST | + tstamp->rx_tstamp_dynflag; } } }