From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f177.google.com (mail-pd0-f177.google.com [209.85.192.177]) by dpdk.org (Postfix) with ESMTP id 8B363568A for ; Mon, 20 Jul 2015 19:25:00 +0200 (CEST) Received: by pdrg1 with SMTP id g1so104621846pdr.2 for ; Mon, 20 Jul 2015 10:25:00 -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=v7GCnt7OepBZCrTaAuzUMsierq5piI7TyHQR0uJKOYE=; b=jK/Yr4rcrcl5/fHZgUtTliCLv7HMu8wxic0n8jYQC6sv4Jt6deDIJyyOYSoIUJTFSC Z0ngHns+QtgEXUaQNon3zy1qoU7LetNcWvRCjJZlQCPup8nxuVAC+2e1NIC/HmktsuvG TSYbjl5E4IiPyx8WZlpEZ2F9K74vV1yu42xGoyBYwkGHo8GbqElz9mbL1Zqj/U/g1E8B 5sSsjlTyteOutFsx3a4PbYtm2+0uXpOiykosPK9nDOWwFpzKRuwhjL8ggAPG4dVC+kgd sMrHI8MtzKSK9ChS92yZWmLSJ7s4Fr1UHEKzT/Ho2E1k0/plAuPggIK3yEPLBMrvGqlU jh1g== X-Gm-Message-State: ALoCoQngoc72ZoNihZ5j82H4ah3/hReJ3W/aw4oMCq/vsiL0N96zw3Zm/0dmpOgmEOn0I35zk6AD X-Received: by 10.66.230.201 with SMTP id ta9mr2702074pac.95.1437413099993; Mon, 20 Jul 2015 10:24:59 -0700 (PDT) Received: from urahara.home.lan (static-50-53-82-155.bvtn.or.frontiernet.net. [50.53.82.155]) by smtp.gmail.com with ESMTPSA id fv5sm22906763pdb.19.2015.07.20.10.24.58 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 Jul 2015 10:24:59 -0700 (PDT) From: Stephen Hemminger To: changchun.ouyang@intel.com Date: Mon, 20 Jul 2015 10:25:04 -0700 Message-Id: <1437413106-16069-2-git-send-email-stephen@networkplumber.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1437413106-16069-1-git-send-email-stephen@networkplumber.org> References: <1437413106-16069-1-git-send-email-stephen@networkplumber.org> Cc: dev@dpdk.org Subject: [dpdk-dev] [PATCH v2 1/3] virtio: fix the vq size issue 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: Mon, 20 Jul 2015 17:25:01 -0000 From: Ouyang Changchun This commit breaks virtio basic packets rx functionality: d78deadae4dca240e85054bf2d604a801676becc The QEMU use 256 as default vring size, also use this default value to calculate the virtio avail ring base address and used ring base address, and vhost in the backend use the ring base address to do packet IO. Virtio spec also says the queue size in PCI configuration is read-only, so virtio front end can't change it. just need use the read-only value to allocate space for vring and calculate the avail and used ring base address. Otherwise, the avail and used ring base address will be different between host and guest, accordingly, packet IO can't work normally. Signed-off-by: Changchun Ouyang Acked-by: Stephen Hemminger --- drivers/net/virtio/virtio_ethdev.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 9ca9bb2..94b7a81 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -276,8 +276,6 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev, */ vq_size = VIRTIO_READ_REG_2(hw, VIRTIO_PCI_QUEUE_NUM); PMD_INIT_LOG(DEBUG, "vq_size: %d nb_desc:%d", vq_size, nb_desc); - if (nb_desc == 0) - nb_desc = vq_size; if (vq_size == 0) { PMD_INIT_LOG(ERR, "%s: virtqueue does not exist", __func__); return -EINVAL; @@ -288,15 +286,9 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev, return -EINVAL; } - 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 (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); if (queue_type == VTNET_RQ) { snprintf(vq_name, sizeof(vq_name), "port%d_rvq%d", -- 2.1.4