diff mbox series

[RFC,v2,virtio,1/7] pds_vdpa: Add new vDPA driver for AMD/Pensando DSC

Message ID 20230309013046.23523-2-shannon.nelson@amd.com (mailing list archive)
State Superseded
Headers show
Series pds_vdpa driver | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Nelson, Shannon March 9, 2023, 1:30 a.m. UTC
This is the initial auxiliary driver framework for a new vDPA
device driver, an auxiliary_bus client of the pds_core driver.
The pds_core driver supplies the PCI services for the VF device
and for accessing the adminq in the PF device.

This patch adds the very basics of registering for the auxiliary
device, setting up debugfs entries, and registering with devlink.

Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
---
 drivers/vdpa/Makefile        |  1 +
 drivers/vdpa/pds/Makefile    |  8 +++
 drivers/vdpa/pds/aux_drv.c   | 99 ++++++++++++++++++++++++++++++++++++
 drivers/vdpa/pds/aux_drv.h   | 15 ++++++
 drivers/vdpa/pds/debugfs.c   | 25 +++++++++
 drivers/vdpa/pds/debugfs.h   | 18 +++++++
 include/linux/pds/pds_vdpa.h | 12 +++++
 7 files changed, 178 insertions(+)
 create mode 100644 drivers/vdpa/pds/Makefile
 create mode 100644 drivers/vdpa/pds/aux_drv.c
 create mode 100644 drivers/vdpa/pds/aux_drv.h
 create mode 100644 drivers/vdpa/pds/debugfs.c
 create mode 100644 drivers/vdpa/pds/debugfs.h
 create mode 100644 include/linux/pds/pds_vdpa.h

Comments

Simon Horman March 12, 2023, 2:06 p.m. UTC | #1
On Wed, Mar 08, 2023 at 05:30:40PM -0800, Shannon Nelson wrote:
> This is the initial auxiliary driver framework for a new vDPA
> device driver, an auxiliary_bus client of the pds_core driver.
> The pds_core driver supplies the PCI services for the VF device
> and for accessing the adminq in the PF device.
> 
> This patch adds the very basics of registering for the auxiliary
> device, setting up debugfs entries, and registering with devlink.
> 
> Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>

...

> diff --git a/drivers/vdpa/pds/Makefile b/drivers/vdpa/pds/Makefile
> new file mode 100644
> index 000000000000..a9cd2f450ae1
> --- /dev/null
> +++ b/drivers/vdpa/pds/Makefile
> @@ -0,0 +1,8 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +# Copyright(c) 2023 Advanced Micro Devices, Inc
> +
> +obj-$(CONFIG_PDS_VDPA) := pds_vdpa.o
> +
> +pds_vdpa-y := aux_drv.o
> +
> +pds_vdpa-$(CONFIG_DEBUG_FS) += debugfs.o
> diff --git a/drivers/vdpa/pds/aux_drv.c b/drivers/vdpa/pds/aux_drv.c
> new file mode 100644
> index 000000000000..b3f36170253c
> --- /dev/null
> +++ b/drivers/vdpa/pds/aux_drv.c
> @@ -0,0 +1,99 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/* Copyright(c) 2023 Advanced Micro Devices, Inc */
> +
> +#include <linux/auxiliary_bus.h>
> +
> +#include <linux/pds/pds_core.h>

Perhaps I'm missing something obvious, but
pds_core.h doesn't exist (yet).

> +#include <linux/pds/pds_auxbus.h>
> +#include <linux/pds/pds_vdpa.h>

...

> diff --git a/drivers/vdpa/pds/debugfs.c b/drivers/vdpa/pds/debugfs.c
> new file mode 100644
> index 000000000000..3c163dc7b66f
> --- /dev/null
> +++ b/drivers/vdpa/pds/debugfs.c
> @@ -0,0 +1,25 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/* Copyright(c) 2023 Advanced Micro Devices, Inc */
> +
> +#include <linux/pds/pds_core.h>
> +#include <linux/pds/pds_auxbus.h>
> +
> +#include "aux_drv.h"
> +#include "debugfs.h"
> +
> +#ifdef CONFIG_DEBUG_FS

