summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorYuanhan Liu <yuanhan.liu@linux.intel.com>2016-05-11 07:02:58 +0800
committerYuanhan Liu <yuanhan.liu@linux.intel.com>2016-06-22 09:07:36 +0200
commit16ae8abe1cb8b545d4ca5cdee0e3db32c6b8b498 (patch)
treeaf7b02cbb603daebc0b6a0d82a83daa339888a3a /examples
parenta67f286a6596e6269bb3b83e01f9b42bb5544b46 (diff)
downloaddpdk-16ae8abe1cb8b545d4ca5cdee0e3db32c6b8b498.zip
dpdk-16ae8abe1cb8b545d4ca5cdee0e3db32c6b8b498.tar.gz
dpdk-16ae8abe1cb8b545d4ca5cdee0e3db32c6b8b498.tar.xz
vhost: remove dependency on device private field
This change could let us avoid the dependency of "virtio_net" struct, to prepare for the ABI refactoring. Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com> Tested-by: Rich Lane <rich.lane@bigswitch.com> Acked-by: Rich Lane <rich.lane@bigswitch.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/tep_termination/main.c14
-rw-r--r--examples/tep_termination/main.h1
-rw-r--r--examples/vhost/main.c10
3 files changed, 19 insertions, 6 deletions
diff --git a/examples/tep_termination/main.c b/examples/tep_termination/main.c
index fb0c7fc..8c627d2 100644
--- a/examples/tep_termination/main.c
+++ b/examples/tep_termination/main.c
@@ -919,12 +919,20 @@ destroy_device(volatile struct virtio_net *dev)
struct virtio_net_data_ll *ll_main_dev_cur;
struct virtio_net_data_ll *ll_lcore_dev_last = NULL;
struct virtio_net_data_ll *ll_main_dev_last = NULL;
- struct vhost_dev *vdev;
+ struct vhost_dev *vdev = NULL;
int lcore;
dev->flags &= ~VIRTIO_DEV_RUNNING;
- vdev = (struct vhost_dev *)dev->priv;
+ ll_main_dev_cur = ll_root_used;
+ while (ll_main_dev_cur != NULL) {
+ if (ll_main_dev_cur->vdev->vid == dev->vid) {
+ vdev = ll_main_dev_cur->vdev;
+ break;
+ }
+ }
+ if (!vdev)
+ return;
/* set the remove flag. */
vdev->remove = 1;
@@ -1019,7 +1027,7 @@ new_device(struct virtio_net *dev)
return -1;
}
vdev->dev = dev;
- dev->priv = vdev;
+ vdev->vid = dev->vid;
/* Add device to main ll */
ll_dev = get_data_ll_free_entry(&ll_root_free);
if (ll_dev == NULL) {
diff --git a/examples/tep_termination/main.h b/examples/tep_termination/main.h
index 4b123ab..f786640 100644
--- a/examples/tep_termination/main.h
+++ b/examples/tep_termination/main.h
@@ -71,6 +71,7 @@ struct device_statistics {
* Device linked list structure for data path.
*/
struct vhost_dev {
+ int vid;
/**< Pointer to device created by vhost lib. */
struct virtio_net *dev;
/**< Number of memory regions for gpa to hpa translation. */
diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 4e26a8b..77214a6 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -1173,10 +1173,15 @@ switch_worker(void *arg __rte_unused)
static void
destroy_device (volatile struct virtio_net *dev)
{
- struct vhost_dev *vdev;
+ struct vhost_dev *vdev = NULL;
int lcore;
- vdev = (struct vhost_dev *)dev->priv;
+ TAILQ_FOREACH(vdev, &vhost_dev_list, global_vdev_entry) {
+ if (vdev->vid == dev->vid)
+ break;
+ }
+ if (!vdev)
+ return;
/*set the remove flag. */
vdev->remove = 1;
while(vdev->ready != DEVICE_SAFE_REMOVE) {
@@ -1231,7 +1236,6 @@ new_device (struct virtio_net *dev)
return -1;
}
vdev->dev = dev;
- dev->priv = vdev;
vdev->vid = vid;
TAILQ_INSERT_TAIL(&vhost_dev_list, vdev, global_vdev_entry);