Subject: [PATCH net-next 2/4] net/ionic: Add devlink parameter for RDMA

From: Eric Joyner <[email-masked]>
Date: Tue, 5 May 2026 21:19:33 -0700

From: Abhijit Gangurde <[email-masked]>

Provides a devlink parameter to the ionic Ethernet driver to
enable/disable the RDMA feature.

Signed-off-by: Abhijit Gangurde <[email-masked]>
Signed-off-by: Eric Joyner <[email-masked]>
---
 .../net/ethernet/pensando/ionic/ionic_aux.c   |  3 +-
 .../ethernet/pensando/ionic/ionic_devlink.c   | 75 +++++++++++++++++++
 2 files changed, 77 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/pensando/ionic/ionic_aux.c b/drivers/net/ethernet/pensando/ionic/ionic_aux.c
index 4f193d0ee87a..689624f19f45 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_aux.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_aux.c
@@ -23,7 +23,8 @@ int ionic_auxbus_register(struct ionic_lif *lif)
 	struct auxiliary_device *aux_dev;
 	int err, id;
 
-	if (!(le64_to_cpu(lif->ionic->ident.lif.capabilities) & IONIC_LIF_CAP_RDMA))
+	if (!IS_ENABLED(CONFIG_INFINIBAND_IONIC) ||
+	    !(le64_to_cpu(lif->ionic->ident.lif.capabilities) & IONIC_LIF_CAP_RDMA))
 		return 0;
 
 	ionic_adev = kzalloc_obj(*ionic_adev);
diff --git a/drivers/net/ethernet/pensando/ionic/ionic_devlink.c b/drivers/net/ethernet/pensando/ionic/ionic_devlink.c
index 4ec66a6be073..ab4f6a37c7f8 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_devlink.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_devlink.c
@@ -8,6 +8,7 @@
 #include "ionic_bus.h"
 #include "ionic_lif.h"
 #include "ionic_devlink.h"
+#include "ionic_aux.h"
 
 static int ionic_dl_flash_update(struct devlink *dl,
 				 struct devlink_flash_update_params *params,
@@ -56,6 +57,72 @@ static const struct devlink_ops ionic_dl_ops = {
 	.flash_update	= ionic_dl_flash_update,
 };
 
+static bool is_aux_enabled(struct ionic *ionic)
+{
+	return !!ionic->lif->ionic_adev;
+}
+
+static int ionic_devlink_enable_rdma_get(struct devlink *dl, u32 id,
+					 struct devlink_param_gset_ctx *ctx,
+					 struct netlink_ext_ack *extack)
+{
+	ctx->val.vbool = is_aux_enabled(devlink_priv(dl));
+	return 0;
+}
+
+static int ionic_devlink_enable_rdma_set(struct devlink *dl, u32 id,
+					 struct devlink_param_gset_ctx *ctx,
+					 struct netlink_ext_ack *extack)
+{
+	struct ionic *ionic = devlink_priv(dl);
+	int err = 0;
+
+	if (ctx->val.vbool == is_aux_enabled(ionic))
+		return err;
+
+	if (ctx->val.vbool)
+		err = ionic_auxbus_register(ionic->lif);
+	else
+		ionic_auxbus_unregister(ionic->lif);
+
+	return err;
+}
+
+static int ionic_devlink_enable_rdma_validate(struct devlink *dl, u32 id,
+					      union devlink_param_value val,
+					      struct netlink_ext_ack *extack)
+{
+	struct ionic *ionic = devlink_priv(dl);
+	bool new_state = val.vbool;
+
+	if (new_state &&
+	    !(le64_to_cpu(ionic->ident.lif.capabilities) & IONIC_LIF_CAP_RDMA))
+		return -EOPNOTSUPP;
+
+	return 0;
+}
+
+static const struct devlink_param ionic_dl_rdma_params[] = {
+	DEVLINK_PARAM_GENERIC(ENABLE_RDMA, BIT(DEVLINK_PARAM_CMODE_RUNTIME),
+			      ionic_devlink_enable_rdma_get, ionic_devlink_enable_rdma_set,
+			      ionic_devlink_enable_rdma_validate),
+};
+
+static int ionic_dl_rdma_params_register(struct devlink *dl)
+{
+	if (!IS_ENABLED(CONFIG_INFINIBAND_IONIC))
+		return 0;
+
+	return devlink_params_register(dl, ionic_dl_rdma_params,
+				       ARRAY_SIZE(ionic_dl_rdma_params));
+}
+
+static void ionic_devlink_rdma_params_unregister(struct devlink *dl)
+{
+	devlink_params_unregister(dl, ionic_dl_rdma_params,
+				  ARRAY_SIZE(ionic_dl_rdma_params));
+}
+
 struct ionic *ionic_devlink_alloc(struct device *dev)
 {
 	struct devlink *dl;
@@ -82,9 +149,17 @@ int ionic_devlink_register(struct ionic *ionic)
 
 	attrs.flavour = DEVLINK_PORT_FLAVOUR_PHYSICAL;
 	devlink_port_attrs_set(&ionic->dl_port, &attrs);
+
+	err = ionic_dl_rdma_params_register(dl);
+	if (err) {
+		dev_err(ionic->dev, "ionic_dl_rdma_params_register failed: %d\n", err);
+		return err;
+	}
+
 	err = devlink_port_register(dl, &ionic->dl_port, 0);
 	if (err) {
 		dev_err(ionic->dev, "devlink_port_register failed: %d\n", err);
+		ionic_devlink_rdma_params_unregister(dl);
 		return err;
 	}
 
-- 
2.17.1