Thread (26 messages) 26 messages, 4 authors, 2023-03-30

Re: [PATCH v6 net-next 01/14] pds_core: initial framework for pds_core PF driver

From: Shannon Nelson <hidden>
Date: 2023-03-26 04:07:34

On 3/25/23 4:39 PM, Jakub Kicinski wrote:
On Fri, 24 Mar 2023 12:02:30 -0700 Shannon Nelson wrote:
quoted
This is the initial PCI driver framework for the new pds_core device
driver and its family of devices.  This does the very basics of
registering for the new PF PCI device 1dd8:100c, setting up debugfs
entries, and registering with devlink.
quoted
+     debugfs_create_file("state", 0400, pdsc->dentry,
+                         pdsc, &core_state_fops);
debugfs_create_ulong() ?
Sure, that seems reasonable.  I'll double check that I don't have others 
that need the same treatment.

quoted
diff --git a/drivers/net/ethernet/amd/pds_core/devlink.c b/drivers/net/ethernet/amd/pds_core/devlink.c
new file mode 100644
index 000000000000..a9021bfe680a
--- /dev/null
+++ b/drivers/net/ethernet/amd/pds_core/devlink.c
@@ -0,0 +1,51 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright(c) 2023 Advanced Micro Devices, Inc */
+
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/pci.h>
+
+#include "core.h"
+
+static const struct devlink_ops pdsc_dl_ops = {
+};
+
+static const struct devlink_ops pdsc_dl_vf_ops = {
+};
+
+struct pdsc *pdsc_dl_alloc(struct device *dev, bool is_pf)
+{
+     const struct devlink_ops *ops;
+     struct devlink *dl;
+
+     ops = is_pf ? &pdsc_dl_ops : &pdsc_dl_vf_ops;
+     dl = devlink_alloc(ops, sizeof(struct pdsc), dev);
+     if (!dl)
+             return NULL;
+
+     return devlink_priv(dl);
+}
+
+void pdsc_dl_free(struct pdsc *pdsc)
+{
+     struct devlink *dl = priv_to_devlink(pdsc);
+
+     devlink_free(dl);
+}
+
+int pdsc_dl_register(struct pdsc *pdsc)
+{
+     struct devlink *dl = priv_to_devlink(pdsc);
+
+     devlink_register(dl);
+
+     return 0;
+}
+
+void pdsc_dl_unregister(struct pdsc *pdsc)
+{
+     struct devlink *dl = priv_to_devlink(pdsc);
+
+     devlink_unregister(dl);
Don't put core devlink functionality in a separate file.
You're not wrapping all pci_* calls in your own wrappers, why are you
wrapping delvink? And use explicit locking, please. devl_* APIs.
Wrapping the devlink_register gives me the ability to abstract out the 
bit of additional logic that gets added in a later patch, and now the 
locking logic you mention, and is much like how other relatively current 
drivers have done it, such as in ionic, ice, and mlx5.

Sure, I can set up the dev_lock() and use the newer devl_* APIs.

sln
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help