From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 4B30C68FB for ; Mon, 20 Oct 2014 06:31:02 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 19 Oct 2014 21:39:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,749,1406617200"; d="scan'208";a="617018752" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga002.fm.intel.com with ESMTP; 19 Oct 2014 21:39:04 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id s9K4d2Tk004092; Mon, 20 Oct 2014 12:39:02 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id s9K4d0Fs028211; Mon, 20 Oct 2014 12:39:02 +0800 Received: (from hxie5@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id s9K4d01M028207; Mon, 20 Oct 2014 12:39:00 +0800 From: Huawei Xie To: dev@dpdk.org Date: Mon, 20 Oct 2014 12:38:21 +0800 Message-Id: <1413779906-28113-10-git-send-email-huawei.xie@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1413779906-28113-1-git-send-email-huawei.xie@intel.com> References: <1413779906-28113-1-git-send-email-huawei.xie@intel.com> Subject: [dpdk-dev] [PATCH 09/14] other APIs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Oct 2014 04:31:03 -0000 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 --- examples/vhost/main.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) 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; } -- 1.8.1.4