From: "Iremonger, Bernard" <bernard.iremonger@intel.com>
To: Wojciech Zmuda <woz@semihalf.com>, "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] af_packet: make the device detachable
Date: Mon, 8 Feb 2016 16:07:58 +0000 [thread overview]
Message-ID: <8CEF83825BEC744B83065625E567D7C219FAF745@IRSMSX108.ger.corp.intel.com> (raw)
In-Reply-To: <1452002675-8919-1-git-send-email-woz@semihalf.com>
Hi Wojciech,
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wojciech Zmuda
> Sent: Tuesday, January 5, 2016 2:05 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH] af_packet: make the device detachable
>
> Fix memory leak when detaching virtual device. Set dev_flags to
> RTE_ETH_DEV_DETACHABLE and implement pmd_af_packet_drv.uninit
> method.
> Copy device name to ethdev->data to make it compatibile with
Typo, compatibile should be compatible.
> rte_eth_dev_allocated().
>
> Signed-off-by: Wojciech Zmuda <woz@semihalf.com>
> ---
> drivers/net/af_packet/rte_eth_af_packet.c | 29
> ++++++++++++++++++++++++++++-
> 1 file changed, 28 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/af_packet/rte_eth_af_packet.c
> b/drivers/net/af_packet/rte_eth_af_packet.c
> index 767f36b..7ef65ff 100644
> --- a/drivers/net/af_packet/rte_eth_af_packet.c
> +++ b/drivers/net/af_packet/rte_eth_af_packet.c
> @@ -667,11 +667,13 @@ rte_pmd_init_internals(const char *name,
> data->nb_tx_queues = (uint16_t)nb_queues;
> data->dev_link = pmd_link;
> data->mac_addrs = &(*internals)->eth_addr;
> + strncpy(data->name,
> + (*eth_dev)->data->name, strlen((*eth_dev)->data-
> >name));
>
> (*eth_dev)->data = data;
> (*eth_dev)->dev_ops = &ops;
> (*eth_dev)->driver = NULL;
> - (*eth_dev)->data->dev_flags = 0;
> + (*eth_dev)->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
> (*eth_dev)->data->drv_name = drivername;
> (*eth_dev)->data->kdrv = RTE_KDRV_NONE;
> (*eth_dev)->data->numa_node = numa_node; @@ -836,10 +838,35
> @@ exit:
> return ret;
> }
>
> +static int
> +rte_pmd_af_packet_devuninit(const char *name) {
> + struct rte_eth_dev *eth_dev = NULL;
> +
> + RTE_LOG(INFO, PMD, "Closing AF_PACKET ethdev on numa socket
> %u\n",
> + rte_socket_id());
> +
> + if (name == NULL)
> + return -1;
> +
> + /* reserve an ethdev entry */
Above comment should be /* find the ethdev entry */
> + eth_dev = rte_eth_dev_allocated(name);
> + if (eth_dev == NULL)
> + return -1;
> +
In rte_pmd_init_internals() memory is allocated for rx and tx queues this should also be freed.
Line 606: rx_queue->rd = rte_zmalloc_socket(name, rdsize, 0, numa_node);
Line 620:tx_queue->rd = rte_zmalloc_socket(name, rdsize, 0, numa_node);
rte_free((*internals)->rx_queue[q].rd);
rte_free((*internals)->tx_queue[q].rd);
> + rte_free(eth_dev->data->dev_private);
> + rte_free(eth_dev->data);
> +
> + rte_eth_dev_release_port(eth_dev);
> +
> + return 0;
> +}
> +
> static struct rte_driver pmd_af_packet_drv = {
> .name = "eth_af_packet",
> .type = PMD_VDEV,
> .init = rte_pmd_af_packet_devinit,
> + .uninit = rte_pmd_af_packet_devuninit,
> };
>
> PMD_REGISTER_DRIVER(pmd_af_packet_drv);
> --
> 1.9.1
next prev parent reply other threads:[~2016-02-08 16:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-05 14:04 Wojciech Zmuda
2016-02-08 16:07 ` Iremonger, Bernard [this message]
2016-02-09 9:34 ` Iremonger, Bernard
2016-02-09 16:09 ` [dpdk-dev] [PATCH v2] " Wojciech Zmuda
2016-02-09 16:37 ` Bruce Richardson
2016-02-10 15:42 ` Wojciech Żmuda
2016-02-10 18:25 ` John W. Linville
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=8CEF83825BEC744B83065625E567D7C219FAF745@IRSMSX108.ger.corp.intel.com \
--to=bernard.iremonger@intel.com \
--cc=dev@dpdk.org \
--cc=woz@semihalf.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).