examples/rxtx_callbacks: fix HW timestamp config
authorHarman Kalra <hkalra@marvell.com>
Tue, 30 Jul 2019 07:46:45 +0000 (07:46 +0000)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 30 Jul 2019 09:21:49 +0000 (11:21 +0200)
Since all PMDs doesn't implement per queue offload capabilities but
supports RX timestamping and also since rx_offload_capa includes all
rx_queue_offload_capa's. Hence moving the logic to enable HW timestamp
via DEV_RX_OFFLOAD_TIMESTAMP flag before device configuration so that
this application can work with all PMDs.

Fixes: cd1dadeb9b2a ("examples/rxtx_callbacks: support HW timestamp")

Signed-off-by: Harman Kalra <hkalra@marvell.com>
Reviewed-by: Jerin Jacob <jerinj@marvell.com>
examples/rxtx_callbacks/main.c

index c1abe9e..dbcd9f4 100644 (file)
@@ -117,6 +117,15 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
                port_conf.txmode.offloads |=
                        DEV_TX_OFFLOAD_MBUF_FAST_FREE;
 
+       if (hw_timestamping) {
+               if (!(dev_info.rx_offload_capa & DEV_RX_OFFLOAD_TIMESTAMP)) {
+                       printf("\nERROR: Port %u does not support hardware timestamping\n"
+                                       , port);
+                       return -1;
+               }
+               port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
+       }
+
        retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
        if (retval != 0)
                return retval;
@@ -127,15 +136,6 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 
        rxconf = dev_info.default_rxconf;
 
-       if (hw_timestamping) {
-               if (!(dev_info.rx_offload_capa & DEV_RX_OFFLOAD_TIMESTAMP)) {
-                       printf("\nERROR: Port %u does not support hardware timestamping\n"
-                                       , port);
-                       return -1;
-               }
-               rxconf.offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
-       }
-
        for (q = 0; q < rx_rings; q++) {
                retval = rte_eth_rx_queue_setup(port, q, nb_rxd,
                        rte_eth_dev_socket_id(port), &rxconf, mbuf_pool);