From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Stephen Hemminger <stephen@networkplumber.org>, dev@dpdk.org
Cc: Stephen Hemminger <sthemmin@microsoft.com>
Subject: Re: [dpdk-dev] [PATCH 2/2] net/netvsc: free all queues on close
Date: Tue, 30 Apr 2019 09:11:02 +0100 [thread overview]
Message-ID: <4c4d8b2c-fb1a-a975-7c6f-cacf7dfe1a7c@intel.com> (raw)
Message-ID: <20190430081102.CrOnPs-3RP6_jsCP7T1SkF2bsF9YjgZjeKI5f43F13Y@z> (raw)
In-Reply-To: <20190429203325.10696-3-stephen@networkplumber.org>
On 4/29/2019 9:33 PM, Stephen Hemminger wrote:
> When dev_close is called, the netvsc driver will clean up all
> queues including the primary ring buffer.
>
> Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
> ---
> drivers/net/netvsc/hn_ethdev.c | 8 +++++--
> drivers/net/netvsc/hn_rxtx.c | 39 ++++++++++++++++++++++++++++------
> drivers/net/netvsc/hn_var.h | 1 +
> 3 files changed, 40 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c
> index 407ee484935a..553cb06f6e33 100644
> --- a/drivers/net/netvsc/hn_ethdev.c
> +++ b/drivers/net/netvsc/hn_ethdev.c
> @@ -112,6 +112,9 @@ eth_dev_vmbus_allocate(struct rte_vmbus_device *dev, size_t private_data_size)
> eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
> eth_dev->intr_handle = &dev->intr_handle;
>
> + /* allow ethdev to remove on close */
> + eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
> +
> return eth_dev;
> }
>
> @@ -632,11 +635,12 @@ hn_dev_stop(struct rte_eth_dev *dev)
> }
>
> static void
> -hn_dev_close(struct rte_eth_dev *dev __rte_unused)
> +hn_dev_close(struct rte_eth_dev *dev)
> {
> - PMD_INIT_LOG(DEBUG, "close");
> + PMD_INIT_FUNC_TRACE();
>
> hn_vf_close(dev);
> + hn_dev_free_queues(dev);
> }
>
> static const struct eth_dev_ops hn_eth_dev_ops = {
> diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c
> index 7856f7e6ec48..1bebae7cddd4 100644
> --- a/drivers/net/netvsc/hn_rxtx.c
> +++ b/drivers/net/netvsc/hn_rxtx.c
> @@ -840,12 +840,9 @@ hn_dev_rx_queue_setup(struct rte_eth_dev *dev,
> return error;
> }
>
> -void
> -hn_dev_rx_queue_release(void *arg)
> +static void
> +hn_rx_queue_free(struct hn_rx_queue *rxq, bool keep_primary)
> {
> - struct hn_rx_queue *rxq = arg;
> -
> - PMD_INIT_FUNC_TRACE();
>
> if (!rxq)
> return;
> @@ -857,12 +854,22 @@ hn_dev_rx_queue_release(void *arg)
> hn_vf_rx_queue_release(rxq->hv, rxq->queue_id);
>
> /* Keep primary queue to allow for control operations */
> - if (rxq != rxq->hv->primary) {
> + if (keep_primary && rxq != rxq->hv->primary) {
Isn't something wrong in this logic, when 'keep_primary' is 'false', it will
prevent taking this branch and it will prevent freeing _any_ 'rxq->event_buf' &
'rxq'. There is already a primary queue check after '&&', this flag looks like
working more like enable/disable freeing queues more than being related to primary.
And int he '.dev_close()' path [1] this function is called with 'false', so
queue resources are not cleaned properly.
[1]
hn_dev_close
hn_dev_free_queues
foreach rx_queue
hn_rx_queue_free(rxq, false);
> rte_free(rxq->event_buf);
> rte_free(rxq);
> }
> }
>
> +void
> +hn_dev_rx_queue_release(void *arg)
> +{
> + struct hn_rx_queue *rxq = arg;
> +
> + PMD_INIT_FUNC_TRACE();
> +
> + hn_rx_queue_free(rxq, true);
> +}
> +
> int
> hn_dev_tx_done_cleanup(void *arg, uint32_t free_cnt)
> {
> @@ -1440,3 +1447,23 @@ hn_recv_pkts(void *prxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
>
> return nb_rcv;
> }
> +
> +void
> +hn_dev_free_queues(struct rte_eth_dev *dev)
> +{
> + unsigned int i;
> +
> + for (i = 0; i < dev->data->nb_rx_queues; i++) {
> + struct hn_rx_queue *rxq = dev->data->rx_queues[i];
> +
> + hn_rx_queue_free(rxq, false);
> + dev->data->rx_queues[i] = NULL;
> + }
> + dev->data->nb_rx_queues = 0;
> +
> + for (i = 0; i < dev->data->nb_tx_queues; i++) {
> + hn_dev_tx_queue_release(dev->data->tx_queues[i]);
> + dev->data->tx_queues[i] = NULL;
> + }
> + dev->data->nb_tx_queues = 0;
> +}
> diff --git a/drivers/net/netvsc/hn_var.h b/drivers/net/netvsc/hn_var.h
> index 8383f3246ca4..de885d898e6a 100644
> --- a/drivers/net/netvsc/hn_var.h
> +++ b/drivers/net/netvsc/hn_var.h
> @@ -173,6 +173,7 @@ int hn_dev_rx_queue_setup(struct rte_eth_dev *dev,
> const struct rte_eth_rxconf *rx_conf,
> struct rte_mempool *mp);
> void hn_dev_rx_queue_release(void *arg);
> +void hn_dev_free_queues(struct rte_eth_dev *dev);
>
> /* Check if VF is attached */
> static inline bool
>
next prev parent reply other threads:[~2019-04-30 8:11 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-29 20:33 [dpdk-dev] [PATCH 0/2] netvsc pmd fixes for 19.05 Stephen Hemminger
2019-04-29 20:33 ` Stephen Hemminger
2019-04-29 20:33 ` [dpdk-dev] [PATCH 1/2] net/netvsc: reset mbuf port on VF receive Stephen Hemminger
2019-04-29 20:33 ` Stephen Hemminger
2019-04-30 8:01 ` Ferruh Yigit
2019-04-30 8:01 ` Ferruh Yigit
2019-04-30 15:05 ` Stephen Hemminger
2019-04-30 15:05 ` Stephen Hemminger
2019-04-29 20:33 ` [dpdk-dev] [PATCH 2/2] net/netvsc: free all queues on close Stephen Hemminger
2019-04-29 20:33 ` Stephen Hemminger
2019-04-30 8:11 ` Ferruh Yigit [this message]
2019-04-30 8:11 ` Ferruh Yigit
2019-04-30 18:12 ` [dpdk-dev] [PATCH v2 0/2] netvsc PMD fixes for 19.05 Stephen Hemminger
2019-04-30 18:12 ` Stephen Hemminger
2019-04-30 18:12 ` [dpdk-dev] [PATCH v2 1/2] net/netvsc: reset mbuf port on VF receive Stephen Hemminger
2019-04-30 18:12 ` Stephen Hemminger
2019-04-30 18:12 ` [dpdk-dev] [PATCH v2 2/2] net/netvsc: free all queues on close Stephen Hemminger
2019-04-30 18:12 ` Stephen Hemminger
2019-05-02 18:24 ` [dpdk-dev] [PATCH v2 0/2] netvsc PMD fixes for 19.05 Ferruh Yigit
2019-05-02 18:24 ` 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=4c4d8b2c-fb1a-a975-7c6f-cacf7dfe1a7c@intel.com \
--to=ferruh.yigit@intel.com \
--cc=dev@dpdk.org \
--cc=stephen@networkplumber.org \
--cc=sthemmin@microsoft.com \
/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).