From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id D72B0A0A04;
	Fri, 15 Jan 2021 15:29:31 +0100 (CET)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 7B647141116;
	Fri, 15 Jan 2021 15:29:31 +0100 (CET)
Received: from us-smtp-delivery-124.mimecast.com
 (us-smtp-delivery-124.mimecast.com [63.128.21.124])
 by mails.dpdk.org (Postfix) with ESMTP id F337A141115
 for <dev@dpdk.org>; Fri, 15 Jan 2021 15:29:29 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;
 s=mimecast20190719; t=1610720969;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=ghoVIKgjVDf7BHCFz3B1YL/2G4aXjyUgOcu6MYbc3hI=;
 b=gPGgBYESMum/WLjbxVmlEq2bUjEFFW+6bH5YWeM/Y472GZyJVn5YA9AmXVqeaWJqrtOqaf
 GB4Eknr8EI2FnraqTHQ/U+GUMjFa+2dlTqaV9VhVHSpNkY6zdfNllUE0i9FQeBvCFpy1VW
 y5jUQjN5iKejxz+J5qG4flcA4U1Xqf0=
Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com
 [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id
 us-mta-70-XtCgKATuNnSLfggMgfFIUA-1; Fri, 15 Jan 2021 09:29:25 -0500
X-MC-Unique: XtCgKATuNnSLfggMgfFIUA-1
Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com
 [10.5.11.13])
 (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
 (No client certificate requested)
 by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 64EF99CC03;
 Fri, 15 Jan 2021 14:29:24 +0000 (UTC)
Received: from [10.36.110.24] (unknown [10.36.110.24])
 by smtp.corp.redhat.com (Postfix) with ESMTPS id 0EECF6F963;
 Fri, 15 Jan 2021 14:29:18 +0000 (UTC)
To: Adrian Moreno <amorenoz@redhat.com>, dev@dpdk.org, chenbo.xia@intel.com,
 olivier.matz@6wind.com, david.marchand@redhat.com
References: <20201220211405.313012-1-maxime.coquelin@redhat.com>
 <20201220211405.313012-26-maxime.coquelin@redhat.com>
 <3dc4e2f1-b761-9a1b-1271-afdf43201095@redhat.com>
From: Maxime Coquelin <maxime.coquelin@redhat.com>
Message-ID: <94a346be-eb18-16c0-1db7-83c70f372d38@redhat.com>
Date: Fri, 15 Jan 2021 15:29:17 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.6.0
MIME-Version: 1.0
In-Reply-To: <3dc4e2f1-b761-9a1b-1271-afdf43201095@redhat.com>
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13
Authentication-Results: relay.mimecast.com;
 auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com
X-Mimecast-Spam-Score: 0
X-Mimecast-Originator: redhat.com
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Subject: Re: [dpdk-dev] [PATCH 25/40] net/virtio: add Virtio-user features
 ops
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>



On 1/13/21 2:57 PM, Adrian Moreno wrote:
> 
> 
> On 12/20/20 10:13 PM, Maxime Coquelin wrote:
>> This patch introduce new callbacks for getting
>> and setting Virtio features, and implements them
>> for the different backend types.
>>
>> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
>> ---
>>  drivers/net/virtio/virtio_user/vhost.h        |   2 +
>>  drivers/net/virtio/virtio_user/vhost_kernel.c | 150 +++++++++---------
>>  .../net/virtio/virtio_user/vhost_kernel_tap.c |  23 +++
>>  .../net/virtio/virtio_user/vhost_kernel_tap.h |   1 +
>>  drivers/net/virtio/virtio_user/vhost_user.c   |  63 +++++++-
>>  drivers/net/virtio/virtio_user/vhost_vdpa.c   |  38 +++--
>>  .../net/virtio/virtio_user/virtio_user_dev.c  |   5 +-
>>  drivers/net/virtio/virtio_user_ethdev.c       |   3 +-
>>  8 files changed, 188 insertions(+), 97 deletions(-)
>>

...

>> diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c
>> index 5ab15318ac..d204fa1eb0 100644
>> --- a/drivers/net/virtio/virtio_user/vhost_user.c
>> +++ b/drivers/net/virtio/virtio_user/vhost_user.c
>> @@ -143,6 +143,62 @@ vhost_user_set_owner(struct virtio_user_dev *dev)
>>  	return 0;
>>  }
>>  
>> +static int
>> +vhost_user_get_features(struct virtio_user_dev *dev, uint64_t *features)
>> +{
>> +	int ret;
>> +	struct vhost_user_msg msg = {
>> +		.request = VHOST_USER_GET_FEATURES,
>> +		.flags = VHOST_USER_VERSION,
>> +	};
>> +
>> +	ret = vhost_user_write(dev->vhostfd, &msg, NULL, 0);
>> +	if (ret < 0)
>> +		goto err;
>> +
>> +	ret = vhost_user_read(dev->vhostfd, &msg);
>> +	if (ret < 0)
>> +		goto err;
>> +
>> +	if (msg.request != VHOST_USER_GET_FEATURES) {
>> +		PMD_DRV_LOG(ERR, "Unexpected request type (%d)", msg.request);
>> +		goto err;
>> +	}
>> +
>> +	if (msg.size != sizeof(*features)) {
>> +		PMD_DRV_LOG(ERR, "Unexpected payload size (%d)", msg.size);
>> +		goto err;
>> +	}
>> +
>> +	*features = msg.payload.u64;
>> +
>> +	return 0;
>> +err:
>> +	PMD_DRV_LOG(ERR, "Failed to get backend features");
>> +
> On possibly socket-related errors, it's sometimes useful to print
> sterror(errno). WDYT?
>> +	return -1;
>> +}


I agree, I will do it in vhost_user_read/vhost_user_write.
Actually I have a already done it in vhost_user_write after earlier
comment from Chenbo.

Thanks,
Maxime