Again, perhaps I'm missing something obvious, but
compilation of this file is guarded by CONFIG_DEBUG_FS (in ./Makefile).
So I don't think this guard is needed here.

> +
> +static struct dentry *dbfs_dir;
> +
> +void pds_vdpa_debugfs_create(void)
> +{
> +	dbfs_dir = debugfs_create_dir(PDS_VDPA_DRV_NAME, NULL);
> +}
> +
> +void pds_vdpa_debugfs_destroy(void)
> +{
> +	debugfs_remove_recursive(dbfs_dir);
> +	dbfs_dir = NULL;
> +}
> +
> +#endif /* CONFIG_DEBUG_FS */
Simon Horman March 12, 2023, 2:35 p.m. UTC | #2
On Sun, Mar 12, 2023 at 03:06:39PM +0100, Simon Horman wrote:
> On Wed, Mar 08, 2023 at 05:30:40PM -0800, Shannon Nelson wrote:
> > This is the initial auxiliary driver framework for a new vDPA
> > device driver, an auxiliary_bus client of the pds_core driver.
> > The pds_core driver supplies the PCI services for the VF device
> > and for accessing the adminq in the PF device.
> > 
> > This patch adds the very basics of registering for the auxiliary
> > device, setting up debugfs entries, and registering with devlink.
> > 
> > Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
> 
> ...
> 
> > diff --git a/drivers/vdpa/pds/Makefile b/drivers/vdpa/pds/Makefile
> > new file mode 100644
> > index 000000000000..a9cd2f450ae1
> > --- /dev/null
> > +++ b/drivers/vdpa/pds/Makefile
> > @@ -0,0 +1,8 @@
> > +# SPDX-License-Identifier: GPL-2.0-only
> > +# Copyright(c) 2023 Advanced Micro Devices, Inc
> > +
> > +obj-$(CONFIG_PDS_VDPA) := pds_vdpa.o
> > +
> > +pds_vdpa-y := aux_drv.o
> > +
> > +pds_vdpa-$(CONFIG_DEBUG_FS) += debugfs.o
> > diff --git a/drivers/vdpa/pds/aux_drv.c b/drivers/vdpa/pds/aux_drv.c
> > new file mode 100644
> > index 000000000000..b3f36170253c
> > --- /dev/null
> > +++ b/drivers/vdpa/pds/aux_drv.c
> > @@ -0,0 +1,99 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +/* Copyright(c) 2023 Advanced Micro Devices, Inc */
> > +
> > +#include <linux/auxiliary_bus.h>
> > +
> > +#include <linux/pds/pds_core.h>
> 
> Perhaps I'm missing something obvious, but
> pds_core.h doesn't exist (yet).

The obvious thing that I was missing is that it is added by

* [PATCH RFC v4 net-next 00/13] pds_core driver
Nelson, Shannon March 13, 2023, 4:13 p.m. UTC | #3
On 3/12/23 7:35 AM, Simon Horman wrote:
> On Sun, Mar 12, 2023 at 03:06:39PM +0100, Simon Horman wrote:
>> On Wed, Mar 08, 2023 at 05:30:40PM -0800, Shannon Nelson wrote:
>>> This is the initial auxiliary driver framework for a new vDPA
>>> device driver, an auxiliary_bus client of the pds_core driver.
>>> The pds_core driver supplies the PCI services for the VF device
>>> and for accessing the adminq in the PF device.
>>>
>>> This patch adds the very basics of registering for the auxiliary
>>> device, setting up debugfs entries, and registering with devlink.
>>>
>>> Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
>>
>> ...
>>
>>> diff --git a/drivers/vdpa/pds/Makefile b/drivers/vdpa/pds/Makefile
>>> new file mode 100644
>>> index 000000000000..a9cd2f450ae1
>>> --- /dev/null
>>> +++ b/drivers/vdpa/pds/Makefile
>>> @@ -0,0 +1,8 @@
>>> +# SPDX-License-Identifier: GPL-2.0-only
>>> +# Copyright(c) 2023 Advanced Micro Devices, Inc
>>> +
>>> +obj-$(CONFIG_PDS_VDPA) := pds_vdpa.o
>>> +
>>> +pds_vdpa-y := aux_drv.o
>>> +
>>> +pds_vdpa-$(CONFIG_DEBUG_FS) += debugfs.o
>>> diff --git a/drivers/vdpa/pds/aux_drv.c b/drivers/vdpa/pds/aux_drv.c
>>> new file mode 100644
>>> index 000000000000..b3f36170253c
>>> --- /dev/null
>>> +++ b/drivers/vdpa/pds/aux_drv.c
>>> @@ -0,0 +1,99 @@
>>> +// SPDX-License-Identifier: GPL-2.0-only
>>> +/* Copyright(c) 2023 Advanced Micro Devices, Inc */
>>> +
>>> +#include <linux/auxiliary_bus.h>
>>> +
>>> +#include <linux/pds/pds_core.h>
>>
>> Perhaps I'm missing something obvious, but
>> pds_core.h doesn't exist (yet).
> 
> The obvious thing that I was missing is that it is added by
> 
> * [PATCH RFC v4 net-next 00/13] pds_core driver

