From: "Charles (Chas) Williams" <ciwillia@brocade.com>
To: <dev@dpdk.org>
Cc: <mtetsuyah@gmail.com>, <yuanhan.liu@linux.intel.com>,
"Charles (Chas) Williams" <ciwillia@brocade.com>
Subject: [dpdk-dev] [PATCH 2/2] vhost: start vhost servers once
Date: Wed, 28 Dec 2016 16:10:52 -0500 [thread overview]
Message-ID: <1482959452-18486-2-git-send-email-ciwillia@brocade.com> (raw)
In-Reply-To: <1482959452-18486-1-git-send-email-ciwillia@brocade.com>
Start a vhost server once during devinit instead of during device start
and stop. Some vhost clients, QEMU, don't re-attaching to sockets when
the vhost server is stopped and later started. Preserve existing behavior
for vhost clients.
Fixes: ee584e9710b9 ("vhost: add driver on top of the library")
Signed-off-by: Chas Williams <ciwillia@brocade.com>
---
drivers/net/vhost/rte_eth_vhost.c | 36 +++++++++++++++++++++++++++++++-----
1 file changed, 31 insertions(+), 5 deletions(-)
diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index ba559ff..914d83f 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -772,9 +772,8 @@ vhost_driver_session_stop(void)
}
static int
-eth_dev_start(struct rte_eth_dev *dev)
+vhost_dev_start(struct pmd_internal *internal)
{
- struct pmd_internal *internal = dev->data->dev_private;
int ret = 0;
if (rte_atomic16_cmpset(&internal->once, 0, 1)) {
@@ -792,10 +791,8 @@ eth_dev_start(struct rte_eth_dev *dev)
}
static void
-eth_dev_stop(struct rte_eth_dev *dev)
+vhost_dev_stop(struct pmd_internal *internal)
{
- struct pmd_internal *internal = dev->data->dev_private;
-
if (rte_atomic16_cmpset(&internal->once, 1, 0)) {
rte_vhost_driver_unregister(internal->iface_name);
@@ -805,6 +802,27 @@ eth_dev_stop(struct rte_eth_dev *dev)
}
static int
+eth_dev_start(struct rte_eth_dev *dev)
+{
+ struct pmd_internal *internal = dev->data->dev_private;
+ int ret = 0;
+
+ if (internal->flags & RTE_VHOST_USER_CLIENT)
+ ret = vhost_dev_start(internal);
+
+ return ret;
+}
+
+static void
+eth_dev_stop(struct rte_eth_dev *dev)
+{
+ struct pmd_internal *internal = dev->data->dev_private;
+
+ if (internal->flags & RTE_VHOST_USER_CLIENT)
+ vhost_dev_stop(internal);
+}
+
+static int
eth_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
uint16_t nb_rx_desc __rte_unused,
unsigned int socket_id,
@@ -1079,6 +1097,11 @@ eth_dev_vhost_create(const char *name, char *iface_name, int16_t queues,
eth_dev->rx_pkt_burst = eth_vhost_rx;
eth_dev->tx_pkt_burst = eth_vhost_tx;
+ if ((flags & RTE_VHOST_USER_CLIENT) == 0) {
+ if (vhost_dev_start(internal))
+ goto error;
+ }
+
return data->port_id;
error:
@@ -1216,6 +1239,9 @@ rte_pmd_vhost_remove(const char *name)
eth_dev_stop(eth_dev);
+ if ((internal->flags & RTE_VHOST_USER_CLIENT) == 0)
+ vhost_dev_stop(internal);
+
rte_free(vring_states[eth_dev->data->port_id]);
vring_states[eth_dev->data->port_id] = NULL;
--
2.1.4
next prev parent reply other threads:[~2016-12-28 21:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-28 21:10 [dpdk-dev] [PATCH 1/2] vhost: reference count fix for nb_started_ports Charles (Chas) Williams
2016-12-28 21:10 ` Charles (Chas) Williams [this message]
2016-12-29 8:52 ` [dpdk-dev] [PATCH 2/2] vhost: start vhost servers once Yuanhan Liu
2016-12-29 15:58 ` Charles (Chas) Williams
2016-12-30 3:15 ` Yuanhan Liu
2016-12-30 21:26 ` Charles (Chas) Williams
2017-01-03 8:16 ` Yuanhan Liu
2016-12-29 8:51 ` [dpdk-dev] [PATCH 1/2] vhost: reference count fix for nb_started_ports Yuanhan Liu
2016-12-29 15:49 ` Charles (Chas) Williams
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=1482959452-18486-2-git-send-email-ciwillia@brocade.com \
--to=ciwillia@brocade.com \
--cc=dev@dpdk.org \
--cc=mtetsuyah@gmail.com \
--cc=yuanhan.liu@linux.intel.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).