From: "Tan, Jianfeng" <jianfeng.tan@intel.com>
To: Tetsuya Mukawa <mukawa@igel.co.jp>, dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH] vhost: Fix default value of kickfd and callfd
Date: Thu, 10 Mar 2016 14:39:33 +0800 [thread overview]
Message-ID: <56E116A5.40501@intel.com> (raw)
In-Reply-To: <56E1155F.30201@igel.co.jp>
On 3/10/2016 2:34 PM, Tetsuya Mukawa wrote:
> On 2016/03/10 15:25, Tan, Jianfeng wrote:
>>
>> On 3/10/2016 2:14 PM, Tetsuya Mukawa wrote:
>>> Currently, default value of kickfd and callfd is -1.
>>> If the value is -1, current code guess kickfd and callfd hasn't been
>>> initialized yet. And vhost library will guess the virtqueue isn't ready
>>> for processing.
>>> But callfd and kickfd will be set as -1 when "--enable-kvm"
>>> isn't specified in QEMU command line. It means we cannot treat -1 as
>>> uninitialized state. The patch changes default value to -2. And the
>>> patch defines -2 as VIRTIO_UNINITIALIZED_EVENTFD.
>>>
>>> Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
>>> ---
>>> lib/librte_vhost/rte_virtio_net.h | 1 +
>>> lib/librte_vhost/vhost_user/virtio-net-user.c | 7 ++++---
>>> lib/librte_vhost/virtio-net.c | 4 ++--
>>> 3 files changed, 7 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/lib/librte_vhost/rte_virtio_net.h
>>> b/lib/librte_vhost/rte_virtio_net.h
>>> index 7d1fde2..d745707 100644
>>> --- a/lib/librte_vhost/rte_virtio_net.h
>>> +++ b/lib/librte_vhost/rte_virtio_net.h
>>> @@ -89,6 +89,7 @@ struct vhost_virtqueue {
>>> uint16_t vhost_hlen; /**< Vhost header length
>>> (varies depending on RX merge buffers. */
>>> volatile uint16_t last_used_idx; /**< Last index used
>>> on the available ring */
>>> volatile uint16_t last_used_idx_res; /**< Used for
>>> multiple devices reserving buffers. */
>>> +#define VIRTIO_UNINITIALIZED_EVENTFD (-2)
>>> int callfd; /**< Used to notify the guest
>>> (trigger interrupt). */
>>> int kickfd; /**< Currently unused as
>>> polling mode is enabled. */
>>> int enabled;
>>> diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c
>>> b/lib/librte_vhost/vhost_user/virtio-net-user.c
>>> index 65b5652..591f9bf 100644
>>> --- a/lib/librte_vhost/vhost_user/virtio-net-user.c
>>> +++ b/lib/librte_vhost/vhost_user/virtio-net-user.c
>>> @@ -225,8 +225,8 @@ static int
>>> vq_is_ready(struct vhost_virtqueue *vq)
>>> {
>>> return vq && vq->desc &&
>>> - vq->kickfd != -1 &&
>>> - vq->callfd != -1;
>>> + vq->kickfd != VIRTIO_UNINITIALIZED_EVENTFD &&
>>> + vq->callfd != VIRTIO_UNINITIALIZED_EVENTFD;
>>> }
>>> static int
>>> @@ -318,7 +318,8 @@ user_get_vring_base(struct vhost_device_ctx ctx,
>>> */
>>> if (dev->virtqueue[state->index]->kickfd >= 0) {
>>> close(dev->virtqueue[state->index]->kickfd);
>> Then -1 will be a valid value, need to check if it's not -1 to
>> close()? Nevertheless, close(-1) brings no big problem.
>>
> We did it in above 'if' condition checking, then close(-1) will not be
> called.
Sorry, missed that. So when kickfd == -1, need to be set to
VIRTIO_UNINITIALIZED_EVENTFD?
Thanks,
Jianfeng
>
> Thanks,
> Tetsuya
>
>> Thanks,
>> Jianfeng
>>
>>> - dev->virtqueue[state->index]->kickfd = -1;
>>> + dev->virtqueue[state->index]->kickfd =
>>> + VIRTIO_UNINITIALIZED_EVENTFD;
>>> }
>>> return 0;
>>> diff --git a/lib/librte_vhost/virtio-net.c
>>> b/lib/librte_vhost/virtio-net.c
>>> index fe1a77e..3498e9d 100644
>>> --- a/lib/librte_vhost/virtio-net.c
>>> +++ b/lib/librte_vhost/virtio-net.c
>>> @@ -263,8 +263,8 @@ init_vring_queue(struct vhost_virtqueue *vq, int
>>> qp_idx)
>>> {
>>> memset(vq, 0, sizeof(struct vhost_virtqueue));
>>> - vq->kickfd = -1;
>>> - vq->callfd = -1;
>>> + vq->kickfd = VIRTIO_UNINITIALIZED_EVENTFD;
>>> + vq->callfd = VIRTIO_UNINITIALIZED_EVENTFD;
>>> /* Backends are set to -1 indicating an inactive device. */
>>> vq->backend = -1;
next prev parent reply other threads:[~2016-03-10 6:39 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-10 6:14 Tetsuya Mukawa
2016-03-10 6:25 ` Tan, Jianfeng
2016-03-10 6:34 ` Tetsuya Mukawa
2016-03-10 6:39 ` Tan, Jianfeng [this message]
2016-03-10 6:42 ` Tetsuya Mukawa
2016-03-10 7:06 ` [dpdk-dev] [PATCH v2] " Tetsuya Mukawa
2016-03-11 7:19 ` Yuanhan Liu
2016-03-14 1:54 ` Tetsuya Mukawa
2016-03-14 2:08 ` Yuanhan Liu
2016-03-14 7:54 ` Tetsuya Mukawa
2016-03-14 8:21 ` Yuanhan Liu
2016-03-14 8:31 ` Tetsuya Mukawa
2016-03-14 8:53 ` [dpdk-dev] [PATCH v3] " Tetsuya Mukawa
2016-03-14 9:12 ` Yuanhan Liu
2016-03-14 23:19 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56E116A5.40501@intel.com \
--to=jianfeng.tan@intel.com \
--cc=dev@dpdk.org \
--cc=mukawa@igel.co.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).