Sorry about that - I can try to make that dependency more obvious in the 
next round.

sln
Simon Horman March 13, 2023, 4:26 p.m. UTC | #4
On Mon, Mar 13, 2023 at 09:13:11AM -0700, Shannon Nelson wrote:
> On 3/12/23 7:35 AM, Simon Horman wrote:
> > On Sun, Mar 12, 2023 at 03:06:39PM +0100, Simon Horman wrote:
> > > On Wed, Mar 08, 2023 at 05:30:40PM -0800, Shannon Nelson wrote:
> > > > This is the initial auxiliary driver framework for a new vDPA
> > > > device driver, an auxiliary_bus client of the pds_core driver.
> > > > The pds_core driver supplies the PCI services for the VF device
> > > > and for accessing the adminq in the PF device.
> > > > 
> > > > This patch adds the very basics of registering for the auxiliary
> > > > device, setting up debugfs entries, and registering with devlink.
> > > > 
> > > > Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
> > > 
> > > ...
> > > 
> > > > diff --git a/drivers/vdpa/pds/Makefile b/drivers/vdpa/pds/Makefile
> > > > new file mode 100644
> > > > index 000000000000..a9cd2f450ae1
> > > > --- /dev/null
> > > > +++ b/drivers/vdpa/pds/Makefile
> > > > @@ -0,0 +1,8 @@
> > > > +# SPDX-License-Identifier: GPL-2.0-only
> > > > +# Copyright(c) 2023 Advanced Micro Devices, Inc
> > > > +
> > > > +obj-$(CONFIG_PDS_VDPA) := pds_vdpa.o
> > > > +
> > > > +pds_vdpa-y := aux_drv.o
> > > > +
> > > > +pds_vdpa-$(CONFIG_DEBUG_FS) += debugfs.o
> > > > diff --git a/drivers/vdpa/pds/aux_drv.c b/drivers/vdpa/pds/aux_drv.c
> > > > new file mode 100644
> > > > index 000000000000..b3f36170253c
> > > > --- /dev/null
> > > > +++ b/drivers/vdpa/pds/aux_drv.c
> > > > @@ -0,0 +1,99 @@
> > > > +// SPDX-License-Identifier: GPL-2.0-only
> > > > +/* Copyright(c) 2023 Advanced Micro Devices, Inc */
> > > > +
> > > > +#include <linux/auxiliary_bus.h>
> > > > +
> > > > +#include <linux/pds/pds_core.h>
> > > 
> > > Perhaps I'm missing something obvious, but
> > > pds_core.h doesn't exist (yet).
> > 
> > The obvious thing that I was missing is that it is added by
> > 
> > * [PATCH RFC v4 net-next 00/13] pds_core driver
> 
> Sorry about that - I can try to make that dependency more obvious in the
> next round.

That might be a good idea.
But I am likewise sorry for jumping the gun with my email yesterday.
diff mbox series

Patch

