Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp249258pxj; Tue, 1 Jun 2021 20:59:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJzIRPeqJK2mk5QKeNN/k+5cHIAxYGxwy09Ug6B9vCrun39Ygzk+50I6Cyq2EsYYLkA8Ge X-Received: by 2002:a02:b68c:: with SMTP id i12mr27635531jam.133.1622606361228; Tue, 01 Jun 2021 20:59:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622606361; cv=none; d=google.com; s=arc-20160816; b=xXWQ/Dix0cdqtUT2VLcC7Ixl7pcbBobf/+agkIZFSumrS+BOi+CaHWyjJ+PJ89mUuK fwzZwM9XislD0+HVbpmCffi6oIsa3f8d2BvDLwYs2wSG8dm0VeyOEpG7yz9M2z+vDgGH +eyFpdRbWALgc62286UQGtG9zB3/eD3CkVfT5O5eW5bb7tlAAN3qAmMbnkNtSNDeudXe lwbidfe2bDOxc6/jWGsKv776PWB4TqRXJLP8JLDHcXWda/qGayyyixBEirFXB680umVc +jPvKRdWoR0hKQe3J1nm11HyMInDdt5mCKrJGs8ecauew0MzWEC3HdgxQsseK/R7qleT yZIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xpp86MKQOz0QZsgGameycFz6/zr05nCyS0wGULJidQo=; b=xpFB0eEyKmQd9wVVCoB1ktZm7RlpDFxDjXJ2zr7xrsUoVXi6pPvaY0IaneqfbgUibQ XEV+FIvdbbgI2EIRXfdM8ra4Q2snus7QoxPzAiUc2Mj3e8TVgXFmzRHJljS3MXX/LEEP m7NfJ2b7Y5aZtUZWRKkWBVp5qow7zbZR3RSmRH0KHR0GJcMF62Va+uZ+PnKOBRS7xnxv UC17VYNKhnb4EbdxQgdGG0DemmZbXTNuzIoBTo0c1Vg3/FZhoKTZ10A2dhsiblVMPWR8 XOLhhPsd9RPZmgXps8MU3UuXHtWPiwne+mA5oWXBY/i6j6dosP18pwbKAfpu+DsAatiA Mv0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EEyZRWdn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c15si11617798iln.17.2021.06.01.20.59.06; Tue, 01 Jun 2021 20:59:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EEyZRWdn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230378AbhFBCRh (ORCPT + 99 others); Tue, 1 Jun 2021 22:17:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:33529 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230242AbhFBCRf (ORCPT ); Tue, 1 Jun 2021 22:17:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622600152; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xpp86MKQOz0QZsgGameycFz6/zr05nCyS0wGULJidQo=; b=EEyZRWdnzxJ92DOiM4xZpPhMV6brZBY4HgLm4kRwuSqCWhMFHsOWbb6da0BNA/1R8CDw1A MFCni970uAFv8tAEsBnNjfZ39XkN/u7PYlPLQc5hM0psO5FujFsv8LaIYugNHmDH2Hl/j8 H/ncTp7B9eFaB9L8MTMbr9dB9OlR9Ck= 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-26-MBW2L-pqMV-XN_dfTNrBqQ-1; Tue, 01 Jun 2021 22:15:51 -0400 X-MC-Unique: MBW2L-pqMV-XN_dfTNrBqQ-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 548CD10082E0; Wed, 2 Jun 2021 02:15:50 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-99.pek2.redhat.com [10.72.12.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id C719B6A03C; Wed, 2 Jun 2021 02:15:47 +0000 (UTC) From: Jason Wang To: mst@redhat.com, jasowang@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, netdev@vger.kernel.org Cc: eli@mellanox.com Subject: [PATCH V2 RESEND 2/4] virtio-pci library: introduce vp_modern_get_driver_features() Date: Wed, 2 Jun 2021 10:15:34 +0800 Message-Id: <20210602021536.39525-3-jasowang@redhat.com> In-Reply-To: <20210602021536.39525-1-jasowang@redhat.com> References: <20210602021536.39525-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch introduce a helper to get driver/guest features from the device. Signed-off-by: Jason Wang --- drivers/virtio/virtio_pci_modern_dev.c | 21 +++++++++++++++++++++ include/linux/virtio_pci_modern.h | 1 + 2 files changed, 22 insertions(+) diff --git a/drivers/virtio/virtio_pci_modern_dev.c b/drivers/virtio/virtio_pci_modern_dev.c index 54f297028586..e11ed748e661 100644 --- a/drivers/virtio/virtio_pci_modern_dev.c +++ b/drivers/virtio/virtio_pci_modern_dev.c @@ -383,6 +383,27 @@ u64 vp_modern_get_features(struct virtio_pci_modern_device *mdev) } EXPORT_SYMBOL_GPL(vp_modern_get_features); +/* + * vp_modern_get_driver_features - get driver features from device + * @mdev: the modern virtio-pci device + * + * Returns the driver features read from the device + */ +u64 vp_modern_get_driver_features(struct virtio_pci_modern_device *mdev) +{ + struct virtio_pci_common_cfg __iomem *cfg = mdev->common; + + u64 features; + + vp_iowrite32(0, &cfg->guest_feature_select); + features = vp_ioread32(&cfg->guest_feature); + vp_iowrite32(1, &cfg->guest_feature_select); + features |= ((u64)vp_ioread32(&cfg->guest_feature) << 32); + + return features; +} +EXPORT_SYMBOL_GPL(vp_modern_get_driver_features); + /* * vp_modern_set_features - set features to device * @mdev: the modern virtio-pci device diff --git a/include/linux/virtio_pci_modern.h b/include/linux/virtio_pci_modern.h index 6a95b58fd0f4..eb2bd9b4077d 100644 --- a/include/linux/virtio_pci_modern.h +++ b/include/linux/virtio_pci_modern.h @@ -79,6 +79,7 @@ static inline void vp_iowrite64_twopart(u64 val, } u64 vp_modern_get_features(struct virtio_pci_modern_device *mdev); +u64 vp_modern_get_driver_features(struct virtio_pci_modern_device *mdev); void vp_modern_set_features(struct virtio_pci_modern_device *mdev, u64 features); u32 vp_modern_generation(struct virtio_pci_modern_device *mdev); -- 2.25.1