[dpdk-dev,09/14] other APIs

Message ID 1413779906-28113-10-git-send-email-huawei.xie@intel.com (mailing list archive)
State Accepted, archived
Headers

Commit Message

Huawei Xie Oct. 20, 2014, 4:38 a.m. UTC
  other vhost APIs
	rte_vhost_driver_register: register vhost driver
	rte_vhost_driver_callback_register: register new_device/destroy_device callback
	rte_vhost_driver_session_start: start vhost session loop
	rte_vhost_feature_disable: disable merge-able feature
	rte_vhost_enable_guest_notification: disable guest notification


Signed-off-by: Huawei Xie <huawei.xie@intel.com>
---
 examples/vhost/main.c | 29 ++++++++++-------------------
 1 file changed, 10 insertions(+), 19 deletions(-)
  

Comments

Thomas Monjalon Oct. 23, 2014, 9:44 a.m. UTC | #1
2014-10-20 12:38, Huawei Xie:
> other vhost APIs
> 	rte_vhost_driver_register: register vhost driver
> 	rte_vhost_driver_callback_register: register new_device/destroy_device callback
> 	rte_vhost_driver_session_start: start vhost session loop
> 	rte_vhost_feature_disable: disable merge-able feature
> 	rte_vhost_enable_guest_notification: disable guest notification

This patch should be splitted.
I'm doing the adjustment before applying.
  

Patch

diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index aaac88b..e0bd452 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -175,6 +175,7 @@  uint32_t num_devices = 0;
  * disabled on default.
  */
 static uint32_t zero_copy;
+static int mergeable;
 
 /* number of descriptors to apply*/
 static uint32_t num_rx_descriptor = RTE_TEST_RX_DESC_DEFAULT_ZCP;
@@ -218,10 +219,6 @@  static uint32_t burst_rx_retry_num = BURST_RX_RETRIES;
 /* Character device basename. Can be set by user. */
 static char dev_basename[MAX_BASENAME_SZ] = "vhost-net";
 
-
-/* This can be set by the user so it is made available here. */
-extern uint64_t VHOST_FEATURES;
-
 /* Default configuration for rx and tx thresholds etc. */
 static struct rte_eth_rxconf rx_conf_default = {
 	.rx_thresh = {
@@ -674,11 +671,11 @@  us_vhost_parse_args(int argc, char **argv)
 					us_vhost_usage(prgname);
 					return -1;
 				} else {
+					mergeable = !!ret;
 					if (ret) {
 						vmdq_conf_default.rxmode.jumbo_frame = 1;
 						vmdq_conf_default.rxmode.max_rx_pkt_len
 							= JUMBO_FRAME_MAX_SIZE;
-						VHOST_FEATURES = (1ULL << VIRTIO_NET_F_MRG_RXBUF);
 					}
 				}
 			}
@@ -2275,16 +2272,6 @@  init_data_ll (void)
 }
 
 /*
- * Set virtqueue flags so that we do not receive interrupts.
- */
-static void
-set_irq_status (struct virtio_net *dev)
-{
-	dev->virtqueue[VIRTIO_RXQ]->used->flags = VRING_USED_F_NO_NOTIFY;
-	dev->virtqueue[VIRTIO_TXQ]->used->flags = VRING_USED_F_NO_NOTIFY;
-}
-
-/*
  * Remove a device from the specific data core linked list and from the main linked list. Synchonization
  * occurs through the use of the lcore dev_removal_flag. Device is made volatile here to avoid re-ordering
  * of dev->remove=1 which can cause an infinite loop in the rte_pause loop.
@@ -2735,7 +2722,8 @@  new_device (struct virtio_net *dev)
 	memset(&dev_statistics[dev->device_fh], 0, sizeof(struct device_statistics));
 
 	/* Disable notifications. */
-	set_irq_status(dev);
+	rte_vhost_enable_guest_notification(dev, VIRTIO_RXQ, 0);
+	rte_vhost_enable_guest_notification(dev, VIRTIO_TXQ, 0);
 	lcore_info[vdev->coreid].lcore_ll->device_num++;
 	dev->flags |= VIRTIO_DEV_RUNNING;
 
@@ -3040,15 +3028,18 @@  MAIN(int argc, char *argv[])
 				lcore_id);
 	}
 
+	if (mergeable == 0)
+		rte_vhost_feature_disable(1ULL << VIRTIO_NET_F_MRG_RXBUF);
+
 	/* Register CUSE device to handle IOCTLs. */
-	ret = register_cuse_device((char*)&dev_basename, dev_index, get_virtio_net_callbacks());
+	ret = rte_vhost_driver_register((char *)&dev_basename);
 	if (ret != 0)
 		rte_exit(EXIT_FAILURE,"CUSE device setup failure.\n");
 
-	init_virtio_net(&virtio_net_device_ops);
+	rte_vhost_driver_callback_register(&virtio_net_device_ops);
 
 	/* Start CUSE session. */
-	start_cuse_session_loop();
+	rte_vhost_driver_session_start();
 	return 0;
 
 }