From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qc0-f171.google.com (mail-qc0-f171.google.com [209.85.216.171]) by dpdk.org (Postfix) with ESMTP id 04C29C310 for ; Thu, 11 Jun 2015 17:53:35 +0200 (CEST) Received: by qcnj1 with SMTP id j1so3251797qcn.0 for ; Thu, 11 Jun 2015 08:53:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LJ5A0ahAZuWS6bDwzi6V9WDVTw4fgVT8d+9R6zY/iGE=; b=CLC9MNKdnX9r2MiuLp4uEMtXv1bapXShEgf9sBAd6JSZzkzNYnJixSwbIhihZwdM74 Ch15H64BMjjY/rUpj7zlzKxEx9zZtjCsujNpCNRQe0ZGwl6M62asDPSTHMs+8+HXAE1S Kjwm/A0EAZY9trqKzgkKTrl85Sdsin9ZXBEYwarvdU1ae5BuFVZBpB61ufazEOFQjR4g K6vYmVWAuOUi2ras1sePnhaWd77PqeNZBokQevVcKqz6gxNo1f731R3bpOezpn8wxUcf 3uoNec04J5/w4RgVDGxbcg59QSZnQajYdeKA1iUBLxZ0KrbYqvRp+HGBOYmZM53odo/5 47LQ== X-Gm-Message-State: ALoCoQn5xTTVV6lxJL9TryEAChJHM0E4CAGZOy3rPlTkBR+5+dhbbDDvC6XW7quI9S8sjNsHE2lk X-Received: by 10.55.24.74 with SMTP id j71mr20299635qkh.48.1434038014594; Thu, 11 Jun 2015 08:53:34 -0700 (PDT) Received: from urahara.home.lan (static-50-53-82-155.bvtn.or.frontiernet.net. [50.53.82.155]) by mx.google.com with ESMTPSA id v13sm405348qhd.31.2015.06.11.08.53.33 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Jun 2015 08:53:34 -0700 (PDT) From: Stephen Hemminger To: changchun.ouyang@intel.com Date: Thu, 11 Jun 2015 08:53:27 -0700 Message-Id: <1434038007-8964-6-git-send-email-stephen@networkplumber.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1434038007-8964-1-git-send-email-stephen@networkplumber.org> References: <1434038007-8964-1-git-send-email-stephen@networkplumber.org> Cc: dev@dpdk.org, Stephen Hemminger Subject: [dpdk-dev] [PATCH 5/5] virtio: fix ring size negotiation 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: Thu, 11 Jun 2015 15:53:35 -0000 From: Stephen Hemminger Negotate the virtio ring size. The host may allow for very large rings but application may only want a smaller ring. Conversely, if the number of descriptors requested exceeds the virtio host queue size, then just silently use the smaller host size. This fixes issues with virtio in non-QEMU envirionments. For example Google Compute Engine allows up to 16K elements in ring. Signed-off-by: Stephen Hemminger --- drivers/net/virtio/virtio_ethdev.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 2afa371..befd0bc 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -267,13 +267,21 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev, if (vq_size == 0) { PMD_INIT_LOG(ERR, "%s: virtqueue does not exist", __func__); return -EINVAL; - } else if (!rte_is_power_of_2(vq_size)) { + } + + if (!rte_is_power_of_2(vq_size)) { PMD_INIT_LOG(ERR, "%s: virtqueue size is not powerof 2", __func__); return -EINVAL; - } else if (nb_desc != vq_size) { - PMD_INIT_LOG(ERR, "Warning: nb_desc(%d) is not equal to vq size (%d), fall to vq size", - nb_desc, vq_size); - nb_desc = vq_size; + } + + if (nb_desc < vq_size) { + if (!rte_is_power_of_2(nb_desc)) { + PMD_INIT_LOG(ERR, + "nb_desc(%u) size is not powerof 2", + nb_desc); + return -EINVAL; + } + vq_size = nb_desc; } if (queue_type == VTNET_RQ) { -- 2.1.4