From: Abhijit Gangurde <abhijit.gangurde@amd.com>
To: <shannon.nelson@amd.com>, <brett.creeley@amd.com>,
<davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>,
<pabeni@redhat.com>, <corbet@lwn.net>, <jgg@ziepe.ca>,
<leon@kernel.org>, <andrew+netdev@lunn.ch>
Cc: <allen.hubbe@amd.com>, <nikhil.agarwal@amd.com>,
<linux-rdma@vger.kernel.org>, <netdev@vger.kernel.org>,
<linux-doc@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Abhijit Gangurde <abhijit.gangurde@amd.com>,
Andrew Boyer <andrew.boyer@amd.com>
Subject: [PATCH 08/14] RDMA/ionic: Register auxiliary module for ionic ethernet adapter
Date: Wed, 23 Apr 2025 15:59:07 +0530 [thread overview]
Message-ID: <20250423102913.438027-9-abhijit.gangurde@amd.com> (raw)
In-Reply-To: <20250423102913.438027-1-abhijit.gangurde@amd.com>
Register auxiliary module to create ibdevice for ionic
ethernet adapter.
Co-developed-by: Andrew Boyer <andrew.boyer@amd.com>
Signed-off-by: Andrew Boyer <andrew.boyer@amd.com>
Co-developed-by: Allen Hubbe <allen.hubbe@amd.com>
Signed-off-by: Allen Hubbe <allen.hubbe@amd.com>
Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
---
drivers/infiniband/hw/ionic/ionic_ibdev.c | 152 ++++++++++++++++++++++
drivers/infiniband/hw/ionic/ionic_ibdev.h | 27 ++++
2 files changed, 179 insertions(+)
create mode 100644 drivers/infiniband/hw/ionic/ionic_ibdev.c
create mode 100644 drivers/infiniband/hw/ionic/ionic_ibdev.h
diff --git a/drivers/infiniband/hw/ionic/ionic_ibdev.c b/drivers/infiniband/hw/ionic/ionic_ibdev.c
new file mode 100644
index 000000000000..91110dc08590
--- /dev/null
+++ b/drivers/infiniband/hw/ionic/ionic_ibdev.c
@@ -0,0 +1,152 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2018-2025, Advanced Micro Devices, Inc. */
+
+#include <linux/module.h>
+#include <linux/printk.h>
+#include <net/addrconf.h>
+
+#include "ionic_ibdev.h"
+
+#define DRIVER_DESCRIPTION "AMD Pensando RoCE HCA driver"
+#define DEVICE_DESCRIPTION "AMD Pensando RoCE HCA"
+
+MODULE_AUTHOR("Allen Hubbe <allen.hubbe@amd.com>");
+MODULE_DESCRIPTION(DRIVER_DESCRIPTION);
+MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS("NET_IONIC");
+
+static const struct auxiliary_device_id ionic_aux_id_table[] = {
+ { .name = "ionic.rdma", },
+ {},
+};
+
+MODULE_DEVICE_TABLE(auxiliary, ionic_aux_id_table);
+
+static void ionic_destroy_ibdev(struct ionic_ibdev *dev)
+{
+ ib_unregister_device(&dev->ibdev);
+ ib_dealloc_device(&dev->ibdev);
+}
+
+static struct ionic_ibdev *ionic_create_ibdev(void *handle,
+ struct net_device *ndev)
+{
+ const union ionic_lif_identity *ident;
+ int rc, lif_index, version;
+ struct ib_device *ibdev;
+ struct ionic_ibdev *dev;
+
+ ident = ionic_api_get_identity(handle, &lif_index);
+ version = ident->rdma.version;
+
+ if (version < IONIC_MIN_RDMA_VERSION ||
+ version > IONIC_MAX_RDMA_VERSION) {
+ netdev_err(ndev, FW_INFO "ionic_rdma: incompatible version, fw ver %u\n",
+ version);
+ netdev_err(ndev, FW_INFO "ionic_rdma: Driver Min Version %u\n",
+ IONIC_MIN_RDMA_VERSION);
+ netdev_err(ndev, FW_INFO "ionic_rdma: Driver Max Version %u\n",
+ IONIC_MAX_RDMA_VERSION);
+ rc = -EINVAL;
+ goto err_dev;
+ }
+
+ dev = ib_alloc_device(ionic_ibdev, ibdev);
+ if (!dev) {
+ rc = -ENOMEM;
+ goto err_dev;
+ }
+
+ dev->hwdev = ndev->dev.parent;
+ dev->ndev = ndev;
+ dev->handle = handle;
+ dev->lif_index = lif_index;
+ dev->ident = ident;
+ dev->rdma_version = ident->rdma.version;
+
+ ibdev = &dev->ibdev;
+ ibdev->dev.parent = dev->hwdev;
+
+ strscpy(ibdev->name, "ionic_%d", IB_DEVICE_NAME_MAX);
+ strscpy(ibdev->node_desc, DEVICE_DESCRIPTION, IB_DEVICE_NODE_DESC_MAX);
+
+ ibdev->node_type = RDMA_NODE_IB_CA;
+ ibdev->phys_port_cnt = 1;
+
+ addrconf_ifid_eui48((u8 *)&ibdev->node_guid, ndev);
+
+ rc = ib_register_device(ibdev, "ionic_%d", ibdev->dev.parent);
+ if (rc)
+ goto err_register;
+
+ return dev;
+
+err_register:
+ ib_dealloc_device(&dev->ibdev);
+err_dev:
+ return ERR_PTR(rc);
+}
+
+static int ionic_aux_probe(struct auxiliary_device *adev,
+ const struct auxiliary_device_id *id)
+{
+ struct ionic_aux_dev *ionic_adev;
+ struct net_device *ndev;
+ struct ionic_ibdev *dev;
+
+ ionic_adev = container_of(adev, struct ionic_aux_dev, adev);
+ ndev = ionic_api_get_netdev_from_handle(ionic_adev->handle);
+ if (IS_ERR(ndev))
+ return dev_err_probe(&adev->dev, PTR_ERR(ndev),
+ "Failed to get netdevice\n");
+
+ dev_put(ndev);
+
+ dev = ionic_create_ibdev(ionic_adev->handle, ndev);
+ if (IS_ERR(dev))
+ return dev_err_probe(&adev->dev, PTR_ERR(dev),
+ "Failed to register ibdev\n");
+
+ auxiliary_set_drvdata(adev, dev);
+ ibdev_dbg(&dev->ibdev, "registered\n");
+
+ return 0;
+}
+
+static void ionic_aux_remove(struct auxiliary_device *adev)
+{
+ struct ionic_ibdev *dev = auxiliary_get_drvdata(adev);
+
+ dev_dbg(&adev->dev, "unregister ibdev\n");
+ ionic_destroy_ibdev(dev);
+ dev_dbg(&adev->dev, "unregistered\n");
+}
+
+static struct auxiliary_driver ionic_aux_r_driver = {
+ .name = "rdma",
+ .probe = ionic_aux_probe,
+ .remove = ionic_aux_remove,
+ .id_table = ionic_aux_id_table,
+};
+
+static int __init ionic_mod_init(void)
+{
+ int rc;
+
+ rc = auxiliary_driver_register(&ionic_aux_r_driver);
+ if (rc)
+ goto err_aux;
+
+ return 0;
+
+err_aux:
+ return rc;
+}
+
+static void __exit ionic_mod_exit(void)
+{
+ auxiliary_driver_unregister(&ionic_aux_r_driver);
+}
+
+module_init(ionic_mod_init);
+module_exit(ionic_mod_exit);
diff --git a/drivers/infiniband/hw/ionic/ionic_ibdev.h b/drivers/infiniband/hw/ionic/ionic_ibdev.h
new file mode 100644
index 000000000000..a4461b23aec3
--- /dev/null
+++ b/drivers/infiniband/hw/ionic/ionic_ibdev.h
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2025, Advanced Micro Devices, Inc. */
+
+#ifndef _IONIC_IBDEV_H_
+#define _IONIC_IBDEV_H_
+
+#include <rdma/ib_verbs.h>
+#include <linux/ionic/ionic_api.h>
+
+#define IONIC_MIN_RDMA_VERSION 0
+#define IONIC_MAX_RDMA_VERSION 2
+
+struct ionic_ibdev {
+ struct ib_device ibdev;
+
+ struct device *hwdev;
+ struct net_device *ndev;
+
+ const union ionic_lif_identity *ident;
+
+ void *handle;
+ int lif_index;
+
+ u8 rdma_version;
+};
+
+#endif /* _IONIC_IBDEV_H_ */
--
2.34.1
next prev parent reply other threads:[~2025-04-23 10:31 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-23 10:28 [PATCH 00/14] Introduce AMD Pensando RDMA driver Abhijit Gangurde
2025-04-23 10:29 ` [PATCH 01/14] net: ionic: Rename neqs_per_lif to reflect rdma capability Abhijit Gangurde
2025-04-23 10:29 ` [PATCH 02/14] net: ionic: Create an auxiliary device for rdma driver Abhijit Gangurde
2025-04-23 10:29 ` [PATCH 03/14] net: ionic: Export the APIs from net driver to get RDMA capabilities Abhijit Gangurde
2025-04-23 10:29 ` [PATCH 04/14] net: ionic: Export the APIs from net driver to support device commands Abhijit Gangurde
2025-04-23 10:29 ` [PATCH 05/14] net: ionic: Provide doorbell and CMB region information Abhijit Gangurde
2025-04-23 10:29 ` [PATCH 06/14] net: ionic: Move header files to a common location Abhijit Gangurde
2025-04-23 10:29 ` [PATCH 07/14] RDMA: Add IONIC to rdma_driver_id definition Abhijit Gangurde
2025-04-23 10:29 ` Abhijit Gangurde [this message]
2025-04-24 13:08 ` [PATCH 08/14] RDMA/ionic: Register auxiliary module for ionic ethernet adapter Jason Gunthorpe
2025-04-25 10:16 ` Abhijit Gangurde
2025-04-25 17:10 ` Leon Romanovsky
2025-04-28 4:34 ` Abhijit Gangurde
2025-04-23 10:29 ` [PATCH 09/14] RDMA/ionic: Create device queues to support admin operations Abhijit Gangurde
2025-04-23 10:29 ` [PATCH 10/14] RDMA/ionic: Register device ops for control path Abhijit Gangurde
2025-04-23 10:29 ` [PATCH 11/14] RDMA/ionic: Register device ops for datapath Abhijit Gangurde
2025-04-23 10:29 ` [PATCH 12/14] RDMA/ionic: Register device ops for miscellaneous functionality Abhijit Gangurde
2025-04-23 10:29 ` [PATCH 13/14] RDMA/ionic: Implement device stats ops Abhijit Gangurde
2025-04-23 10:29 ` [PATCH 14/14] RDMA/ionic: Add Makefile/Kconfig to kernel build environment Abhijit Gangurde
2025-04-24 21:57 ` kernel test robot
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=20250423102913.438027-9-abhijit.gangurde@amd.com \
--to=abhijit.gangurde@amd.com \
--cc=allen.hubbe@amd.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrew.boyer@amd.com \
--cc=brett.creeley@amd.com \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jgg@ziepe.ca \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nikhil.agarwal@amd.com \
--cc=pabeni@redhat.com \
--cc=shannon.nelson@amd.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