From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f54.google.com (mail-pa0-f54.google.com [209.85.220.54]) by dpdk.org (Postfix) with ESMTP id BE9758E7A for ; Wed, 19 Aug 2015 11:53:01 +0200 (CEST) Received: by pacgr6 with SMTP id gr6so154177774pac.2 for ; Wed, 19 Aug 2015 02:53:01 -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; bh=And2GCZlXjUL4Fxa7uHsWhIR6KfbvgfhK/9XsWL+LkU=; b=GvfLbvXoKn6++/ZstaHkrMJMxSTvYxAfuS8rYmU4f17K5sJ9CGTGybNbtcTDivqGuZ 1qUc/Xy4cicKQRDYU8comlpBH9d1STEvv+L1x5fLEjnDDGbwwcSkKiwfyK4wnCrEyaq6 bVadzQ7QLhNrBHspI0nkH48fbWMQfsb98RrwSP8Un13LlBw4YIX9YT2eTr3IHbu9Evln PxrAh5cl7d3a528qLgUh0DDvyFwCLJ0Dy8Q5yzqZgnWjAkWCfVzQ4AoyS1Plr5kwxngf PFsLRJUB2kQz3X+5VqqgF6en2F+B93KC0vFuxnrhhnSIlj5EqYwcn1rYAupKh2yQ1puL jpKQ== X-Gm-Message-State: ALoCoQmatt02PY669vNqEnQEq0quq3a0a4MVCfMhdKnDAUDNw4i5AQrsEnKNRewTdm2rC1TmUsLZ X-Received: by 10.66.249.101 with SMTP id yt5mr23063504pac.116.1439977981046; Wed, 19 Aug 2015 02:53:01 -0700 (PDT) Received: from localhost.localdomain (napt.igel.co.jp. [219.106.231.132]) by smtp.gmail.com with ESMTPSA id qe3sm212368pbc.73.2015.08.19.02.52.59 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Aug 2015 02:53:00 -0700 (PDT) From: Tetsuya Mukawa To: dev@dpdk.org Date: Wed, 19 Aug 2015 18:51:07 +0900 Message-Id: <1439977869-28091-1-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 2.1.4 Subject: [dpdk-dev] [PATCH 1/3] vhost: Fix return value of GET_VRING_BASE message 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: Wed, 19 Aug 2015 09:53:02 -0000 When vhost-user frontend sends GET_VRING_BASE, last used index of vring should be returned. In DPDK vhost library, 'last_used_idx' represents it. But the value can be over max index value. To return correct value to vhost frontend, it's needed to be masked. Signed-off-by: Tetsuya Mukawa --- lib/librte_vhost/virtio-net.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c index b520ec5..144f301 100644 --- a/lib/librte_vhost/virtio-net.c +++ b/lib/librte_vhost/virtio-net.c @@ -661,7 +661,8 @@ get_vring_base(struct vhost_device_ctx ctx, uint32_t index, state->index = index; /* State->index refers to the queue index. The txq is 1, rxq is 0. */ - state->num = dev->virtqueue[state->index]->last_used_idx; + state->num = dev->virtqueue[state->index]->last_used_idx + & (dev->virtqueue[state->index]->size - 1); return 0; } -- 2.1.4