diff mbox

[dpdk-dev,1/2] examples/vhost: support new VMDQ API and new nic i40e

Message ID 1415831647-11139-2-git-send-email-huawei.xie@intel.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Huawei Xie Nov. 12, 2014, 10:34 p.m. UTC
In Niantic, if VMDQ mode is set, all queues are allocated to VMDQ in DPDK.
In I40E, only configured part of continous queues are allocated to VMDQ.
The rte_eth_dev_info structure is extened to provide VMDQ queue base, queue number, and VMDQ pool base information.
This patch support the new VMDQ API in vhost example.

FIXME in PMD:
 * added mac address will be flushed at rte_eth_dev_start.
 * we don't support selectively setting up queues well. 

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

Comments

Ouyang Changchun Nov. 13, 2014, 12:49 a.m. UTC | #1
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Huawei Xie
> Sent: Thursday, November 13, 2014 6:34 AM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH 1/2] examples/vhost: support new VMDQ API
> and new nic i40e
> 
> In Niantic, if VMDQ mode is set, all queues are allocated to VMDQ in DPDK.
> In I40E, only configured part of continous queues are allocated to VMDQ.
> The rte_eth_dev_info structure is extened to provide VMDQ queue base,
> queue number, and VMDQ pool base information.
> This patch support the new VMDQ API in vhost example.
> 
> FIXME in PMD:
>  * added mac address will be flushed at rte_eth_dev_start.
>  * we don't support selectively setting up queues well.
> 
> Signed-off-by: Huawei Xie <huawei.xie@intel.com>
> ---
>  examples/vhost/main.c | 25 +++++++++++++++++++------
>  1 file changed, 19 insertions(+), 6 deletions(-)
> 
> diff --git a/examples/vhost/main.c b/examples/vhost/main.c index
> a93f7a0..2b1bf02 100644
> --- a/examples/vhost/main.c
> +++ b/examples/vhost/main.c
> @@ -53,7 +53,7 @@
> 
>  #include "main.h"
> 
> -#define MAX_QUEUES 128
> +#define MAX_QUEUES 256
> 
>  /* the maximum number of external ports supported */  #define
> MAX_SUP_PORTS 1 @@ -282,6 +282,9 @@ static struct rte_eth_conf
> vmdq_conf_default = {  static unsigned lcore_ids[RTE_MAX_LCORE];  static
> uint8_t ports[RTE_MAX_ETHPORTS];  static unsigned num_ports = 0; /**<
> The number of ports specified in command line */
> +static uint16_t num_pf_queues, num_vmdq_queues; static uint16_t
> +vmdq_pool_base, vmdq_queue_base; static uint16_t queues_per_pool;
> 
>  static const uint16_t external_pkt_default_vlan_tag = 2000;  const uint16_t
> vlan_tags[] = { @@ -417,7 +420,6 @@ port_init(uint8_t port)
> 
>  	/*configure the number of supported virtio devices based on VMDQ
> limits */
>  	num_devices = dev_info.max_vmdq_pools;
> -	num_queues = dev_info.max_rx_queues;
> 
>  	if (zero_copy) {
>  		rx_ring_size = num_rx_descriptor;
> @@ -437,10 +439,19 @@ port_init(uint8_t port)
>  	retval = get_eth_conf(&port_conf, num_devices);
>  	if (retval < 0)
>  		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;
> +	num_vmdq_queues = num_devices * queues_per_pool;
> +	num_queues = num_pf_queues + num_vmdq_queues;
> +	vmdq_queue_base = dev_info.vmdq_queue_base;
> +	vmdq_pool_base  = dev_info.vmdq_pool_base;
> +	printf("pf queue num: %u, configured vmdq pool num: %u, each
> vmdq pool has %u queues\n",
> +		num_pf_queues, num_devices, queues_per_pool);
>

Better to use RTE_LOG to replace printf.
 
>  	if (port >= rte_eth_dev_count()) return -1;
> 
> -	rx_rings = (uint16_t)num_queues,
> +	rx_rings = (uint16_t)dev_info.max_rx_queues;
>  	/* Configure ethernet device. */
>  	retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
>  	if (retval != 0)
> @@ -931,7 +942,8 @@ link_vmdq(struct vhost_dev *vdev, struct rte_mbuf
> *m)
>  		vdev->vlan_tag);
> 
>  	/* Register the MAC address. */
> -	ret = rte_eth_dev_mac_addr_add(ports[0], &vdev->mac_address,
> (uint32_t)dev->device_fh);
> +	ret = rte_eth_dev_mac_addr_add(ports[0], &vdev->mac_address,
> +				(uint32_t)dev->device_fh +
> vmdq_pool_base);
>  	if (ret)
>  		RTE_LOG(ERR, VHOST_DATA, "(%"PRIu64") Failed to add
> device MAC address to VMDQ\n",
>  					dev->device_fh);
> @@ -2602,7 +2614,7 @@ new_device (struct virtio_net *dev)
>  	ll_dev->vdev = vdev;
>  	add_data_ll_entry(&ll_root_used, ll_dev);
>  	vdev->vmdq_rx_q
> -		= dev->device_fh * (num_queues / num_devices);
> +		= dev->device_fh * queues_per_pool + vmdq_queue_base;
> 
>  	if (zero_copy) {
>  		uint32_t index = vdev->vmdq_rx_q;
> @@ -2837,7 +2849,8 @@ MAIN(int argc, char *argv[])
>  	unsigned lcore_id, core_id = 0;
>  	unsigned nb_ports, valid_num_ports;
>  	int ret;
> -	uint8_t portid, queue_id = 0;
> +	uint8_t portid;
> +	uint16_t queue_id;

If max queue is 256, and queue_id vary from 0 to 255, then uint8_t is enough to denote it.
Any other consideration here to change it to uint16_t?

>  	static pthread_t tid;
> 
>  	/* init EAL */
> --
> 1.8.1.4
Huawei Xie Nov. 13, 2014, 1:20 a.m. UTC | #2
> -----Original Message-----
> From: Ouyang, Changchun
> Sent: Wednesday, November 12, 2014 5:50 PM
> To: Xie, Huawei; dev@dpdk.org
> Cc: Ouyang, Changchun
> Subject: RE: [dpdk-dev] [PATCH 1/2] examples/vhost: support new VMDQ API
> and new nic i40e
> 
> 
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Huawei Xie
> > Sent: Thursday, November 13, 2014 6:34 AM
> > To: dev@dpdk.org
> > Subject: [dpdk-dev] [PATCH 1/2] examples/vhost: support new VMDQ API
> > and new nic i40e
> >
> > In Niantic, if VMDQ mode is set, all queues are allocated to VMDQ in DPDK.
> > In I40E, only configured part of continous queues are allocated to VMDQ.
> > The rte_eth_dev_info structure is extened to provide VMDQ queue base,
> > queue number, and VMDQ pool base information.
> > This patch support the new VMDQ API in vhost example.
> >
> > FIXME in PMD:
> >  * added mac address will be flushed at rte_eth_dev_start.
> >  * we don't support selectively setting up queues well.
> >
> > Signed-off-by: Huawei Xie <huawei.xie@intel.com>
> > ---
> >  examples/vhost/main.c | 25 +++++++++++++++++++------
> >  1 file changed, 19 insertions(+), 6 deletions(-)
> >
> > diff --git a/examples/vhost/main.c b/examples/vhost/main.c index
> > a93f7a0..2b1bf02 100644
> > --- a/examples/vhost/main.c
> > +++ b/examples/vhost/main.c
> > @@ -53,7 +53,7 @@
> >
> >  #include "main.h"
> >
> > -#define MAX_QUEUES 128
> > +#define MAX_QUEUES 256
> >
> >  /* the maximum number of external ports supported */  #define
> > MAX_SUP_PORTS 1 @@ -282,6 +282,9 @@ static struct rte_eth_conf
> > vmdq_conf_default = {  static unsigned lcore_ids[RTE_MAX_LCORE];  static
> > uint8_t ports[RTE_MAX_ETHPORTS];  static unsigned num_ports = 0; /**<
> > The number of ports specified in command line */
> > +static uint16_t num_pf_queues, num_vmdq_queues; static uint16_t
> > +vmdq_pool_base, vmdq_queue_base; static uint16_t queues_per_pool;
> >
> >  static const uint16_t external_pkt_default_vlan_tag = 2000;  const uint16_t
> > vlan_tags[] = { @@ -417,7 +420,6 @@ port_init(uint8_t port)
> >
> >  	/*configure the number of supported virtio devices based on VMDQ
> > limits */
> >  	num_devices = dev_info.max_vmdq_pools;
> > -	num_queues = dev_info.max_rx_queues;
> >
> >  	if (zero_copy) {
> >  		rx_ring_size = num_rx_descriptor;
> > @@ -437,10 +439,19 @@ port_init(uint8_t port)
> >  	retval = get_eth_conf(&port_conf, num_devices);
> >  	if (retval < 0)
> >  		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;
> > +	num_vmdq_queues = num_devices * queues_per_pool;
> > +	num_queues = num_pf_queues + num_vmdq_queues;
> > +	vmdq_queue_base = dev_info.vmdq_queue_base;
> > +	vmdq_pool_base  = dev_info.vmdq_pool_base;
> > +	printf("pf queue num: %u, configured vmdq pool num: %u, each
> > vmdq pool has %u queues\n",
> > +		num_pf_queues, num_devices, queues_per_pool);
> >
> 
> Better to use RTE_LOG to replace printf.
> 
> >  	if (port >= rte_eth_dev_count()) return -1;
> >
> > -	rx_rings = (uint16_t)num_queues,
> > +	rx_rings = (uint16_t)dev_info.max_rx_queues;
> >  	/* Configure ethernet device. */
> >  	retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
> >  	if (retval != 0)
> > @@ -931,7 +942,8 @@ link_vmdq(struct vhost_dev *vdev, struct rte_mbuf
> > *m)
> >  		vdev->vlan_tag);
> >
> >  	/* Register the MAC address. */
> > -	ret = rte_eth_dev_mac_addr_add(ports[0], &vdev->mac_address,
> > (uint32_t)dev->device_fh);
> > +	ret = rte_eth_dev_mac_addr_add(ports[0], &vdev->mac_address,
> > +				(uint32_t)dev->device_fh +
> > vmdq_pool_base);
> >  	if (ret)
> >  		RTE_LOG(ERR, VHOST_DATA, "(%"PRIu64") Failed to add
> > device MAC address to VMDQ\n",
> >  					dev->device_fh);
> > @@ -2602,7 +2614,7 @@ new_device (struct virtio_net *dev)
> >  	ll_dev->vdev = vdev;
> >  	add_data_ll_entry(&ll_root_used, ll_dev);
> >  	vdev->vmdq_rx_q
> > -		= dev->device_fh * (num_queues / num_devices);
> > +		= dev->device_fh * queues_per_pool + vmdq_queue_base;
> >
> >  	if (zero_copy) {
> >  		uint32_t index = vdev->vmdq_rx_q;
> > @@ -2837,7 +2849,8 @@ MAIN(int argc, char *argv[])
> >  	unsigned lcore_id, core_id = 0;
> >  	unsigned nb_ports, valid_num_ports;
> >  	int ret;
> > -	uint8_t portid, queue_id = 0;
> > +	uint8_t portid;
> > +	uint16_t queue_id;
> 
> If max queue is 256, and queue_id vary from 0 to 255, then uint8_t is enough to
> denote it.
> Any other consideration here to change it to uint16_t?
queue_id is compared with MAX_QUEUE + 1 which will be always false.
check the patch, I couldn't copy the code to here.
> 
> >  	static pthread_t tid;
> >
> >  	/* init EAL */
> > --
> > 1.8.1.4
Chen, Jing D Nov. 13, 2014, 5:58 a.m. UTC | #3
Hi,

> -----Original Message-----
> From: Xie, Huawei
> Sent: Thursday, November 13, 2014 6:34 AM
> To: dev@dpdk.org
> Cc: Chen, Jing D; Xie, Huawei
> Subject: [PATCH 1/2] examples/vhost: support new VMDQ API and new nic
> i40e
> 
> In Niantic, if VMDQ mode is set, all queues are allocated to VMDQ in DPDK.
> In I40E, only configured part of continous queues are allocated to VMDQ.
> The rte_eth_dev_info structure is extened to provide VMDQ queue base,
> queue number, and VMDQ pool base information.
> This patch support the new VMDQ API in vhost example.
> 
> FIXME in PMD:
>  * added mac address will be flushed at rte_eth_dev_start.
>  * we don't support selectively setting up queues well.
> 
> Signed-off-by: Huawei Xie <huawei.xie@intel.com>
> ---
>  examples/vhost/main.c | 25 +++++++++++++++++++------
>  1 file changed, 19 insertions(+), 6 deletions(-)
> 
> diff --git a/examples/vhost/main.c b/examples/vhost/main.c
> index a93f7a0..2b1bf02 100644
> --- a/examples/vhost/main.c
> +++ b/examples/vhost/main.c
> @@ -53,7 +53,7 @@
> 
>  #include "main.h"
> 
> -#define MAX_QUEUES 128
> +#define MAX_QUEUES 256
> 
>  /* the maximum number of external ports supported */
>  #define MAX_SUP_PORTS 1
> @@ -282,6 +282,9 @@ static struct rte_eth_conf vmdq_conf_default = {
>  static unsigned lcore_ids[RTE_MAX_LCORE];
>  static uint8_t ports[RTE_MAX_ETHPORTS];
>  static unsigned num_ports = 0; /**< The number of ports specified in
> command line */
> +static uint16_t num_pf_queues, num_vmdq_queues;
> +static uint16_t vmdq_pool_base, vmdq_queue_base;
> +static uint16_t queues_per_pool;
> 
>  static const uint16_t external_pkt_default_vlan_tag = 2000;
>  const uint16_t vlan_tags[] = {
> @@ -417,7 +420,6 @@ port_init(uint8_t port)
> 
>  	/*configure the number of supported virtio devices based on VMDQ
> limits */
>  	num_devices = dev_info.max_vmdq_pools;
> -	num_queues = dev_info.max_rx_queues;
> 
>  	if (zero_copy) {
>  		rx_ring_size = num_rx_descriptor;
> @@ -437,10 +439,19 @@ port_init(uint8_t port)
>  	retval = get_eth_conf(&port_conf, num_devices);
>  	if (retval < 0)
>  		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;
> +	num_vmdq_queues = num_devices * queues_per_pool;
> +	num_queues = num_pf_queues + num_vmdq_queues;
> +	vmdq_queue_base = dev_info.vmdq_queue_base;
> +	vmdq_pool_base  = dev_info.vmdq_pool_base;
> +	printf("pf queue num: %u, configured vmdq pool num: %u, each
> vmdq pool has %u queues\n",
> +		num_pf_queues, num_devices, queues_per_pool);
> 
>  	if (port >= rte_eth_dev_count()) return -1;
> 
> -	rx_rings = (uint16_t)num_queues,
> +	rx_rings = (uint16_t)dev_info.max_rx_queues;

You removed line 'num_queues = dev_info.max_rx_queues'  and calculate 'num_queues' 
with another equation. I assume you thought it may not equals.
So, why you assign dev_info.max_rx_queues to rx_rings again? Won't it better to use 'num_queues' 

>  	/* Configure ethernet device. */
>  	retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
>  	if (retval != 0)
> @@ -931,7 +942,8 @@ link_vmdq(struct vhost_dev *vdev, struct rte_mbuf
> *m)
>  		vdev->vlan_tag);
> 
>  	/* Register the MAC address. */
> -	ret = rte_eth_dev_mac_addr_add(ports[0], &vdev->mac_address,
> (uint32_t)dev->device_fh);
> +	ret = rte_eth_dev_mac_addr_add(ports[0], &vdev->mac_address,
> +				(uint32_t)dev->device_fh +
> vmdq_pool_base);
>  	if (ret)
>  		RTE_LOG(ERR, VHOST_DATA, "(%"PRIu64") Failed to add
> device MAC address to VMDQ\n",
>  					dev->device_fh);
> @@ -2602,7 +2614,7 @@ new_device (struct virtio_net *dev)
>  	ll_dev->vdev = vdev;
>  	add_data_ll_entry(&ll_root_used, ll_dev);
>  	vdev->vmdq_rx_q
> -		= dev->device_fh * (num_queues / num_devices);
> +		= dev->device_fh * queues_per_pool + vmdq_queue_base;
> 
>  	if (zero_copy) {
>  		uint32_t index = vdev->vmdq_rx_q;
> @@ -2837,7 +2849,8 @@ MAIN(int argc, char *argv[])
>  	unsigned lcore_id, core_id = 0;
>  	unsigned nb_ports, valid_num_ports;
>  	int ret;
> -	uint8_t portid, queue_id = 0;
> +	uint8_t portid;
> +	uint16_t queue_id;
>  	static pthread_t tid;
> 
>  	/* init EAL */
> --
> 1.8.1.4
Huawei Xie Nov. 14, 2014, 6:30 a.m. UTC | #4
> -----Original Message-----
> From: Chen, Jing D
> Sent: Wednesday, November 12, 2014 10:58 PM
> To: Xie, Huawei; dev@dpdk.org
> Subject: RE: [PATCH 1/2] examples/vhost: support new VMDQ API and new nic
> i40e
> 
> Hi,
> 
> > -----Original Message-----
> > From: Xie, Huawei
> > Sent: Thursday, November 13, 2014 6:34 AM
> > To: dev@dpdk.org
> > Cc: Chen, Jing D; Xie, Huawei
> > Subject: [PATCH 1/2] examples/vhost: support new VMDQ API and new nic
> > i40e
> >
> > In Niantic, if VMDQ mode is set, all queues are allocated to VMDQ in DPDK.
> > In I40E, only configured part of continous queues are allocated to VMDQ.
> > The rte_eth_dev_info structure is extened to provide VMDQ queue base,
> > queue number, and VMDQ pool base information.
> > This patch support the new VMDQ API in vhost example.
> >
> > FIXME in PMD:
> >  * added mac address will be flushed at rte_eth_dev_start.
> >  * we don't support selectively setting up queues well.
> >
> > Signed-off-by: Huawei Xie <huawei.xie@intel.com>
> > ---
> >  examples/vhost/main.c | 25 +++++++++++++++++++------
> >  1 file changed, 19 insertions(+), 6 deletions(-)
> >
> > diff --git a/examples/vhost/main.c b/examples/vhost/main.c
> > index a93f7a0..2b1bf02 100644
> > --- a/examples/vhost/main.c
> > +++ b/examples/vhost/main.c
> > @@ -53,7 +53,7 @@
> >
> >  #include "main.h"
> >
> > -#define MAX_QUEUES 128
> > +#define MAX_QUEUES 256
> >
> >  /* the maximum number of external ports supported */
> >  #define MAX_SUP_PORTS 1
> > @@ -282,6 +282,9 @@ static struct rte_eth_conf vmdq_conf_default = {
> >  static unsigned lcore_ids[RTE_MAX_LCORE];
> >  static uint8_t ports[RTE_MAX_ETHPORTS];
> >  static unsigned num_ports = 0; /**< The number of ports specified in
> > command line */
> > +static uint16_t num_pf_queues, num_vmdq_queues;
> > +static uint16_t vmdq_pool_base, vmdq_queue_base;
> > +static uint16_t queues_per_pool;
> >
> >  static const uint16_t external_pkt_default_vlan_tag = 2000;
> >  const uint16_t vlan_tags[] = {
> > @@ -417,7 +420,6 @@ port_init(uint8_t port)
> >
> >  	/*configure the number of supported virtio devices based on VMDQ
> > limits */
> >  	num_devices = dev_info.max_vmdq_pools;
> > -	num_queues = dev_info.max_rx_queues;
> >
> >  	if (zero_copy) {
> >  		rx_ring_size = num_rx_descriptor;
> > @@ -437,10 +439,19 @@ port_init(uint8_t port)
> >  	retval = get_eth_conf(&port_conf, num_devices);
> >  	if (retval < 0)
> >  		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;
> > +	num_vmdq_queues = num_devices * queues_per_pool;
> > +	num_queues = num_pf_queues + num_vmdq_queues;
> > +	vmdq_queue_base = dev_info.vmdq_queue_base;
> > +	vmdq_pool_base  = dev_info.vmdq_pool_base;
> > +	printf("pf queue num: %u, configured vmdq pool num: %u, each
> > vmdq pool has %u queues\n",
> > +		num_pf_queues, num_devices, queues_per_pool);
> >
> >  	if (port >= rte_eth_dev_count()) return -1;
> >
> > -	rx_rings = (uint16_t)num_queues,
> > +	rx_rings = (uint16_t)dev_info.max_rx_queues;
> 
> You removed line 'num_queues = dev_info.max_rx_queues'  and calculate
> 'num_queues'
> with another equation. I assume you thought it may not equals.
> So, why you assign dev_info.max_rx_queues to rx_rings again? Won't it better to
> use 'num_queues'

Actually they are the same here.
We use max_rx_queues just to say that we initialize all queues rather than part of
queues.
If all PMDs(1G,10G,i40e) supports selectively initializing queues, then we could only initialize
num_device queues rather than total queues, even without initializing PF queues..
> 
> >  	/* Configure ethernet device. */
> >  	retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
> >  	if (retval != 0)
> > @@ -931,7 +942,8 @@ link_vmdq(struct vhost_dev *vdev, struct rte_mbuf
> > *m)
> >  		vdev->vlan_tag);
> >
> >  	/* Register the MAC address. */
> > -	ret = rte_eth_dev_mac_addr_add(ports[0], &vdev->mac_address,
> > (uint32_t)dev->device_fh);
> > +	ret = rte_eth_dev_mac_addr_add(ports[0], &vdev->mac_address,
> > +				(uint32_t)dev->device_fh +
> > vmdq_pool_base);
> >  	if (ret)
> >  		RTE_LOG(ERR, VHOST_DATA, "(%"PRIu64") Failed to add
> > device MAC address to VMDQ\n",
> >  					dev->device_fh);
> > @@ -2602,7 +2614,7 @@ new_device (struct virtio_net *dev)
> >  	ll_dev->vdev = vdev;
> >  	add_data_ll_entry(&ll_root_used, ll_dev);
> >  	vdev->vmdq_rx_q
> > -		= dev->device_fh * (num_queues / num_devices);
> > +		= dev->device_fh * queues_per_pool + vmdq_queue_base;
> >
> >  	if (zero_copy) {
> >  		uint32_t index = vdev->vmdq_rx_q;
> > @@ -2837,7 +2849,8 @@ MAIN(int argc, char *argv[])
> >  	unsigned lcore_id, core_id = 0;
> >  	unsigned nb_ports, valid_num_ports;
> >  	int ret;
> > -	uint8_t portid, queue_id = 0;
> > +	uint8_t portid;
> > +	uint16_t queue_id;
> >  	static pthread_t tid;
> >
> >  	/* init EAL */
> > --
> > 1.8.1.4
Chen, Jing D Nov. 14, 2014, 7:24 a.m. UTC | #5
> -----Original Message-----
> From: Xie, Huawei
> Sent: Friday, November 14, 2014 2:31 PM
> To: Chen, Jing D; dev@dpdk.org
> Subject: RE: [PATCH 1/2] examples/vhost: support new VMDQ API and new
> nic i40e
> 
> 
> 
> > -----Original Message-----
> > From: Chen, Jing D
> > Sent: Wednesday, November 12, 2014 10:58 PM
> > To: Xie, Huawei; dev@dpdk.org
> > Subject: RE: [PATCH 1/2] examples/vhost: support new VMDQ API and
> new nic
> > i40e
> >
> > Hi,
> >
> > > -----Original Message-----
> > > From: Xie, Huawei
> > > Sent: Thursday, November 13, 2014 6:34 AM
> > > To: dev@dpdk.org
> > > Cc: Chen, Jing D; Xie, Huawei
> > > Subject: [PATCH 1/2] examples/vhost: support new VMDQ API and new
> nic
> > > i40e
> > >
> > > In Niantic, if VMDQ mode is set, all queues are allocated to VMDQ in
> DPDK.
> > > In I40E, only configured part of continous queues are allocated to VMDQ.
> > > The rte_eth_dev_info structure is extened to provide VMDQ queue base,
> > > queue number, and VMDQ pool base information.
> > > This patch support the new VMDQ API in vhost example.
> > >
> > > FIXME in PMD:
> > >  * added mac address will be flushed at rte_eth_dev_start.
> > >  * we don't support selectively setting up queues well.
> > >
> > > Signed-off-by: Huawei Xie <huawei.xie@intel.com>
> > > ---
> > >  examples/vhost/main.c | 25 +++++++++++++++++++------
> > >  1 file changed, 19 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/examples/vhost/main.c b/examples/vhost/main.c
> > > index a93f7a0..2b1bf02 100644
> > > --- a/examples/vhost/main.c
> > > +++ b/examples/vhost/main.c
> > > @@ -53,7 +53,7 @@
> > >
> > >  #include "main.h"
> > >
> > > -#define MAX_QUEUES 128
> > > +#define MAX_QUEUES 256
> > >
> > >  /* the maximum number of external ports supported */
> > >  #define MAX_SUP_PORTS 1
> > > @@ -282,6 +282,9 @@ static struct rte_eth_conf vmdq_conf_default = {
> > >  static unsigned lcore_ids[RTE_MAX_LCORE];
> > >  static uint8_t ports[RTE_MAX_ETHPORTS];
> > >  static unsigned num_ports = 0; /**< The number of ports specified in
> > > command line */
> > > +static uint16_t num_pf_queues, num_vmdq_queues;
> > > +static uint16_t vmdq_pool_base, vmdq_queue_base;
> > > +static uint16_t queues_per_pool;
> > >
> > >  static const uint16_t external_pkt_default_vlan_tag = 2000;
> > >  const uint16_t vlan_tags[] = {
> > > @@ -417,7 +420,6 @@ port_init(uint8_t port)
> > >
> > >  	/*configure the number of supported virtio devices based on VMDQ
> > > limits */
> > >  	num_devices = dev_info.max_vmdq_pools;
> > > -	num_queues = dev_info.max_rx_queues;
> > >
> > >  	if (zero_copy) {
> > >  		rx_ring_size = num_rx_descriptor;
> > > @@ -437,10 +439,19 @@ port_init(uint8_t port)
> > >  	retval = get_eth_conf(&port_conf, num_devices);
> > >  	if (retval < 0)
> > >  		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;
> > > +	num_vmdq_queues = num_devices * queues_per_pool;
> > > +	num_queues = num_pf_queues + num_vmdq_queues;
> > > +	vmdq_queue_base = dev_info.vmdq_queue_base;
> > > +	vmdq_pool_base  = dev_info.vmdq_pool_base;
> > > +	printf("pf queue num: %u, configured vmdq pool num: %u, each
> > > vmdq pool has %u queues\n",
> > > +		num_pf_queues, num_devices, queues_per_pool);
> > >
> > >  	if (port >= rte_eth_dev_count()) return -1;
> > >
> > > -	rx_rings = (uint16_t)num_queues,
> > > +	rx_rings = (uint16_t)dev_info.max_rx_queues;
> >
> > You removed line 'num_queues = dev_info.max_rx_queues'  and calculate
> > 'num_queues'
> > with another equation. I assume you thought it may not equals.
> > So, why you assign dev_info.max_rx_queues to rx_rings again? Won't it
> better to
> > use 'num_queues'
> 
> Actually they are the same here.
> We use max_rx_queues just to say that we initialize all queues rather than
> part of
> queues.
> If all PMDs(1G,10G,i40e) supports selectively initializing queues, then we
> could only initialize
> num_device queues rather than total queues, even without initializing PF
> queues..
> >
> > >  	/* Configure ethernet device. */
> > >  	retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
> > >  	if (retval != 0)
> > > @@ -931,7 +942,8 @@ link_vmdq(struct vhost_dev *vdev, struct
> rte_mbuf
> > > *m)
> > >  		vdev->vlan_tag);
> > >
> > >  	/* Register the MAC address. */
> > > -	ret = rte_eth_dev_mac_addr_add(ports[0], &vdev->mac_address,
> > > (uint32_t)dev->device_fh);
> > > +	ret = rte_eth_dev_mac_addr_add(ports[0], &vdev->mac_address,
> > > +				(uint32_t)dev->device_fh +
> > > vmdq_pool_base);
> > >  	if (ret)
> > >  		RTE_LOG(ERR, VHOST_DATA, "(%"PRIu64") Failed to add
> > > device MAC address to VMDQ\n",
> > >  					dev->device_fh);
> > > @@ -2602,7 +2614,7 @@ new_device (struct virtio_net *dev)
> > >  	ll_dev->vdev = vdev;
> > >  	add_data_ll_entry(&ll_root_used, ll_dev);
> > >  	vdev->vmdq_rx_q
> > > -		= dev->device_fh * (num_queues / num_devices);
> > > +		= dev->device_fh * queues_per_pool + vmdq_queue_base;
> > >
> > >  	if (zero_copy) {
> > >  		uint32_t index = vdev->vmdq_rx_q;
> > > @@ -2837,7 +2849,8 @@ MAIN(int argc, char *argv[])
> > >  	unsigned lcore_id, core_id = 0;
> > >  	unsigned nb_ports, valid_num_ports;
> > >  	int ret;
> > > -	uint8_t portid, queue_id = 0;
> > > +	uint8_t portid;
> > > +	uint16_t queue_id;
> > >  	static pthread_t tid;
> > >
> > >  	/* init EAL */
> > > --
> > > 1.8.1.4

Acked-by : Jing Chen <jing.d.chen@intel.com>
diff mbox

Patch

diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index a93f7a0..2b1bf02 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -53,7 +53,7 @@ 
 
 #include "main.h"
 
-#define MAX_QUEUES 128
+#define MAX_QUEUES 256
 
 /* the maximum number of external ports supported */
 #define MAX_SUP_PORTS 1
@@ -282,6 +282,9 @@  static struct rte_eth_conf vmdq_conf_default = {
 static unsigned lcore_ids[RTE_MAX_LCORE];
 static uint8_t ports[RTE_MAX_ETHPORTS];
 static unsigned num_ports = 0; /**< The number of ports specified in command line */
+static uint16_t num_pf_queues, num_vmdq_queues;
+static uint16_t vmdq_pool_base, vmdq_queue_base;
+static uint16_t queues_per_pool;
 
 static const uint16_t external_pkt_default_vlan_tag = 2000;
 const uint16_t vlan_tags[] = {
@@ -417,7 +420,6 @@  port_init(uint8_t port)
 
 	/*configure the number of supported virtio devices based on VMDQ limits */
 	num_devices = dev_info.max_vmdq_pools;
-	num_queues = dev_info.max_rx_queues;
 
 	if (zero_copy) {
 		rx_ring_size = num_rx_descriptor;
@@ -437,10 +439,19 @@  port_init(uint8_t port)
 	retval = get_eth_conf(&port_conf, num_devices);
 	if (retval < 0)
 		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;
+	num_vmdq_queues = num_devices * queues_per_pool;
+	num_queues = num_pf_queues + num_vmdq_queues;
+	vmdq_queue_base = dev_info.vmdq_queue_base;
+	vmdq_pool_base  = dev_info.vmdq_pool_base;
+	printf("pf queue num: %u, configured vmdq pool num: %u, each vmdq pool has %u queues\n",
+		num_pf_queues, num_devices, queues_per_pool);
 
 	if (port >= rte_eth_dev_count()) return -1;
 
-	rx_rings = (uint16_t)num_queues,
+	rx_rings = (uint16_t)dev_info.max_rx_queues;
 	/* Configure ethernet device. */
 	retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
 	if (retval != 0)
@@ -931,7 +942,8 @@  link_vmdq(struct vhost_dev *vdev, struct rte_mbuf *m)
 		vdev->vlan_tag);
 
 	/* Register the MAC address. */
-	ret = rte_eth_dev_mac_addr_add(ports[0], &vdev->mac_address, (uint32_t)dev->device_fh);
+	ret = rte_eth_dev_mac_addr_add(ports[0], &vdev->mac_address,
+				(uint32_t)dev->device_fh + vmdq_pool_base);
 	if (ret)
 		RTE_LOG(ERR, VHOST_DATA, "(%"PRIu64") Failed to add device MAC address to VMDQ\n",
 					dev->device_fh);
@@ -2602,7 +2614,7 @@  new_device (struct virtio_net *dev)
 	ll_dev->vdev = vdev;
 	add_data_ll_entry(&ll_root_used, ll_dev);
 	vdev->vmdq_rx_q
-		= dev->device_fh * (num_queues / num_devices);
+		= dev->device_fh * queues_per_pool + vmdq_queue_base;
 
 	if (zero_copy) {
 		uint32_t index = vdev->vmdq_rx_q;
@@ -2837,7 +2849,8 @@  MAIN(int argc, char *argv[])
 	unsigned lcore_id, core_id = 0;
 	unsigned nb_ports, valid_num_ports;
 	int ret;
-	uint8_t portid, queue_id = 0;
+	uint8_t portid;
+	uint16_t queue_id;
 	static pthread_t tid;
 
 	/* init EAL */