From: Jason Wang <jasowang@redhat.com> To: mst@redhat.com, jasowang@redhat.com Cc: kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, rob.miller@broadcom.com, lingshan.zhu@intel.com, eperezma@redhat.com, lulu@redhat.com, shahafs@mellanox.com, hanand@xilinx.com, mhabets@solarflare.com, gdawar@xilinx.com, saugatm@xilinx.com, vmireyno@marvell.com, zhangweining@ruijie.com.cn, eli@mellanox.com Subject: [PATCH 6/6] vdpa: vp_vdpa: report doorbell location Date: Fri, 29 May 2020 16:03:03 +0800 [thread overview] Message-ID: <20200529080303.15449-7-jasowang@redhat.com> (raw) In-Reply-To: <20200529080303.15449-1-jasowang@redhat.com> This patch adds support for reporting doorbell location in vp_vdpa driver. The doorbell mapping could be then enabled by e.g launching qemu's virtio-net-pci device with page-per-vq enabled. Signed-off-by: Jason Wang <jasowang@redhat.com> --- drivers/vdpa/vp_vdpa/vp_vdpa.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/drivers/vdpa/vp_vdpa/vp_vdpa.c b/drivers/vdpa/vp_vdpa/vp_vdpa.c index e59c310e2156..a5ca49533138 100644 --- a/drivers/vdpa/vp_vdpa/vp_vdpa.c +++ b/drivers/vdpa/vp_vdpa/vp_vdpa.c @@ -30,6 +30,7 @@ struct vp_vring { void __iomem *notify; char msix_name[256]; + resource_size_t notify_pa; struct vdpa_callback cb; int irq; }; @@ -136,7 +137,8 @@ static int find_capability(struct pci_dev *dev, u8 cfg_type, return 0; } -static void __iomem *map_capability(struct vp_vdpa *vp_vdpa, int off) +static void __iomem *map_capability(struct vp_vdpa *vp_vdpa, int off, + resource_size_t *pa) { struct pci_dev *pdev = vp_vdpa->pdev; u32 offset; @@ -149,6 +151,9 @@ static void __iomem *map_capability(struct vp_vdpa *vp_vdpa, int off) off + offsetof(struct virtio_pci_cap, offset), &offset); + if (pa) + *pa = pci_resource_start(pdev, bar) + offset; + return vp_vdpa->base[bar] + offset; } @@ -283,6 +288,18 @@ static u64 vp_vdpa_get_vq_state(struct vdpa_device *vdpa, u16 qid) return 0; } +static struct vdpa_notification_area +vp_vdpa_get_vq_notification(struct vdpa_device *vdpa, u16 qid) +{ + struct vp_vdpa *vp_vdpa = vdpa_to_vp(vdpa); + struct vdpa_notification_area notify; + + notify.addr = vp_vdpa->vring[qid].notify_pa; + notify.size = vp_vdpa->notify_off_multiplier; + + return notify; +} + static int vp_vdpa_set_vq_state(struct vdpa_device *vdpa, u16 qid, u64 num) { @@ -423,6 +440,7 @@ static const struct vdpa_config_ops vp_vdpa_ops = { .set_status = vp_vdpa_set_status, .get_vq_num_max = vp_vdpa_get_vq_num_max, .get_vq_state = vp_vdpa_get_vq_state, + .get_vq_notification = vp_vdpa_get_vq_notification, .set_vq_state = vp_vdpa_set_vq_state, .set_vq_cb = vp_vdpa_set_vq_cb, .set_vq_ready = vp_vdpa_set_vq_ready, @@ -445,6 +463,7 @@ static int vp_vdpa_probe(struct pci_dev *pdev, const struct pci_device_id *id) struct vp_vdpa *vp_vdpa; int common, notify, device, ret, i; struct virtio_device_id virtio_id; + resource_size_t notify_pa; u16 notify_off; /* We only own devices >= 0x1000 and <= 0x107f: leave the rest. */ @@ -525,9 +544,9 @@ static int vp_vdpa_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (ret) dev_warn(&pdev->dev, "Failed to enable 64-bit or 32-bit DMA. Trying to continue, but this might not work.\n"); - vp_vdpa->device = map_capability(vp_vdpa, device); - vp_vdpa->notify = map_capability(vp_vdpa, notify); - vp_vdpa->common = map_capability(vp_vdpa, common); + vp_vdpa->device = map_capability(vp_vdpa, device, NULL); + vp_vdpa->notify = map_capability(vp_vdpa, notify, ¬ify_pa); + vp_vdpa->common = map_capability(vp_vdpa, common, NULL); vp_vdpa->id = virtio_id; ret = vdpa_register_device(&vp_vdpa->vdpa); @@ -545,6 +564,8 @@ static int vp_vdpa_probe(struct pci_dev *pdev, const struct pci_device_id *id) vp_vdpa->vring[i].irq = -1; vp_vdpa->vring[i].notify = vp_vdpa->notify + notify_off * vp_vdpa->notify_off_multiplier; + vp_vdpa->vring[i].notify_pa = notify_pa + + notify_off * vp_vdpa->notify_off_multiplier; } return 0; -- 2.20.1
WARNING: multiple messages have this Message-ID (diff)
From: Jason Wang <jasowang@redhat.com> To: mst@redhat.com, jasowang@redhat.com Cc: shahafs@mellanox.com, lulu@redhat.com, kvm@vger.kernel.org, saugatm@xilinx.com, netdev@vger.kernel.org, mhabets@solarflare.com, vmireyno@marvell.com, linux-kernel@vger.kernel.org, gdawar@xilinx.com, virtualization@lists.linux-foundation.org, eperezma@redhat.com, hanand@xilinx.com, zhangweining@ruijie.com.cn, eli@mellanox.com, lingshan.zhu@intel.com, rob.miller@broadcom.com Subject: [PATCH 6/6] vdpa: vp_vdpa: report doorbell location Date: Fri, 29 May 2020 16:03:03 +0800 [thread overview] Message-ID: <20200529080303.15449-7-jasowang@redhat.com> (raw) In-Reply-To: <20200529080303.15449-1-jasowang@redhat.com> This patch adds support for reporting doorbell location in vp_vdpa driver. The doorbell mapping could be then enabled by e.g launching qemu's virtio-net-pci device with page-per-vq enabled. Signed-off-by: Jason Wang <jasowang@redhat.com> --- drivers/vdpa/vp_vdpa/vp_vdpa.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/drivers/vdpa/vp_vdpa/vp_vdpa.c b/drivers/vdpa/vp_vdpa/vp_vdpa.c index e59c310e2156..a5ca49533138 100644 --- a/drivers/vdpa/vp_vdpa/vp_vdpa.c +++ b/drivers/vdpa/vp_vdpa/vp_vdpa.c @@ -30,6 +30,7 @@ struct vp_vring { void __iomem *notify; char msix_name[256]; + resource_size_t notify_pa; struct vdpa_callback cb; int irq; }; @@ -136,7 +137,8 @@ static int find_capability(struct pci_dev *dev, u8 cfg_type, return 0; } -static void __iomem *map_capability(struct vp_vdpa *vp_vdpa, int off) +static void __iomem *map_capability(struct vp_vdpa *vp_vdpa, int off, + resource_size_t *pa) { struct pci_dev *pdev = vp_vdpa->pdev; u32 offset; @@ -149,6 +151,9 @@ static void __iomem *map_capability(struct vp_vdpa *vp_vdpa, int off) off + offsetof(struct virtio_pci_cap, offset), &offset); + if (pa) + *pa = pci_resource_start(pdev, bar) + offset; + return vp_vdpa->base[bar] + offset; } @@ -283,6 +288,18 @@ static u64 vp_vdpa_get_vq_state(struct vdpa_device *vdpa, u16 qid) return 0; } +static struct vdpa_notification_area +vp_vdpa_get_vq_notification(struct vdpa_device *vdpa, u16 qid) +{ + struct vp_vdpa *vp_vdpa = vdpa_to_vp(vdpa); + struct vdpa_notification_area notify; + + notify.addr = vp_vdpa->vring[qid].notify_pa; + notify.size = vp_vdpa->notify_off_multiplier; + + return notify; +} + static int vp_vdpa_set_vq_state(struct vdpa_device *vdpa, u16 qid, u64 num) { @@ -423,6 +440,7 @@ static const struct vdpa_config_ops vp_vdpa_ops = { .set_status = vp_vdpa_set_status, .get_vq_num_max = vp_vdpa_get_vq_num_max, .get_vq_state = vp_vdpa_get_vq_state, + .get_vq_notification = vp_vdpa_get_vq_notification, .set_vq_state = vp_vdpa_set_vq_state, .set_vq_cb = vp_vdpa_set_vq_cb, .set_vq_ready = vp_vdpa_set_vq_ready, @@ -445,6 +463,7 @@ static int vp_vdpa_probe(struct pci_dev *pdev, const struct pci_device_id *id) struct vp_vdpa *vp_vdpa; int common, notify, device, ret, i; struct virtio_device_id virtio_id; + resource_size_t notify_pa; u16 notify_off; /* We only own devices >= 0x1000 and <= 0x107f: leave the rest. */ @@ -525,9 +544,9 @@ static int vp_vdpa_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (ret) dev_warn(&pdev->dev, "Failed to enable 64-bit or 32-bit DMA. Trying to continue, but this might not work.\n"); - vp_vdpa->device = map_capability(vp_vdpa, device); - vp_vdpa->notify = map_capability(vp_vdpa, notify); - vp_vdpa->common = map_capability(vp_vdpa, common); + vp_vdpa->device = map_capability(vp_vdpa, device, NULL); + vp_vdpa->notify = map_capability(vp_vdpa, notify, ¬ify_pa); + vp_vdpa->common = map_capability(vp_vdpa, common, NULL); vp_vdpa->id = virtio_id; ret = vdpa_register_device(&vp_vdpa->vdpa); @@ -545,6 +564,8 @@ static int vp_vdpa_probe(struct pci_dev *pdev, const struct pci_device_id *id) vp_vdpa->vring[i].irq = -1; vp_vdpa->vring[i].notify = vp_vdpa->notify + notify_off * vp_vdpa->notify_off_multiplier; + vp_vdpa->vring[i].notify_pa = notify_pa + + notify_off * vp_vdpa->notify_off_multiplier; } return 0; -- 2.20.1
next prev parent reply other threads:[~2020-05-29 8:04 UTC|newest] Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-05-29 8:02 [PATCH 0/6] vDPA: doorbell mapping Jason Wang 2020-05-29 8:02 ` Jason Wang 2020-05-29 8:02 ` [PATCH 1/6] vhost: allow device that does not depend on vhost worker Jason Wang 2020-05-29 8:02 ` Jason Wang 2020-06-02 5:01 ` Michael S. Tsirkin 2020-06-02 7:04 ` Jason Wang 2020-06-02 7:04 ` Jason Wang 2020-05-29 8:02 ` [PATCH 2/6] vhost: use mmgrab() instead of mmget() for non worker device Jason Wang 2020-05-29 8:03 ` [PATCH 3/6] vdpa: introduce get_vq_notification method Jason Wang 2020-05-29 8:03 ` Jason Wang 2020-05-29 8:03 ` [PATCH 4/6] vhost_vdpa: support doorbell mapping via mmap Jason Wang 2020-05-29 9:16 ` Mika Penttilä 2020-05-29 9:24 ` Jason Wang 2020-05-29 18:30 ` Rob Miller 2020-05-29 18:30 ` [virtio-dev] " Rob Miller 2020-06-02 2:04 ` Jason Wang 2020-06-02 2:04 ` Jason Wang 2020-06-02 2:04 ` Jason Wang 2020-06-01 19:22 ` kbuild test robot 2020-06-01 19:22 ` kbuild test robot 2020-06-01 19:22 ` kbuild test robot 2020-06-02 4:56 ` Michael S. Tsirkin 2020-06-02 4:56 ` Michael S. Tsirkin 2020-06-02 6:49 ` Jason Wang 2020-06-02 6:49 ` Jason Wang 2020-06-02 13:31 ` Michael S. Tsirkin 2020-06-02 13:31 ` Michael S. Tsirkin 2020-06-03 4:18 ` Jason Wang 2020-06-03 4:18 ` Jason Wang 2020-06-03 6:34 ` Michael S. Tsirkin 2020-06-03 6:34 ` Michael S. Tsirkin 2020-06-03 6:37 ` Jason Wang 2020-06-03 6:37 ` Jason Wang 2020-05-29 8:03 ` [PATCH 5/6] vdpa: introduce virtio pci driver Jason Wang 2020-05-29 8:03 ` Jason Wang 2020-06-02 5:08 ` Michael S. Tsirkin 2020-06-02 7:08 ` Jason Wang 2020-06-05 8:54 ` Jason Wang 2020-06-05 8:54 ` Jason Wang 2020-06-07 13:51 ` Michael S. Tsirkin 2020-06-07 13:51 ` Michael S. Tsirkin 2020-06-08 3:32 ` Jason Wang 2020-06-08 3:32 ` Jason Wang 2020-06-08 6:32 ` Michael S. Tsirkin 2020-06-08 9:18 ` Jason Wang 2020-06-08 9:31 ` Michael S. Tsirkin 2020-06-08 9:43 ` Jason Wang 2020-06-08 9:45 ` Michael S. Tsirkin 2020-06-08 9:45 ` Michael S. Tsirkin 2020-06-08 9:46 ` Jason Wang 2020-06-08 9:54 ` Michael S. Tsirkin 2020-06-08 10:07 ` Jason Wang 2020-06-08 13:29 ` Michael S. Tsirkin 2020-06-08 13:29 ` Michael S. Tsirkin 2020-06-09 5:55 ` Jason Wang 2020-06-02 5:09 ` Michael S. Tsirkin 2020-06-02 7:12 ` Jason Wang 2020-06-04 18:50 ` Michael S. Tsirkin 2020-05-29 8:03 ` Jason Wang [this message] 2020-05-29 8:03 ` [PATCH 6/6] vdpa: vp_vdpa: report doorbell location Jason Wang
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200529080303.15449-7-jasowang@redhat.com \ --to=jasowang@redhat.com \ --cc=eli@mellanox.com \ --cc=eperezma@redhat.com \ --cc=gdawar@xilinx.com \ --cc=hanand@xilinx.com \ --cc=kvm@vger.kernel.org \ --cc=lingshan.zhu@intel.com \ --cc=linux-kernel@vger.kernel.org \ --cc=lulu@redhat.com \ --cc=mhabets@solarflare.com \ --cc=mst@redhat.com \ --cc=netdev@vger.kernel.org \ --cc=rob.miller@broadcom.com \ --cc=saugatm@xilinx.com \ --cc=shahafs@mellanox.com \ --cc=virtualization@lists.linux-foundation.org \ --cc=vmireyno@marvell.com \ --cc=zhangweining@ruijie.com.cn \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.