ethdev: clarify device queue state after start and stop
RFC 1/1 ethdev: clarify device queue state after start and stop
Drivers start/stop device queues on port start/stop, but not all drivers update queue state accordingly.
This becomes more visible if a specific queue stopped explicitly and port stopped/started later, in this case although all queues are started, the state of that specific queue is stopped and it is misleading.
Misrepresentation of queue state became a defect with commit [1] that does forwarding decision based on queue state and commit [2] that gets up to date queue state from ethdev/device before forwarding.
This patch documents that status of all queues of a device should be RTE_ETH_QUEUE_STATE_STOPPED after port stop and their status should beRTE_ETH_QUEUE_STATE_STARTED after port start.
Also an unit test added to verify drivers.
---
Cc: Jie Hai <[email protected]>
Cc: Song Jiale <[email protected]>
Cc: Yuan Peng <[email protected]>
Cc: Raslan Darawsheh <[email protected]>
Cc: Qiming Yang <[email protected]>
--- app/test/meson.build | 2 + app/test/test_ethdev_api.c | 169 +++++++++++++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 5 ++ 3 files changed, 176 insertions(+) create mode 100644 app/test/test_ethdev_api.c
app/test/meson.build +2 -0
@@ -49,6 +49,7 @@ test_sources = files( 'test_efd_perf.c', 'test_errno.c', 'test_ethdev_link.c', + 'test_ethdev_api.c', 'test_event_crypto_adapter.c', 'test_event_eth_rx_adapter.c', 'test_event_ring.c',
@@ -187,6 +188,7 @@ fast_tests = [ ['eal_fs_autotest', true, true], ['errno_autotest', true, true], ['ethdev_link_status', true, true], + ['ethdev_api', true, true], ['event_ring_autotest', true, true], ['fib_autotest', true, true], ['fib6_autotest', true, true],
app/test/test_ethdev_api.c new file +169 -0
169 lines not on this page · raw message
lib/ethdev/rte_ethdev.h +5 -0
@@ -2788,6 +2788,9 @@ int rte_eth_dev_tx_queue_stop(uint16_t port_id, uint16_t tx_queue_id);* Device RTE_ETH_DEV_NOLIVE_MAC_ADDR flag causes MAC address to be set before * PMD port start callback function is invoked. * +* All device queues (except form deferred queues) status should be +* `RTE_ETH_QUEUE_STATE_STARTED` after start. +* * On success, all basic functions exported by the Ethernet API (link status, * receive/transmit, and so on) can be invoked. *
@@ -2804,6 +2807,8 @@ int rte_eth_dev_start(uint16_t port_id);* Stop an Ethernet device. The device can be restarted with a call to * rte_eth_dev_start() * +* All device queues status should be `RTE_ETH_QUEUE_STATE_STOPPED` after stop. +* * @param port_id * The port identifier of the Ethernet device. * @return
Signature · 1 line
2.34.1
Hi Ferruh,
The commit log says "commit [1]" and "commit [2]" but does not seem to provide the URLs for the [1] and [2]. What are these resources? I'd like to know.
Thank you.
Quoted 254 lines · Ferruh Yigit
Drivers start/stop device queues on port start/stop, but not all drivers update queue state accordingly.
This becomes more visible if a specific queue stopped explicitly and port stopped/started later, in this case although all queues are started, the state of that specific queue is stopped and it is misleading.
Misrepresentation of queue state became a defect with commit [1] that does forwarding decision based on queue state and commit [2] that gets up to date queue state from ethdev/device before forwarding.
This patch documents that status of all queues of a device should be
RTE_ETH_QUEUE_STATE_STOPPEDafter port stop and their status should beRTE_ETH_QUEUE_STATE_STARTEDafter port start.Also an unit test added to verify drivers.
Signed-off-by Ferruh Yigit <[email protected]>---
Cc: Jie Hai <[email protected]>
Cc: Song Jiale <[email protected]>
Cc: Yuan Peng <[email protected]>
Cc: Raslan Darawsheh <[email protected]>
Cc: Qiming Yang <[email protected]>
---app/test/meson.build | 2 + app/test/test_ethdev_api.c | 169 +++++++++++++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 5 ++ 3 files changed, 176 insertions(+)create mode 100644
app/test/test_ethdev_api.capp/test/meson.build +2
-0@@ -49,6 +49,7 @@ test_sources = files( 'test_efd_perf.c', 'test_errno.c', 'test_ethdev_link.c', + 'test_ethdev_api.c', 'test_event_crypto_adapter.c', 'test_event_eth_rx_adapter.c', 'test_event_ring.c',@@ -187,6 +188,7 @@ fast_tests = [ ['eal_fs_autotest', true, true], ['errno_autotest', true, true], ['ethdev_link_status', true, true], + ['ethdev_api', true, true], ['event_ring_autotest', true, true], ['fib_autotest', true, true], ['fib6_autotest', true, true],app/test/test_ethdev_api.c new file +169
-0@@ -0,0 +1,169 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2023, Advanced Micro Devices, Inc. +*/ + +#include <rte_log.h> +#include <rte_ethdev.h> + +#include <rte_test.h> +#include "test.h" + +#define NUM_RXQ 2 +#define NUM_TXQ 2 +#define NUM_RXD 512 +#define NUM_TXD 512 +#define NUM_MBUF 1024 +#define MBUF_CACHE_SIZE 256 + +static int32_t +ethdev_api_queue_status (void ) +{ +struct rte_eth_dev_info dev_info; +struct rte_eth_rxq_info rx_qinfo; +struct rte_eth_txq_info tx_qinfo; +struct rte_mempool *mbuf_pool; +/*struct rte_eth_rxconf rx_conf;*/ +/*struct rte_eth_txconf tx_conf;*/ +struct rte_eth_conf eth_conf; +uint16_t port_id; +int ret; + + mbuf_pool =rte_pktmbuf_pool_create ("MBUF_POOL" ,NUM_MBUF ,MBUF_CACHE_SIZE ,0 , +RTE_MBUF_DEFAULT_BUF_SIZE ,rte_socket_id ()); + +RTE_ETH_FOREACH_DEV (port_id) { +memset (ð_conf,0 ,sizeof (dev_info)); + ret =rte_eth_dev_configure (port_id,NUM_RXQ ,NUM_TXQ , ð_conf); +TEST_ASSERT (ret ==0 , +"Port(%u) failed to configure.\n" , port_id); + +/* RxQ setup */ +/*memset(&rx_conf, 0, sizeof(rx_conf));*/ +for (uint16_t queue_id =0 ; queue_id <NUM_RXQ ; queue_id++) { + ret =rte_eth_rx_queue_setup (port_id, queue_id,NUM_RXD , +rte_socket_id (),NULL , mbuf_pool); +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to setup RxQ.\n" , + port_id, queue_id); + } + +/* TxQ setup */ +/*memset(&tx_conf, 0, sizeof(tx_conf));*/ +for (uint16_t queue_id =0 ; queue_id <NUM_TXQ ; queue_id++) { + ret =rte_eth_tx_queue_setup (port_id, queue_id,NUM_TXD , +rte_socket_id (),NULL ); +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to setup TxQ.\n" , + port_id, queue_id); + } + + ret =rte_eth_dev_info_get (port_id, &dev_info); +TEST_ASSERT (ret ==0 , +"Port(%u) failed to get dev info.\n" , port_id); + +/* Initial RxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_rx_queues; queue_id++) { + ret =rte_eth_rx_queue_info_get (port_id, queue_id, &rx_qinfo); +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get RxQ info.\n" , + port_id, queue_id); + +TEST_ASSERT (rx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED , +"Wrong initial Rx queue(%u) state(%d)\n" , + queue_id, rx_qinfo.queue_state); + } + +/* Initial TxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_tx_queues; queue_id++) { + ret =rte_eth_tx_queue_info_get (port_id, queue_id, &tx_qinfo); +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get TxQ info.\n" , + port_id, queue_id); + +TEST_ASSERT (tx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED , +"Wrong initial Tx queue(%u) state(%d)\n" , + queue_id, tx_qinfo.queue_state); + } + + + ret =rte_eth_dev_start (port_id); +TEST_ASSERT (ret ==0 , +"Port(%u) failed to start.\n" , port_id); + +/* Started RxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_rx_queues; queue_id++) { + ret =rte_eth_rx_queue_info_get (port_id, queue_id, &rx_qinfo); +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get RxQ info.\n" , + port_id, queue_id); + +TEST_ASSERT (rx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STARTED , +"Wrong started Rx queue(%u) state(%d)\n" , + queue_id, rx_qinfo.queue_state); + } + +/* Started TxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_tx_queues; queue_id++) { + ret =rte_eth_tx_queue_info_get (port_id, queue_id, &tx_qinfo); +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get TxQ info.\n" , + port_id, queue_id); + +TEST_ASSERT (tx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STARTED , +"Wrong started Tx queue(%u) state(%d)\n" , + queue_id, tx_qinfo.queue_state); + } + + + ret =rte_eth_dev_stop (port_id); +TEST_ASSERT (ret ==0 , +"Port(%u) failed to stop.\n" , port_id); + +/* Stopped RxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_rx_queues; queue_id++) { + ret =rte_eth_rx_queue_info_get (port_id, queue_id, &rx_qinfo); +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get RxQ info.\n" , + port_id, queue_id); + +TEST_ASSERT (rx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED , +"Wrong stopped Rx queue(%u) state(%d)\n" , + queue_id, rx_qinfo.queue_state); + } + +/* Stopped TxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_tx_queues; queue_id++) { + ret =rte_eth_tx_queue_info_get (port_id, queue_id, &tx_qinfo); +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get TxQ info.\n" , + port_id, queue_id); + +TEST_ASSERT (tx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED , +"Wrong stopped Tx queue(%u) state(%d)\n" , + queue_id, tx_qinfo.queue_state); + } + } + +return TEST_SUCCESS ; +} + +static struct unit_test_suite ethdev_api_testsuite = { + .suite_name ="ethdev API tests" , + .setup =NULL , + .teardown =NULL , + .unit_test_cases = { +TEST_CASE (ethdev_api_queue_status), +TEST_CASES_END ()/**< NULL terminate unit test array */ + } +}; + +static int +test_ethdev_api (void ) +{ +rte_log_set_global_level (RTE_LOG_DEBUG ); +rte_log_set_level (RTE_LOGTYPE_EAL ,RTE_LOG_DEBUG ); + +return unit_test_suite_runner (ðdev_api_testsuite); +} + +REGISTER_TEST_COMMAND (ethdev_api, test_ethdev_api);lib/ethdev/rte_ethdev.h +5
-0@@ -2788,6 +2788,9 @@ int rte_eth_dev_tx_queue_stop(uint16_t port_id, uint16_t tx_queue_id);* Device RTE_ETH_DEV_NOLIVE_MAC_ADDR flag causes MAC address to be set before * PMD port start callback function is invoked. * +* All device queues (except form deferred queues) status should be +* `RTE_ETH_QUEUE_STATE_STARTED` after start. +* * On success, all basic functions exported by the Ethernet API (link status, * receive/transmit, and so on) can be invoked. * @@ -2804,6 +2807,8 @@ int rte_eth_dev_start(uint16_t port_id);* Stop an Ethernet device. The device can be restarted with a call to * rte_eth_dev_start() * +* All device queues status should be `RTE_ETH_QUEUE_STATE_STOPPED` after stop. +* * @param port_id * The port identifier of the Ethernet device. * @return Signature · 1 line
2.34.1
Quoted 6 lines · Ivan Malov
Hi Ferruh,
The commit log says "commit [1]" and "commit [2]" but does not seem to provide the URLs for the [1] and [2]. What are these resources? I'd like to know.
Ahh, I missed to add them to commit log, will add to next version:
[1]3c4426db54fc ("app/testpmd: do not poll stopped queues")
[2]5028f207a4fa ("app/testpmd: fix secondary process packet forwarding")
Quoted 282 lines
Thank you.
Quoted 278 lines · Ferruh Yigit
Drivers start/stop device queues on port start/stop, but not all drivers update queue state accordingly.
This becomes more visible if a specific queue stopped explicitly and port stopped/started later, in this case although all queues are started, the state of that specific queue is stopped and it is misleading.
Misrepresentation of queue state became a defect with commit [1] that does forwarding decision based on queue state and commit [2] that gets up to date queue state from ethdev/device before forwarding.
This patch documents that status of all queues of a device should be
RTE_ETH_QUEUE_STATE_STOPPEDafter port stop and their status should beRTE_ETH_QUEUE_STATE_STARTEDafter port start.Also an unit test added to verify drivers.
Signed-off-by Ferruh Yigit <[email protected]>---
Cc: Jie Hai <[email protected]>
Cc: Song Jiale <[email protected]>
Cc: Yuan Peng <[email protected]>
Cc: Raslan Darawsheh <[email protected]>
Cc: Qiming Yang <[email protected]>
---
app/test/meson.build | 2 +app/test/test_ethdev_api.c| 169 +++++++++++++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 5 ++3 files changed, 176 insertions(+)create mode 100644
app/test/test_ethdev_api.capp/test/meson.build +2
-0@@ -49,6 +49,7 @@ test_sources = files( 'test_efd_perf.c', 'test_errno.c', 'test_ethdev_link.c', + 'test_ethdev_api.c', 'test_event_crypto_adapter.c', 'test_event_eth_rx_adapter.c', 'test_event_ring.c',@@ -187,6 +188,7 @@ fast_tests = [ ['eal_fs_autotest', true, true], ['errno_autotest', true, true], ['ethdev_link_status', true, true], + ['ethdev_api', true, true], ['event_ring_autotest', true, true], ['fib_autotest', true, true], ['fib6_autotest', true, true],app/test/test_ethdev_api.c new file +31
-0@@ -0,0 +1,169 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2023, Advanced Micro Devices, Inc. +*/ + +#include <rte_log.h> +#include <rte_ethdev.h> + +#include <rte_test.h> +#include "test.h" + +#define NUM_RXQ 2 +#define NUM_TXQ 2 +#define NUM_RXD 512 +#define NUM_TXD 512 +#define NUM_MBUF 1024 +#define MBUF_CACHE_SIZE 256 + +static int32_t +ethdev_api_queue_status (void ) +{ + struct rte_eth_dev_info dev_info; + struct rte_eth_rxq_info rx_qinfo; + struct rte_eth_txq_info tx_qinfo; + struct rte_mempool *mbuf_pool; + /*struct rte_eth_rxconf rx_conf;*/ + /*struct rte_eth_txconf tx_conf;*/ + struct rte_eth_conf eth_conf; + uint16_t port_id; + int ret; + + mbuf_pool = rte_pktmbuf_pool_create("MBUF_POOL", NUM_MBUF,
MBUF_CACHE_SIZE, 0,
+RTE_MBUF_DEFAULT_BUF_SIZE,rte_socket_id()); +
+RTE_ETH_FOREACH_DEV(port_id){
+memset(ð_conf, 0, sizeof(dev_info));
+ ret =rte_eth_dev_configure(port_id, NUM_RXQ, NUM_TXQ, ð_conf);
+ TEST_ASSERT(ret == 0,
+ "Port(%u) failed to configure.\n",port_id);app/test/test_ethdev_api.c new file +27
-0+ + /* RxQ setup */ + /*memset(&rx_conf, 0, sizeof(rx_conf));*/ + for (uint16_t queue_id = 0; queue_id < NUM_RXQ; queue_id++) { + ret = rte_eth_rx_queue_setup(port_id, queue_id, NUM_RXD, + rte_socket_id(), NULL, mbuf_pool); + TEST_ASSERT(ret == 0, + "Port(%u), queue(%u) failed to setup RxQ.\n", + port_id, queue_id); + } + + /* TxQ setup */ + /*memset(&tx_conf, 0, sizeof(tx_conf));*/ + for (uint16_t queue_id = 0; queue_id < NUM_TXQ; queue_id++) { + ret = rte_eth_tx_queue_setup(port_id, queue_id, NUM_TXD, + rte_socket_id(), NULL); + TEST_ASSERT(ret == 0, + "Port(%u), queue(%u) failed to setup TxQ.\n", + port_id, queue_id); + } + + ret = rte_eth_dev_info_get(port_id, &dev_info); + TEST_ASSERT(ret == 0, + "Port(%u) failed to get dev info.\n", port_id); + + /* Initial RxQ */ + for (uint16_t queue_id = 0; queue_id < dev_info.nb_rx_queues;queue_id++) {
+ ret =rte_eth_rx_queue_info_get(port_id, queue_id, &rx_qinfo);
+ TEST_ASSERT(ret == 0,
+ "Port(%u), queue(%u) failed to get RxQ info.\n", +port_id,queue_id);
+
+ TEST_ASSERT(rx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED,
+ "Wrong initial Rx queue(%u) state(%d)\n", +queue_id, rx_qinfo.queue_state);
+ }
+
+ /* Initial TxQ */
+ for (uint16_tqueue_id= 0;queue_id< dev_info.nb_tx_queues; queue_id++) {
+ ret =rte_eth_tx_queue_info_get(port_id, queue_id, &tx_qinfo);
+ TEST_ASSERT(ret == 0,
+ "Port(%u), queue(%u) failed to get TxQ info.\n", +port_id,queue_id);
+
+ TEST_ASSERT(tx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED,
+ "Wrong initial Tx queue(%u) state(%d)\n", +queue_id, tx_qinfo.queue_state);
+ }app/test/test_ethdev_api.c new file +8
-0+ + + ret = rte_eth_dev_start(port_id); + TEST_ASSERT(ret == 0, + "Port(%u) failed to start.\n", port_id); + + /* Started RxQ */ + for (uint16_t queue_id = 0; queue_id < dev_info.nb_rx_queues;queue_id++) {
+ ret =rte_eth_rx_queue_info_get(port_id, queue_id, &rx_qinfo);
+ TEST_ASSERT(ret == 0,
+ "Port(%u), queue(%u) failed to get RxQ info.\n", +port_id,queue_id);
+
+ TEST_ASSERT(rx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STARTED,
+ "Wrong started Rx queue(%u) state(%d)\n", +queue_id, rx_qinfo.queue_state);
+ }
+
+ /* Started TxQ */
+ for (uint16_tqueue_id= 0;queue_id< dev_info.nb_tx_queues; queue_id++) {
+ ret =rte_eth_tx_queue_info_get(port_id, queue_id, &tx_qinfo);
+ TEST_ASSERT(ret == 0,
+ "Port(%u), queue(%u) failed to get TxQ info.\n", +port_id,queue_id);
+
+ TEST_ASSERT(tx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STARTED,
+ "Wrong started Tx queue(%u) state(%d)\n", +queue_id, tx_qinfo.queue_state);
+ }app/test/test_ethdev_api.c new file +8
-0+ + + ret = rte_eth_dev_stop(port_id); + TEST_ASSERT(ret == 0, + "Port(%u) failed to stop.\n", port_id); + + /* Stopped RxQ */ + for (uint16_t queue_id = 0; queue_id < dev_info.nb_rx_queues;queue_id++) {
+ ret =rte_eth_rx_queue_info_get(port_id, queue_id, &rx_qinfo);
+ TEST_ASSERT(ret == 0,
+ "Port(%u), queue(%u) failed to get RxQ info.\n", +port_id,queue_id);
+
+ TEST_ASSERT(rx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED,
+ "Wrong stopped Rx queue(%u) state(%d)\n", +queue_id, rx_qinfo.queue_state);
+ }
+
+ /* Stopped TxQ */
+ for (uint16_tqueue_id= 0;queue_id< dev_info.nb_tx_queues; queue_id++) {
+ ret =rte_eth_tx_queue_info_get(port_id, queue_id, &tx_qinfo);
+ TEST_ASSERT(ret == 0,
+ "Port(%u), queue(%u) failed to get TxQ info.\n", +port_id,queue_id);
+
+ TEST_ASSERT(tx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED,
+ "Wrong stopped Tx queue(%u) state(%d)\n", +queue_id, tx_qinfo.queue_state);
+ }
+ }app/test/test_ethdev_api.c new file +24
-0+ + return TEST_SUCCESS; +} + +static struct unit_test_suite ethdev_api_testsuite = { + .suite_name = "ethdev API tests", + .setup = NULL, + .teardown = NULL, + .unit_test_cases = { + TEST_CASE(ethdev_api_queue_status), + TEST_CASES_END() /**< NULL terminate unit test array */ + } +}; + +static int +test_ethdev_api (void ) +{ + rte_log_set_global_level(RTE_LOG_DEBUG); + rte_log_set_level(RTE_LOGTYPE_EAL, RTE_LOG_DEBUG); + + return unit_test_suite_runner(ðdev_api_testsuite); +} + +REGISTER_TEST_COMMAND (ethdev_api, test_ethdev_api);lib/ethdev/rte_ethdev.h +0
-0@@ -2788,6 +2788,9 @@ int rte_eth_dev_tx_queue_stop(uint16_t port_id, uint16_t tx_queue_id); * Device RTE_ETH_DEV_NOLIVE_MAC_ADDR flag causes MAC address to beset before
* PMD port start callback function is invoked.
*
+ * All device queues (except form deferred queues) status should be
+ *RTE_ETH_QUEUE_STATE_STARTEDafter start.
+ *
* On success, all basic functions exported by the Ethernet API (link status,
* receive/transmit, and so on) can be invoked.
*lib/ethdev/rte_ethdev.h +1
-0@@ -2804,6 +2807,8 @@ int rte_eth_dev_start(uint16_t port_id); * Stop an Ethernet device. The device can be restarted with a call to * rte_eth_dev_start() * + * All device queues status should be `RTE_ETH_QUEUE_STATE_STOPPED`after stop.
+ *
* @paramport_id
* The port identifier of the Ethernet device.
* @return
--
2.34.1
Hi Ferruh,
PSB
Thank you.
Quoted 83 lines · Ferruh Yigit
Drivers start/stop device queues on port start/stop, but not all drivers update queue state accordingly.
This becomes more visible if a specific queue stopped explicitly and port stopped/started later, in this case although all queues are started, the state of that specific queue is stopped and it is misleading.
Misrepresentation of queue state became a defect with commit [1] that does forwarding decision based on queue state and commit [2] that gets up to date queue state from ethdev/device before forwarding.
This patch documents that status of all queues of a device should be
RTE_ETH_QUEUE_STATE_STOPPEDafter port stop and their status should beRTE_ETH_QUEUE_STATE_STARTEDafter port start.Also an unit test added to verify drivers.
Signed-off-by Ferruh Yigit <[email protected]>---
Cc: Jie Hai <[email protected]>
Cc: Song Jiale <[email protected]>
Cc: Yuan Peng <[email protected]>
Cc: Raslan Darawsheh <[email protected]>
Cc: Qiming Yang <[email protected]>
---app/test/meson.build | 2 + app/test/test_ethdev_api.c | 169 +++++++++++++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 5 ++ 3 files changed, 176 insertions(+)create mode 100644
app/test/test_ethdev_api.capp/test/meson.build +2
-0@@ -49,6 +49,7 @@ test_sources = files( 'test_efd_perf.c', 'test_errno.c', 'test_ethdev_link.c', + 'test_ethdev_api.c', 'test_event_crypto_adapter.c', 'test_event_eth_rx_adapter.c', 'test_event_ring.c',@@ -187,6 +188,7 @@ fast_tests = [ ['eal_fs_autotest', true, true], ['errno_autotest', true, true], ['ethdev_link_status', true, true], + ['ethdev_api', true, true], ['event_ring_autotest', true, true], ['fib_autotest', true, true], ['fib6_autotest', true, true],app/test/test_ethdev_api.c new file +25
-0@@ -0,0 +1,169 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2023, Advanced Micro Devices, Inc. +*/ + +#include <rte_log.h> +#include <rte_ethdev.h> + +#include <rte_test.h> +#include "test.h" + +#define NUM_RXQ 2 +#define NUM_TXQ 2 +#define NUM_RXD 512 +#define NUM_TXD 512 +#define NUM_MBUF 1024 +#define MBUF_CACHE_SIZE 256 + +static int32_t +ethdev_api_queue_status (void ) +{ +struct rte_eth_dev_info dev_info; +struct rte_eth_rxq_info rx_qinfo; +struct rte_eth_txq_info tx_qinfo; +struct rte_mempool *mbuf_pool; +/*struct rte_eth_rxconf rx_conf;*/
app/test/test_ethdev_api.c line 35
Quoted 10 lines
app/test/test_ethdev_api.c new file +10
-0+/*struct rte_eth_txconf tx_conf;*/ +struct rte_eth_conf eth_conf; +uint16_t port_id; +int ret; + + mbuf_pool =rte_pktmbuf_pool_create ("MBUF_POOL" ,NUM_MBUF ,MBUF_CACHE_SIZE ,0 , +RTE_MBUF_DEFAULT_BUF_SIZE ,rte_socket_id ()); + +RTE_ETH_FOREACH_DEV (port_id) { +memset (ð_conf,0 ,sizeof (dev_info));
This clears "eth_conf", but the sizeof is "dev_info". Why?
Quoted 161 lines
app/test/test_ethdev_api.c new file +134
-0+ ret =rte_eth_dev_configure (port_id,NUM_RXQ ,NUM_TXQ , ð_conf); +TEST_ASSERT (ret ==0 , +"Port(%u) failed to configure.\n" , port_id); + +/* RxQ setup */ +/*memset(&rx_conf, 0, sizeof(rx_conf));*/ +for (uint16_t queue_id =0 ; queue_id <NUM_RXQ ; queue_id++) { + ret =rte_eth_rx_queue_setup (port_id, queue_id,NUM_RXD , +rte_socket_id (),NULL , mbuf_pool); +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to setup RxQ.\n" , + port_id, queue_id); + } + +/* TxQ setup */ +/*memset(&tx_conf, 0, sizeof(tx_conf));*/ +for (uint16_t queue_id =0 ; queue_id <NUM_TXQ ; queue_id++) { + ret =rte_eth_tx_queue_setup (port_id, queue_id,NUM_TXD , +rte_socket_id (),NULL ); +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to setup TxQ.\n" , + port_id, queue_id); + } + + ret =rte_eth_dev_info_get (port_id, &dev_info); +TEST_ASSERT (ret ==0 , +"Port(%u) failed to get dev info.\n" , port_id); + +/* Initial RxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_rx_queues; queue_id++) { + ret =rte_eth_rx_queue_info_get (port_id, queue_id, &rx_qinfo); +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get RxQ info.\n" , + port_id, queue_id); + +TEST_ASSERT (rx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED , +"Wrong initial Rx queue(%u) state(%d)\n" , + queue_id, rx_qinfo.queue_state); + } + +/* Initial TxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_tx_queues; queue_id++) { + ret =rte_eth_tx_queue_info_get (port_id, queue_id, &tx_qinfo); +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get TxQ info.\n" , + port_id, queue_id); + +TEST_ASSERT (tx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED , +"Wrong initial Tx queue(%u) state(%d)\n" , + queue_id, tx_qinfo.queue_state); + } + + + ret =rte_eth_dev_start (port_id); +TEST_ASSERT (ret ==0 , +"Port(%u) failed to start.\n" , port_id); + +/* Started RxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_rx_queues; queue_id++) { + ret =rte_eth_rx_queue_info_get (port_id, queue_id, &rx_qinfo); +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get RxQ info.\n" , + port_id, queue_id); + +TEST_ASSERT (rx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STARTED , +"Wrong started Rx queue(%u) state(%d)\n" , + queue_id, rx_qinfo.queue_state); + } + +/* Started TxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_tx_queues; queue_id++) { + ret =rte_eth_tx_queue_info_get (port_id, queue_id, &tx_qinfo); +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get TxQ info.\n" , + port_id, queue_id); + +TEST_ASSERT (tx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STARTED , +"Wrong started Tx queue(%u) state(%d)\n" , + queue_id, tx_qinfo.queue_state); + } + + + ret =rte_eth_dev_stop (port_id); +TEST_ASSERT (ret ==0 , +"Port(%u) failed to stop.\n" , port_id); + +/* Stopped RxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_rx_queues; queue_id++) { + ret =rte_eth_rx_queue_info_get (port_id, queue_id, &rx_qinfo); +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get RxQ info.\n" , + port_id, queue_id); + +TEST_ASSERT (rx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED , +"Wrong stopped Rx queue(%u) state(%d)\n" , + queue_id, rx_qinfo.queue_state); + } + +/* Stopped TxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_tx_queues; queue_id++) { + ret =rte_eth_tx_queue_info_get (port_id, queue_id, &tx_qinfo); +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get TxQ info.\n" , + port_id, queue_id); + +TEST_ASSERT (tx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED , +"Wrong stopped Tx queue(%u) state(%d)\n" , + queue_id, tx_qinfo.queue_state); + } + } + +return TEST_SUCCESS ; +} + +static struct unit_test_suite ethdev_api_testsuite = { + .suite_name ="ethdev API tests" , + .setup =NULL , + .teardown =NULL , + .unit_test_cases = { +TEST_CASE (ethdev_api_queue_status), +TEST_CASES_END ()/**< NULL terminate unit test array */ + } +}; + +static int +test_ethdev_api (void ) +{ +rte_log_set_global_level (RTE_LOG_DEBUG ); +rte_log_set_level (RTE_LOGTYPE_EAL ,RTE_LOG_DEBUG ); + +return unit_test_suite_runner (ðdev_api_testsuite); +} + +REGISTER_TEST_COMMAND (ethdev_api, test_ethdev_api);lib/ethdev/rte_ethdev.h +5
-0@@ -2788,6 +2788,9 @@ int rte_eth_dev_tx_queue_stop(uint16_t port_id, uint16_t tx_queue_id);* Device RTE_ETH_DEV_NOLIVE_MAC_ADDR flag causes MAC address to be set before * PMD port start callback function is invoked. * +* All device queues (except form deferred queues) status should be +* `RTE_ETH_QUEUE_STATE_STARTED` after start. +* * On success, all basic functions exported by the Ethernet API (link status, * receive/transmit, and so on) can be invoked. * @@ -2804,6 +2807,8 @@ int rte_eth_dev_start(uint16_t port_id);* Stop an Ethernet device. The device can be restarted with a call to * rte_eth_dev_start() * +* All device queues status should be `RTE_ETH_QUEUE_STATE_STOPPED` after stop. +* * @param port_id * The port identifier of the Ethernet device. * @return Signature · 1 line
2.34.1
Quoted 95 lines · Ivan Malov
Hi Ferruh,
PSB
Thank you.
Quoted 87 lines · Ferruh Yigit
Drivers start/stop device queues on port start/stop, but not all drivers update queue state accordingly.
This becomes more visible if a specific queue stopped explicitly and port stopped/started later, in this case although all queues are started, the state of that specific queue is stopped and it is misleading.
Misrepresentation of queue state became a defect with commit [1] that does forwarding decision based on queue state and commit [2] that gets up to date queue state from ethdev/device before forwarding.
This patch documents that status of all queues of a device should be
RTE_ETH_QUEUE_STATE_STOPPEDafter port stop and their status should beRTE_ETH_QUEUE_STATE_STARTEDafter port start.Also an unit test added to verify drivers.
Signed-off-by Ferruh Yigit <[email protected]>---
Cc: Jie Hai <[email protected]>
Cc: Song Jiale <[email protected]>
Cc: Yuan Peng <[email protected]>
Cc: Raslan Darawsheh <[email protected]>
Cc: Qiming Yang <[email protected]>
---
app/test/meson.build | 2 +app/test/test_ethdev_api.c| 169 +++++++++++++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 5 ++3 files changed, 176 insertions(+)create mode 100644
app/test/test_ethdev_api.capp/test/meson.build +2
-0@@ -49,6 +49,7 @@ test_sources = files( 'test_efd_perf.c', 'test_errno.c', 'test_ethdev_link.c', + 'test_ethdev_api.c', 'test_event_crypto_adapter.c', 'test_event_eth_rx_adapter.c', 'test_event_ring.c',@@ -187,6 +188,7 @@ fast_tests = [ ['eal_fs_autotest', true, true], ['errno_autotest', true, true], ['ethdev_link_status', true, true], + ['ethdev_api', true, true], ['event_ring_autotest', true, true], ['fib_autotest', true, true], ['fib6_autotest', true, true],app/test/test_ethdev_api.c new file +29
-0@@ -0,0 +1,169 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2023, Advanced Micro Devices, Inc. +*/ + +#include <rte_log.h> +#include <rte_ethdev.h> + +#include <rte_test.h> +#include "test.h" + +#define NUM_RXQ 2 +#define NUM_TXQ 2 +#define NUM_RXD 512 +#define NUM_TXD 512 +#define NUM_MBUF 1024 +#define MBUF_CACHE_SIZE 256 + +static int32_t +ethdev_api_queue_status (void ) +{ + struct rte_eth_dev_info dev_info; + struct rte_eth_rxq_info rx_qinfo; + struct rte_eth_txq_info tx_qinfo; + struct rte_mempool *mbuf_pool; + /*struct rte_eth_rxconf rx_conf;*/ + /*struct rte_eth_txconf tx_conf;*/ + struct rte_eth_conf eth_conf; + uint16_t port_id; + int ret;
Quoted 9 lines
Quoted 7 lines
app/test/test_ethdev_api.c new file +2
-0+ + mbuf_pool = rte_pktmbuf_pool_create("MBUF_POOL", NUM_MBUF,
MBUF_CACHE_SIZE, 0,
+RTE_MBUF_DEFAULT_BUF_SIZE,rte_socket_id()); +
+RTE_ETH_FOREACH_DEV(port_id){
+memset(ð_conf, 0, sizeof(dev_info));This clears "
eth_conf", but the sizeof is "dev_info". Why?
Will fix in next version, thx.
Quoted 83 lines · Ferruh Yigit
Drivers start/stop device queues on port start/stop, but not all drivers update queue state accordingly.
This becomes more visible if a specific queue stopped explicitly and port stopped/started later, in this case although all queues are started, the state of that specific queue is stopped and it is misleading.
Misrepresentation of queue state became a defect with commit [1] that does forwarding decision based on queue state and commit [2] that gets up to date queue state from ethdev/device before forwarding.
This patch documents that status of all queues of a device should be
RTE_ETH_QUEUE_STATE_STOPPEDafter port stop and their status should beRTE_ETH_QUEUE_STATE_STARTEDafter port start.Also an unit test added to verify drivers.
Signed-off-by Ferruh Yigit <[email protected]>---
Cc: Jie Hai <[email protected]>
Cc: Song Jiale <[email protected]>
Cc: Yuan Peng <[email protected]>
Cc: Raslan Darawsheh <[email protected]>
Cc: Qiming Yang <[email protected]>--- app/test/meson.build | 2 + app/test/test_ethdev_api.c | 169 +++++++++++++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 5 ++ 3 files changed, 176 insertions(+)create mode 100644
app/test/test_ethdev_api.capp/test/meson.build +2
-0@@ -49,6 +49,7 @@ test_sources = files( 'test_efd_perf.c', 'test_errno.c', 'test_ethdev_link.c', + 'test_ethdev_api.c', 'test_event_crypto_adapter.c', 'test_event_eth_rx_adapter.c', 'test_event_ring.c',@@ -187,6 +188,7 @@ fast_tests = [ ['eal_fs_autotest', true, true], ['errno_autotest', true, true], ['ethdev_link_status', true, true], + ['ethdev_api', true, true], ['event_ring_autotest', true, true], ['fib_autotest', true, true], ['fib6_autotest', true, true],app/test/test_ethdev_api.c new file +25
-0@@ -0,0 +1,169 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2023, Advanced Micro Devices, Inc. +*/ + +#include <rte_log.h> +#include <rte_ethdev.h> + +#include <rte_test.h> +#include "test.h" + +#define NUM_RXQ 2 +#define NUM_TXQ 2 +#define NUM_RXD 512 +#define NUM_TXD 512 +#define NUM_MBUF 1024 +#define MBUF_CACHE_SIZE 256 + +static int32_t +ethdev_api_queue_status (void ) +{ +struct rte_eth_dev_info dev_info; +struct rte_eth_rxq_info rx_qinfo; +struct rte_eth_txq_info tx_qinfo; +struct rte_mempool *mbuf_pool; +/*struct rte_eth_rxconf rx_conf;*/
app/test/test_ethdev_api.c line 35
Quoted 10 lines
app/test/test_ethdev_api.c new file +10
-0+/*struct rte_eth_txconf tx_conf;*/ +struct rte_eth_conf eth_conf; +uint16_t port_id; +int ret; + + mbuf_pool =rte_pktmbuf_pool_create ("MBUF_POOL" ,NUM_MBUF ,MBUF_CACHE_SIZE ,0 , +RTE_MBUF_DEFAULT_BUF_SIZE ,rte_socket_id ()); + +RTE_ETH_FOREACH_DEV (port_id) { +memset (ð_conf,0 ,sizeof (dev_info));
+1 need to modify.
app/test/test_ethdev_api.c line 41
Quoted 6 lines
app/test/test_ethdev_api.c new file +6
-0+ ret =rte_eth_dev_configure (port_id,NUM_RXQ ,NUM_TXQ , ð_conf); +TEST_ASSERT (ret ==0 , +"Port(%u) failed to configure.\n" , port_id); + +/* RxQ setup */ +/*memset(&rx_conf, 0, sizeof(rx_conf));*/
What's here for?
Quoted 11 lines
app/test/test_ethdev_api.c new file +11
-0+for (uint16_t queue_id =0 ; queue_id <NUM_RXQ ; queue_id++) { + ret =rte_eth_rx_queue_setup (port_id, queue_id,NUM_RXD , +rte_socket_id (),NULL , mbuf_pool); +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to setup RxQ.\n" , + port_id, queue_id); + } + +/* TxQ setup */ +/*memset(&tx_conf, 0, sizeof(tx_conf));*/ +for (uint16_t queue_id =0 ; queue_id <NUM_TXQ ; queue_id++) {
app/test/test_ethdev_api.c line 62
Quoted 10 lines
app/test/test_ethdev_api.c new file +10
-0+ ret =rte_eth_tx_queue_setup (port_id, queue_id,NUM_TXD , +rte_socket_id (),NULL ); +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to setup TxQ.\n" , + port_id, queue_id); + } + + ret =rte_eth_dev_info_get (port_id, &dev_info); +TEST_ASSERT (ret ==0 , +"Port(%u) failed to get dev info.\n" , port_id);
dev_info_get() seems an useless code here.
Because NUM_RXQ and NUM_TXQ can be used directly in following codes.
Quoted 9 lines
app/test/test_ethdev_api.c new file +9
-0+ +/* Initial RxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_rx_queues; queue_id++) { + ret =rte_eth_rx_queue_info_get (port_id, queue_id, &rx_qinfo); +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get RxQ info.\n" , + port_id, queue_id); + + TEST_ASSERT(rx_qinfo.queue_state == RTE_ETH_QUEUE_STATE_STOPPED,
app/test/test_ethdev_api.c line 81
Quoted 10 lines
app/test/test_ethdev_api.c new file +10
-0+"Wrong initial Rx queue(%u) state(%d)\n" , + queue_id, rx_qinfo.queue_state); + } + +/* Initial TxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_tx_queues; queue_id++) { + ret =rte_eth_tx_queue_info_get (port_id, queue_id, &tx_qinfo); +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get TxQ info.\n" , + port_id, queue_id);
Some drivers don't support this API. So it should be ok for these drivers.
Quoted 111 lines
app/test/test_ethdev_api.c new file +88
-0+ +TEST_ASSERT (tx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED , +"Wrong initial Tx queue(%u) state(%d)\n" , + queue_id, tx_qinfo.queue_state); + } + + + ret =rte_eth_dev_start (port_id); +TEST_ASSERT (ret ==0 , +"Port(%u) failed to start.\n" , port_id); + +/* Started RxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_rx_queues; queue_id++) { + ret =rte_eth_rx_queue_info_get (port_id, queue_id, &rx_qinfo); +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get RxQ info.\n" , + port_id, queue_id); + +TEST_ASSERT (rx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STARTED , +"Wrong started Rx queue(%u) state(%d)\n" , + queue_id, rx_qinfo.queue_state); + } + +/* Started TxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_tx_queues; queue_id++) { + ret =rte_eth_tx_queue_info_get (port_id, queue_id, &tx_qinfo); +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get TxQ info.\n" , + port_id, queue_id); + +TEST_ASSERT (tx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STARTED , +"Wrong started Tx queue(%u) state(%d)\n" , + queue_id, tx_qinfo.queue_state); + } + + + ret =rte_eth_dev_stop (port_id); +TEST_ASSERT (ret ==0 , +"Port(%u) failed to stop.\n" , port_id); + +/* Stopped RxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_rx_queues; queue_id++) { + ret =rte_eth_rx_queue_info_get (port_id, queue_id, &rx_qinfo); +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get RxQ info.\n" , + port_id, queue_id); + +TEST_ASSERT (rx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED , +"Wrong stopped Rx queue(%u) state(%d)\n" , + queue_id, rx_qinfo.queue_state); + } + +/* Stopped TxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_tx_queues; queue_id++) { + ret =rte_eth_tx_queue_info_get (port_id, queue_id, &tx_qinfo); +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get TxQ info.\n" , + port_id, queue_id); + +TEST_ASSERT (tx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED , +"Wrong stopped Tx queue(%u) state(%d)\n" , + queue_id, tx_qinfo.queue_state); + } + } + +return TEST_SUCCESS ; +} + +static struct unit_test_suite ethdev_api_testsuite = { + .suite_name ="ethdev API tests" , + .setup =NULL , + .teardown =NULL , + .unit_test_cases = { +TEST_CASE (ethdev_api_queue_status), +TEST_CASES_END ()/**< NULL terminate unit test array */ + } +}; + +static int +test_ethdev_api (void ) +{ +rte_log_set_global_level (RTE_LOG_DEBUG ); +rte_log_set_level (RTE_LOGTYPE_EAL ,RTE_LOG_DEBUG ); + +return unit_test_suite_runner (ðdev_api_testsuite); +} + +REGISTER_TEST_COMMAND (ethdev_api, test_ethdev_api);lib/ethdev/rte_ethdev.h +5
-0@@ -2788,6 +2788,9 @@ int rte_eth_dev_tx_queue_stop(uint16_t port_id, uint16_t tx_queue_id);* Device RTE_ETH_DEV_NOLIVE_MAC_ADDR flag causes MAC address to be set before * PMD port start callback function is invoked. * +* All device queues (except form deferred queues) status should be +* `RTE_ETH_QUEUE_STATE_STARTED` after start. +* * On success, all basic functions exported by the Ethernet API (link status, * receive/transmit, and so on) can be invoked. * @@ -2804,6 +2807,8 @@ int rte_eth_dev_start(uint16_t port_id);* Stop an Ethernet device. The device can be restarted with a call to * rte_eth_dev_start() * +* All device queues status should be `RTE_ETH_QUEUE_STATE_STOPPED` after stop. +* * @param port_id * The port identifier of the Ethernet device. * @return
Quoted 89 lines · lihuisong (C)
Quoted 87 lines · Ferruh Yigit
Drivers start/stop device queues on port start/stop, but not all drivers update queue state accordingly.
This becomes more visible if a specific queue stopped explicitly and port stopped/started later, in this case although all queues are started, the state of that specific queue is stopped and it is misleading.
Misrepresentation of queue state became a defect with commit [1] that does forwarding decision based on queue state and commit [2] that gets up to date queue state from ethdev/device before forwarding.
This patch documents that status of all queues of a device should be
RTE_ETH_QUEUE_STATE_STOPPEDafter port stop and their status should beRTE_ETH_QUEUE_STATE_STARTEDafter port start.Also an unit test added to verify drivers.
Signed-off-by Ferruh Yigit <[email protected]>---
Cc: Jie Hai <[email protected]>
Cc: Song Jiale <[email protected]>
Cc: Yuan Peng <[email protected]>
Cc: Raslan Darawsheh <[email protected]>
Cc: Qiming Yang <[email protected]>
---
app/test/meson.build | 2 +app/test/test_ethdev_api.c| 169 +++++++++++++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 5 ++3 files changed, 176 insertions(+)create mode 100644
app/test/test_ethdev_api.capp/test/meson.build +2
-0@@ -49,6 +49,7 @@ test_sources = files( 'test_efd_perf.c', 'test_errno.c', 'test_ethdev_link.c', + 'test_ethdev_api.c', 'test_event_crypto_adapter.c', 'test_event_eth_rx_adapter.c', 'test_event_ring.c',@@ -187,6 +188,7 @@ fast_tests = [ ['eal_fs_autotest', true, true], ['errno_autotest', true, true], ['ethdev_link_status', true, true], + ['ethdev_api', true, true], ['event_ring_autotest', true, true], ['fib_autotest', true, true], ['fib6_autotest', true, true],app/test/test_ethdev_api.c new file +29
-0@@ -0,0 +1,169 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2023, Advanced Micro Devices, Inc. +*/ + +#include <rte_log.h> +#include <rte_ethdev.h> + +#include <rte_test.h> +#include "test.h" + +#define NUM_RXQ 2 +#define NUM_TXQ 2 +#define NUM_RXD 512 +#define NUM_TXD 512 +#define NUM_MBUF 1024 +#define MBUF_CACHE_SIZE 256 + +static int32_t +ethdev_api_queue_status (void ) +{ + struct rte_eth_dev_info dev_info; + struct rte_eth_rxq_info rx_qinfo; + struct rte_eth_txq_info tx_qinfo; + struct rte_mempool *mbuf_pool; + /*struct rte_eth_rxconf rx_conf;*/ + /*struct rte_eth_txconf tx_conf;*/ + struct rte_eth_conf eth_conf; + uint16_t port_id; + int ret;
Quoted 9 lines
Quoted 7 lines
app/test/test_ethdev_api.c new file +2
-0+ + mbuf_pool = rte_pktmbuf_pool_create("MBUF_POOL", NUM_MBUF,
MBUF_CACHE_SIZE, 0,
+RTE_MBUF_DEFAULT_BUF_SIZE,rte_socket_id()); +
+RTE_ETH_FOREACH_DEV(port_id){
+memset(ð_conf, 0, sizeof(dev_info));+1 need to modify.
ack
Quoted 9 lines
Quoted 7 lines
+ ret =
rte_eth_dev_configure(port_id, NUM_RXQ, NUM_TXQ, ð_conf);
+ TEST_ASSERT(ret == 0,
+ "Port(%u) failed to configure.\n",port_id); +
+ /* RxQ setup */
+ /*memset(&rx_conf, 0, sizeof(rx_conf));*/What's here for?
will remove
Quoted 15 lines
Quoted 15 lines
+ for (
uint16_tqueue_id= 0;queue_id<NUM_RXQ; queue_id++) { + ret =rte_eth_rx_queue_setup(port_id, queue_id, NUM_RXD, + rte_socket_id(), NULL, mbuf_pool);
+ TEST_ASSERT(ret == 0,
+ "Port(%u), queue(%u) failed to setup RxQ.\n", +port_id,queue_id);
+ }
+
+ /* TxQ setup */
+ /*memset(&tx_conf, 0, sizeof(tx_conf));*/
+ for (uint16_tqueue_id= 0;queue_id<NUM_TXQ; queue_id++) { + ret =rte_eth_tx_queue_setup(port_id, queue_id, NUM_TXD, + rte_socket_id(), NULL);
+ TEST_ASSERT(ret == 0,
+ "Port(%u), queue(%u) failed to setup TxQ.\n",
Quoted 9 lines
Quoted 6 lines
+
port_id,queue_id);
+ }
+
+ ret =rte_eth_dev_info_get(port_id, &dev_info); + TEST_ASSERT(ret == 0,
+ "Port(%u) failed to get dev info.\n",port_id);
dev_info_get()seems an useless code here.
BecauseNUM_RXQandNUM_TXQcan be used directly in following codes.
Yes, it can be used as NUM_RXQ and NUM_TXQ, but I think it is better for testing to get this from the device, as it can be more close the what application does.
Quoted 17 lines
Quoted 17 lines
+
+ /* Initial RxQ */
+ for (uint16_tqueue_id= 0;queue_id< dev_info.nb_rx_queues; queue_id++) {
+ ret =rte_eth_rx_queue_info_get(port_id, queue_id, &rx_qinfo);
+ TEST_ASSERT(ret == 0,
+ "Port(%u), queue(%u) failed to get RxQ info.\n", +port_id,queue_id);
+
+ TEST_ASSERT(rx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED,
+ "Wrong initial Rx queue(%u) state(%d)\n", +queue_id, rx_qinfo.queue_state);
+ }
+
+ /* Initial TxQ */
Quoted 9 lines
Quoted 7 lines
+ for (
uint16_tqueue_id= 0;queue_id< dev_info.nb_tx_queues; queue_id++) {
+ ret =rte_eth_tx_queue_info_get(port_id, queue_id, &tx_qinfo);
+ TEST_ASSERT(ret == 0,
+ "Port(%u), queue(%u) failed to get TxQ info.\n", +port_id,queue_id);Some drivers don't support this API. So it should be ok for these drivers.
True, will skip if ret is '-ENOTSUP'
Quoted 128 lines
Quoted 128 lines
+
+ TEST_ASSERT(tx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED,
+ "Wrong initial Tx queue(%u) state(%d)\n", +queue_id, tx_qinfo.queue_state); + }app/test/test_ethdev_api.c new file +8
-0+ + + ret = rte_eth_dev_start(port_id); + TEST_ASSERT(ret == 0, + "Port(%u) failed to start.\n", port_id); + + /* Started RxQ */ + for (uint16_t queue_id = 0; queue_id < dev_info.nb_rx_queues;queue_id++) {
+ ret =rte_eth_rx_queue_info_get(port_id, queue_id, &rx_qinfo);
+ TEST_ASSERT(ret == 0,
+ "Port(%u), queue(%u) failed to get RxQ info.\n", +port_id,queue_id);
+
+ TEST_ASSERT(rx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STARTED,
+ "Wrong started Rx queue(%u) state(%d)\n", +queue_id, rx_qinfo.queue_state);
+ }
+
+ /* Started TxQ */
+ for (uint16_tqueue_id= 0;queue_id< dev_info.nb_tx_queues; queue_id++) {
+ ret =rte_eth_tx_queue_info_get(port_id, queue_id, &tx_qinfo);
+ TEST_ASSERT(ret == 0,
+ "Port(%u), queue(%u) failed to get TxQ info.\n", +port_id,queue_id);
+
+ TEST_ASSERT(tx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STARTED,
+ "Wrong started Tx queue(%u) state(%d)\n", +queue_id, tx_qinfo.queue_state);
+ }app/test/test_ethdev_api.c new file +8
-0+ + + ret = rte_eth_dev_stop(port_id); + TEST_ASSERT(ret == 0, + "Port(%u) failed to stop.\n", port_id); + + /* Stopped RxQ */ + for (uint16_t queue_id = 0; queue_id < dev_info.nb_rx_queues;queue_id++) {
+ ret =rte_eth_rx_queue_info_get(port_id, queue_id, &rx_qinfo);
+ TEST_ASSERT(ret == 0,
+ "Port(%u), queue(%u) failed to get RxQ info.\n", +port_id,queue_id);
+
+ TEST_ASSERT(rx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED,
+ "Wrong stopped Rx queue(%u) state(%d)\n", +queue_id, rx_qinfo.queue_state);
+ }
+
+ /* Stopped TxQ */
+ for (uint16_tqueue_id= 0;queue_id< dev_info.nb_tx_queues; queue_id++) {
+ ret =rte_eth_tx_queue_info_get(port_id, queue_id, &tx_qinfo);
+ TEST_ASSERT(ret == 0,
+ "Port(%u), queue(%u) failed to get TxQ info.\n", +port_id,queue_id);
+
+ TEST_ASSERT(tx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED,
+ "Wrong stopped Tx queue(%u) state(%d)\n", +queue_id, tx_qinfo.queue_state);
+ }
+ }app/test/test_ethdev_api.c new file +24
-0+ + return TEST_SUCCESS; +} + +static struct unit_test_suite ethdev_api_testsuite = { + .suite_name = "ethdev API tests", + .setup = NULL, + .teardown = NULL, + .unit_test_cases = { + TEST_CASE(ethdev_api_queue_status), + TEST_CASES_END() /**< NULL terminate unit test array */ + } +}; + +static int +test_ethdev_api (void ) +{ + rte_log_set_global_level(RTE_LOG_DEBUG); + rte_log_set_level(RTE_LOGTYPE_EAL, RTE_LOG_DEBUG); + + return unit_test_suite_runner(ðdev_api_testsuite); +} + +REGISTER_TEST_COMMAND (ethdev_api, test_ethdev_api);lib/ethdev/rte_ethdev.h +0
-0@@ -2788,6 +2788,9 @@ int rte_eth_dev_tx_queue_stop(uint16_t port_id, uint16_t tx_queue_id); * Device RTE_ETH_DEV_NOLIVE_MAC_ADDR flag causes MAC address to beset before
* PMD port start callback function is invoked.
*
+ * All device queues (except form deferred queues) status should be
+ *RTE_ETH_QUEUE_STATE_STARTEDafter start.
+ *
* On success, all basic functions exported by the Ethernet API (link status,
* receive/transmit, and so on) can be invoked.
*lib/ethdev/rte_ethdev.h +1
-0@@ -2804,6 +2807,8 @@ int rte_eth_dev_start(uint16_t port_id); * Stop an Ethernet device. The device can be restarted with a call to * rte_eth_dev_start() * + * All device queues status should be `RTE_ETH_QUEUE_STATE_STOPPED`after stop.
+ *
* @paramport_id
* The port identifier of the Ethernet device.
* @return
PATCH 1/1 ethdev: clarify device queue state after start and stop
In reply to Ferruh YigitDrivers start/stop device queues on port start/stop, but not all drivers update queue state accordingly.
This becomes more visible if a specific queue stopped explicitly and port stopped/started later, in this case although all queues are started, the state of that specific queue is stopped and it is misleading.
Misrepresentation of queue state became a defect with commit [1] that does forwarding decision based on queue state and commit [2] that gets up to date queue state from ethdev/device before forwarding.
[1]
commit 3c4426db54fc ("app/testpmd: do not poll stopped queues")
[2]
commit 5028f207a4fa ("app/testpmd: fix secondary process packet forwarding")
This patch documents that status of all queues of a device should be RTE_ETH_QUEUE_STATE_STOPPED after port stop and their status should beRTE_ETH_QUEUE_STATE_STARTED after port start.
Also an unit test added to verify drivers.
---
Cc: Jie Hai <[email protected]>
Cc: Song Jiale <[email protected]>
Cc: Yuan Peng <[email protected]>
Cc: Raslan Darawsheh <[email protected]>
Cc: Qiming Yang <[email protected]>
Cc: Ivan Malov <[email protected]>
Cc: Huisong Li <[email protected]>
v1:
* fix memset
* remove commented out code
* update unit test to skip queue state if
rte_eth_[rt]x_queue_info_get() is not supported
--- app/test/meson.build | 1 + app/test/test_ethdev_api.c | 184 +++++++++++++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 5 + 3 files changed, 190 insertions(+) create mode 100644 app/test/test_ethdev_api.c
app/test/meson.build +1 -0
@@ -65,6 +65,7 @@ source_file_deps = { 'test_efd_perf.c': ['efd', 'hash'], 'test_errno.c': [], 'test_ethdev_link.c': ['ethdev'], + 'test_ethdev_api.c': ['ethdev'], 'test_event_crypto_adapter.c': ['cryptodev', 'eventdev', 'bus_vdev'], 'test_event_eth_rx_adapter.c': ['ethdev', 'eventdev', 'bus_vdev'], 'test_event_eth_tx_adapter.c': ['bus_vdev', 'ethdev', 'net_ring', 'eventdev'],
app/test/test_ethdev_api.c new file +184 -0
184 lines not on this page · raw message
lib/ethdev/rte_ethdev.h +5 -0
@@ -2812,6 +2812,9 @@ int rte_eth_dev_tx_queue_stop(uint16_t port_id, uint16_t tx_queue_id);* Device RTE_ETH_DEV_NOLIVE_MAC_ADDR flag causes MAC address to be set before * PMD port start callback function is invoked. * +* All device queues (except form deferred start queues) status should be +* `RTE_ETH_QUEUE_STATE_STARTED` after start. +* * On success, all basic functions exported by the Ethernet API (link status, * receive/transmit, and so on) can be invoked. *
@@ -2828,6 +2831,8 @@ int rte_eth_dev_start(uint16_t port_id);* Stop an Ethernet device. The device can be restarted with a call to * rte_eth_dev_start() * +* All device queues status should be `RTE_ETH_QUEUE_STATE_STOPPED` after stop. +* * @param port_id * The port identifier of the Ethernet device. * @return
Signature · 1 line
2.34.1
Hello Ferruh,
Quoted 52 lines · Ferruh Yigit
Drivers start/stop device queues on port start/stop, but not all drivers update queue state accordingly.
This becomes more visible if a specific queue stopped explicitly and port stopped/started later, in this case although all queues are started, the state of that specific queue is stopped and it is misleading.
Misrepresentation of queue state became a defect with commit [1] that does forwarding decision based on queue state and commit [2] that gets up to date queue state from ethdev/device before forwarding.
[1]
commit3c4426db54fc("app/testpmd: do not poll stopped queues")[2]
commit5028f207a4fa("app/testpmd: fix secondary process packet forwarding")This patch documents that status of all queues of a device should be
RTE_ETH_QUEUE_STATE_STOPPEDafter port stop and their status should beRTE_ETH_QUEUE_STATE_STARTEDafter port start.Also an unit test added to verify drivers.
Signed-off-by Ferruh Yigit <[email protected]>---
Cc: Jie Hai <[email protected]>
Cc: Song Jiale <[email protected]>
Cc: Yuan Peng <[email protected]>
Cc: Raslan Darawsheh <[email protected]>
Cc: Qiming Yang <[email protected]>
Cc: Ivan Malov <[email protected]>
Cc: Huisong Li <[email protected]>v1:
* fix memset
* remove commented out code
* update unit test to skip queue state if
rte_eth_[rt]x_queue_info_get() is not supported--- app/test/meson.build | 1 + app/test/test_ethdev_api.c | 184 +++++++++++++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 5 + 3 files changed, 190 insertions(+) create mode 100644 app/test/test_ethdev_api.capp/test/meson.build +0
-0
app/test/meson.build source_file_deps = { · line 68
Quoted 4 lines
app/test/meson.build +1
-0@@ -65,6 +65,7 @@ source_file_deps = { 'test_efd_perf.c': ['efd', 'hash'], 'test_errno.c': [], 'test_ethdev_link.c': ['ethdev'], + 'test_ethdev_api.c': ['ethdev'],
Nit: aphabetical sort
Quoted 27 lines
app/test/meson.build +0
-0'test_event_crypto_adapter.c': ['cryptodev', 'eventdev', 'bus_vdev'], 'test_event_eth_rx_adapter.c': ['ethdev', 'eventdev', 'bus_vdev'], 'test_event_eth_tx_adapter.c': ['bus_vdev', 'ethdev', 'net_ring', 'eventdev'],app/test/test_ethdev_api.c new file +18
-0@@ -0,0 +1,184 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2023, Advanced Micro Devices, Inc. +*/ + +#include <rte_log.h> +#include <rte_ethdev.h> + +#include <rte_test.h> +#include "test.h" + +#define NUM_RXQ 2 +#define NUM_TXQ 2 +#define NUM_RXD 512 +#define NUM_TXD 512 +#define NUM_MBUF 1024 +#define MBUF_CACHE_SIZE 256 + +static int32_t
app/test/test_ethdev_api.c line 28
Quoted 10 lines
app/test/test_ethdev_api.c new file +10
-0+ethdev_api_queue_status (void) +{ +struct rte_eth_dev_info dev_info; +struct rte_eth_rxq_info rx_qinfo; +struct rte_eth_txq_info tx_qinfo; +struct rte_mempool *mbuf_pool; +struct rte_eth_conf eth_conf; +uint16_t port_id; +int ret; +
Should we return TEST_SKIPPED if no ethdev port is present? It seems more valid to me than returning TEST_SUCCESS.
Quoted 87 lines
app/test/test_ethdev_api.c new file +87
-0+ mbuf_pool =rte_pktmbuf_pool_create ("MBUF_POOL" ,NUM_MBUF ,MBUF_CACHE_SIZE ,0 , +RTE_MBUF_DEFAULT_BUF_SIZE ,rte_socket_id ()); + +RTE_ETH_FOREACH_DEV (port_id) { +memset (ð_conf,0 ,sizeof (eth_conf)); + ret =rte_eth_dev_configure (port_id,NUM_RXQ ,NUM_TXQ , ð_conf); +TEST_ASSERT (ret ==0 , +"Port(%u) failed to configure.\n" , port_id); + +/* RxQ setup */ +for (uint16_t queue_id =0 ; queue_id <NUM_RXQ ; queue_id++) { + ret =rte_eth_rx_queue_setup (port_id, queue_id,NUM_RXD , +rte_socket_id (),NULL , mbuf_pool); +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to setup RxQ.\n" , + port_id, queue_id); + } + +/* TxQ setup */ +for (uint16_t queue_id =0 ; queue_id <NUM_TXQ ; queue_id++) { + ret =rte_eth_tx_queue_setup (port_id, queue_id,NUM_TXD , +rte_socket_id (),NULL ); +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to setup TxQ.\n" , + port_id, queue_id); + } + + ret =rte_eth_dev_info_get (port_id, &dev_info); +TEST_ASSERT (ret ==0 , +"Port(%u) failed to get dev info.\n" , port_id); + +/* Initial RxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_rx_queues; queue_id++) { + ret =rte_eth_rx_queue_info_get (port_id, queue_id, &rx_qinfo); +if (ret == -ENOTSUP ) +continue ; + +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get RxQ info.\n" , + port_id, queue_id); + +TEST_ASSERT (rx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED , +"Wrong initial Rx queue(%u) state(%d)\n" , + queue_id, rx_qinfo.queue_state); + } + +/* Initial TxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_tx_queues; queue_id++) { + ret =rte_eth_tx_queue_info_get (port_id, queue_id, &tx_qinfo); +if (ret == -ENOTSUP ) +continue ; + +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get TxQ info.\n" , + port_id, queue_id); + +TEST_ASSERT (tx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED , +"Wrong initial Tx queue(%u) state(%d)\n" , + queue_id, tx_qinfo.queue_state); + } + + + ret =rte_eth_dev_start (port_id); +TEST_ASSERT (ret ==0 , +"Port(%u) failed to start.\n" , port_id); + +/* Started RxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_rx_queues; queue_id++) { + ret =rte_eth_rx_queue_info_get (port_id, queue_id, &rx_qinfo); +if (ret == -ENOTSUP ) +continue ; + +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get RxQ info.\n" , + port_id, queue_id); + +TEST_ASSERT (rx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STARTED , +"Wrong started Rx queue(%u) state(%d)\n" , + queue_id, rx_qinfo.queue_state); + } + +/* Started TxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_tx_queues; queue_id++) { + ret =rte_eth_tx_queue_info_get (port_id, queue_id, &tx_qinfo); +if (ret == -ENOTSUP ) +continue ; +
app/test/test_ethdev_api.c line 125
Quoted 10 lines
app/test/test_ethdev_api.c new file +10
-0+TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get TxQ info.\n" , + port_id, queue_id); + +TEST_ASSERT (tx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STARTED , +"Wrong started Tx queue(%u) state(%d)\n" , + queue_id, tx_qinfo.queue_state); + } + +
Nit: I would remove one of those empty lines.
Quoted 49 lines
app/test/test_ethdev_api.c new file +49
-0+ ret =rte_eth_dev_stop (port_id); +TEST_ASSERT (ret ==0 , +"Port(%u) failed to stop.\n" , port_id); + +/* Stopped RxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_rx_queues; queue_id++) { + ret =rte_eth_rx_queue_info_get (port_id, queue_id, &rx_qinfo); +if (ret == -ENOTSUP ) +continue ; + +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get RxQ info.\n" , + port_id, queue_id); + +TEST_ASSERT (rx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED , +"Wrong stopped Rx queue(%u) state(%d)\n" , + queue_id, rx_qinfo.queue_state); + } + +/* Stopped TxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_tx_queues; queue_id++) { + ret =rte_eth_tx_queue_info_get (port_id, queue_id, &tx_qinfo); +if (ret == -ENOTSUP ) +continue ; + +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get TxQ info.\n" , + port_id, queue_id); + +TEST_ASSERT (tx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED , +"Wrong stopped Tx queue(%u) state(%d)\n" , + queue_id, tx_qinfo.queue_state); + } + } + +return TEST_SUCCESS ; +} + +static struct unit_test_suite ethdev_api_testsuite = { + .suite_name ="ethdev API tests" , + .setup =NULL , + .teardown =NULL , + .unit_test_cases = { +TEST_CASE (ethdev_api_queue_status), +/* TODO: Add deferred_start queue status test */ +TEST_CASES_END ()/**< NULL terminate unit test array */ + } +}; +
app/test/test_ethdev_api.c line 184
Quoted 10 lines
app/test/test_ethdev_api.c new file +10
-0+static int +test_ethdev_api (void ) +{ +rte_log_set_global_level (RTE_LOG_DEBUG ); +rte_log_set_level (RTE_LOGTYPE_EAL ,RTE_LOG_DEBUG ); + +return unit_test_suite_runner (ðdev_api_testsuite); +} + +REGISTER_TEST_COMMAND (ethdev_api, test_ethdev_api);
REGISTER_FAST_TEST or REGISTER_DRIVER_TEST.
Quoted 24 lines
lib/ethdev/rte_ethdev.h +5
-1@@ -2812,6 +2812,9 @@ int rte_eth_dev_tx_queue_stop(uint16_t port_id, uint16_t tx_queue_id);* Device RTE_ETH_DEV_NOLIVE_MAC_ADDR flag causes MAC address to be set before * PMD port start callback function is invoked. * +* All device queues (except form deferred start queues) status should be +* `RTE_ETH_QUEUE_STATE_STARTED` after start. +* * On success, all basic functions exported by the Ethernet API (link status, * receive/transmit, and so on) can be invoked. * @@ -2828,6 +2831,8 @@ int rte_eth_dev_start(uint16_t port_id);* Stop an Ethernet device. The device can be restarted with a call to * rte_eth_dev_start() * +* All device queues status should be `RTE_ETH_QUEUE_STATE_STOPPED` after stop. +* * @param port_id * The port identifier of the Ethernet device. * @return --
Quoted 2 lines
2.34.1
The rest lgtm.
Signature · 1 line
David Marchand
Quoted 50 lines · David Marchand
Hello Ferruh,
Quoted 47 lines · Ferruh Yigit
Drivers start/stop device queues on port start/stop, but not all drivers update queue state accordingly.
This becomes more visible if a specific queue stopped explicitly and port stopped/started later, in this case although all queues are started, the state of that specific queue is stopped and it is misleading.
Misrepresentation of queue state became a defect with commit [1] that does forwarding decision based on queue state and commit [2] that gets up to date queue state from ethdev/device before forwarding.
[1]
commit3c4426db54fc("app/testpmd: do not poll stopped queues")[2]
commit5028f207a4fa("app/testpmd: fix secondary process packet forwarding")This patch documents that status of all queues of a device should be
RTE_ETH_QUEUE_STATE_STOPPEDafter port stop and their status should beRTE_ETH_QUEUE_STATE_STARTEDafter port start.Also an unit test added to verify drivers.
Signed-off-by Ferruh Yigit <[email protected]>---
Cc: Jie Hai <[email protected]>
Cc: Song Jiale <[email protected]>
Cc: Yuan Peng <[email protected]>
Cc: Raslan Darawsheh <[email protected]>
Cc: Qiming Yang <[email protected]>
Cc: Ivan Malov <[email protected]>
Cc: Huisong Li <[email protected]>v1:
* fix memset
* remove commented out code
* update unit test to skip queue state if
rte_eth_[rt]x_queue_info_get() is not supported--- app/test/meson.build | 1 + app/test/test_ethdev_api.c | 184 +++++++++++++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 5 + 3 files changed, 190 insertions(+) create mode 100644 app/test/test_ethdev_api.c
Quoted 12 lines
app/test/meson.build source_file_deps = { · line 68
Quoted 9 lines
app/test/meson.build +1
-0@@ -65,6 +65,7 @@ source_file_deps = { 'test_efd_perf.c': ['efd', 'hash'], 'test_errno.c': [], 'test_ethdev_link.c': ['ethdev'], + 'test_ethdev_api.c': ['ethdev'],Nit: aphabetical sort
ack
Quoted 32 lines
Quoted 32 lines
app/test/meson.build +0
-0'test_event_crypto_adapter.c': ['cryptodev', 'eventdev', 'bus_vdev'], 'test_event_eth_rx_adapter.c': ['ethdev', 'eventdev', 'bus_vdev'], 'test_event_eth_tx_adapter.c': ['bus_vdev', 'ethdev', 'net_ring', 'eventdev'],app/test/test_ethdev_api.c new file +23
-0@@ -0,0 +1,184 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2023, Advanced Micro Devices, Inc. +*/ + +#include <rte_log.h> +#include <rte_ethdev.h> + +#include <rte_test.h> +#include "test.h" + +#define NUM_RXQ 2 +#define NUM_TXQ 2 +#define NUM_RXD 512 +#define NUM_TXD 512 +#define NUM_MBUF 1024 +#define MBUF_CACHE_SIZE 256 + +static int32_t +ethdev_api_queue_status (void ) +{ +struct rte_eth_dev_info dev_info; +struct rte_eth_rxq_info rx_qinfo; +struct rte_eth_txq_info tx_qinfo;
Quoted 9 lines
app/test/test_ethdev_api.c line 28
Quoted 5 lines
app/test/test_ethdev_api.c new file +5
-0+struct rte_mempool *mbuf_pool; +struct rte_eth_conf eth_conf; +uint16_t port_id; +int ret; +Should we return
TEST_SKIPPEDif no ethdev port is present? It seems more valid to me than returningTEST_SUCCESS.
+1 to TEST_SKIPPED
Quoted 92 lines
Quoted 92 lines
app/test/test_ethdev_api.c new file +91
-0+ mbuf_pool =rte_pktmbuf_pool_create ("MBUF_POOL" ,NUM_MBUF ,MBUF_CACHE_SIZE ,0 , +RTE_MBUF_DEFAULT_BUF_SIZE ,rte_socket_id ()); + +RTE_ETH_FOREACH_DEV (port_id) { +memset (ð_conf,0 ,sizeof (eth_conf)); + ret =rte_eth_dev_configure (port_id,NUM_RXQ ,NUM_TXQ , ð_conf); +TEST_ASSERT (ret ==0 , +"Port(%u) failed to configure.\n" , port_id); + +/* RxQ setup */ +for (uint16_t queue_id =0 ; queue_id <NUM_RXQ ; queue_id++) { + ret =rte_eth_rx_queue_setup (port_id, queue_id,NUM_RXD , +rte_socket_id (),NULL , mbuf_pool); +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to setup RxQ.\n" , + port_id, queue_id); + } + +/* TxQ setup */ +for (uint16_t queue_id =0 ; queue_id <NUM_TXQ ; queue_id++) { + ret =rte_eth_tx_queue_setup (port_id, queue_id,NUM_TXD , +rte_socket_id (),NULL ); +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to setup TxQ.\n" , + port_id, queue_id); + } + + ret =rte_eth_dev_info_get (port_id, &dev_info); +TEST_ASSERT (ret ==0 , +"Port(%u) failed to get dev info.\n" , port_id); + +/* Initial RxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_rx_queues; queue_id++) { + ret =rte_eth_rx_queue_info_get (port_id, queue_id, &rx_qinfo); +if (ret == -ENOTSUP ) +continue ; + +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get RxQ info.\n" , + port_id, queue_id); + +TEST_ASSERT (rx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED , +"Wrong initial Rx queue(%u) state(%d)\n" , + queue_id, rx_qinfo.queue_state); + } + +/* Initial TxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_tx_queues; queue_id++) { + ret =rte_eth_tx_queue_info_get (port_id, queue_id, &tx_qinfo); +if (ret == -ENOTSUP ) +continue ; + +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get TxQ info.\n" , + port_id, queue_id); + +TEST_ASSERT (tx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED , +"Wrong initial Tx queue(%u) state(%d)\n" , + queue_id, tx_qinfo.queue_state); + } + + + ret =rte_eth_dev_start (port_id); +TEST_ASSERT (ret ==0 , +"Port(%u) failed to start.\n" , port_id); + +/* Started RxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_rx_queues; queue_id++) { + ret =rte_eth_rx_queue_info_get (port_id, queue_id, &rx_qinfo); +if (ret == -ENOTSUP ) +continue ; + +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get RxQ info.\n" , + port_id, queue_id); + +TEST_ASSERT (rx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STARTED , +"Wrong started Rx queue(%u) state(%d)\n" , + queue_id, rx_qinfo.queue_state); + } + +/* Started TxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_tx_queues; queue_id++) { + ret =rte_eth_tx_queue_info_get (port_id, queue_id, &tx_qinfo); +if (ret == -ENOTSUP ) +continue ; + +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get TxQ info.\n" , + port_id, queue_id); +
Quoted 9 lines
app/test/test_ethdev_api.c line 125
Quoted 6 lines
app/test/test_ethdev_api.c new file +6
-0+TEST_ASSERT (tx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STARTED , +"Wrong started Tx queue(%u) state(%d)\n" , + queue_id, tx_qinfo.queue_state); + } + +Nit: I would remove one of those empty lines.
ack
Quoted 53 lines
Quoted 53 lines
app/test/test_ethdev_api.c new file +53
-0+ ret =rte_eth_dev_stop (port_id); +TEST_ASSERT (ret ==0 , +"Port(%u) failed to stop.\n" , port_id); + +/* Stopped RxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_rx_queues; queue_id++) { + ret =rte_eth_rx_queue_info_get (port_id, queue_id, &rx_qinfo); +if (ret == -ENOTSUP ) +continue ; + +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get RxQ info.\n" , + port_id, queue_id); + +TEST_ASSERT (rx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED , +"Wrong stopped Rx queue(%u) state(%d)\n" , + queue_id, rx_qinfo.queue_state); + } + +/* Stopped TxQ */ +for (uint16_t queue_id =0 ; queue_id < dev_info.nb_tx_queues; queue_id++) { + ret =rte_eth_tx_queue_info_get (port_id, queue_id, &tx_qinfo); +if (ret == -ENOTSUP ) +continue ; + +TEST_ASSERT (ret ==0 , +"Port(%u), queue(%u) failed to get TxQ info.\n" , + port_id, queue_id); + +TEST_ASSERT (tx_qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED , +"Wrong stopped Tx queue(%u) state(%d)\n" , + queue_id, tx_qinfo.queue_state); + } + } + +return TEST_SUCCESS ; +} + +static struct unit_test_suite ethdev_api_testsuite = { + .suite_name ="ethdev API tests" , + .setup =NULL , + .teardown =NULL , + .unit_test_cases = { +TEST_CASE (ethdev_api_queue_status), +/* TODO: Add deferred_start queue status test */ +TEST_CASES_END ()/**< NULL terminate unit test array */ + } +}; + +static int +test_ethdev_api (void ) +{ +rte_log_set_global_level (RTE_LOG_DEBUG );
Quoted 9 lines
app/test/test_ethdev_api.c line 184
Quoted 6 lines
app/test/test_ethdev_api.c new file +6
-0+rte_log_set_level (RTE_LOGTYPE_EAL ,RTE_LOG_DEBUG ); + +return unit_test_suite_runner (ðdev_api_testsuite); +} + +REGISTER_TEST_COMMAND (ethdev_api, test_ethdev_api);
REGISTER_FAST_TESTorREGISTER_DRIVER_TEST.
This is not driver test, and not ready enough to add fast test, we need to be sure all drivers updates queue state properly, so for now I think better to keep macro as it is.
Quoted 21 lines
Quoted 21 lines
lib/ethdev/rte_ethdev.h +5
-0@@ -2812,6 +2812,9 @@ int rte_eth_dev_tx_queue_stop(uint16_t port_id, uint16_t tx_queue_id);* Device RTE_ETH_DEV_NOLIVE_MAC_ADDR flag causes MAC address to be set before * PMD port start callback function is invoked. * +* All device queues (except form deferred start queues) status should be +* `RTE_ETH_QUEUE_STATE_STARTED` after start. +* * On success, all basic functions exported by the Ethernet API (link status, * receive/transmit, and so on) can be invoked. * @@ -2828,6 +2831,8 @@ int rte_eth_dev_start(uint16_t port_id);* Stop an Ethernet device. The device can be restarted with a call to * rte_eth_dev_start() * +* All device queues status should be `RTE_ETH_QUEUE_STATE_STOPPED` after stop. +*
Quoted 10 lines
Quoted 6 lines
lib/ethdev/rte_ethdev.h +0
-1* @param port_id * The port identifier of the Ethernet device. * @return -- 2.34.1
The rest lgtm.
Thanks for review, will send a new version soon
PATCH v2 1/1 ethdev: clarify device queue state after start and stop
In reply to Ferruh YigitDrivers start/stop device queues on port start/stop, but not all drivers update queue state accordingly.
This becomes more visible if a specific queue stopped explicitly and port stopped/started later, in this case although all queues are started, the state of that specific queue is stopped and it is misleading.
Misrepresentation of queue state became a defect with commit [1] that does forwarding decision based on queue state and commit [2] that gets up to date queue state from ethdev/device before forwarding.
[1]
commit 3c4426db54fc ("app/testpmd: do not poll stopped queues")
[2]
commit 5028f207a4fa ("app/testpmd: fix secondary process packet forwarding")
This patch documents that status of all queues of a device should be RTE_ETH_QUEUE_STATE_STOPPED after port stop and their status should beRTE_ETH_QUEUE_STATE_STARTED after port start.
Also an unit test added to verify drivers.
---
Cc: Jie Hai <[email protected]>
Cc: Song Jiale <[email protected]>
Cc: Yuan Peng <[email protected]>
Cc: Raslan Darawsheh <[email protected]>
Cc: Qiming Yang <[email protected]>
Cc: Ivan Malov <[email protected]>
Cc: Huisong Li <[email protected]>
v1:
* fix memset
* remove commented out code
* update unit test to skip queue state if
rte_eth_[rt]x_queue_info_get() is not supported
v2:
* return test_skipped when there is no port available
* Syntax fixes
--- app/test/meson.build | 1 + app/test/test_ethdev_api.c | 185 +++++++++++++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 5 + 3 files changed, 191 insertions(+) create mode 100644 app/test/test_ethdev_api.c
app/test/meson.build +1 -0
@@ -68,6 +68,7 @@ source_file_deps = { 'test_efd.c': ['efd', 'net'], 'test_efd_perf.c': ['efd', 'hash'], 'test_errno.c': [], + 'test_ethdev_api.c': ['ethdev'], 'test_ethdev_link.c': ['ethdev'], 'test_event_crypto_adapter.c': ['cryptodev', 'eventdev', 'bus_vdev'], 'test_event_eth_rx_adapter.c': ['ethdev', 'eventdev', 'bus_vdev'],
app/test/test_ethdev_api.c new file +185 -0
185 lines not on this page · raw message
lib/ethdev/rte_ethdev.h +5 -0
@@ -2812,6 +2812,9 @@ int rte_eth_dev_tx_queue_stop(uint16_t port_id, uint16_t tx_queue_id);* Device RTE_ETH_DEV_NOLIVE_MAC_ADDR flag causes MAC address to be set before * PMD port start callback function is invoked. * +* All device queues (except form deferred start queues) status should be +* `RTE_ETH_QUEUE_STATE_STARTED` after start. +* * On success, all basic functions exported by the Ethernet API (link status, * receive/transmit, and so on) can be invoked. *
@@ -2828,6 +2831,8 @@ int rte_eth_dev_start(uint16_t port_id);* Stop an Ethernet device. The device can be restarted with a call to * rte_eth_dev_start() * +* All device queues status should be `RTE_ETH_QUEUE_STATE_STOPPED` after stop. +* * @param port_id * The port identifier of the Ethernet device. * @return
Signature · 1 line
2.34.1
13/10/2023 17:57, Ferruh Yigit:
Quoted 15 lines
Drivers start/stop device queues on port start/stop, but not all drivers update queue state accordingly.
This becomes more visible if a specific queue stopped explicitly and port stopped/started later, in this case although all queues are started, the state of that specific queue is stopped and it is misleading.
Misrepresentation of queue state became a defect with commit [1] that does forwarding decision based on queue state and commit [2] that gets up to date queue state from ethdev/device before forwarding.
[1]
commit3c4426db54fc("app/testpmd: do not poll stopped queues")
Quoted 6 lines
[2]
commit5028f207a4fa("app/testpmd: fix secondary process packet forwarding")This patch documents that status of all queues of a device should be
RTE_ETH_QUEUE_STATE_STOPPEDafter port stop and their status should beRTE_ETH_QUEUE_STATE_STARTEDafter port start.
It is so basic that it may look stupid :)
Yes we still have to enforce such basic things, thank you for this work.
Quoted 1 line
+REGISTER_TEST_COMMAND(ethdev_api,
test_ethdev_api);
Maybe add a comment here to explain it is not part of basic suites, waiting for all drivers being compliant.
lib/ethdev/rte_ethdev.h int rte_eth_dev_start(uint16_t port_id); · line 2835
Quoted 12 lines
+ * All device queues (except form deferred start queues) status should be
+ *RTE_ETH_QUEUE_STATE_STARTEDafter start.
+ *
* On success, all basic functions exported by the Ethernet API (link status,
* receive/transmit, and so on) can be invoked.
*lib/ethdev/rte_ethdev.h +2
-0@@ -2828,6 +2831,8 @@ int rte_eth_dev_start(uint16_t port_id);* Stop an Ethernet device. The device can be restarted with a call to * rte_eth_dev_start() * +* All device queues status should be `RTE_ETH_QUEUE_STATE_STOPPED` after stop. +*
Quoted 23 lines · Thomas Monjalon
13/10/2023 17:57, Ferruh Yigit:
Quoted 15 lines
Drivers start/stop device queues on port start/stop, but not all drivers update queue state accordingly.
This becomes more visible if a specific queue stopped explicitly and port stopped/started later, in this case although all queues are started, the state of that specific queue is stopped and it is misleading.
Misrepresentation of queue state became a defect with commit [1] that does forwarding decision based on queue state and commit [2] that gets up to date queue state from ethdev/device before forwarding.
[1]
commit3c4426db54fc("app/testpmd: do not poll stopped queues")Quoted 6 lines
[2]
commit5028f207a4fa("app/testpmd: fix secondary process packet forwarding")This patch documents that status of all queues of a device should be
RTE_ETH_QUEUE_STATE_STOPPEDafter port stop and their status should beRTE_ETH_QUEUE_STATE_STARTEDafter port start.
Quoted 8 lines
It is so basic that it may look stupid :)
Yes we still have to enforce such basic things, thank you for this work.Quoted 1 line
+REGISTER_TEST_COMMAND(ethdev_api,
test_ethdev_api);Maybe add a comment here to explain it is not part of basic suites, waiting for all drivers being compliant.
ack, I will add while merging
Quoted 16 lines
lib/ethdev/rte_ethdev.h int rte_eth_dev_start(uint16_t port_id); · line 2835
Quoted 12 lines
+ * All device queues (except form deferred start queues) status should be
+ *RTE_ETH_QUEUE_STATE_STARTEDafter start.
+ *
* On success, all basic functions exported by the Ethernet API (link status,
* receive/transmit, and so on) can be invoked.
*lib/ethdev/rte_ethdev.h +2
-0@@ -2828,6 +2831,8 @@ int rte_eth_dev_start(uint16_t port_id);* Stop an Ethernet device. The device can be restarted with a call to * rte_eth_dev_start() * +* All device queues status should be `RTE_ETH_QUEUE_STATE_STOPPED` after stop. +* Acked-by Thomas Monjalon <[email protected]>
Ferruh Yigit
AppliedQuoted 23 lines · Thomas Monjalon
13/10/2023 17:57, Ferruh Yigit:
Quoted 15 lines
Drivers start/stop device queues on port start/stop, but not all drivers update queue state accordingly.
This becomes more visible if a specific queue stopped explicitly and port stopped/started later, in this case although all queues are started, the state of that specific queue is stopped and it is misleading.
Misrepresentation of queue state became a defect with commit [1] that does forwarding decision based on queue state and commit [2] that gets up to date queue state from ethdev/device before forwarding.
[1]
commit3c4426db54fc("app/testpmd: do not poll stopped queues")Quoted 6 lines
[2]
commit5028f207a4fa("app/testpmd: fix secondary process packet forwarding")This patch documents that status of all queues of a device should be
RTE_ETH_QUEUE_STATE_STOPPEDafter port stop and their status should beRTE_ETH_QUEUE_STATE_STARTEDafter port start.
Quoted 8 lines
It is so basic that it may look stupid :)
Yes we still have to enforce such basic things, thank you for this work.Quoted 1 line
+REGISTER_TEST_COMMAND(ethdev_api,
test_ethdev_api);Maybe add a comment here to explain it is not part of basic suites, waiting for all drivers being compliant.
Following comment added while merging:
/* TODO: Make part of the fast test suite, REGISTER_FAST_TEST(),
* when all drivers complies to the queue state requirement
*/
Quoted 6 lines
Quoted 6 lines
+ * All device queues (except form deferred start queues) status should be
+ *RTE_ETH_QUEUE_STATE_STARTEDafter start.
+ *
* On success, all basic functions exported by the Ethernet API (link status,
* receive/transmit, and so on) can be invoked.
*
Quoted 10 lines
lib/ethdev/rte_ethdev.h int rte_eth_dev_start(uint16_t port_id); · line 2835
Quoted 6 lines
lib/ethdev/rte_ethdev.h +2
-0@@ -2828,6 +2831,8 @@ int rte_eth_dev_start(uint16_t port_id);* Stop an Ethernet device. The device can be restarted with a call to * rte_eth_dev_start() * +* All device queues status should be `RTE_ETH_QUEUE_STATE_STOPPED` after stop. +* Acked-by Thomas Monjalon <[email protected]>
Applied to dpdk-next-net/main, thanks.