Skip to contentSkip to conversation

ethdev: Allow rte_eth_dev_configure with zero RX/TX queues

RFC PATCH In review Simon Kagstrom 4 participants 9 messages May 16, 2016 – Dec 20, 2018

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 ethdev: Allow rte_eth_dev_configure with zero RX/TX queues

This allows releasing RX/TX queue memory.
---
We're using DPDK 16.04 and have a test suite which performs a sequence of separate tests of the type

allocate mempool
rte_eth_dev_configure(port, n_rxq, n_txq, ...)
setup rx/tx queues
rte_eth_dev_start(port)

<perform actual test>

stop rx/tx queues
rte_eth_dev_stop(port)

-> rte_eth_dev_configure(port, 0, 0, ...)

check that there are no leaks from the mempool

The crucial point is the marked line above. This is done so that the rx_queue_release/tx_queue_release callbacks in the PMD is called, so that mbufs allocated by the driver is released.

Without this patch, this explicitly isn't allowed. Is there a particular reason why it shouldn't? It was introduced in

d505ba80a165a9735f3d9d3c6ab68a7bd85f271b

"ethdev: support unidirectional configuration"

 lib/librte_ether/rte_ethdev.c | 5 -----
 1 file changed, 5 deletions(-)
lib/librte_ether/rte_ethdev.c +0 -5
index a31018e..5481d45 100644
@@ -944,11 +944,6 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	 */
 	(*dev->dev_ops->dev_infos_get)(dev, &dev_info);
 
-	if (nb_rx_q == 0 && nb_tx_q == 0) {
-		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d both rx and tx queue cannot be 0\n", port_id);
-		return -EINVAL;
-	}
-
 	if (nb_rx_q > dev_info.max_rx_queues) {
 		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d nb_rx_queues=%d > %d\n",
 				port_id, nb_rx_q, dev_info.max_rx_queues);
Signature · 1 line
1.9.1
#1 lore raw
Quoted 28 lines

-----Original Message-----
From: Simon Kagstrom [mailto:[email protected]]
Sent: Monday, May 16, 2016 10:34 AM
To: [email protected]; [email protected]; Pattan, Reshma <[email protected]>
Subject: [PATCH / RFC ] ethdev: Allow rte_eth_dev_configure with zero RX/TX queues

This allows releasing RX/TX queue memory.
---

Without this patch, this explicitly isn't allowed. Is there a particular reason why it shouldn't? It was introduced in

d505ba80a165a9735f3d9d3c6ab68a7bd85f271b

"ethdev: support unidirectional configuration"

 lib/librte_ether/rte_ethdev.c | 5 -----
 1 file changed, 5 deletions(-)
lib/librte_ether/rte_ethdev.c index renamed from lib/librte_ether/rte_ethdev.c +0 -0

a31018e..5481d45 100644

lib/librte_ether/rte_ethdev.c rte_eth_dev_configure(uint8_t port_id, uint16_t · line 953

Quoted 10 lines
lib/librte_ether/rte_ethdev.c +0 -5
@@ -944,11 +944,6 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t
 nb_rx_q, uint16_t nb_tx_q,
 	 */
 	(*dev->dev_ops->dev_infos_get)(dev, &dev_info);
 
-	if (nb_rx_q == 0 && nb_tx_q == 0) {
-		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d both rx and tx
 queue cannot be 0\n", port_id);
-		return -EINVAL;
-	}
-

This was added to allow devices, at least with one direction (RX/TX) supported. As, devices with both directions disabled doesn't make sense right?

Thanks,
Reshma

#2 lore raw
Quoted 9 lines · Reshma
Quoted 9 lines
lib/librte_ether/rte_ethdev.c index renamed from lib/librte_ether/rte_ethdev.c +0 -0

a31018e..5481d45 100644

lib/librte_ether/rte_ethdev.c +0 -0
@@ -944,11 +944,6 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t
 nb_rx_q, uint16_t nb_tx_q,
 	 */
 	(*dev->dev_ops->dev_infos_get)(dev, &dev_info);
 
Quoted 7 lines

lib/librte_ether/rte_ethdev.c rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, · line 950

Quoted 5 lines
lib/librte_ether/rte_ethdev.c +0 -4
-	if (nb_rx_q == 0 && nb_tx_q == 0) {
-		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d both rx and tx
 queue cannot be 0\n", port_id);
-		return -EINVAL;
-	}

This was added to allow devices, at least with one direction (RX/TX) supported. As, devices with both directions disabled doesn't make sense right?

Well, not for running them, no. But this is a part of the shutdown procedure between tests (I should have been more clear I guess).

As far as I can see in the code, rte_eth_dev_configure() is the only point which actually calls {rx,tx}_queue_release(), so without this call, we can't get the memory pool full again.

So basically, our test suite looks like

rte_eth_dev_configure(port, 32, 32); // For example <run a test>
rte_eth_dev_configure(port, 0, 0);
Check that the mempool is full again

  rte_eth_dev_configure(port, 32, 32);
  <run another test>
  rte_eth_dev_configure(port, 0, 0);
  Check that the mempool is full again
  ...

And without this fix, the mempool check fails since a few of the buffers are tied up in the RX descriptor ring of the PMD.

// Simon

#3 lore raw
Quoted 28 lines

-----Original Message-----
From: Simon Kågström [mailto:[email protected]]
Sent: Monday, May 16, 2016 11:33 AM
To: Pattan, Reshma <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH / RFC ] ethdev: Allow rte_eth_dev_configure with zero RX/TX queues

