From: Tetsuya Mukawa <mukawa@igel.co.jp>
To: dev@dpdk.org
Cc: nakajima.yoshihiro@lab.ntt.co.jp, masutani.hitoshi@lab.ntt.co.jp
Subject: [dpdk-dev] [RFC PATCH 1/2] librte_pmd_pcap: Add support for port hotplug
Date: Wed, 29 Oct 2014 17:51:01 +0900 [thread overview]
Message-ID: <1414572662-21408-1-git-send-email-mukawa@igel.co.jp> (raw)
This patch adds finalization code to free resources allocated by the
PMD.
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
---
lib/librte_pmd_pcap/rte_eth_pcap.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/lib/librte_pmd_pcap/rte_eth_pcap.c b/lib/librte_pmd_pcap/rte_eth_pcap.c
index f12d1e7..90fc065 100644
--- a/lib/librte_pmd_pcap/rte_eth_pcap.c
+++ b/lib/librte_pmd_pcap/rte_eth_pcap.c
@@ -499,6 +499,13 @@ static struct eth_dev_ops ops = {
.stats_reset = eth_stats_reset,
};
+static struct eth_driver rte_pcap_pmd = {
+ .pci_drv = {
+ .name = "rte_pcap_pmd",
+ .drv_flags = RTE_PCI_DRV_DETACHABLE,
+ },
+};
+
/*
* Function handler that opens the pcap file for reading a stores a
* reference of it for use it later on.
@@ -743,6 +750,7 @@ rte_pmd_init_internals(const char *name, const unsigned nb_rx_queues,
(*eth_dev)->data = data;
(*eth_dev)->dev_ops = &ops;
(*eth_dev)->pci_dev = pci_dev;
+ (*eth_dev)->driver = &rte_pcap_pmd;
return 0;
@@ -927,10 +935,33 @@ rte_pmd_pcap_devinit(const char *name, const char *params)
}
+static int
+rte_pmd_pcap_devclose(const char *name, const char *params __rte_unused)
+{
+ struct rte_eth_dev *eth_dev = NULL;
+
+ RTE_LOG(INFO, PMD, "Closing pcap ethdev on numa socket %u\n",
+ rte_socket_id());
+
+ /* reserve an ethdev entry */
+ eth_dev = rte_eth_dev_allocated(name);
+ if (eth_dev == NULL)
+ return -1;
+
+ rte_free(eth_dev->data->dev_private);
+ rte_free(eth_dev->data);
+ rte_free(eth_dev->pci_dev);
+
+ rte_eth_dev_free(name);
+
+ return 0;
+}
+
static struct rte_driver pmd_pcap_drv = {
.name = "eth_pcap",
.type = PMD_VDEV,
.init = rte_pmd_pcap_devinit,
+ .close = rte_pmd_pcap_devclose,
};
PMD_REGISTER_DRIVER(pmd_pcap_drv);
--
1.9.1
next reply other threads:[~2014-10-29 8:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-29 8:51 Tetsuya Mukawa [this message]
2014-10-29 8:51 ` [dpdk-dev] [RFC PATCH 2/2] testpmd: Add support for the port hotplug framework Tetsuya Mukawa
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=1414572662-21408-1-git-send-email-mukawa@igel.co.jp \
--to=mukawa@igel.co.jp \
--cc=dev@dpdk.org \
--cc=masutani.hitoshi@lab.ntt.co.jp \
--cc=nakajima.yoshihiro@lab.ntt.co.jp \
/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).