Commit ffad4278 authored by Abhijit Gangurde's avatar Abhijit Gangurde Committed by Leon Romanovsky
Browse files

net: ionic: Create an auxiliary device for rdma driver



To support RDMA capable ethernet device, create an auxiliary device in
the ionic Ethernet driver. The RDMA device is modeled as an auxiliary
device to the Ethernet device.

Reviewed-by: default avatarShannon Nelson <shannon.nelson@amd.com>
Signed-off-by: default avatarAbhijit Gangurde <abhijit.gangurde@amd.com>
Link: https://patch.msgid.link/20250903061606.4139957-2-abhijit.gangurde@amd.com


Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
parent f5b6b463
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ Contents
- Identifying the Adapter
- Enabling the driver
- Configuring the driver
- RDMA Support via Auxiliary Device
- Statistics
- Support

@@ -105,6 +106,15 @@ XDP
Support for XDP includes the basics, plus Jumbo frames, Redirect and
ndo_xmit.  There is no current support for zero-copy sockets or HW offload.

RDMA Support via Auxiliary Device
=================================

The ionic driver supports RDMA (Remote Direct Memory Access) functionality
through the Linux auxiliary device framework when advertised by the firmware.
RDMA capability is detected during device initialization, and if supported,
the ethernet driver will create an auxiliary device that allows the RDMA
driver to bind and provide InfiniBand/RoCE functionality.

Statistics
==========

+1 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ config IONIC
	select NET_DEVLINK
	select DIMLIB
	select PAGE_POOL
	select AUXILIARY_BUS
	help
	  This enables the support for the Pensando family of Ethernet
	  adapters.  More specific information on this driver can be
+1 −1
Original line number Diff line number Diff line
@@ -5,5 +5,5 @@ obj-$(CONFIG_IONIC) := ionic.o

ionic-y := ionic_main.o ionic_bus_pci.o ionic_devlink.o ionic_dev.o \
	   ionic_debugfs.o ionic_lif.o ionic_rx_filter.o ionic_ethtool.o \
	   ionic_txrx.o ionic_stats.o ionic_fw.o
	   ionic_txrx.o ionic_stats.o ionic_fw.o ionic_aux.o
ionic-$(CONFIG_PTP_1588_CLOCK) += ionic_phc.o
+21 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (C) 2018-2025, Advanced Micro Devices, Inc. */

#ifndef _IONIC_API_H_
#define _IONIC_API_H_

#include <linux/auxiliary_bus.h>

/**
 * struct ionic_aux_dev - Auxiliary device information
 * @lif:        Logical interface
 * @idx:        Index identifier
 * @adev:       Auxiliary device
 */
struct ionic_aux_dev {
	struct ionic_lif *lif;
	int idx;
	struct auxiliary_device adev;
};

#endif /* _IONIC_API_H_ */
+80 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
/* Copyright (C) 2018-2025, Advanced Micro Devices, Inc. */

#include <linux/kernel.h>
#include "ionic.h"
#include "ionic_lif.h"
#include "ionic_aux.h"

static DEFINE_IDA(aux_ida);

static void ionic_auxbus_release(struct device *dev)
{
	struct ionic_aux_dev *ionic_adev;

	ionic_adev = container_of(dev, struct ionic_aux_dev, adev.dev);
	ida_free(&aux_ida, ionic_adev->adev.id);
	kfree(ionic_adev);
}

int ionic_auxbus_register(struct ionic_lif *lif)
{
	struct ionic_aux_dev *ionic_adev;
	struct auxiliary_device *aux_dev;
	int err, id;

	if (!(le64_to_cpu(lif->ionic->ident.lif.capabilities) & IONIC_LIF_CAP_RDMA))
		return 0;

	ionic_adev = kzalloc(sizeof(*ionic_adev), GFP_KERNEL);
	if (!ionic_adev)
		return -ENOMEM;

	aux_dev = &ionic_adev->adev;

	id = ida_alloc(&aux_ida, GFP_KERNEL);
	if (id < 0) {
		dev_err(lif->ionic->dev, "Failed to allocate aux id: %d\n", id);
		kfree(ionic_adev);
		return id;
	}

	aux_dev->id = id;
	aux_dev->name = "rdma";
	aux_dev->dev.parent = &lif->ionic->pdev->dev;
	aux_dev->dev.release = ionic_auxbus_release;
	ionic_adev->lif = lif;
	err = auxiliary_device_init(aux_dev);
	if (err) {
		dev_err(lif->ionic->dev, "Failed to initialize %s aux device: %d\n",
			aux_dev->name, err);
		ida_free(&aux_ida, id);
		kfree(ionic_adev);
		return err;
	}

	err = auxiliary_device_add(aux_dev);
	if (err) {
		dev_err(lif->ionic->dev, "Failed to add %s aux device: %d\n",
			aux_dev->name, err);
		auxiliary_device_uninit(aux_dev);
		return err;
	}

	lif->ionic_adev = ionic_adev;
	return 0;
}

void ionic_auxbus_unregister(struct ionic_lif *lif)
{
	mutex_lock(&lif->adev_lock);
	if (!lif->ionic_adev)
		goto out;

	auxiliary_device_delete(&lif->ionic_adev->adev);
	auxiliary_device_uninit(&lif->ionic_adev->adev);

	lif->ionic_adev = NULL;
out:
	mutex_unlock(&lif->adev_lock);
}
Loading