* [dpdk-dev] [PATCH] vhost: introduce new function helper
@ 2018-06-13 11:54 xiangxia.m.yue
2018-06-15 7:52 ` Maxime Coquelin
2018-06-15 7:59 ` Maxime Coquelin
0 siblings, 2 replies; 3+ messages in thread
From: xiangxia.m.yue @ 2018-06-13 11:54 UTC (permalink / raw)
To: dev; +Cc: Tonghao Zhang
From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
Introduce an new common helper to avoid redundancy.
Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
---
lib/librte_vhost/vhost.c | 27 +++++++++++++++++----------
lib/librte_vhost/vhost.h | 1 +
lib/librte_vhost/vhost_user.c | 23 ++---------------------
3 files changed, 20 insertions(+), 31 deletions(-)
diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
index afded49..493b204 100644
--- a/lib/librte_vhost/vhost.c
+++ b/lib/librte_vhost/vhost.c
@@ -295,6 +295,22 @@
return i;
}
+void
+vhost_destroy_device_notify(struct virtio_net *dev)
+{
+ struct rte_vdpa_device *vdpa_dev;
+ int did;
+
+ if (dev->flags & VIRTIO_DEV_RUNNING) {
+ did = dev->vdpa_dev_id;
+ vdpa_dev = rte_vdpa_get_device(did);
+ if (vdpa_dev && vdpa_dev->ops->dev_close)
+ vdpa_dev->ops->dev_close(dev->vid);
+ dev->flags &= ~VIRTIO_DEV_RUNNING;
+ dev->notify_ops->destroy_device(dev->vid);
+ }
+}
+
/*
* Invoked when there is the vhost-user connection is broken (when
* the virtio device is being detached).
@@ -303,20 +319,11 @@
vhost_destroy_device(int vid)
{
struct virtio_net *dev = get_device(vid);
- struct rte_vdpa_device *vdpa_dev;
- int did = -1;
if (dev == NULL)
return;
- if (dev->flags & VIRTIO_DEV_RUNNING) {
- did = dev->vdpa_dev_id;
- vdpa_dev = rte_vdpa_get_device(did);
- if (vdpa_dev && vdpa_dev->ops->dev_close)
- vdpa_dev->ops->dev_close(dev->vid);
- dev->flags &= ~VIRTIO_DEV_RUNNING;
- dev->notify_ops->destroy_device(vid);
- }
+ vhost_destroy_device_notify(dev);
cleanup_device(dev, 1);
free_device(dev);
diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
index 58c425a..cd1cfcb 100644
--- a/lib/librte_vhost/vhost.h
+++ b/lib/librte_vhost/vhost.h
@@ -535,6 +535,7 @@ struct virtio_net {
void cleanup_device(struct virtio_net *dev, int destroy);
void reset_device(struct virtio_net *dev);
void vhost_destroy_device(int);
+void vhost_destroy_device_notify(struct virtio_net *dev);
void cleanup_vq(struct vhost_virtqueue *vq, int destroy);
void free_vq(struct vhost_virtqueue *vq);
diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 947290f..6e8d566 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -135,17 +135,7 @@
static int
vhost_user_reset_owner(struct virtio_net *dev)
{
- struct rte_vdpa_device *vdpa_dev;
- int did = -1;
-
- if (dev->flags & VIRTIO_DEV_RUNNING) {
- did = dev->vdpa_dev_id;
- vdpa_dev = rte_vdpa_get_device(did);
- if (vdpa_dev && vdpa_dev->ops->dev_close)
- vdpa_dev->ops->dev_close(dev->vid);
- dev->flags &= ~VIRTIO_DEV_RUNNING;
- dev->notify_ops->destroy_device(dev->vid);
- }
+ vhost_destroy_device_notify(dev);
cleanup_device(dev, 0);
reset_device(dev);
@@ -996,18 +986,9 @@
VhostUserMsg *msg)
{
struct vhost_virtqueue *vq = dev->virtqueue[msg->payload.state.index];
- struct rte_vdpa_device *vdpa_dev;
- int did = -1;
/* We have to stop the queue (virtio) if it is running. */
- if (dev->flags & VIRTIO_DEV_RUNNING) {
- did = dev->vdpa_dev_id;
- vdpa_dev = rte_vdpa_get_device(did);
- if (vdpa_dev && vdpa_dev->ops->dev_close)
- vdpa_dev->ops->dev_close(dev->vid);
- dev->flags &= ~VIRTIO_DEV_RUNNING;
- dev->notify_ops->destroy_device(dev->vid);
- }
+ vhost_destroy_device_notify(dev);
dev->flags &= ~VIRTIO_DEV_READY;
dev->flags &= ~VIRTIO_DEV_VDPA_CONFIGURED;
--
1.8.3.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH] vhost: introduce new function helper
2018-06-13 11:54 [dpdk-dev] [PATCH] vhost: introduce new function helper xiangxia.m.yue
@ 2018-06-15 7:52 ` Maxime Coquelin
2018-06-15 7:59 ` Maxime Coquelin
1 sibling, 0 replies; 3+ messages in thread
From: Maxime Coquelin @ 2018-06-15 7:52 UTC (permalink / raw)
To: xiangxia.m.yue, dev
On 06/13/2018 01:54 PM, xiangxia.m.yue@gmail.com wrote:
> From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
>
> Introduce an new common helper to avoid redundancy.
>
> Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> ---
> lib/librte_vhost/vhost.c | 27 +++++++++++++++++----------
> lib/librte_vhost/vhost.h | 1 +
> lib/librte_vhost/vhost_user.c | 23 ++---------------------
> 3 files changed, 20 insertions(+), 31 deletions(-)
>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Thanks,
Maxime
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH] vhost: introduce new function helper
2018-06-13 11:54 [dpdk-dev] [PATCH] vhost: introduce new function helper xiangxia.m.yue
2018-06-15 7:52 ` Maxime Coquelin
@ 2018-06-15 7:59 ` Maxime Coquelin
1 sibling, 0 replies; 3+ messages in thread
From: Maxime Coquelin @ 2018-06-15 7:59 UTC (permalink / raw)
To: xiangxia.m.yue, dev
On 06/13/2018 01:54 PM, xiangxia.m.yue@gmail.com wrote:
> From: Tonghao Zhang<xiangxia.m.yue@gmail.com>
>
> Introduce an new common helper to avoid redundancy.
>
> Signed-off-by: Tonghao Zhang<xiangxia.m.yue@gmail.com>
> ---
> lib/librte_vhost/vhost.c | 27 +++++++++++++++++----------
> lib/librte_vhost/vhost.h | 1 +
> lib/librte_vhost/vhost_user.c | 23 ++---------------------
> 3 files changed, 20 insertions(+), 31 deletions(-)
Applied to dpdk-next-virtio/master
Thanks,
Maxime
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-06-15 7:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-13 11:54 [dpdk-dev] [PATCH] vhost: introduce new function helper xiangxia.m.yue
2018-06-15 7:52 ` Maxime Coquelin
2018-06-15 7:59 ` Maxime Coquelin
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).