From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <changchun.ouyang@intel.com>
Received: from mga11.intel.com (mga11.intel.com [192.55.52.93])
 by dpdk.org (Postfix) with ESMTP id 35DFC594F
 for <dev@dpdk.org>; Thu, 13 Nov 2014 01:40:40 +0100 (CET)
Received: from fmsmga001.fm.intel.com ([10.253.24.23])
 by fmsmga102.fm.intel.com with ESMTP; 12 Nov 2014 16:50:34 -0800
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.07,372,1413270000"; d="scan'208";a="621528521"
Received: from pgsmsx101.gar.corp.intel.com ([10.221.44.78])
 by fmsmga001.fm.intel.com with ESMTP; 12 Nov 2014 16:49:43 -0800
Received: from pgsmsx106.gar.corp.intel.com (10.221.44.98) by
 PGSMSX101.gar.corp.intel.com (10.221.44.78) with Microsoft SMTP Server (TLS)
 id 14.3.195.1; Thu, 13 Nov 2014 08:49:39 +0800
Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by
 pgsmsx106.gar.corp.intel.com (10.221.44.98) with Microsoft SMTP Server (TLS)
 id 14.3.195.1; Thu, 13 Nov 2014 08:49:39 +0800
Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.216]) by
 SHSMSX152.ccr.corp.intel.com ([169.254.6.5]) with mapi id 14.03.0195.001;
 Thu, 13 Nov 2014 08:49:38 +0800
From: "Ouyang, Changchun" <changchun.ouyang@intel.com>
To: "Xie, Huawei" <huawei.xie@intel.com>, "dev@dpdk.org" <dev@dpdk.org>
Thread-Topic: [dpdk-dev] [PATCH 1/2] examples/vhost: support new VMDQ API
 and new	nic i40e
Thread-Index: AQHP/sny/ZivKXL9GE6LtRYyiw1pVpxduVFw
Date: Thu, 13 Nov 2014 00:49:37 +0000
Message-ID: <F52918179C57134FAEC9EA62FA2F96251189F32D@shsmsx102.ccr.corp.intel.com>
References: <1415831647-11139-1-git-send-email-huawei.xie@intel.com>
 <1415831647-11139-2-git-send-email-huawei.xie@intel.com>
In-Reply-To: <1415831647-11139-2-git-send-email-huawei.xie@intel.com>
Accept-Language: zh-CN, en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-originating-ip: [10.239.127.40]
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
Subject: Re: [dpdk-dev] [PATCH 1/2] examples/vhost: support new VMDQ API and
 new	nic i40e
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Thu, 13 Nov 2014 00:40:42 -0000



> -----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
>=20
> 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.
>=20
> FIXME in PMD:
>  * added mac address will be flushed at rte_eth_dev_start.
>  * we don't support selectively setting up queues well.
>=20
> Signed-off-by: Huawei Xie <huawei.xie@intel.com>
> ---
>  examples/vhost/main.c | 25 +++++++++++++++++++------
>  1 file changed, 19 insertions(+), 6 deletions(-)
>=20
> 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 @@
>=20
>  #include "main.h"
>=20
> -#define MAX_QUEUES 128
> +#define MAX_QUEUES 256
>=20
>  /* the maximum number of external ports supported */  #define
> MAX_SUP_PORTS 1 @@ -282,6 +282,9 @@ static struct rte_eth_conf
> vmdq_conf_default =3D {  static unsigned lcore_ids[RTE_MAX_LCORE];  stati=
c
> uint8_t ports[RTE_MAX_ETHPORTS];  static unsigned num_ports =3D 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;
>=20
>  static const uint16_t external_pkt_default_vlan_tag =3D 2000;  const uin=
t16_t
> vlan_tags[] =3D { @@ -417,7 +420,6 @@ port_init(uint8_t port)
>=20
>  	/*configure the number of supported virtio devices based on VMDQ
> limits */
>  	num_devices =3D dev_info.max_vmdq_pools;
> -	num_queues =3D dev_info.max_rx_queues;
>=20
>  	if (zero_copy) {
>  		rx_ring_size =3D num_rx_descriptor;
> @@ -437,10 +439,19 @@ port_init(uint8_t port)
>  	retval =3D 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 =3D dev_info.max_rx_queues -
> dev_info.vmdq_queue_num;
> +	queues_per_pool =3D dev_info.vmdq_queue_num /
> dev_info.max_vmdq_pools;
> +	num_vmdq_queues =3D num_devices * queues_per_pool;
> +	num_queues =3D num_pf_queues + num_vmdq_queues;
> +	vmdq_queue_base =3D dev_info.vmdq_queue_base;
> +	vmdq_pool_base  =3D 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.
=20
>  	if (port >=3D rte_eth_dev_count()) return -1;
>=20
> -	rx_rings =3D (uint16_t)num_queues,
> +	rx_rings =3D (uint16_t)dev_info.max_rx_queues;
>  	/* Configure ethernet device. */
>  	retval =3D rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
>  	if (retval !=3D 0)
> @@ -931,7 +942,8 @@ link_vmdq(struct vhost_dev *vdev, struct rte_mbuf
> *m)
>  		vdev->vlan_tag);
>=20
>  	/* Register the MAC address. */
> -	ret =3D rte_eth_dev_mac_addr_add(ports[0], &vdev->mac_address,
> (uint32_t)dev->device_fh);
> +	ret =3D 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 =3D vdev;
>  	add_data_ll_entry(&ll_root_used, ll_dev);
>  	vdev->vmdq_rx_q
> -		=3D dev->device_fh * (num_queues / num_devices);
> +		=3D dev->device_fh * queues_per_pool + vmdq_queue_base;
>=20
>  	if (zero_copy) {
>  		uint32_t index =3D vdev->vmdq_rx_q;
> @@ -2837,7 +2849,8 @@ MAIN(int argc, char *argv[])
>  	unsigned lcore_id, core_id =3D 0;
>  	unsigned nb_ports, valid_num_ports;
>  	int ret;
> -	uint8_t portid, queue_id =3D 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 enoug=
h to denote it.
Any other consideration here to change it to uint16_t?

>  	static pthread_t tid;
>=20
>  	/* init EAL */
> --
> 1.8.1.4