[dpdk-dev,4/6] vhost: Add new command line option: rxq

Message ID 1432194581-15301-5-git-send-email-changchun.ouyang@intel.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Ouyang Changchun May 21, 2015, 7:49 a.m. UTC
  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 <changchun.ouyang@intel.com>
---
 examples/vhost/main.c | 46 ++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 42 insertions(+), 4 deletions(-)
  

Comments

Thomas F Herbert May 22, 2015, 1:39 a.m. UTC | #1
On 5/21/15 3:49 AM, Ouyang Changchun wrote:
> Sample vhost need know the queue number user want to enable for each virtio device,
> so add the new option '--rxq' into it.
Could you also add the new --rxq option description to us_vhost_usage()?
>
> Signed-off-by: Changchun Ouyang <changchun.ouyang@intel.com>
> ---
>   examples/vhost/main.c | 46 ++++++++++++++++++++++++++++++++++++++++++----
>   1 file changed, 42 insertions(+), 4 deletions(-)
>
> diff --git a/examples/vhost/main.c b/examples/vhost/main.c
> index 408eb3f..16d4463 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,14 @@ 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;
> +	}
>
>   	if (zero_copy) {
>   		rx_ring_size = num_rx_descriptor;
> @@ -431,7 +440,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 +585,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 +612,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 +789,20 @@ 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) || (!POWEROF2(ret))) {
> +					RTE_LOG(INFO, VHOST_CONFIG,
> +					"Invalid argument for rxq [1,2,4],"
> +					"power of 2 required.\n");
> +					us_vhost_usage(prgname);
> +					return -1;
> +				} else {
> +					rxq = ret;
> +				}
> +			}
>   			break;
>
>   			/* Invalid option - print options. */
> @@ -813,6 +838,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;
>   }
>
>
  
Ouyang Changchun May 22, 2015, 6:05 a.m. UTC | #2
Hi Thomas,

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Thomas F Herbert
> Sent: Friday, May 22, 2015 9:39 AM
> To: dpdk >> dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH 4/6] vhost: Add new command line option:
> rxq
> 
> 
> 
> On 5/21/15 3:49 AM, Ouyang Changchun wrote:
> > Sample vhost need know the queue number user want to enable for each
> > virtio device, so add the new option '--rxq' into it.
> Could you also add the new --rxq option description to us_vhost_usage()?

Actually we have, please see below

> +585,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);
> >   }

Thanks
Changchun
  
Thomas F Herbert May 22, 2015, 12:51 p.m. UTC | #3
On 5/22/15 2:05 AM, Ouyang, Changchun wrote:
> Hi Thomas,
>
>> -----Original Message-----
>> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Thomas F Herbert
>> Sent: Friday, May 22, 2015 9:39 AM
>> To: dpdk >> dev@dpdk.org
>> Subject: Re: [dpdk-dev] [PATCH 4/6] vhost: Add new command line option:
>> rxq
>>
>>
>>
>> On 5/21/15 3:49 AM, Ouyang Changchun wrote:
>>> Sample vhost need know the queue number user want to enable for each
>>> virtio device, so add the new option '--rxq' into it.
>> Could you also add the new --rxq option description to us_vhost_usage()?
>
> Actually we have, please see below
True enough. However, the code calls rte_eal_init() before parsing args 
and therefore takes rte_exit before printing usage of the non-eal options.
>
>> +585,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);
>>>    }
>
> Thanks
> Changchun
>
  
Ouyang Changchun May 23, 2015, 1:25 a.m. UTC | #4
Hi Thomas,

> -----Original Message-----
> From: Thomas F Herbert [mailto:therbert@redhat.com]
> Sent: Friday, May 22, 2015 8:51 PM
> To: Ouyang, Changchun; dpdk >> dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH 4/6] vhost: Add new command line option:
> rxq
> 
> 
> 
> On 5/22/15 2:05 AM, Ouyang, Changchun wrote:
> > Hi Thomas,
> >
> >> -----Original Message-----
> >> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Thomas F
> Herbert
> >> Sent: Friday, May 22, 2015 9:39 AM
> >> To: dpdk >> dev@dpdk.org
> >> Subject: Re: [dpdk-dev] [PATCH 4/6] vhost: Add new command line
> option:
> >> rxq
> >>
> >>
> >>
> >> On 5/21/15 3:49 AM, Ouyang Changchun wrote:
> >>> Sample vhost need know the queue number user want to enable for
> each
> >>> virtio device, so add the new option '--rxq' into it.
> >> Could you also add the new --rxq option description to us_vhost_usage()?
> >
> > Actually we have, please see below
> True enough. However, the code calls rte_eal_init() before parsing args and
> therefore takes rte_exit before printing usage of the non-eal options.

Yes, it is really the case for every other options, and for every other samples in dpdk.
Anyway I can't put --rxq and its description into eal layer, as it belongs to vhost sample here.

Thanks
Changchun
  
Ouyang Changchun May 26, 2015, 7:21 a.m. UTC | #5
Hi Thomas,

> -----Original Message-----
> From: Ouyang, Changchun
> Sent: Saturday, May 23, 2015 9:25 AM
> To: Thomas F Herbert; dpdk >> dev@dpdk.org
> Cc: Ouyang, Changchun
> Subject: RE: [dpdk-dev] [PATCH 4/6] vhost: Add new command line option:
> rxq
> 
> Hi Thomas,
> 
> > -----Original Message-----
> > From: Thomas F Herbert [mailto:therbert@redhat.com]
> > Sent: Friday, May 22, 2015 8:51 PM
> > To: Ouyang, Changchun; dpdk >> dev@dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH 4/6] vhost: Add new command line option:
> > rxq
> >
> >
> >
> > On 5/22/15 2:05 AM, Ouyang, Changchun wrote:
> > > Hi Thomas,
> > >
> > >> -----Original Message-----
> > >> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Thomas F
> > Herbert
> > >> Sent: Friday, May 22, 2015 9:39 AM
> > >> To: dpdk >> dev@dpdk.org
> > >> Subject: Re: [dpdk-dev] [PATCH 4/6] vhost: Add new command line
> > option:
> > >> rxq
> > >>
> > >>
> > >>
> > >> On 5/21/15 3:49 AM, Ouyang Changchun wrote:
> > >>> Sample vhost need know the queue number user want to enable for
> > each
> > >>> virtio device, so add the new option '--rxq' into it.
> > >> Could you also add the new --rxq option description to
> us_vhost_usage()?
> > >
> > > Actually we have, please see below
> > True enough. However, the code calls rte_eal_init() before parsing
> > args and therefore takes rte_exit before printing usage of the non-eal
> options.

Use this command line could address your question:
vhost-switch -c 0xf -n 4 -- -help
it will go through eal  and come to helper function in vhost-switch, then you can see the usage info for vhost.

Thanks
Changchun
  

Patch

diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 408eb3f..16d4463 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,14 @@  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;
+	}
 
 	if (zero_copy) {
 		rx_ring_size = num_rx_descriptor;
@@ -431,7 +440,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 +585,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 +612,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 +789,20 @@  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) || (!POWEROF2(ret))) {
+					RTE_LOG(INFO, VHOST_CONFIG,
+					"Invalid argument for rxq [1,2,4],"
+					"power of 2 required.\n");
+					us_vhost_usage(prgname);
+					return -1;
+				} else {
+					rxq = ret;
+				}
+			}
 			break;
 
 			/* Invalid option - print options. */
@@ -813,6 +838,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;
 }