Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp13624855pxu; Sun, 3 Jan 2021 23:02:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJwfDwLFv5Bc6wb1gRDoczTDRrcJlWIMKkfBdcpWQAVZtkdrmo+NWVmxU8aokpjIUjOg8wWl X-Received: by 2002:a17:906:369a:: with SMTP id a26mr63276240ejc.276.1609743721290; Sun, 03 Jan 2021 23:02:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609743721; cv=none; d=google.com; s=arc-20160816; b=ltBVzL8k/JAdk2VNMTm6JlHsJFho22EuwGQuDQ10N6OnSzTyF083oXnfUa6NV5d0k0 Eexmqff0Gb7Wl7DtQUsPHvZZflsskP3iyvipcx5Lsw/Vlv6uvx/0oegPxwv7HNxXIIDA acsGLzhRjunGx3wvm3q75hIaDS86V/e33pSCpW786QDFaSM37W9eIMz/FRcW0kShEG3X Haf5sEIF/CxrEKrVGIkXgw7DDD1hgzSWN3t/BT8nQjuyFff2mSf8H737FTgWOm2SG3t2 RavnMSq35x3UNJ0NS9Rs1B3XsBl7BvhQy3r4lBstgo/HJK6hmSYDeLoQuQcsSKaBrSU/ cdlQ== 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=rlSrvPYi7Sf8S1ru+B79DHoQTOX3kJJE4+lQVOglXBY=; b=F5cy1WQt6195lYiyvrW0mqdRXO6gsjA/e0HnTQGmiJ9QyGoBHQtkSEG+kaxCGe+V43 zHDEqYQ9fZa1V0o06ITtuQs9CmrLD71Bxloe5bGW9oYhCMgXBHfhmzsiGfxLfcF0aulg 0ZsHDFJYZd86RoZzQyq+1ABcLBm2oPZiU69m0mVDnN+dhrcT48D9ZTdLAbq9Jc1ujGsG 0cZ+exbBBRITj55YBG2ILeILBwcrDTPhLalgVtntnIPfiGSsa7d734gdXLgWwSqpT2OR bo3roIWv3czqodMca3Zl1ob/rOS9yGdHhtyXv5xQwXJaDFEYShqNjW65SyzlIbrbWYg+ gGSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=g+CddEQa; 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 t18si21628879ejc.249.2021.01.03.23.01.38; Sun, 03 Jan 2021 23:02:01 -0800 (PST) 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=g+CddEQa; 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 S1728268AbhADG5c (ORCPT + 99 others); Mon, 4 Jan 2021 01:57:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:33361 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728180AbhADG5b (ORCPT ); Mon, 4 Jan 2021 01:57:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609743365; 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=rlSrvPYi7Sf8S1ru+B79DHoQTOX3kJJE4+lQVOglXBY=; b=g+CddEQaAlM7V0Mm1FxGi3btgzV8Uy1TMDspWA2ENNjV4D0QFZlBmbrfSEiiLrwpg0YVvm ylsFhcRNEUFE6P1GiQaYi2DYNqGd89sFAzxiBfzHF/TvCCXQZs+QmWcwjBl7s8TdxBHpJl crE5+CO1zpvwU2EyKzDDLyOcoDrr8wE= 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-194-jCOuCDYrNcO9gR2RY9bYRQ-1; Mon, 04 Jan 2021 01:56:01 -0500 X-MC-Unique: jCOuCDYrNcO9gR2RY9bYRQ-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 85ED6180A087; Mon, 4 Jan 2021 06:56:00 +0000 (UTC) Received: from jason-ThinkPad-X1-Carbon-6th.redhat.com (ovpn-13-91.pek2.redhat.com [10.72.13.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id D943D1002388; Mon, 4 Jan 2021 06:55:57 +0000 (UTC) From: Jason Wang To: mst@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Cc: shahafs@mellanox.com, lulu@redhat.com, sgarzare@redhat.com, rdunlap@infradead.org, Jason Wang Subject: [PATCH V3 13/19] virtio-pci-modern: introduce helper for getting queue nums Date: Mon, 4 Jan 2021 14:54:57 +0800 Message-Id: <20210104065503.199631-14-jasowang@redhat.com> In-Reply-To: <20210104065503.199631-1-jasowang@redhat.com> References: <20210104065503.199631-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 introduces helper for getting queue num of modern device. Signed-off-by: Jason Wang --- drivers/virtio/virtio_pci_modern.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c index 7a89226135af..bccad1329871 100644 --- a/drivers/virtio/virtio_pci_modern.c +++ b/drivers/virtio/virtio_pci_modern.c @@ -292,6 +292,17 @@ static u16 vp_modern_get_queue_size(struct virtio_pci_modern_device *mdev, } +/* + * vp_modern_get_num_queues - get the number of virtqueues + * @mdev: the modern virtio-pci device + * + * Returns the number of virtqueues + */ +static u16 vp_modern_get_num_queues(struct virtio_pci_modern_device *mdev) +{ + return vp_ioread16(&mdev->common->num_queues); +} + /* virtio config->finalize_features() implementation */ static int vp_finalize_features(struct virtio_device *vdev) { @@ -510,7 +521,7 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev, u16 num, off; int err; - if (index >= vp_ioread16(&cfg->num_queues)) + if (index >= vp_modern_get_num_queues(mdev)) return ERR_PTR(-ENOENT); /* Select the queue we're interested in */ -- 2.25.1