From patchwork Thu Mar 18 22:35:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 89512 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id ED425A0561; Thu, 18 Mar 2021 23:35:47 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4E8C6140F7A; Thu, 18 Mar 2021 23:35:43 +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 06B4040698 for ; Thu, 18 Mar 2021 23:35:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616106940; 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=7xcrkadB1qGzY6dpc4GsF2QtUz26/iLF6RbWMM+cs/A=; b=QKbu8wcJ84YPZTgaJBI+IBd1RKt4cLVsLmd75E5Si88vpSb+T+blTIwp+RajDiS918gcpF bbHZEPfPTLs4vWNrn/LQvJ3JWj24lKHoUPKE2VydgTo2bhmOvRs2np3Q7pKrumIHgNq4+K S+UzL6rvvvyOKRSjPUPkK66YDos/2RM= 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-374-_O7esr4NN8yjKLuIoPZaWA-1; Thu, 18 Mar 2021 18:35:38 -0400 X-MC-Unique: _O7esr4NN8yjKLuIoPZaWA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 548C310866A5; Thu, 18 Mar 2021 22:35:37 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.36.110.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2E3E610F1; Thu, 18 Mar 2021 22:35:35 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, chenbo.xia@intel.com, amorenoz@redhat.com, david.marchand@redhat.com Cc: Maxime Coquelin Date: Thu, 18 Mar 2021 23:35:24 +0100 Message-Id: <20210318223526.168614-2-maxime.coquelin@redhat.com> In-Reply-To: <20210318223526.168614-1-maxime.coquelin@redhat.com> References: <20210318223526.168614-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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 Subject: [dpdk-dev] [RFC 1/3] net/virtio: keep device and frontend features separated X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch is preliminary rework to add support for getting and setting device's config space. In order to get or set a device config such as its MAC address, we need to know whether the device itself support the feature, or if it is emulated by the frontend. Signed-off-by: Maxime Coquelin --- drivers/net/virtio/virtio_user/virtio_user_dev.c | 10 ++-------- drivers/net/virtio/virtio_user_ethdev.c | 5 +++-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index 1b54d55bd8..8757a23f6e 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -572,11 +572,7 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues, if (dev->backend_type == VIRTIO_USER_BACKEND_VHOST_USER) dev->frontend_features |= (1ull << VIRTIO_NET_F_STATUS); - /* - * Device features = - * (frontend_features | backend_features) & ~unsupported_features; - */ - dev->device_features |= dev->frontend_features; + dev->frontend_features &= ~dev->unsupported_features; dev->device_features &= ~dev->unsupported_features; if (rte_mem_event_callback_register(VIRTIO_USER_MEM_EVENT_CLB_NAME, @@ -940,12 +936,10 @@ virtio_user_dev_server_reconnect(struct virtio_user_dev *dev) return -1; } - dev->device_features |= dev->frontend_features; - /* unmask vhost-user unsupported features */ dev->device_features &= ~(dev->unsupported_features); - dev->features &= dev->device_features; + dev->features &= (dev->device_features | dev->frontend_features); /* For packed ring, resetting queues is required in reconnection. */ if (virtio_with_packed_queue(hw) && diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c index 1810a54694..bb36316186 100644 --- a/drivers/net/virtio/virtio_user_ethdev.c +++ b/drivers/net/virtio/virtio_user_ethdev.c @@ -110,7 +110,8 @@ virtio_user_get_features(struct virtio_hw *hw) struct virtio_user_dev *dev = virtio_user_get_dev(hw); /* unmask feature bits defined in vhost user protocol */ - return dev->device_features & VIRTIO_PMD_SUPPORTED_GUEST_FEATURES; + return (dev->device_features | dev->frontend_features) & + VIRTIO_PMD_SUPPORTED_GUEST_FEATURES; } static void @@ -118,7 +119,7 @@ virtio_user_set_features(struct virtio_hw *hw, uint64_t features) { struct virtio_user_dev *dev = virtio_user_get_dev(hw); - dev->features = features & dev->device_features; + dev->features = features & (dev->device_features | dev->frontend_features); } static int