From patchwork Wed Apr 28 08:21:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhu, Lingshan" X-Patchwork-Id: 12228349 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=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 09F16C43470 for ; Wed, 28 Apr 2021 08:27:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C373261423 for ; Wed, 28 Apr 2021 08:27:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237537AbhD1I1p (ORCPT ); Wed, 28 Apr 2021 04:27:45 -0400 Received: from mga04.intel.com ([192.55.52.120]:7991 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231635AbhD1I1o (ORCPT ); Wed, 28 Apr 2021 04:27:44 -0400 IronPort-SDR: 2zKtKa8S+oFbtnM2IwuXLgHv9V3XXQn3pNz3czSLjsEU69JDM1PljUhMfJd7yeZh0Z0A4jdY3j 6GtUKV3tZaIw== X-IronPort-AV: E=McAfee;i="6200,9189,9967"; a="194573424" X-IronPort-AV: E=Sophos;i="5.82,257,1613462400"; d="scan'208";a="194573424" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2021 01:26:59 -0700 IronPort-SDR: qF1yCpea3G+3k0EktqFIR0vwPr4mAoOu/4FPz7HSdbKMJoN2jdxgk3Hi++L/vcBgvGia0r+Isb D9KQ0yksG7rw== X-IronPort-AV: E=Sophos;i="5.82,257,1613462400"; d="scan'208";a="430192243" Received: from unknown (HELO localhost.localdomain.bj.intel.com) ([10.240.193.73]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2021 01:26:57 -0700 From: Zhu Lingshan To: jasowang@redhat.com, mst@redhat.com Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Zhu Lingshan Subject: [PATCH 1/2] vDPA/ifcvf: record virtio notify base Date: Wed, 28 Apr 2021 16:21:32 +0800 Message-Id: <20210428082133.6766-2-lingshan.zhu@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210428082133.6766-1-lingshan.zhu@intel.com> References: <20210428082133.6766-1-lingshan.zhu@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This commit records virtio notify base addr to implemente doorbell mapping feature Signed-off-by: Zhu Lingshan Reported-by: kernel test robot --- drivers/vdpa/ifcvf/ifcvf_base.c | 1 + drivers/vdpa/ifcvf/ifcvf_base.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/vdpa/ifcvf/ifcvf_base.c b/drivers/vdpa/ifcvf/ifcvf_base.c index 1a661ab45af5..cc61a5bfc5b1 100644 --- a/drivers/vdpa/ifcvf/ifcvf_base.c +++ b/drivers/vdpa/ifcvf/ifcvf_base.c @@ -133,6 +133,7 @@ int ifcvf_init_hw(struct ifcvf_hw *hw, struct pci_dev *pdev) &hw->notify_off_multiplier); hw->notify_bar = cap.bar; hw->notify_base = get_cap_addr(hw, &cap); + hw->notify_pa = pci_resource_start(pdev, cap.bar) + cap.offset; IFCVF_DBG(pdev, "hw->notify_base = %p\n", hw->notify_base); break; diff --git a/drivers/vdpa/ifcvf/ifcvf_base.h b/drivers/vdpa/ifcvf/ifcvf_base.h index 0111bfdeb342..bcca7c1669dd 100644 --- a/drivers/vdpa/ifcvf/ifcvf_base.h +++ b/drivers/vdpa/ifcvf/ifcvf_base.h @@ -98,6 +98,7 @@ struct ifcvf_hw { char config_msix_name[256]; struct vdpa_callback config_cb; unsigned int config_irq; + phys_addr_t notify_pa; }; struct ifcvf_adapter { From patchwork Wed Apr 28 08:21:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhu, Lingshan" X-Patchwork-Id: 12228351 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=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 45529C43461 for ; Wed, 28 Apr 2021 08:27:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 13BDD61422 for ; Wed, 28 Apr 2021 08:27:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237684AbhD1I1s (ORCPT ); Wed, 28 Apr 2021 04:27:48 -0400 Received: from mga04.intel.com ([192.55.52.120]:7991 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231635AbhD1I1q (ORCPT ); Wed, 28 Apr 2021 04:27:46 -0400 IronPort-SDR: qDy/ROmfXerGipvHRgdyTvxz3wCG5nI8sToAqdH7YPPnyox4Z1Grp3Z1AAsDzVxCc9TMSbuSFQ 0JVUz9ze0eww== X-IronPort-AV: E=McAfee;i="6200,9189,9967"; a="194573427" X-IronPort-AV: E=Sophos;i="5.82,257,1613462400"; d="scan'208";a="194573427" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2021 01:27:02 -0700 IronPort-SDR: pEieoWPS439dCUpyUuZKXm1DshukFKzgSi+hhDVT3w21b8a+JXdIEe5AMuK9bHNhSEoA8Puo8o BTZZhWXslXbg== X-IronPort-AV: E=Sophos;i="5.82,257,1613462400"; d="scan'208";a="430192264" Received: from unknown (HELO localhost.localdomain.bj.intel.com) ([10.240.193.73]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2021 01:26:59 -0700 From: Zhu Lingshan To: jasowang@redhat.com, mst@redhat.com Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Zhu Lingshan Subject: [PATCH 2/2] vDPA/ifcvf: implement doorbell mapping for ifcvf Date: Wed, 28 Apr 2021 16:21:33 +0800 Message-Id: <20210428082133.6766-3-lingshan.zhu@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210428082133.6766-1-lingshan.zhu@intel.com> References: <20210428082133.6766-1-lingshan.zhu@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This commit implements doorbell mapping feature for ifcvf. This feature maps the notify page to userspace, to eliminate vmexit when kick a vq. Signed-off-by: Zhu Lingshan --- drivers/vdpa/ifcvf/ifcvf_main.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c b/drivers/vdpa/ifcvf/ifcvf_main.c index e48e6b74fe2e..afcb71bc0f51 100644 --- a/drivers/vdpa/ifcvf/ifcvf_main.c +++ b/drivers/vdpa/ifcvf/ifcvf_main.c @@ -413,6 +413,23 @@ static int ifcvf_vdpa_get_vq_irq(struct vdpa_device *vdpa_dev, return vf->vring[qid].irq; } +static struct vdpa_notification_area ifcvf_get_vq_notification(struct vdpa_device *vdpa_dev, + u16 idx) +{ + struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); + struct vdpa_notification_area area; + + if (vf->notify_pa % PAGE_SIZE) { + area.addr = 0; + area.size = 0; + } else { + area.addr = vf->notify_pa; + area.size = PAGE_SIZE; + } + + return area; +} + /* * IFCVF currently does't have on-chip IOMMU, so not * implemented set_map()/dma_map()/dma_unmap() @@ -440,6 +457,7 @@ static const struct vdpa_config_ops ifc_vdpa_ops = { .get_config = ifcvf_vdpa_get_config, .set_config = ifcvf_vdpa_set_config, .set_config_cb = ifcvf_vdpa_set_config_cb, + .get_vq_notification = ifcvf_get_vq_notification, }; static int ifcvf_probe(struct pci_dev *pdev, const struct pci_device_id *id)