Quoted 10 lines · Reshma
Quoted 10 lines
(quoted diff) +0 -0

b/lib/librte_ether/rte_ethdev.c index
a31018e..5481d45 100644

lib/librte_ether/rte_ethdev.c +0 -0
@@ -944,11 +944,6 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t
 nb_rx_q, uint16_t nb_tx_q,
 	 */
 	(*dev->dev_ops->dev_infos_get)(dev, &dev_info);
 
Quoted 7 lines

lib/librte_ether/rte_ethdev.c rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, · line 950

Quoted 5 lines
lib/librte_ether/rte_ethdev.c +0 -4
-	if (nb_rx_q == 0 && nb_tx_q == 0) {
-		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d both rx and tx
 queue cannot be 0\n", port_id);
-		return -EINVAL;
-	}

This was added to allow devices, at least with one direction (RX/TX)

Quoted 5 lines

supported. As, devices with both directions disabled doesn't make sense right?

Well, not for running them, no. But this is a part of the shutdown procedure between tests (I should have been more clear I guess).

Yes I understood this. But I am not sure if you can use rte_eth_dev_configure(port, 0, 0) to free the resources. Can you check if you can use rte_eth_dev_rx_queue_stop/ rte_eth_dev_tx_queue_stop to achieve the same, because they do take care of releasing mbufs, but doesn't free the queue's sw-ring and queue.

Thanks,
Reshma

#4 lore raw
Quoted 9 lines · Reshma
Quoted 5 lines
Quoted 1 line

This was added to allow devices, at least with one direction (RX/TX)

supported. As, devices with both directions disabled doesn't make sense right?

Well, not for running them, no. But this is a part of the shutdown procedure between tests (I should have been more clear I guess).

Yes I understood this. But I am not sure if you can use rte_eth_dev_configure(port, 0, 0) to free the resources. Can you check if you can use rte_eth_dev_rx_queue_stop/ rte_eth_dev_tx_queue_stop to achieve the same, because they do take care of releasing mbufs, but doesn't free the queue's sw-ring and queue.

But isn't that very strange behavior. Aren't the descriptor rings allocated in rx_queue_setup()? If so, the sequence

  rx_queue_stop(); // Release buffers
  rx_queue_start();

would leave the descriptor ring empty after start, i.e., not able to receive data.

// Simon

#5 lore raw

Ping? Any more comments on this?

// Simon

Quoted 22 lines · Simon Kågström
Quoted 9 lines · Reshma
Quoted 5 lines
Quoted 1 line

This was added to allow devices, at least with one direction (RX/TX)

supported. As, devices with both directions disabled doesn't make sense right?

Well, not for running them, no. But this is a part of the shutdown procedure between tests (I should have been more clear I guess).

