ethdev: include mbuf registration in Tx timestamp API
authorThomas Monjalon <thomas@monjalon.net>
Mon, 2 Nov 2020 19:51:00 +0000 (20:51 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 3 Nov 2020 15:21:15 +0000 (16:21 +0100)
Previously, the Tx timestamp field and flag were registered in testpmd,
as described in mlx5 guide.
For consistency between Rx and Tx timestamps,
managing mbuf registrations inside the driver, as properly documented,
is a simpler expectation.

The only driver to support this feature (mlx5) is updated
as well as the testpmd application.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
Acked-by: David Marchand <david.marchand@redhat.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
app/test-pmd/config.c
doc/guides/nics/mlx5.rst
drivers/net/mlx5/mlx5_ethdev.c
lib/librte_ethdev/rte_ethdev.h

index 1668ae3..9a2baf1 100644 (file)
@@ -3955,44 +3955,6 @@ show_tx_pkt_times(void)
 void
 set_tx_pkt_times(unsigned int *tx_times)
 {
-       uint16_t port_id;
-       int offload_found = 0;
-       int offset;
-       int flag;
-
-       static const struct rte_mbuf_dynfield desc_offs = {
-               .name = RTE_MBUF_DYNFIELD_TIMESTAMP_NAME,
-               .size = sizeof(uint64_t),
-               .align = __alignof__(uint64_t),
-       };
-       static const struct rte_mbuf_dynflag desc_flag = {
-               .name = RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME,
-       };
-
-       RTE_ETH_FOREACH_DEV(port_id) {
-               struct rte_eth_dev_info dev_info = { 0 };
-               int ret;
-
-               ret = rte_eth_dev_info_get(port_id, &dev_info);
-               if (ret == 0 && dev_info.tx_offload_capa &
-                               DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP) {
-                       offload_found = 1;
-                       break;
-               }
-       }
-       if (!offload_found) {
-               printf("No device supporting Tx timestamp scheduling found, "
-                      "dynamic flag and field not registered\n");
-               return;
-       }
-       offset = rte_mbuf_dynfield_register(&desc_offs);
-       if (offset < 0 && rte_errno != EEXIST)
-               printf("Dynamic timestamp field registration error: %d",
-                      rte_errno);
-       flag = rte_mbuf_dynflag_register(&desc_flag);
-       if (flag < 0 && rte_errno != EEXIST)
-               printf("Dynamic timestamp flag registration error: %d",
-                      rte_errno);
        tx_pkt_times_inter = tx_times[0];
        tx_pkt_times_intra = tx_times[1];
 }
index afa65a1..fa8b13d 100644 (file)
@@ -237,9 +237,8 @@ Limitations
   ``txq_inline_max`` and ``txq_inline_mpw`` devargs keys.
 
 - To provide the packet send scheduling on mbuf timestamps the ``tx_pp``
-  parameter should be specified, RTE_MBUF_DYNFIELD_TIMESTAMP_NAME and
-  RTE_MBUF_DYNFLAG_TIMESTAMP_NAME should be registered by application.
-  When PMD sees the RTE_MBUF_DYNFLAG_TIMESTAMP_NAME set on the packet
+  parameter should be specified.
+  When PMD sees the RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME set on the packet
   being sent it tries to synchronize the time of packet appearing on
   the wire with the specified packet timestamp. It the specified one
   is in the past it should be ignored, if one is in the distant future
index 7631f64..76ef026 100644 (file)
@@ -88,7 +88,13 @@ mlx5_dev_configure(struct rte_eth_dev *dev)
 
        if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG)
                dev->data->dev_conf.rxmode.offloads |= DEV_RX_OFFLOAD_RSS_HASH;
-
+       if ((dev->data->dev_conf.txmode.offloads &
+                       DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP) &&
+                       rte_mbuf_dyn_tx_timestamp_register(NULL, NULL) != 0) {
+               DRV_LOG(ERR, "port %u cannot register Tx timestamp field/flag",
+                       dev->data->port_id);
+               return -rte_errno;
+       }
        memcpy(priv->rss_conf.rss_key,
               use_app_rss_key ?
               dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key :
index 4988054..f689550 100644 (file)
@@ -1413,8 +1413,11 @@ struct rte_eth_conf {
 #define DEV_TX_OFFLOAD_IP_TNL_TSO       0x00080000
 /** Device supports outer UDP checksum */
 #define DEV_TX_OFFLOAD_OUTER_UDP_CKSUM  0x00100000
-
-/** Device supports send on timestamp */
+/**
+ * Device sends on time read from RTE_MBUF_DYNFIELD_TIMESTAMP_NAME
+ * if RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME is set in ol_flags.
+ * The mbuf field and flag are registered when the offload is configured.
+ */
 #define DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP 0x00200000