DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Thomas Monjalon <thomas@monjalon.net>, arybchenko@solarflare.com
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [RFC] ethdev: complete closing to free all resources
Date: Fri, 28 Sep 2018 13:46:09 +0100	[thread overview]
Message-ID: <e6cc3b3a-bae7-3946-534a-78603bd488cb@intel.com> (raw)
In-Reply-To: <20180907233929.21950-1-thomas@monjalon.net>

On 9/8/2018 12:39 AM, Thomas Monjalon wrote:
> After closing a port, it cannot be restarted.
> So there is no reason to not free all associated resources.
> 
> The last step was done with rte_eth_dev_detach() which is deprecated.
> Instead of removing the associated rte_device, the driver should check
> if no more port (ethdev, cryptodev, etc) is still open for the device.
> Then the device resources can be freed by the driver inside the
> dev_close() driver callback operation.
> 
> The last ethdev freeing (dev_private and final release), which were done
> by rte_eth_dev_detach(), are now done at the end of rte_eth_dev_close().
> 
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
> This patch contains only the change in the close function as RFC.
> 
> This idea was presented at Dublin during the "hotplug talk".
> ---
>  lib/librte_ethdev/rte_ethdev.c | 5 +++++
>  lib/librte_ethdev/rte_ethdev.h | 5 +++--
>  2 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
> index 4c3202505..071fcbd23 100644
> --- a/lib/librte_ethdev/rte_ethdev.c
> +++ b/lib/librte_ethdev/rte_ethdev.c
> @@ -1358,6 +1358,7 @@ void
>  rte_eth_dev_close(uint16_t port_id)
>  {
>  	struct rte_eth_dev *dev;
> +	struct rte_bus *bus;
>  
>  	RTE_ETH_VALID_PORTID_OR_RET(port_id);
>  	dev = &rte_eth_devices[port_id];
> @@ -1372,6 +1373,10 @@ rte_eth_dev_close(uint16_t port_id)
>  	dev->data->nb_tx_queues = 0;
>  	rte_free(dev->data->tx_queues);
>  	dev->data->tx_queues = NULL;
> +
> +	rte_free(dev->data->dev_private);
> +
> +	rte_eth_dev_release_port(dev);

These already done in:
rte_eth_dev_pci_generic_remove()
	rte_eth_dev_pci_release()

Perhaps all content of rte_eth_dev_pci_release(), including above updates,
should move to rte_eth_dev_close() and rte_eth_dev_pci_generic_remove() call
rte_eth_dev_close() directly.


Just thinking aloud,

driver->probe() called when a new device added.
Application startup can be thought as all devices added one by one. [Perhaps
this can be change in the future to add devices only when explicitly stated]

driver->remove() called when device removed.
When application terminated this path not called at all, perhaps we need a way
to remove all devices one by one on exit.

eth_dev_close(), when eth_dev removed in ethdev layer but device is not removed
in eal level,

I think it make sense for eth_dev_close():
- It does more cleanup, free resources and port_id
- but it may need to do more clean up, like call uninit() and do more driver
internal clean up too, and clean up the hw.
- so call stack can be:
  driver->remove()
    rte_eth_dev_pci_generic_remove()
      eth_dev_close()
        dev_uninit() [driver unint function ]


Another question, after eth_dev_close() ethdev is not usable and not able to
restart it back. So why we need eth_dev_close() in addition to dev remove, why
not directly call rte_eth_dev_detach()?


>  }
>  
>  int
> diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h
> index 7070e9ab4..37a757a7a 100644
> --- a/lib/librte_ethdev/rte_ethdev.h
> +++ b/lib/librte_ethdev/rte_ethdev.h
> @@ -1797,8 +1797,9 @@ int rte_eth_dev_set_link_down(uint16_t port_id);
>  
>  /**
>   * Close a stopped Ethernet device. The device cannot be restarted!
> - * The function frees all resources except for needed by the
> - * closed state. To free these resources, call rte_eth_dev_detach().
> + * The function frees all port resources.
> + * If there is no more port associated with the underlying device,
> + * the driver should free the device resources.
>   *
>   * @param port_id
>   *   The port identifier of the Ethernet device.
> 

  parent reply	other threads:[~2018-09-28 12:47 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-07 23:39 Thomas Monjalon
2018-09-10  8:03 ` Andrew Rybchenko
2018-09-10  8:42   ` Thomas Monjalon
2018-09-10  8:54     ` Andrew Rybchenko
2018-09-12 14:57       ` Thomas Monjalon
2018-09-12 15:44         ` Andrew Rybchenko
2018-09-28 12:46 ` Ferruh Yigit [this message]
2018-10-09 22:00   ` Thomas Monjalon
2018-10-09 22:17 ` [dpdk-dev] [PATCH v2] ethdev: complete closing of port Thomas Monjalon
2018-10-10  6:15   ` Andrew Rybchenko
2018-10-10  7:44     ` Thomas Monjalon
2018-10-10  7:50       ` Andrew Rybchenko
2018-10-10  8:39         ` Thomas Monjalon
2018-10-10 15:01           ` Andrew Rybchenko
2018-10-10 16:43             ` Thomas Monjalon
2018-10-10 18:01               ` Andrew Rybchenko
2018-10-10 19:03                 ` Thomas Monjalon
2018-10-14 23:20 ` [dpdk-dev] [PATCH v3 0/2] ethdev port freeing Thomas Monjalon
2018-10-14 23:20   ` [dpdk-dev] [PATCH v3 1/2] ethdev: free all common data when releasing port Thomas Monjalon
2018-10-16 11:16     ` Andrew Rybchenko
2018-10-16 12:22       ` Thomas Monjalon
2018-10-16 12:47         ` Andrew Rybchenko
2018-10-16 12:52           ` Thomas Monjalon
2018-10-16 12:55             ` Andrew Rybchenko
2018-10-14 23:20   ` [dpdk-dev] [PATCH v3 2/2] ethdev: complete closing of port Thomas Monjalon
2018-10-16 11:24     ` Andrew Rybchenko
2018-10-16 12:25       ` Thomas Monjalon
2018-10-17  1:54 ` [dpdk-dev] [PATCH v3 0/4] ethdev port freeing Thomas Monjalon
2018-10-17  1:54   ` [dpdk-dev] [PATCH v3 1/4] app/testpmd: allow detaching a port not closed Thomas Monjalon
2018-10-17  2:06     ` Thomas Monjalon
2018-10-17  6:26     ` Andrew Rybchenko
2018-10-17  8:20       ` Thomas Monjalon
2018-10-17 10:30         ` Iremonger, Bernard
2018-10-17 11:33           ` Thomas Monjalon
2018-10-17  1:54   ` [dpdk-dev] [PATCH v3 2/4] ethdev: free all common data when releasing port Thomas Monjalon
2018-10-17  7:13     ` Andrew Rybchenko
2018-10-17  8:22       ` Thomas Monjalon
2018-10-17  1:54   ` [dpdk-dev] [PATCH v3 3/4] ethdev: remove release function for secondary process Thomas Monjalon
2018-10-17  7:25     ` Andrew Rybchenko
2018-10-17  9:27       ` Thomas Monjalon
2018-10-17  1:54   ` [dpdk-dev] [PATCH v3 4/4] ethdev: complete closing of port Thomas Monjalon
2018-10-17  2:12     ` Thomas Monjalon
2018-10-17 10:24   ` [dpdk-dev] [PATCH v3 0/4] ethdev port freeing Shreyansh Jain
2018-10-17 11:31     ` Thomas Monjalon
2018-10-18  1:23 ` [dpdk-dev] [PATCH v5 0/6] " Thomas Monjalon
2018-10-18  1:23   ` [dpdk-dev] [PATCH v5 1/6] app/testpmd: fix ports list after removing several at once Thomas Monjalon
2018-10-18 10:40     ` Iremonger, Bernard
2018-10-18 11:29       ` Thomas Monjalon
2018-10-18 11:41         ` Iremonger, Bernard
2018-10-18 14:21           ` Thomas Monjalon
2018-10-18 16:42             ` Iremonger, Bernard
2018-10-18 17:06               ` Thomas Monjalon
2018-10-18 11:49         ` Wisam Monther
2018-10-18 13:22           ` Iremonger, Bernard
2018-10-18  1:23   ` [dpdk-dev] [PATCH v5 2/6] app/testpmd: allow detaching a port not closed Thomas Monjalon
2018-10-18  7:45     ` Andrew Rybchenko
2018-10-18 10:51       ` Iremonger, Bernard
2018-10-18 11:24         ` Thomas Monjalon
2018-10-18  1:23   ` [dpdk-dev] [PATCH v5 3/6] ethdev: fix doxygen comments of shared data fields Thomas Monjalon
2018-10-18  7:11     ` Andrew Rybchenko
2018-10-18  1:24   ` [dpdk-dev] [PATCH v5 4/6] ethdev: free all common data when releasing port Thomas Monjalon
2018-10-18  7:13     ` Andrew Rybchenko
2018-10-18  1:24   ` [dpdk-dev] [PATCH v5 5/6] ethdev: remove release function for secondary process Thomas Monjalon
2018-10-18  7:15     ` Andrew Rybchenko
2018-10-18  1:24   ` [dpdk-dev] [PATCH v5 6/6] ethdev: complete closing of port Thomas Monjalon
2018-10-18  8:33     ` Andrew Rybchenko
2018-10-18  9:32       ` Thomas Monjalon
2018-10-19  2:07 ` [dpdk-dev] [PATCH v6 0/6] ethdev port freeing Thomas Monjalon
2018-10-19  2:07   ` [dpdk-dev] [PATCH v6 1/6] app/testpmd: update port list for multiple removals Thomas Monjalon
2018-10-19 14:32     ` Iremonger, Bernard
2018-10-19  2:07   ` [dpdk-dev] [PATCH v6 2/6] app/testpmd: allow detaching a port not closed Thomas Monjalon
2018-10-19 14:32     ` Iremonger, Bernard
2018-10-19  2:07   ` [dpdk-dev] [PATCH v6 3/6] ethdev: fix doxygen comments of shared data fields Thomas Monjalon
2018-10-19  2:07   ` [dpdk-dev] [PATCH v6 4/6] ethdev: free all common data when releasing port Thomas Monjalon
2018-10-19  2:07   ` [dpdk-dev] [PATCH v6 5/6] ethdev: remove release function for secondary process Thomas Monjalon
2018-10-19  2:07   ` [dpdk-dev] [PATCH v6 6/6] ethdev: complete closing of port Thomas Monjalon
2018-10-19 10:13     ` Andrew Rybchenko
2018-10-22 15:43   ` [dpdk-dev] [PATCH v6 0/6] ethdev port freeing Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e6cc3b3a-bae7-3946-534a-78603bd488cb@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=arybchenko@solarflare.com \
    --cc=dev@dpdk.org \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).