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 9AE7B8D86 for ; Wed, 12 Aug 2015 10:03:17 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 12 Aug 2015 01:03:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,659,1432623600"; d="scan'208";a="782522640" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga002.jf.intel.com with ESMTP; 12 Aug 2015 01:03:16 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t7C83C8i027086; Wed, 12 Aug 2015 16:03:12 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t7C83ATW003675; Wed, 12 Aug 2015 16:03:12 +0800 Received: (from couyang@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t7C83AaL003671; Wed, 12 Aug 2015 16:03:10 +0800 From: Ouyang Changchun To: dev@dpdk.org Date: Wed, 12 Aug 2015 16:02:42 +0800 Message-Id: <1439366567-3402-8-git-send-email-changchun.ouyang@intel.com> X-Mailer: git-send-email 1.7.12.2 In-Reply-To: <1439366567-3402-1-git-send-email-changchun.ouyang@intel.com> References: <1434355006-30583-1-git-send-email-changchun.ouyang@intel.com> <1439366567-3402-1-git-send-email-changchun.ouyang@intel.com> Subject: [dpdk-dev] [PATCH v4 07/12] vhost: add new command line option: rxq 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: Wed, 12 Aug 2015 08:03:18 -0000 Sample vhost need know the queue number user want to enable for each virtio device, so add the new option '--rxq' into it. Signed-off-by: Changchun Ouyang --- Changes in v3 - fix coding style Changes in v2 - refine help info - check if rxq = 0 - fix checkpatch errors examples/vhost/main.c | 49 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/examples/vhost/main.c b/examples/vhost/main.c index d3c45dd..5b811af 100644 --- a/examples/vhost/main.c +++ b/examples/vhost/main.c @@ -163,6 +163,9 @@ static int mergeable; /* Do vlan strip on host, enabled on default */ static uint32_t vlan_strip = 1; +/* Rx queue number per virtio device */ +static uint32_t rxq = 1; + /* number of descriptors to apply*/ static uint32_t num_rx_descriptor = RTE_TEST_RX_DESC_DEFAULT_ZCP; static uint32_t num_tx_descriptor = RTE_TEST_TX_DESC_DEFAULT_ZCP; @@ -408,8 +411,19 @@ port_init(uint8_t port) txconf->tx_deferred_start = 1; } - /*configure the number of supported virtio devices based on VMDQ limits */ - num_devices = dev_info.max_vmdq_pools; + /* Configure the virtio devices num based on VMDQ limits */ + switch (rxq) { + case 1: + case 2: + num_devices = dev_info.max_vmdq_pools; + break; + case 4: + num_devices = dev_info.max_vmdq_pools / 2; + break; + default: + RTE_LOG(ERR, VHOST_CONFIG, "rxq invalid for VMDq.\n"); + return -1; + } if (zero_copy) { rx_ring_size = num_rx_descriptor; @@ -431,7 +445,7 @@ port_init(uint8_t port) return retval; /* NIC queues are divided into pf queues and vmdq queues. */ num_pf_queues = dev_info.max_rx_queues - dev_info.vmdq_queue_num; - queues_per_pool = dev_info.vmdq_queue_num / dev_info.max_vmdq_pools; + queues_per_pool = dev_info.vmdq_queue_num / num_devices; num_vmdq_queues = num_devices * queues_per_pool; num_queues = num_pf_queues + num_vmdq_queues; vmdq_queue_base = dev_info.vmdq_queue_base; @@ -576,7 +590,8 @@ us_vhost_usage(const char *prgname) " --rx-desc-num [0-N]: the number of descriptors on rx, " "used only when zero copy is enabled.\n" " --tx-desc-num [0-N]: the number of descriptors on tx, " - "used only when zero copy is enabled.\n", + "used only when zero copy is enabled.\n" + " --rxq [1,2,4]: rx queue number for each vhost device\n", prgname); } @@ -602,6 +617,7 @@ us_vhost_parse_args(int argc, char **argv) {"zero-copy", required_argument, NULL, 0}, {"rx-desc-num", required_argument, NULL, 0}, {"tx-desc-num", required_argument, NULL, 0}, + {"rxq", required_argument, NULL, 0}, {NULL, 0, 0, 0}, }; @@ -778,6 +794,18 @@ us_vhost_parse_args(int argc, char **argv) } } + /* Specify the Rx queue number for each vhost dev. */ + if (!strncmp(long_option[option_index].name, + "rxq", MAX_LONG_OPT_SZ)) { + ret = parse_num_opt(optarg, 4); + if ((ret == -1) || (ret == 0) || (!POWEROF2(ret))) { + RTE_LOG(INFO, VHOST_CONFIG, + "Valid value for rxq is [1,2,4]\n"); + us_vhost_usage(prgname); + return -1; + } else + rxq = ret; + } break; /* Invalid option - print options. */ @@ -813,6 +841,19 @@ us_vhost_parse_args(int argc, char **argv) return -1; } + if (rxq > 1) { + vmdq_conf_default.rxmode.mq_mode = ETH_MQ_RX_VMDQ_RSS; + vmdq_conf_default.rx_adv_conf.rss_conf.rss_hf = ETH_RSS_IP | + ETH_RSS_UDP | ETH_RSS_TCP | ETH_RSS_SCTP; + } + + if ((zero_copy == 1) && (rxq > 1)) { + RTE_LOG(INFO, VHOST_PORT, + "Vhost zero copy doesn't support mq mode," + "please specify '--rxq 1' to disable it.\n"); + return -1; + } + return 0; } -- 1.8.4.2