Yes I understood this. But I am not sure if you can use rte_eth_dev_configure(port, 0, 0) to free the resources. Can you check if you can use rte_eth_dev_rx_queue_stop/ rte_eth_dev_tx_queue_stop to achieve the same, because they do take care of releasing mbufs, but doesn't free the queue's sw-ring and queue.

But isn't that very strange behavior. Aren't the descriptor rings allocated in rx_queue_setup()? If so, the sequence

  rx_queue_stop(); // Release buffers
  rx_queue_start();

would leave the descriptor ring empty after start, i.e., not able to receive data.

// Simon

#6 lore raw
Quoted 10 lines

-----Original Message-----
From: Simon Kågström [mailto:[email protected]]
Sent: Friday, May 20, 2016 7:30 AM
To: Pattan, Reshma <[email protected]>; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH / RFC ] ethdev: Allow rte_eth_dev_configure with zero RX/TX queues

Quoted 2 lines

Ping? Any more comments on this?

Hi, I don't have any objections, just let's wait if any other comments from committee.

Thanks,
Reshma

Quoted 29 lines

// Simon

Quoted 4 lines · Simon Kågström
Quoted 3 lines · Reshma
Quoted 3 lines
Quoted 2 lines

This was added to allow devices, at least with one direction (RX/TX)

supported. As, devices with both directions disabled doesn't make sense

right?

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

Well, not for running them, no. But this is a part of the shutdown procedure between tests (I should have been more clear I guess).

Yes I understood this. But I am not sure if you can use

rte_eth_dev_configure(port, 0, 0) to free the resources.

Quoted 2 lines
Quoted 2 lines

Can you check if you can use rte_eth_dev_rx_queue_stop/ rte_eth_dev_tx_queue_stop to achieve the same, because they do take care

of releasing mbufs, but doesn't free the queue's sw-ring and queue.

Quoted 12 lines

But isn't that very strange behavior. Aren't the descriptor rings allocated in rx_queue_setup()? If so, the sequence

  rx_queue_stop(); // Release buffers
  rx_queue_start();

would leave the descriptor ring empty after start, i.e., not able to receive data.

// Simon

#7 lore raw
In reply to Simon Kagstrom

2016-05-16 11:33, Simon Kagstrom:

Quoted 15 lines

This allows releasing RX/TX queue memory.
---
We're using DPDK 16.04 and have a test suite which performs a sequence of separate tests of the type

allocate mempool
rte_eth_dev_configure(port, n_rxq, n_txq, ...)
setup rx/tx queues
rte_eth_dev_start(port)

<perform actual test>

stop rx/tx queues
rte_eth_dev_stop(port)

Quoted 7 lines

-> rte_eth_dev_configure(port, 0, 0, ...)

check that there are no leaks from the mempool

The crucial point is the marked line above. This is done so that the rx_queue_release/tx_queue_release callbacks in the PMD is called, so that mbufs allocated by the driver is released.

I think you are trying to use a side effect of rte_eth_dev_configure(). After calling rte_eth_dev_stop(), I would say the clean-up should be done by rte_eth_dev_close().
Why not using close?

#8 lore raw
Quoted 20 lines · On 6/23/2016 4:53 PM, thomas.monjalon at 6wind.com (Thomas Monjalon) wrote:

2016-05-16 11:33, Simon Kagstrom:

Quoted 19 lines

This allows releasing RX/TX queue memory.
---
We're using DPDK 16.04 and have a test suite which performs a sequence of separate tests of the type

allocate mempool
rte_eth_dev_configure(port, n_rxq, n_txq, ...)
setup rx/tx queues
rte_eth_dev_start(port)

<perform actual test>

stop rx/tx queues
rte_eth_dev_stop(port)

-> rte_eth_dev_configure(port, 0, 0, ...)

check that there are no leaks from the mempool

Quoted 9 lines
Quoted 3 lines

The crucial point is the marked line above. This is done so that the rx_queue_release/tx_queue_release callbacks in the PMD is called, so that mbufs allocated by the driver is released.

I think you are trying to use a side effect of rte_eth_dev_configure(). After calling rte_eth_dev_stop(), I would say the clean-up should be done by rte_eth_dev_close().
Why not using close?

Hi Simon,

This patch is in patchwork for a long time without response, updating its status as rejected, if it is still relevant please let us know.