[v2] examples/rxtx_callbacks: fix HW timestamp enable

Message ID 1564472662-31089-1-git-send-email-hkalra@marvell.com (mailing list archive)
State Accepted, archived
Headers
Series [v2] examples/rxtx_callbacks: fix HW timestamp enable |

Checks

Context Check Description
ci/iol-Compile-Testing success Compile Testing PASS
ci/Intel-compilation success Compilation OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

Harman Kalra July 30, 2019, 7:46 a.m. UTC
  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")
Cc: barbette@kth.se

Signed-off-by: Harman Kalra <hkalra@marvell.com>
Reviewed-by: Jerin Jacob <jerinj@marvell.com>
---
V2:
* More detailed commit message.

 examples/rxtx_callbacks/main.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
  

Comments

Thomas Monjalon July 30, 2019, 9:13 a.m. UTC | #1
30/07/2019 09:46, Harman Kalra:
> 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")
> Cc: barbette@kth.se
> 
> Signed-off-by: Harman Kalra <hkalra@marvell.com>
> Reviewed-by: Jerin Jacob <jerinj@marvell.com>
> ---
> V2:
> * More detailed commit message.

Applied, thanks.

Note: there is a discussion about dropping this example in next releases.
  

Patch

diff --git a/examples/rxtx_callbacks/main.c b/examples/rxtx_callbacks/main.c
index c1abe9e1a..dbcd9f4fc 100644
--- a/examples/rxtx_callbacks/main.c
+++ b/examples/rxtx_callbacks/main.c
@@ -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);