From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 77BA05323 for ; Tue, 23 Aug 2016 10:01:05 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP; 23 Aug 2016 01:01:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,565,1464678000"; d="scan'208";a="752353966" Received: from yliu-dev.sh.intel.com ([10.239.67.162]) by FMSMGA003.fm.intel.com with ESMTP; 23 Aug 2016 01:01:03 -0700 From: Yuanhan Liu To: dev@dpdk.org Cc: Maxime Coquelin , Yuanhan Liu Date: Tue, 23 Aug 2016 16:10:39 +0800 Message-Id: <1471939839-29778-7-git-send-email-yuanhan.liu@linux.intel.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1471939839-29778-1-git-send-email-yuanhan.liu@linux.intel.com> References: <1471939839-29778-1-git-send-email-yuanhan.liu@linux.intel.com> Subject: [dpdk-dev] [PATCH 6/6] examples/vhost: add an option to enable Tx zero copy 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: Tue, 23 Aug 2016 08:01:07 -0000 Add an option, --tx-zero-copy, to enable Tx zero copy. One thing worth noting while using Tx zero copy is the nb_tx_desc has to be small enough so that the eth driver will hit the mbuf free threshold easily and thus free mbuf more frequently. The reason behind that is, when Tx zero copy is enabled, guest Tx used vring will be updated only when corresponding mbuf is freed. If mbuf is not freed frequently, the guest Tx vring could be starved. Signed-off-by: Yuanhan Liu --- examples/vhost/main.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/examples/vhost/main.c b/examples/vhost/main.c index 9974f0b..e3437ad 100644 --- a/examples/vhost/main.c +++ b/examples/vhost/main.c @@ -130,6 +130,7 @@ static uint32_t enable_tx_csum; static uint32_t enable_tso; static int client_mode; +static int tx_zero_copy; /* Specify timeout (in useconds) between retries on RX. */ static uint32_t burst_rx_delay_time = BURST_RX_WAIT_US; @@ -297,6 +298,17 @@ port_init(uint8_t port) rx_ring_size = RTE_TEST_RX_DESC_DEFAULT; tx_ring_size = RTE_TEST_TX_DESC_DEFAULT; + + /* + * When Tx zero copy is enabled, guest Tx used vring will be updated + * only when corresponding mbuf is freed. Thus, the nb_tx_desc + * (tx_ring_size here) must be small enough so that the driver will + * hit the free threshold easily and free mbufs timely. Otherwise, + * guest Tx vring would be starved. + */ + if (tx_zero_copy) + tx_ring_size = 64; + tx_rings = (uint16_t)rte_lcore_count(); retval = validate_num_devices(MAX_DEVICES); @@ -474,7 +486,8 @@ us_vhost_usage(const char *prgname) " --socket-file: The path of the socket file.\n" " --tx-csum [0|1] disable/enable TX checksum offload.\n" " --tso [0|1] disable/enable TCP segment offload.\n" - " --client register a vhost-user socket as client mode.\n", + " --client register a vhost-user socket as client mode.\n" + " --tx-zero-copy enables Tx zero copy\n", prgname); } @@ -500,6 +513,7 @@ us_vhost_parse_args(int argc, char **argv) {"tx-csum", required_argument, NULL, 0}, {"tso", required_argument, NULL, 0}, {"client", no_argument, &client_mode, 1}, + {"tx-zero-copy", no_argument, &tx_zero_copy, 1}, {NULL, 0, 0, 0}, }; @@ -1531,6 +1545,9 @@ main(int argc, char *argv[]) if (client_mode) flags |= RTE_VHOST_USER_CLIENT; + if (tx_zero_copy) + flags |= RTE_VHOST_USER_TX_ZERO_COPY; + /* Register vhost user driver to handle vhost messages. */ for (i = 0; i < nb_sockets; i++) { ret = rte_vhost_driver_register -- 1.9.0