net/dpaa2: switch Rx timestamp to dynamic mbuf field
authorThomas Monjalon <thomas@monjalon.net>
Thu, 29 Oct 2020 03:02:58 +0000 (04:02 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 3 Nov 2020 15:21:15 +0000 (16:21 +0100)
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.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
Acked-by: David Marchand <david.marchand@redhat.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
drivers/net/dpaa2/dpaa2_ethdev.c
drivers/net/dpaa2/dpaa2_ethdev.h
drivers/net/dpaa2/dpaa2_rxtx.c

index 04e60c5..3b0c771 100644 (file)
@@ -65,6 +65,8 @@ static uint64_t dev_tx_offloads_nodis =
 
 /* enable timestamp in mbuf */
 bool dpaa2_enable_ts[RTE_MAX_ETHPORTS];
+uint64_t dpaa2_timestamp_rx_dynflag;
+int dpaa2_timestamp_dynfield_offset = -1;
 
 struct rte_dpaa2_xstats_name_off {
        char name[RTE_ETH_XSTATS_NAME_SIZE];
@@ -587,7 +589,16 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)
 #if !defined(RTE_LIBRTE_IEEE1588)
        if (rx_offloads & DEV_RX_OFFLOAD_TIMESTAMP)
 #endif
+       {
+               ret = rte_mbuf_dyn_rx_timestamp_register(
+                               &dpaa2_timestamp_dynfield_offset,
+                               &dpaa2_timestamp_rx_dynflag);
+               if (ret != 0) {
+                       DPAA2_PMD_ERR("Error to register timestamp field/flag");
+                       return -rte_errno;
+               }
                dpaa2_enable_ts[dev->data->port_id] = true;
+       }
 
        if (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM)
                tx_l3_csum_offload = true;
index 94cf253..8d82f74 100644 (file)
@@ -92,6 +92,8 @@
 
 /* enable timestamp in mbuf*/
 extern bool dpaa2_enable_ts[];
+extern uint64_t dpaa2_timestamp_rx_dynflag;
+extern int dpaa2_timestamp_dynfield_offset;
 
 #define DPAA2_QOS_TABLE_RECONFIGURE    1
 #define DPAA2_FS_TABLE_RECONFIGURE     2
index 6201de4..9cca6d1 100644 (file)
@@ -31,6 +31,13 @@ dpaa2_dev_rx_parse_slow(struct rte_mbuf *mbuf,
 
 static void enable_tx_tstamp(struct qbman_fd *fd) __rte_unused;
 
+static inline rte_mbuf_timestamp_t *
+dpaa2_timestamp_dynfield(struct rte_mbuf *mbuf)
+{
+       return RTE_MBUF_DYNFIELD(mbuf,
+               dpaa2_timestamp_dynfield_offset, rte_mbuf_timestamp_t *);
+}
+
 #define DPAA2_MBUF_TO_CONTIG_FD(_mbuf, _fd, _bpid)  do { \
        DPAA2_SET_FD_ADDR(_fd, DPAA2_MBUF_VADDR_TO_IOVA(_mbuf)); \
        DPAA2_SET_FD_LEN(_fd, _mbuf->data_len); \
@@ -109,9 +116,10 @@ dpaa2_dev_rx_parse_new(struct rte_mbuf *m, const struct qbman_fd *fd,
        m->ol_flags |= PKT_RX_RSS_HASH;
 
        if (dpaa2_enable_ts[m->port]) {
-               m->timestamp = annotation->word2;
-               m->ol_flags |= PKT_RX_TIMESTAMP;
-               DPAA2_PMD_DP_DEBUG("pkt timestamp:0x%" PRIx64 "", m->timestamp);
+               *dpaa2_timestamp_dynfield(m) = annotation->word2;
+               m->ol_flags |= dpaa2_timestamp_rx_dynflag;
+               DPAA2_PMD_DP_DEBUG("pkt timestamp:0x%" PRIx64 "",
+                               *dpaa2_timestamp_dynfield(m));
        }
 
        DPAA2_PMD_DP_DEBUG("HW frc = 0x%x\t packet type =0x%x "
@@ -223,9 +231,12 @@ dpaa2_dev_rx_parse(struct rte_mbuf *mbuf, void *hw_annot_addr)
        else if (BIT_ISSET_AT_POS(annotation->word8, DPAA2_ETH_FAS_L4CE))
                mbuf->ol_flags |= PKT_RX_L4_CKSUM_BAD;
 
-       mbuf->ol_flags |= PKT_RX_TIMESTAMP;
-       mbuf->timestamp = annotation->word2;
-       DPAA2_PMD_DP_DEBUG("pkt timestamp: 0x%" PRIx64 "", mbuf->timestamp);
+       if (dpaa2_enable_ts[mbuf->port]) {
+               *dpaa2_timestamp_dynfield(mbuf) = annotation->word2;
+               mbuf->ol_flags |= dpaa2_timestamp_rx_dynflag;
+               DPAA2_PMD_DP_DEBUG("pkt timestamp: 0x%" PRIx64 "",
+                               *dpaa2_timestamp_dynfield(mbuf));
+       }
 
        /* Check detailed parsing requirement */
        if (annotation->word3 & 0x7FFFFC3FFFF)
@@ -629,7 +640,7 @@ dpaa2_dev_prefetch_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
                else
                        bufs[num_rx] = eth_fd_to_mbuf(fd, eth_data->port_id);
 #if defined(RTE_LIBRTE_IEEE1588)
-               priv->rx_timestamp = bufs[num_rx]->timestamp;
+               priv->rx_timestamp = *dpaa2_timestamp_dynfield(bufs[num_rx]);
 #endif
 
                if (eth_data->dev_conf.rxmode.offloads &