From: Shannon Nelson via Virtualization <virtualization@lists.linux-foundation.org>
To: <jasowang@redhat.com>, <mst@redhat.com>,
<virtualization@lists.linux-foundation.org>,
<shannon.nelson@amd.com>, <brett.creeley@amd.com>,
<netdev@vger.kernel.org>
Cc: simon.horman@corigine.com, drivers@pensando.io
Subject: [PATCH v6 virtio 07/11] pds_vdpa: virtio bar setup for vdpa
Date: Mon, 15 May 2023 19:55:17 -0700 [thread overview]
Message-ID: <20230516025521.43352-8-shannon.nelson@amd.com> (raw)
In-Reply-To: <20230516025521.43352-1-shannon.nelson@amd.com>
Prep and use the "modern" virtio bar utilities to get our
virtio config space ready.
Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
Acked-by: Jason Wang <jasowang@redhat.com>
---
drivers/vdpa/pds/aux_drv.c | 25 +++++++++++++++++++++++++
drivers/vdpa/pds/aux_drv.h | 3 +++
2 files changed, 28 insertions(+)
diff --git a/drivers/vdpa/pds/aux_drv.c b/drivers/vdpa/pds/aux_drv.c
index aa748cf55d2b..0c4a135b1484 100644
--- a/drivers/vdpa/pds/aux_drv.c
+++ b/drivers/vdpa/pds/aux_drv.c
@@ -4,6 +4,7 @@
#include <linux/auxiliary_bus.h>
#include <linux/pci.h>
#include <linux/vdpa.h>
+#include <linux/virtio_pci_modern.h>
#include <linux/pds/pds_common.h>
#include <linux/pds/pds_core_if.h>
@@ -19,12 +20,22 @@ static const struct auxiliary_device_id pds_vdpa_id_table[] = {
{},
};
+static int pds_vdpa_device_id_check(struct pci_dev *pdev)
+{
+ if (pdev->device != PCI_DEVICE_ID_PENSANDO_VDPA_VF ||
+ pdev->vendor != PCI_VENDOR_ID_PENSANDO)
+ return -ENODEV;
+
+ return PCI_DEVICE_ID_PENSANDO_VDPA_VF;
+}
+
static int pds_vdpa_probe(struct auxiliary_device *aux_dev,
const struct auxiliary_device_id *id)
{
struct pds_auxiliary_dev *padev =
container_of(aux_dev, struct pds_auxiliary_dev, aux_dev);
+ struct device *dev = &aux_dev->dev;
struct pds_vdpa_aux *vdpa_aux;
int err;
@@ -41,8 +52,21 @@ static int pds_vdpa_probe(struct auxiliary_device *aux_dev,
if (err)
goto err_free_mem;
+ /* Find the virtio configuration */
+ vdpa_aux->vd_mdev.pci_dev = padev->vf_pdev;
+ vdpa_aux->vd_mdev.device_id_check = pds_vdpa_device_id_check;
+ vdpa_aux->vd_mdev.dma_mask = DMA_BIT_MASK(PDS_CORE_ADDR_LEN);
+ err = vp_modern_probe(&vdpa_aux->vd_mdev);
+ if (err) {
+ dev_err(dev, "Unable to probe for virtio configuration: %pe\n",
+ ERR_PTR(err));
+ goto err_free_mgmt_info;
+ }
+
return 0;
+err_free_mgmt_info:
+ pci_free_irq_vectors(padev->vf_pdev);
err_free_mem:
kfree(vdpa_aux);
auxiliary_set_drvdata(aux_dev, NULL);
@@ -55,6 +79,7 @@ static void pds_vdpa_remove(struct auxiliary_device *aux_dev)
struct pds_vdpa_aux *vdpa_aux = auxiliary_get_drvdata(aux_dev);
struct device *dev = &aux_dev->dev;
+ vp_modern_remove(&vdpa_aux->vd_mdev);
pci_free_irq_vectors(vdpa_aux->padev->vf_pdev);
kfree(vdpa_aux);
diff --git a/drivers/vdpa/pds/aux_drv.h b/drivers/vdpa/pds/aux_drv.h
index dcec782e79eb..99e0ff340bfa 100644
--- a/drivers/vdpa/pds/aux_drv.h
+++ b/drivers/vdpa/pds/aux_drv.h
@@ -4,6 +4,8 @@
#ifndef _AUX_DRV_H_
#define _AUX_DRV_H_
+#include <linux/virtio_pci_modern.h>
+
#define PDS_VDPA_DRV_DESCRIPTION "AMD/Pensando vDPA VF Device Driver"
#define PDS_VDPA_DRV_NAME KBUILD_MODNAME
@@ -16,6 +18,7 @@ struct pds_vdpa_aux {
int vf_id;
struct dentry *dentry;
+ struct virtio_pci_modern_device vd_mdev;
int nintrs;
};
--
2.17.1
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
next prev parent reply other threads:[~2023-05-16 2:56 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-16 2:55 [PATCH v6 virtio 00/11] pds_vdpa driver Shannon Nelson via Virtualization
2023-05-16 2:55 ` [PATCH v6 virtio 01/11] virtio: allow caller to override device id in vp_modern Shannon Nelson via Virtualization
2023-05-16 2:55 ` [PATCH v6 virtio 02/11] virtio: allow caller to override device DMA mask " Shannon Nelson via Virtualization
2023-05-16 2:55 ` [PATCH v6 virtio 03/11] pds_vdpa: Add new vDPA driver for AMD/Pensando DSC Shannon Nelson via Virtualization
2023-05-16 2:55 ` [PATCH v6 virtio 04/11] pds_vdpa: move enum from common to adminq header Shannon Nelson via Virtualization
2023-05-16 6:12 ` Michael S. Tsirkin
2023-05-16 16:38 ` Shannon Nelson via Virtualization
2023-05-16 2:55 ` [PATCH v6 virtio 05/11] pds_vdpa: new adminq entries Shannon Nelson via Virtualization
2023-05-16 2:55 ` [PATCH v6 virtio 06/11] pds_vdpa: get vdpa management info Shannon Nelson via Virtualization
2023-05-16 2:55 ` Shannon Nelson via Virtualization [this message]
2023-05-16 2:55 ` [PATCH v6 virtio 08/11] pds_vdpa: add vdpa config client commands Shannon Nelson via Virtualization
2023-05-16 2:55 ` [PATCH v6 virtio 09/11] pds_vdpa: add support for vdpa and vdpamgmt interfaces Shannon Nelson via Virtualization
[not found] ` <ZGNcZHUAC21S+uSK@corigine.com>
2023-05-16 16:39 ` Shannon Nelson via Virtualization
2023-05-16 2:55 ` [PATCH v6 virtio 10/11] pds_vdpa: subscribe to the pds_core events Shannon Nelson via Virtualization
2023-05-16 3:30 ` Jason Wang
2023-05-16 2:55 ` [PATCH v6 virtio 11/11] pds_vdpa: pds_vdps.rst and Kconfig Shannon Nelson via Virtualization
2023-05-16 3:29 ` Jason Wang
2023-05-17 2:24 ` kernel test robot
2023-05-17 3:56 ` Shannon Nelson via Virtualization
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=20230516025521.43352-8-shannon.nelson@amd.com \
--to=virtualization@lists.linux-foundation.org \
--cc=brett.creeley@amd.com \
--cc=drivers@pensando.io \
--cc=jasowang@redhat.com \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=shannon.nelson@amd.com \
--cc=simon.horman@corigine.com \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).