From: Marcin Kerlin <marcinx.kerlin@intel.com>
To: dev@dpdk.org
Cc: pablo.de.lara.guarch@intel.com, thomas.monjalon@6wind.com,
Marcin Kerlin <marcinx.kerlin@intel.com>
Subject: [dpdk-dev] [PATCH 2/2] app/testpmd: fix handling of multiprocess
Date: Fri, 29 Jul 2016 17:56:59 +0200 [thread overview]
Message-ID: <1469807819-7905-3-git-send-email-marcinx.kerlin@intel.com> (raw)
In-Reply-To: <1469807819-7905-1-git-send-email-marcinx.kerlin@intel.com>
Added lookup for pool name because secondary process should attach to
mempool created by primary process rather than create new.
Added function free_mp_shared_dev_data() which causes that if secondary
process quit or force quit then detach own devices from common array
rte_eth_dev_data[] for all processes. This allows to have a up-to-date
list of devices and run again secondary application with the same name.
Signed-off-by: Marcin Kerlin <marcinx.kerlin@intel.com>
---
app/test-pmd/testpmd.c | 30 ++++++++++++++++++++++++++++--
app/test-pmd/testpmd.h | 1 +
2 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 1428974..2fa33d0 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -453,8 +453,10 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf,
rte_mempool_obj_iter(rte_mp, rte_pktmbuf_init, NULL);
} else {
/* wrapper to rte_mempool_create() */
- rte_mp = rte_pktmbuf_pool_create(pool_name, nb_mbuf,
- mb_mempool_cache, 0, mbuf_seg_size, socket_id);
+ rte_mp = rte_mempool_lookup(pool_name);
+ if (rte_mp == NULL)
+ rte_mp = rte_pktmbuf_pool_create(pool_name, nb_mbuf,
+ mb_mempool_cache, 0, mbuf_seg_size, socket_id);
}
}
@@ -1610,6 +1612,29 @@ detach_port(uint8_t port_id)
return;
}
+void free_mp_shared_dev_data(portid_t pid)
+{
+ portid_t pi;
+
+ if (port_id_is_invalid(pid, ENABLED_WARN))
+ return;
+
+ /* free data only if the secondary process exits */
+ if (rte_eal_process_type() != RTE_PROC_SECONDARY)
+ return;
+
+ FOREACH_PORT(pi, ports) {
+ if (pid != pi && pid != (portid_t)RTE_PORT_ALL)
+ continue;
+
+ if (!port_is_closed(pi))
+ return;
+
+ if (rte_eth_dev_release_dev_data(pi) < 0)
+ return;
+ }
+}
+
void
pmd_test_exit(void)
{
@@ -1625,6 +1650,7 @@ pmd_test_exit(void)
fflush(stdout);
stop_port(pt_id);
close_port(pt_id);
+ free_mp_shared_dev_data(pt_id);
}
}
printf("\nBye...\n");
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 2b281cc..63f82f7 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -553,6 +553,7 @@ void attach_port(char *identifier);
void detach_port(uint8_t port_id);
int all_ports_stopped(void);
int port_is_started(portid_t port_id);
+void free_mp_shared_dev_data(portid_t pid);
void pmd_test_exit(void);
void fdir_get_infos(portid_t port_id);
void fdir_set_flex_mask(portid_t port_id,
--
1.9.1
next prev parent reply other threads:[~2016-07-29 14:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-29 15:56 [dpdk-dev] [PATCH 0/2] add ensure consistent device data in multiprocess mode Marcin Kerlin
2016-07-29 15:56 ` [dpdk-dev] [PATCH 1/2] lib/librte_ether: ensure not overwrite device data Marcin Kerlin
2016-07-29 15:56 ` Marcin Kerlin [this message]
2016-08-01 8:44 ` [dpdk-dev] [PATCH 0/2] add ensure consistent device data in multiprocess mode Kerlin, MarcinX
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=1469807819-7905-3-git-send-email-marcinx.kerlin@intel.com \
--to=marcinx.kerlin@intel.com \
--cc=dev@dpdk.org \
--cc=pablo.de.lara.guarch@intel.com \
--cc=thomas.monjalon@6wind.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).