RDMA/bng_re: Add Auxiliary interface

Add basic Auxiliary interface to the driver which supports
the BCM5770X NIC family.

Signed-off-by: Siva Reddy Kallam <siva.kallam@broadcom.com>
Link: https://patch.msgid.link/20251117171136.128193-3-siva.kallam@broadcom.com
Reviewed-by: Usman Ansari <usman.ansari@broadcom.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
This commit is contained in:
Siva Reddy Kallam
2025-11-17 17:11:20 +00:00
committed by Leon Romanovsky
parent 8ac050ec3b
commit d0da769c19
7 changed files with 189 additions and 0 deletions

View File

@@ -5191,6 +5191,13 @@ W: http://www.broadcom.com
F: drivers/infiniband/hw/bnxt_re/
F: include/uapi/rdma/bnxt_re-abi.h
BROADCOM 800 GIGABIT ROCE DRIVER
M: Siva Reddy Kallam <siva.kallam@broadcom.com>
L: linux-rdma@vger.kernel.org
S: Supported
W: http://www.broadcom.com
F: drivers/infiniband/hw/bng_re/
BROADCOM NVRAM DRIVER
M: Rafał Miłecki <zajec5@gmail.com>
L: linux-mips@vger.kernel.org

View File

@@ -80,6 +80,7 @@ config INFINIBAND_VIRT_DMA
if INFINIBAND_USER_ACCESS || !INFINIBAND_USER_ACCESS
if !UML
source "drivers/infiniband/hw/bnxt_re/Kconfig"
source "drivers/infiniband/hw/bng_re/Kconfig"
source "drivers/infiniband/hw/cxgb4/Kconfig"
source "drivers/infiniband/hw/efa/Kconfig"
source "drivers/infiniband/hw/erdma/Kconfig"

View File

@@ -13,5 +13,6 @@ obj-$(CONFIG_INFINIBAND_HFI1) += hfi1/
obj-$(CONFIG_INFINIBAND_HNS_HIP08) += hns/
obj-$(CONFIG_INFINIBAND_QEDR) += qedr/
obj-$(CONFIG_INFINIBAND_BNXT_RE) += bnxt_re/
obj-$(CONFIG_INFINIBAND_BNG_RE) += bng_re/
obj-$(CONFIG_INFINIBAND_ERDMA) += erdma/
obj-$(CONFIG_INFINIBAND_IONIC) += ionic/

View File

@@ -0,0 +1,10 @@
# SPDX-License-Identifier: GPL-2.0-only
config INFINIBAND_BNG_RE
tristate "Broadcom Next generation RoCE HCA support"
depends on 64BIT
depends on INET && DCB && BNGE
help
This driver supports Broadcom Next generation
50/100/200/400/800 gigabit RoCE HCAs. The module
will be called bng_re. To compile this driver
as a module, choose M here.

View File

@@ -0,0 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
ccflags-y := -I $(srctree)/drivers/net/ethernet/broadcom/bnge
obj-$(CONFIG_INFINIBAND_BNG_RE) += bng_re.o
bng_re-y := bng_dev.o

View File

@@ -0,0 +1,137 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2025 Broadcom.
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/auxiliary_bus.h>
#include <rdma/ib_verbs.h>
#include "bng_re.h"
#include "bnge.h"
#include "bnge_auxr.h"
MODULE_AUTHOR("Siva Reddy Kallam <siva.kallam@broadcom.com>");
MODULE_DESCRIPTION(BNG_RE_DESC);
MODULE_LICENSE("Dual BSD/GPL");
static struct bng_re_dev *bng_re_dev_add(struct auxiliary_device *adev,
struct bnge_auxr_dev *aux_dev)
{
struct bng_re_dev *rdev;
/* Allocate bng_re_dev instance */
rdev = ib_alloc_device(bng_re_dev, ibdev);
if (!rdev) {
pr_err("%s: bng_re_dev allocation failure!", KBUILD_MODNAME);
return NULL;
}
/* Assign auxiliary device specific data */
rdev->netdev = aux_dev->net;
rdev->aux_dev = aux_dev;
rdev->adev = adev;
rdev->fn_id = rdev->aux_dev->pdev->devfn;
return rdev;
}
static int bng_re_add_device(struct auxiliary_device *adev)
{
struct bnge_auxr_priv *auxr_priv =
container_of(adev, struct bnge_auxr_priv, aux_dev);
struct bng_re_en_dev_info *dev_info;
struct bng_re_dev *rdev;
int rc;
dev_info = auxiliary_get_drvdata(adev);
rdev = bng_re_dev_add(adev, auxr_priv->auxr_dev);
if (!rdev) {
rc = -ENOMEM;
goto exit;
}
dev_info->rdev = rdev;
return 0;
exit:
return rc;
}
static void bng_re_remove_device(struct bng_re_dev *rdev,
struct auxiliary_device *aux_dev)
{
ib_dealloc_device(&rdev->ibdev);
}
static int bng_re_probe(struct auxiliary_device *adev,
const struct auxiliary_device_id *id)
{
struct bnge_auxr_priv *aux_priv =
container_of(adev, struct bnge_auxr_priv, aux_dev);
struct bng_re_en_dev_info *en_info;
int rc;
en_info = kzalloc(sizeof(*en_info), GFP_KERNEL);
if (!en_info)
return -ENOMEM;
en_info->auxr_dev = aux_priv->auxr_dev;
auxiliary_set_drvdata(adev, en_info);
rc = bng_re_add_device(adev);
if (rc)
kfree(en_info);
return rc;
}
static void bng_re_remove(struct auxiliary_device *adev)
{
struct bng_re_en_dev_info *dev_info = auxiliary_get_drvdata(adev);
struct bng_re_dev *rdev;
rdev = dev_info->rdev;
if (rdev)
bng_re_remove_device(rdev, adev);
kfree(dev_info);
}
static const struct auxiliary_device_id bng_re_id_table[] = {
{ .name = BNG_RE_ADEV_NAME ".rdma", },
{},
};
MODULE_DEVICE_TABLE(auxiliary, bng_re_id_table);
static struct auxiliary_driver bng_re_driver = {
.name = "rdma",
.probe = bng_re_probe,
.remove = bng_re_remove,
.id_table = bng_re_id_table,
};
static int __init bng_re_mod_init(void)
{
int rc;
rc = auxiliary_driver_register(&bng_re_driver);
if (rc) {
pr_err("%s: Failed to register auxiliary driver\n",
KBUILD_MODNAME);
}
return rc;
}
static void __exit bng_re_mod_exit(void)
{
auxiliary_driver_unregister(&bng_re_driver);
}
module_init(bng_re_mod_init);
module_exit(bng_re_mod_exit);

View File

@@ -0,0 +1,26 @@
/* SPDX-License-Identifier: GPL-2.0 */
// Copyright (c) 2025 Broadcom.
#ifndef __BNG_RE_H__
#define __BNG_RE_H__
#define BNG_RE_ADEV_NAME "bng_en"
#define BNG_RE_DESC "Broadcom 800G RoCE Driver"
#define rdev_to_dev(rdev) ((rdev) ? (&(rdev)->ibdev.dev) : NULL)
struct bng_re_en_dev_info {
struct bng_re_dev *rdev;
struct bnge_auxr_dev *auxr_dev;
};
struct bng_re_dev {
struct ib_device ibdev;
struct net_device *netdev;
struct auxiliary_device *adev;
struct bnge_auxr_dev *aux_dev;
int fn_id;
};
#endif