diff --git a/drivers/vdpa/Makefile b/drivers/vdpa/Makefile
index 59396ff2a318..8f53c6f3cca7 100644
--- a/drivers/vdpa/Makefile
+++ b/drivers/vdpa/Makefile
@@ -7,3 +7,4 @@  obj-$(CONFIG_MLX5_VDPA) += mlx5/
 obj-$(CONFIG_VP_VDPA)    += virtio_pci/
 obj-$(CONFIG_ALIBABA_ENI_VDPA) += alibaba/
 obj-$(CONFIG_SNET_VDPA) += solidrun/
+obj-$(CONFIG_PDS_VDPA) += pds/
diff --git a/drivers/vdpa/pds/Makefile b/drivers/vdpa/pds/Makefile
new file mode 100644
index 000000000000..a9cd2f450ae1
--- /dev/null
+++ b/drivers/vdpa/pds/Makefile
@@ -0,0 +1,8 @@ 
+# SPDX-License-Identifier: GPL-2.0-only
+# Copyright(c) 2023 Advanced Micro Devices, Inc
+
+obj-$(CONFIG_PDS_VDPA) := pds_vdpa.o
+
+pds_vdpa-y := aux_drv.o
+
+pds_vdpa-$(CONFIG_DEBUG_FS) += debugfs.o
diff --git a/drivers/vdpa/pds/aux_drv.c b/drivers/vdpa/pds/aux_drv.c
new file mode 100644
index 000000000000..b3f36170253c
--- /dev/null
+++ b/drivers/vdpa/pds/aux_drv.c
@@ -0,0 +1,99 @@ 
+// SPDX-License-Identifier: GPL-2.0-only
+/* Copyright(c) 2023 Advanced Micro Devices, Inc */
+
+#include <linux/auxiliary_bus.h>
+
+#include <linux/pds/pds_core.h>
+#include <linux/pds/pds_auxbus.h>
+#include <linux/pds/pds_vdpa.h>
+
+#include "aux_drv.h"
+#include "debugfs.h"
+
+static const struct auxiliary_device_id pds_vdpa_id_table[] = {
+	{ .name = PDS_VDPA_DEV_NAME, },
+	{},
+};
+
+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;
+
+	vdpa_aux = kzalloc(sizeof(*vdpa_aux), GFP_KERNEL);
+	if (!vdpa_aux)
+		return -ENOMEM;
+
+	vdpa_aux->padev = padev;
+	auxiliary_set_drvdata(aux_dev, vdpa_aux);
+
+	/* Register our PDS client with the pds_core */
+	err = padev->ops->register_client(padev);
+	if (err) {
+		dev_err(dev, "%s: Failed to register as client: %pe\n",
+			__func__, ERR_PTR(err));
+		goto err_free_mem;
+	}
+
+	return 0;
+
+err_free_mem:
+	kfree(vdpa_aux);
+	auxiliary_set_drvdata(aux_dev, NULL);
+
+	return err;
+}
+
+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;
+
+	vdpa_aux->padev->ops->unregister_client(vdpa_aux->padev);
+
+	kfree(vdpa_aux);
+	auxiliary_set_drvdata(aux_dev, NULL);
+
+	dev_info(dev, "Removed\n");
+}
+
+static struct auxiliary_driver pds_vdpa_driver = {
+	.name = PDS_DEV_TYPE_VDPA_STR,
+	.probe = pds_vdpa_probe,
+	.remove = pds_vdpa_remove,
+	.id_table = pds_vdpa_id_table,
+};
+
+static void __exit pds_vdpa_cleanup(void)
+{
+	auxiliary_driver_unregister(&pds_vdpa_driver);
+
+	pds_vdpa_debugfs_destroy();
+}
+module_exit(pds_vdpa_cleanup);
+
+static int __init pds_vdpa_init(void)
+{
+	int err;
+
+	pds_vdpa_debugfs_create();
+
+	err = auxiliary_driver_register(&pds_vdpa_driver);
+	if (err) {
+		pr_err("%s: aux driver register failed: %pe\n",
+		       PDS_VDPA_DRV_NAME, ERR_PTR(err));
+		pds_vdpa_debugfs_destroy();
+	}
+
+	return err;
+}
+module_init(pds_vdpa_init);
+
+MODULE_DESCRIPTION(PDS_VDPA_DRV_DESCRIPTION);
+MODULE_AUTHOR("AMD/Pensando Systems, Inc");
+MODULE_LICENSE("GPL");
diff --git a/drivers/vdpa/pds/aux_drv.h b/drivers/vdpa/pds/aux_drv.h
new file mode 100644
index 000000000000..14e465944dfd
--- /dev/null
+++ b/drivers/vdpa/pds/aux_drv.h
@@ -0,0 +1,15 @@ 
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* Copyright(c) 2023 Advanced Micro Devices, Inc */
+
+#ifndef _AUX_DRV_H_
+#define _AUX_DRV_H_
+
+#define PDS_VDPA_DRV_DESCRIPTION    "AMD/Pensando vDPA VF Device Driver"
+#define PDS_VDPA_DRV_NAME           "pds_vdpa"
+
+struct pds_vdpa_aux {
+	struct pds_auxiliary_dev *padev;
+
+	struct dentry *dentry;
+};
+#endif /* _AUX_DRV_H_ */
diff --git a/drivers/vdpa/pds/debugfs.c b/drivers/vdpa/pds/debugfs.c
new file mode 100644
index 000000000000..3c163dc7b66f
--- /dev/null
+++ b/drivers/vdpa/pds/debugfs.c
@@ -0,0 +1,25 @@ 
+// SPDX-License-Identifier: GPL-2.0-only
+/* Copyright(c) 2023 Advanced Micro Devices, Inc */
+
+#include <linux/pds/pds_core.h>
+#include <linux/pds/pds_auxbus.h>
+
+#include "aux_drv.h"
+#include "debugfs.h"
+
+#ifdef CONFIG_DEBUG_FS
+
+static struct dentry *dbfs_dir;
+
+void pds_vdpa_debugfs_create(void)
+{
+	dbfs_dir = debugfs_create_dir(PDS_VDPA_DRV_NAME, NULL);
+}
+
+void pds_vdpa_debugfs_destroy(void)
+{
+	debugfs_remove_recursive(dbfs_dir);
+	dbfs_dir = NULL;
+}
+
+#endif /* CONFIG_DEBUG_FS */
diff --git a/drivers/vdpa/pds/debugfs.h b/drivers/vdpa/pds/debugfs.h
new file mode 100644
index 000000000000..fff078a869e5
--- /dev/null
+++ b/drivers/vdpa/pds/debugfs.h
@@ -0,0 +1,18 @@ 
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright(c) 2023 Advanced Micro Devices, Inc */
+
+#ifndef _PDS_VDPA_DEBUGFS_H_
+#define _PDS_VDPA_DEBUGFS_H_
+
+#include <linux/debugfs.h>
+
+#ifdef CONFIG_DEBUG_FS
+
+void pds_vdpa_debugfs_create(void);
+void pds_vdpa_debugfs_destroy(void);
+#else
+static inline void pds_vdpa_debugfs_create(void) { }
+static inline void pds_vdpa_debugfs_destroy(void) { }
+#endif
+
+#endif /* _PDS_VDPA_DEBUGFS_H_ */
diff --git a/include/linux/pds/pds_vdpa.h b/include/linux/pds/pds_vdpa.h
new file mode 100644
index 000000000000..b5154e3b298e
--- /dev/null
+++ b/include/linux/pds/pds_vdpa.h
@@ -0,0 +1,12 @@ 
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* Copyright(c) 2023 Advanced Micro Devices, Inc */
+
+#ifndef _PDS_VDPA_IF_H_
+#define _PDS_VDPA_IF_H_
+
+#include <linux/pds/pds_common.h>
+
+#define PDS_DEV_TYPE_VDPA_STR	"vDPA"
+#define PDS_VDPA_DEV_NAME	PDS_CORE_DRV_NAME "." PDS_DEV_TYPE_VDPA_STR
+
+#endif /* _PDS_VDPA_IF_H_ */