Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3293751pxj; Tue, 1 Jun 2021 01:46:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsgmVcZfiq0dhZ0/nt4NQEh9yBJe2T95IvBdxmMj+t/WV1OYncbRD/5NWFh+mAk3kWatko X-Received: by 2002:a05:6638:a48:: with SMTP id 8mr24760387jap.38.1622537201826; Tue, 01 Jun 2021 01:46:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622537201; cv=none; d=google.com; s=arc-20160816; b=SSLI0CdPFiKNYk9IRjVGMczcPsf1YOCKVa6YANVLKKcWTiKuM4jtWEWP41wJZnXIuj zTWR5znROZt0La0xq9zznJIVdcgX0Go6HYeJ+JWIH3zQPnutRAkSKLjk1plQZj+m5s/E tLNP1yp+1UhUdbVs+8rWCEFgydmvlI0wxYembD3Hi4S1uaR6lA/+VPWtQKx0iwQVDXhz plTEvt/JvJqal3C+b9fWdyz3l5WJ77I9ELuyvGZ10f+ZOQN1t6WX/e0Y1YQ8Ai4VKzNN 3uKNucH1+sCrOLvTA3zf/sNtQwwtIYlDeANoqNsoEOoIOzzlCV7UxTA3Fu8pWH5+xIp1 74IA== 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=cOwR6dhgbSF74aBvOS15Ehsytp2PjW2qpI5X6i75tczGVoeyJx/g9zv6EJ/++P72VL 1eBTOwFsafnf4no+U7D9ZGqWhud2vxHt6HUykI7uE9Ekw1sfWYG3K+XyZUSop4X89v+X DfZKOay40YEkCjnGZvBY4qXWgLgW2L17OzzJevN0pSZ0NWdfir9mjLqx4zJrKWD578ew whMOhvdnUNqmRO6ZoxDuYhorZw7Ysfw+LMxkKGqVq381j5TZ6xenStJblJmC0sdodyGg s1/XNgVC2lDUH3U8Tmtdz85loyNgX4qz0plqY4a3QmyO6UxgV4+m171sEOIqdUH/JnJZ WOzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=T2uPnFPM; 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 k6si15566332ion.34.2021.06.01.01.46.28; Tue, 01 Jun 2021 01:46:41 -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=T2uPnFPM; 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 S233619AbhFAIrS (ORCPT + 99 others); Tue, 1 Jun 2021 04:47:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:60454 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233541AbhFAIrL (ORCPT ); Tue, 1 Jun 2021 04:47:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622537129; 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=T2uPnFPMuoIqtm/jIwaIb9tkA8kH3Jsa4NK/JgagSN4pvSZxU0+0nE4/z4VlGUZHSmrDSU GyO2hkoMQ3ECKckeN5pvNRhn+4Syr57PO8YQ6K5LZ0TCxiS0MCNcaiLnP13B/dC9xWbWpS Xo7K6UfKcvkAZ+sZ+gcC/mKRvyey07w= 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-455-Fm1-Ruf2O6maY4LjyoKtBg-1; Tue, 01 Jun 2021 04:45:26 -0400 X-MC-Unique: Fm1-Ruf2O6maY4LjyoKtBg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2A8C710509DF; Tue, 1 Jun 2021 08:45:25 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-16.pek2.redhat.com [10.72.12.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id A81AA101E5AF; Tue, 1 Jun 2021 08:45:21 +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 2/4] virtio-pci library: introduce vp_modern_get_driver_features() Date: Tue, 1 Jun 2021 16:45:01 +0800 Message-Id: <20210601084503.34724-3-jasowang@redhat.com> In-Reply-To: <20210601084503.34724-1-jasowang@redhat.com> References: <20210601084503.34724-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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