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 E5697A0A02;
	Fri, 15 Jan 2021 10:20:31 +0100 (CET)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 775B4140E21;
	Fri, 15 Jan 2021 10:20:31 +0100 (CET)
Received: from us-smtp-delivery-124.mimecast.com
 (us-smtp-delivery-124.mimecast.com [170.10.133.124])
 by mails.dpdk.org (Postfix) with ESMTP id D4E23140E20
 for <dev@dpdk.org>; Fri, 15 Jan 2021 10:20:29 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;
 s=mimecast20190719; t=1610702429;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=nG7kEcgx1pwt1WMSxqn2m+XrRZYy1jvLrTzpWju1+Q4=;
 b=DR0jNssWbJrJ0tQlj+/H0xJrCA6sKZ5PQhE+WkOeQ54skLZTVI3vpZnLqHhFRJBsgsXuK1
 kpcONMeyateHx3guEu1pARx/+NPHxOokd5uJGSolR4uTskHuOD3/yPUPXvTb7NoMH6hzuk
 eb3L3Che2IsPMk8Y4cjIb+xUr1fGuNo=
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-10-X_0eT3OWMp-_j5yWXolBMQ-1; Fri, 15 Jan 2021 04:20:27 -0500
X-MC-Unique: X_0eT3OWMp-_j5yWXolBMQ-1
Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com
 [10.5.11.16])
 (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
 (No client certificate requested)
 by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 52079802B49;
 Fri, 15 Jan 2021 09:20:26 +0000 (UTC)
Received: from [10.36.110.24] (unknown [10.36.110.24])
 by smtp.corp.redhat.com (Postfix) with ESMTPS id 4382957;
 Fri, 15 Jan 2021 09:20:22 +0000 (UTC)
To: David Marchand <david.marchand@redhat.com>
Cc: dev <dev@dpdk.org>, "Xia, Chenbo" <chenbo.xia@intel.com>,
 Olivier Matz <olivier.matz@6wind.com>,
 Adrian Moreno Zapata <amorenoz@redhat.com>
References: <20201220211405.313012-1-maxime.coquelin@redhat.com>
 <20201220211405.313012-12-maxime.coquelin@redhat.com>
 <CAJFAV8x4ehK+EjFd6g0Vs4qnwnWFqz006-2G3MGAE6wEnZm9FA@mail.gmail.com>
From: Maxime Coquelin <maxime.coquelin@redhat.com>
Message-ID: <137cf084-c6e9-f643-1e9f-fd3be5a7d1e9@redhat.com>
Date: Fri, 15 Jan 2021 10:20:20 +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: <CAJFAV8x4ehK+EjFd6g0Vs4qnwnWFqz006-2G3MGAE6wEnZm9FA@mail.gmail.com>
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16
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 11/40] net/virtio: validate features at bus
 level
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/6/21 10:33 AM, David Marchand wrote:
> On Sun, Dec 20, 2020 at 10:15 PM Maxime Coquelin
> <maxime.coquelin@redhat.com> wrote:
>> diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
>> index 00aa38e4ef..91a93b2b6e 100644
>> --- a/drivers/net/virtio/virtio_ethdev.c
>> +++ b/drivers/net/virtio/virtio_ethdev.c
>> @@ -1315,17 +1315,16 @@ virtio_negotiate_features(struct virtio_hw *hw, uint64_t req_features)
>>         PMD_INIT_LOG(DEBUG, "features after negotiate = %" PRIx64,
>>                 hw->guest_features);
>>
>> -       if (hw->bus_type == VIRTIO_BUS_PCI_MODERN && !vtpci_with_feature(hw, VIRTIO_F_VERSION_1)) {
>> -               PMD_INIT_LOG(ERR,
>> -                       "VIRTIO_F_VERSION_1 features is not enabled.");
>> +       if (VTPCI_OPS(hw)->features_ok(hw) < 0) {
>> +               PMD_INIT_LOG(ERR, "Features not OK at bus level\n");
> 
> We have a log which gives more context in the modern features_ok() callback.
> I don't think we need both log messages.

Yes, maybe overkill. I will remove.

Thanks,
Maxime

>>                 return -1;
>>         }
>>
>> -       if (hw->bus_type == VIRTIO_BUS_PCI_MODERN || hw->bus_type == VIRTIO_BUS_USER) {
>> +       if (vtpci_with_feature(hw, VIRTIO_F_VERSION_1)) {
>>                 vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_FEATURES_OK);
>> +
>>                 if (!(vtpci_get_status(hw) & VIRTIO_CONFIG_STATUS_FEATURES_OK)) {
>> -                       PMD_INIT_LOG(ERR,
>> -                               "failed to set FEATURES_OK status!");
>> +                       PMD_INIT_LOG(ERR, "Failed to set FEATURES_OK status!");
>>                         return -1;
>>                 }
>>         }
>> diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c
>> index 599d8afa6b..3de7980b4f 100644
>> --- a/drivers/net/virtio/virtio_pci.c
>> +++ b/drivers/net/virtio/virtio_pci.c
> 
> [snip]
> 
> 
>> @@ -332,6 +339,17 @@ modern_set_features(struct virtio_hw *hw, uint64_t features)
>>                     &hw->common_cfg->guest_feature);
>>  }
>>
>> +static int
>> +modern_features_ok(struct virtio_hw *hw)
>> +{
>> +       if (!vtpci_with_feature(hw, VIRTIO_F_VERSION_1)) {
>> +               PMD_INIT_LOG(ERR, "Version 1+ required with modern devices\n");
>> +               return -1;
>> +       }
>> +
>> +       return 0;
>> +}
>> +
>>  static uint8_t
>>  modern_get_status(struct virtio_hw *hw)
>>  {
> 
>