Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Siva Reddy Kallam and committed by
Leon Romanovsky
d0da769c 8ac050ec

+189
+7
MAINTAINERS
··· 5191 5191 F: drivers/infiniband/hw/bnxt_re/ 5192 5192 F: include/uapi/rdma/bnxt_re-abi.h 5193 5193 5194 + BROADCOM 800 GIGABIT ROCE DRIVER 5195 + M: Siva Reddy Kallam <siva.kallam@broadcom.com> 5196 + L: linux-rdma@vger.kernel.org 5197 + S: Supported 5198 + W: http://www.broadcom.com 5199 + F: drivers/infiniband/hw/bng_re/ 5200 + 5194 5201 BROADCOM NVRAM DRIVER 5195 5202 M: Rafał Miłecki <zajec5@gmail.com> 5196 5203 L: linux-mips@vger.kernel.org
+1
drivers/infiniband/Kconfig
··· 80 80 if INFINIBAND_USER_ACCESS || !INFINIBAND_USER_ACCESS 81 81 if !UML 82 82 source "drivers/infiniband/hw/bnxt_re/Kconfig" 83 + source "drivers/infiniband/hw/bng_re/Kconfig" 83 84 source "drivers/infiniband/hw/cxgb4/Kconfig" 84 85 source "drivers/infiniband/hw/efa/Kconfig" 85 86 source "drivers/infiniband/hw/erdma/Kconfig"
+1
drivers/infiniband/hw/Makefile
··· 13 13 obj-$(CONFIG_INFINIBAND_HNS_HIP08) += hns/ 14 14 obj-$(CONFIG_INFINIBAND_QEDR) += qedr/ 15 15 obj-$(CONFIG_INFINIBAND_BNXT_RE) += bnxt_re/ 16 + obj-$(CONFIG_INFINIBAND_BNG_RE) += bng_re/ 16 17 obj-$(CONFIG_INFINIBAND_ERDMA) += erdma/ 17 18 obj-$(CONFIG_INFINIBAND_IONIC) += ionic/
+10
drivers/infiniband/hw/bng_re/Kconfig
··· 1 + # SPDX-License-Identifier: GPL-2.0-only 2 + config INFINIBAND_BNG_RE 3 + tristate "Broadcom Next generation RoCE HCA support" 4 + depends on 64BIT 5 + depends on INET && DCB && BNGE 6 + help 7 + This driver supports Broadcom Next generation 8 + 50/100/200/400/800 gigabit RoCE HCAs. The module 9 + will be called bng_re. To compile this driver 10 + as a module, choose M here.
+7
drivers/infiniband/hw/bng_re/Makefile
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + 3 + ccflags-y := -I $(srctree)/drivers/net/ethernet/broadcom/bnge 4 + 5 + obj-$(CONFIG_INFINIBAND_BNG_RE) += bng_re.o 6 + 7 + bng_re-y := bng_dev.o
+137
drivers/infiniband/hw/bng_re/bng_dev.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + // Copyright (c) 2025 Broadcom. 3 + 4 + #include <linux/module.h> 5 + #include <linux/pci.h> 6 + #include <linux/auxiliary_bus.h> 7 + 8 + #include <rdma/ib_verbs.h> 9 + 10 + #include "bng_re.h" 11 + #include "bnge.h" 12 + #include "bnge_auxr.h" 13 + 14 + MODULE_AUTHOR("Siva Reddy Kallam <siva.kallam@broadcom.com>"); 15 + MODULE_DESCRIPTION(BNG_RE_DESC); 16 + MODULE_LICENSE("Dual BSD/GPL"); 17 + 18 + static struct bng_re_dev *bng_re_dev_add(struct auxiliary_device *adev, 19 + struct bnge_auxr_dev *aux_dev) 20 + { 21 + struct bng_re_dev *rdev; 22 + 23 + /* Allocate bng_re_dev instance */ 24 + rdev = ib_alloc_device(bng_re_dev, ibdev); 25 + if (!rdev) { 26 + pr_err("%s: bng_re_dev allocation failure!", KBUILD_MODNAME); 27 + return NULL; 28 + } 29 + 30 + /* Assign auxiliary device specific data */ 31 + rdev->netdev = aux_dev->net; 32 + rdev->aux_dev = aux_dev; 33 + rdev->adev = adev; 34 + rdev->fn_id = rdev->aux_dev->pdev->devfn; 35 + 36 + return rdev; 37 + } 38 + 39 + static int bng_re_add_device(struct auxiliary_device *adev) 40 + { 41 + struct bnge_auxr_priv *auxr_priv = 42 + container_of(adev, struct bnge_auxr_priv, aux_dev); 43 + struct bng_re_en_dev_info *dev_info; 44 + struct bng_re_dev *rdev; 45 + int rc; 46 + 47 + dev_info = auxiliary_get_drvdata(adev); 48 + 49 + rdev = bng_re_dev_add(adev, auxr_priv->auxr_dev); 50 + if (!rdev) { 51 + rc = -ENOMEM; 52 + goto exit; 53 + } 54 + 55 + dev_info->rdev = rdev; 56 + 57 + return 0; 58 + exit: 59 + return rc; 60 + } 61 + 62 + 63 + static void bng_re_remove_device(struct bng_re_dev *rdev, 64 + struct auxiliary_device *aux_dev) 65 + { 66 + ib_dealloc_device(&rdev->ibdev); 67 + } 68 + 69 + 70 + static int bng_re_probe(struct auxiliary_device *adev, 71 + const struct auxiliary_device_id *id) 72 + { 73 + struct bnge_auxr_priv *aux_priv = 74 + container_of(adev, struct bnge_auxr_priv, aux_dev); 75 + struct bng_re_en_dev_info *en_info; 76 + int rc; 77 + 78 + en_info = kzalloc(sizeof(*en_info), GFP_KERNEL); 79 + if (!en_info) 80 + return -ENOMEM; 81 + 82 + en_info->auxr_dev = aux_priv->auxr_dev; 83 + 84 + auxiliary_set_drvdata(adev, en_info); 85 + 86 + rc = bng_re_add_device(adev); 87 + if (rc) 88 + kfree(en_info); 89 + return rc; 90 + } 91 + 92 + static void bng_re_remove(struct auxiliary_device *adev) 93 + { 94 + struct bng_re_en_dev_info *dev_info = auxiliary_get_drvdata(adev); 95 + struct bng_re_dev *rdev; 96 + 97 + rdev = dev_info->rdev; 98 + 99 + if (rdev) 100 + bng_re_remove_device(rdev, adev); 101 + kfree(dev_info); 102 + } 103 + 104 + static const struct auxiliary_device_id bng_re_id_table[] = { 105 + { .name = BNG_RE_ADEV_NAME ".rdma", }, 106 + {}, 107 + }; 108 + 109 + MODULE_DEVICE_TABLE(auxiliary, bng_re_id_table); 110 + 111 + static struct auxiliary_driver bng_re_driver = { 112 + .name = "rdma", 113 + .probe = bng_re_probe, 114 + .remove = bng_re_remove, 115 + .id_table = bng_re_id_table, 116 + }; 117 + 118 + static int __init bng_re_mod_init(void) 119 + { 120 + int rc; 121 + 122 + 123 + rc = auxiliary_driver_register(&bng_re_driver); 124 + if (rc) { 125 + pr_err("%s: Failed to register auxiliary driver\n", 126 + KBUILD_MODNAME); 127 + } 128 + return rc; 129 + } 130 + 131 + static void __exit bng_re_mod_exit(void) 132 + { 133 + auxiliary_driver_unregister(&bng_re_driver); 134 + } 135 + 136 + module_init(bng_re_mod_init); 137 + module_exit(bng_re_mod_exit);
+26
drivers/infiniband/hw/bng_re/bng_re.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + // Copyright (c) 2025 Broadcom. 3 + 4 + #ifndef __BNG_RE_H__ 5 + #define __BNG_RE_H__ 6 + 7 + #define BNG_RE_ADEV_NAME "bng_en" 8 + 9 + #define BNG_RE_DESC "Broadcom 800G RoCE Driver" 10 + 11 + #define rdev_to_dev(rdev) ((rdev) ? (&(rdev)->ibdev.dev) : NULL) 12 + 13 + struct bng_re_en_dev_info { 14 + struct bng_re_dev *rdev; 15 + struct bnge_auxr_dev *auxr_dev; 16 + }; 17 + 18 + struct bng_re_dev { 19 + struct ib_device ibdev; 20 + struct net_device *netdev; 21 + struct auxiliary_device *adev; 22 + struct bnge_auxr_dev *aux_dev; 23 + int fn_id; 24 + }; 25 + 26 + #endif