From patchwork Sun Sep 28 03:21:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huawei Xie X-Patchwork-Id: 613 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 6B69D5929; Sun, 28 Sep 2014 05:14:49 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id B57C31F7 for ; Sun, 28 Sep 2014 05:14:47 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 27 Sep 2014 20:21:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,612,1406617200"; d="scan'208";a="606473199" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga002.fm.intel.com with ESMTP; 27 Sep 2014 20:21:15 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id s8S3LCrj027993; Sun, 28 Sep 2014 11:21:12 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id s8S3LA4u021015; Sun, 28 Sep 2014 11:21:12 +0800 Received: (from hxie5@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id s8S3LAK2021011; Sun, 28 Sep 2014 11:21:10 +0800 From: Huawei Xie To: dev@dpdk.org Date: Sun, 28 Sep 2014 11:21:06 +0800 Message-Id: <1411874466-20973-2-git-send-email-huawei.xie@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1411874466-20973-1-git-send-email-huawei.xie@intel.com> References: <1411874466-20973-1-git-send-email-huawei.xie@intel.com> Subject: [dpdk-dev] [PATCH] examples/vhost: support i40e in vhost example 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" i40e PMD divide queues among MAIN VSI and VMDQ VSI. The queue index and pool index doesn't start from zero. Get VMDQ queue base and pool base from rte_eth_dev_info_get. Currently we set up all queues including pf queues. If PMD supports, we could only set up queues we use. Signed-off-by: Huawei Xie --- examples/vhost/main.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/examples/vhost/main.c b/examples/vhost/main.c index 6569188..2dec252 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 @@ -281,6 +281,8 @@ 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, queues_per_pool; +static uint16_t vmdq_pool_base, vmdq_queue_base; static const uint16_t external_pkt_default_vlan_tag = 2000; const uint16_t vlan_tags[] = { @@ -411,7 +413,11 @@ port_init(uint8_t port) int retval; uint16_t q; - /* The max pool number from dev_info will be used to validate the pool number specified in cmd line */ + + /* + * The max pool number from dev_info will be used to + * validate the pool number specified in cmd line + */ rte_eth_dev_info_get (port, &dev_info); /*configure the number of supported virtio devices based on VMDQ limits */ @@ -436,10 +442,22 @@ 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)num_queues; + tx_rings += num_pf_queues; + /* Configure ethernet device. */ retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf); if (retval != 0) @@ -933,7 +951,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); @@ -2614,8 +2633,8 @@ 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); + vdev->vmdq_rx_q = vmdq_queue_base + + dev->device_fh * (num_queues / queues_per_pool); if (zero_copy) { uint32_t index = vdev->vmdq_rx_q; @@ -2852,7 +2871,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 = 0; static pthread_t tid; /* init EAL */