From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1385C433DB for ; Thu, 18 Mar 2021 02:45:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 88F5C64F2A for ; Thu, 18 Mar 2021 02:45:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231181AbhCRCpS (ORCPT ); Wed, 17 Mar 2021 22:45:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56824 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229702AbhCRCos (ORCPT ); Wed, 17 Mar 2021 22:44:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616035488; 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=RYfa5a2DxRoWjWb7ZGXHEAtX1EgdbLByNOKHYZ6ZtLI=; b=ZbF7JGZrycSWl1Rt0lV/Nr8/gGunT7yqqk/Y643KnAxlutoA9dn3s6MRr8KZr3BJ3yPSdI mJ+zvuaI3Slu+E1Gq88BDyLEeXb1rUiuTRsI1HB5RHl4gE6MlwLOa/pmETHsyJMidUVXUI nYBxEkWtZw5kOC9uF57zPBNL7tZW6oU= 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-573-lMa46TAUM-qfCQ9m7ytemQ-1; Wed, 17 Mar 2021 22:44:46 -0400 X-MC-Unique: lMa46TAUM-qfCQ9m7ytemQ-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 E6DA581744F; Thu, 18 Mar 2021 02:44:44 +0000 (UTC) Received: from wangxiaodeMacBook-Air.local (ovpn-13-131.pek2.redhat.com [10.72.13.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id C163E503EE; Thu, 18 Mar 2021 02:44:38 +0000 (UTC) Subject: Re: [PATCH V5 7/7] vDPA/ifcvf: deduce VIRTIO device ID from pdev ids To: Zhu Lingshan , mst@redhat.com, lulu@redhat.com, leonro@nvidia.com Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210317094933.16417-1-lingshan.zhu@intel.com> <20210317094933.16417-8-lingshan.zhu@intel.com> From: Jason Wang Message-ID: <1ba4d913-b237-8faf-fec8-b844448c26f0@redhat.com> Date: Thu, 18 Mar 2021 10:44:37 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210317094933.16417-8-lingshan.zhu@intel.com> Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ÔÚ 2021/3/17 ÏÂÎç5:49, Zhu Lingshan дµÀ: > This commit deduces the VIRTIO device ID of a probed > device from its pdev device ids. > > Signed-off-by: Zhu Lingshan > --- > drivers/vdpa/ifcvf/ifcvf_base.h | 1 + > drivers/vdpa/ifcvf/ifcvf_main.c | 14 +++++++++++++- > 2 files changed, 14 insertions(+), 1 deletion(-) > > diff --git a/drivers/vdpa/ifcvf/ifcvf_base.h b/drivers/vdpa/ifcvf/ifcvf_base.h > index f77239fc1644..b2eeb16b9c2c 100644 > --- a/drivers/vdpa/ifcvf/ifcvf_base.h > +++ b/drivers/vdpa/ifcvf/ifcvf_base.h > @@ -127,4 +127,5 @@ int ifcvf_verify_min_features(struct ifcvf_hw *hw, u64 features); > u16 ifcvf_get_vq_state(struct ifcvf_hw *hw, u16 qid); > int ifcvf_set_vq_state(struct ifcvf_hw *hw, u16 qid, u16 num); > struct ifcvf_adapter *vf_to_adapter(struct ifcvf_hw *hw); > +int ifcvf_probed_virtio_net(struct ifcvf_hw *hw); > #endif /* _IFCVF_H_ */ > diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c b/drivers/vdpa/ifcvf/ifcvf_main.c > index ea93ea7fd5df..9fade400b5a4 100644 > --- a/drivers/vdpa/ifcvf/ifcvf_main.c > +++ b/drivers/vdpa/ifcvf/ifcvf_main.c > @@ -323,7 +323,19 @@ static u32 ifcvf_vdpa_get_generation(struct vdpa_device *vdpa_dev) > > static u32 ifcvf_vdpa_get_device_id(struct vdpa_device *vdpa_dev) > { > - return VIRTIO_ID_NET; > + struct ifcvf_adapter *adapter = vdpa_to_adapter(vdpa_dev); > + struct pci_dev *pdev = adapter->pdev; > + u32 ret = -ENODEV; > + > + if (pdev->device < 0x1000 || pdev->device > 0x107f) > + return ret; > + > + if (pdev->device < 0x1040) > + ret = pdev->subsystem_device; > + else > + ret = pdev->device - 0x1040; > + > + return ret; > } It would be better to keep the comment. But anyway Acked-by: Jason Wang > > static u32 ifcvf_vdpa_get_vendor_id(struct vdpa_device *vdpa_dev)