nbl driver for Nebulamatrix NICs
Subsystems (4)
illusion.wang
maintainerv23 cover nbl driver for Nebulamatrix NICs
From: illusion wang <[email protected]>
This patch series represents the first phase. We plan to integrate it in two phases: the first phase covers mailbox and chip configuration, while the second phase involves net dev configuration. Together, they will provide basic PF-based Ethernet port transmission and reception capabilities.
After that, we will consider other features, such as ethtool support, flow management, adminq messaging, VF support, debugfs support, etc.
To ensure compatibility, our architecture is divided into the following layers:
1. Dev Layer (Device Layer)
The top-level business logic layer where all operations are device-centric. Every operation is performed relative to the device context. The intergration of base functions encompasses:
management(ctrl only for leonis pf0), network(net_dev,this time not contained),common.
2. Dispatch Layer
The distribution from services to specific data operations is mainly divided into two types: direct pass-through and handling by the management PF. It shields the upper layer from the differences in specific underlying locations.
It describes the processing locations and paths of the services.
3. Resource Layer
Handles tasks dispatched from Dispatch Layer. These tasks fall into two categories:
3.1 Hardware control
The Resource Layer further invokes the HW Layer when hardware access is needed, as only the HW Layer has OS-level privileges.
3.2 Software resource management
Operations like packet statistics collection that don't require hardware access.
4. HW Layer (Hardware Layer)
Serves the Resource Layer by interacting with different hardware chipsets.Writes to hardware registers to drive the hardware based on Resource Layer directives.
5. Channel Layer
Handle communication between PF0(has ctrl func) and other PF,and provide basic interaction channels.
6. Common Layer
Provides fundamental services
changes v22->v23
Link to v22:https://lore.kernel.org/netdev/[email protected]/ AI review issues
chages v21->v22
Link to v21:https://lore.kernel.org/netdev/[email protected]/ AI review issues
changes v20->v21
Link to v20:https://lore.kernel.org/netdev/[email protected]/ I have dropped the old Patch 2 titled "add our driver architecture"
Add new Patch 2 "add core driver architecture and HW layer initialization".
Split original patch8 into three separate patches as suggested
changes v19->v20
Link to v19:https://lore.kernel.org/netdev/[email protected]/ Starting from V20, I have dropped the old Patch 3 titled "P4
configuration invoked during chip initialization". This functionality
will be reimplemented in next phase using the request_firmware() API
with an external firmware blob.
changes v18->v19
Link to v18:https://lore.kernel.org/netdev/[email protected]/ changes v17->v18
Link to v17:https://lore.kernel.org/netdev/[email protected]/ changes v16->v17
Link to v16:https://lore.kernel.org/netdev/[email protected]/ AI review issues
changes v15->v16
Link to v15:https://lore.kernel.org/netdev/[email protected]/ AI review issues
changes v14->v15
Link to v14:https://lore.kernel.org/netdev/[email protected]/ AI review issues
changes v13->v14
Link to v13:https://lore.kernel.org/netdev/[email protected]/ AI review issues
changes v12->v13
Link to v12:https://lore.kernel.org/netdev/[email protected]/ AI review issues
changes v11->v12
Link to v11:https://lore.kernel.org/netdev/[email protected]/ AI review issues
changes v10->v11
Link to v10:https://lore.kernel.org/netdev/[email protected]/ 1.Issues found by Mohsin
2.AI review issues
changes v9->v10
Link to v9:https://lore.kernel.org/netdev/[email protected]/ 1.Issues found by Jakub
2.AI review issue
changes v8->v9
Link to v8:https://lore.kernel.org/netdev/[email protected]/ 1.Issues found by Jakub
2.AI review issue
Changes v7→v8
Link to v7:https://lore.kernel.org/netdev/[email protected]/ 1.Issues found by Paolo
Changes v6->v7
Link to v6:https://lore.kernel.org/netdev/[email protected]/ 1.Issue found by Jakub
2.AI review issue
Changes v5->v6
Link to V5:https://lore.kernel.org/netdev/[email protected]/ 1.put all standard linux includes files the .c file which needs it & others --Andrew
2.AI review issue
Changes v4->v5
Link to V4:https://lore.kernel.org/netdev/[email protected]/ 1.change nbl_core to nbl & change ** pointers to *pointers & others
--Andrew
2.AI review issue
Changes v3->v4
Link to v3: https://lore.kernel.org/netdev/[email protected]
1.cut down to part of a mini driver(mailbox and chip init)
--Jakub Kicinski Simon Horman(some sort of staged approached)
2.modify issues found by ai.
3. Reverse Christmas tree/nbl_err/devm_kfree/remove some macros/
void type to real type/others
--Andrew Lunn
4.change deprecated pci_enable_msix_range to pci_alloc_irq_vectors
5.delete service layer
6.the style of kconfig---Randy Dunlap
7.add to Documentation/networking/device_drivers/ethernet/index.rst
--Simon Horman
Changes v2 →v3
Link to v2: https://lore.kernel.org/netdev/[email protected]/
1.cut down to a mini driver:
delete vf support
use promisc mode to cut down flow management
drop patch15 in v2
delete adminq msg
delete abnormal handling
delete some unimportant interfaces
2.modify issues found by ai review
Changes v1->v2
Link to v1: https://lore.kernel.org/netdev/[email protected]/
1.Format Issues and Compilation Issues
- Paolo Abeni
2.add sysfs patch and drop coexisting patch
- Andrew Lunn
3.delete some unimportant ndo operations
4.add machine generated headers patch
5.Modify the issues found in patch1-2 and apply the same fixes to other
patches
6.modify issues found by nipa
illusion wang (12):
net/nebula-matrix: add minimum nbl build framework net/nebula-matrix: add core driver architecture and HW layer
initialization
net/nebula-matrix: add channel wire opcode enum definitions net/nebula-matrix: add channel layer
net/nebula-matrix: add common resource implementation net/nebula-matrix: add intr resource implementation net/nebula-matrix: add chip-wide hardware init/deinit implementation net/nebula-matrix: dispatch: add control-level routing core
infrastructure
net/nebula-matrix: dispatch: add cross-version channel message
framework
net/nebula-matrix: dispatch: add mutual exclusion lock for shared
hardware resource ops
net/nebula-matrix: add common/ctrl dev init/remove operation net/nebula-matrix: add common dev start/stop operation
.../device_drivers/ethernet/index.rst | 1 + .../ethernet/nebula-matrix/nbl.rst | 28 + MAINTAINERS | 10 + drivers/net/ethernet/Kconfig | 1 + drivers/net/ethernet/Makefile | 1 + drivers/net/ethernet/nebula-matrix/Kconfig | 31 + drivers/net/ethernet/nebula-matrix/Makefile | 6 + .../net/ethernet/nebula-matrix/nbl/Makefile | 15 + .../nbl/nbl_channel/nbl_channel.c | 1118 +++++++++++++++++ .../nbl/nbl_channel/nbl_channel.h | 173 +++ .../nebula-matrix/nbl/nbl_common/nbl_common.c | 206 +++ .../nebula-matrix/nbl/nbl_common/nbl_common.h | 29 + .../net/ethernet/nebula-matrix/nbl/nbl_core.h | 45 + .../nebula-matrix/nbl/nbl_core/nbl_dev.c | 497 ++++++++ .../nebula-matrix/nbl/nbl_core/nbl_dev.h | 57 + .../nebula-matrix/nbl/nbl_core/nbl_dispatch.c | 626 +++++++++ .../nebula-matrix/nbl/nbl_core/nbl_dispatch.h | 40 + .../nebula-matrix/nbl/nbl_hw/nbl_chip.c | 26 + .../nebula-matrix/nbl/nbl_hw/nbl_chip.h | 12 + .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c | 1077 ++++++++++++++++ .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.h | 355 ++++++ .../nbl_hw_leonis/nbl_resource_leonis.c | 309 +++++ .../nbl_hw_leonis/nbl_resource_leonis.h | 12 + .../nebula-matrix/nbl/nbl_hw/nbl_hw_reg.h | 78 ++ .../nebula-matrix/nbl/nbl_hw/nbl_interrupt.c | 387 ++++++ .../nebula-matrix/nbl/nbl_hw/nbl_interrupt.h | 21 + .../nebula-matrix/nbl/nbl_hw/nbl_resource.c | 150 +++ .../nebula-matrix/nbl/nbl_hw/nbl_resource.h | 109 ++ .../nbl/nbl_include/nbl_def_channel.h | 378 ++++++ .../nbl/nbl_include/nbl_def_common.h | 69 + .../nbl/nbl_include/nbl_def_dev.h | 16 + .../nbl/nbl_include/nbl_def_dispatch.h | 42 + .../nbl/nbl_include/nbl_def_hw.h | 53 + .../nbl/nbl_include/nbl_def_resource.h | 38 + .../nbl/nbl_include/nbl_include.h | 66 + .../net/ethernet/nebula-matrix/nbl/nbl_main.c | 240 ++++ 36 files changed, 6322 insertions(+) create mode 100644 Documentation/networking/device_drivers/ethernet/nebula-matrix/nbl.rst create mode 100644 drivers/net/ethernet/nebula-matrix/Kconfig create mode 100644 drivers/net/ethernet/nebula-matrix/Makefile create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/Makefile create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_common/nbl_common.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_common/nbl_common.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_core.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dispatch.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dispatch.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_chip.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_chip.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_resource_leonis.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_resource_leonis.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_reg.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_interrupt.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_interrupt.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_channel.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_common.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_dev.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_dispatch.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_hw.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_resource.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_include.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c
Signature · 1 line
2.47.3
illusion.wang
maintainerPATCH v23 1/12 net/nebula-matrix: add minimum nbl build framework
From: illusion wang <[email protected]>
This patch adds the minimum build infrastructure:
1. Add Kconfig, Makefile and MAINTAINERS entries;
2. Add corresponding driver documentation;
3. Add PCI driver skeleton with empty stubs for nbl driver.
--- .../device_drivers/ethernet/index.rst | 1 + .../ethernet/nebula-matrix/nbl.rst | 28 +++++ MAINTAINERS | 10 ++ drivers/net/ethernet/Kconfig | 1 + drivers/net/ethernet/Makefile | 1 + drivers/net/ethernet/nebula-matrix/Kconfig | 31 ++++++ drivers/net/ethernet/nebula-matrix/Makefile | 6 ++ .../net/ethernet/nebula-matrix/nbl/Makefile | 6 ++ .../net/ethernet/nebula-matrix/nbl/nbl_core.h | 13 +++ .../nbl/nbl_include/nbl_include.h | 14 +++ .../net/ethernet/nebula-matrix/nbl/nbl_main.c | 100 ++++++++++++++++++ 11 files changed, 211 insertions(+) create mode 100644 Documentation/networking/device_drivers/ethernet/nebula-matrix/nbl.rst create mode 100644 drivers/net/ethernet/nebula-matrix/Kconfig create mode 100644 drivers/net/ethernet/nebula-matrix/Makefile create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/Makefile create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_core.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_include.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c
Documentation/networking/device_drivers/ethernet/index.rst +1 -0
@@ -47,6 +47,7 @@ Contents: meta/fbnic microsoft/netvsc mucse/rnpgbe + nebula-matrix/nbl netronome/nfp pensando/ionic pensando/ionic_rdma
Documentation/networking/device_drivers/ethernet/nebula-matrix/nbl.rst new file +28 -0
@@ -0,0 +1,28 @@ +.. SPDX-License-Identifier: GPL-2.0 + +================================================================ +Linux Base Driver for Nebula-matrix m18110-NIC/m18000-NIC family +================================================================ + +Overview: +========= +The m18110-NIC/m18000-NIC is a series of network interface cards for the Data +Center Area. + +The driver supports link-speed 100GbE/25GE/10GE. + +m18110-NIC/m18000-NIC devices support MSI-X interrupt vector for each Tx/Rx +queue and interrupt moderation. + +m18110-NIC/m18000-NIC devices support also various offload features such as +checksum offload, Receive-Side Scaling(RSS). + +Support +======= + +For more information about m18110-NIC/m18000-NIC, please visit the following URL: +https://www.nebula-matrix.com/snic_s1000_en + +If an issue is identified with the released source code on the supported kernel +with a supported adapter, email the specific information related to the issue to [email protected].
MAINTAINERS +10 -0
@@ -18597,6 +18597,16 @@ F: Documentation/devicetree/bindings/hwmon/nuvoton,nct7363.yaml F: Documentation/hwmon/nct7363.rst F: drivers/hwmon/nct7363.c +NEBULA-MATRIX ETHERNET DRIVER (nebula-matrix) +M: Illusion Wang <[email protected]> +M: Dimon Zhao <[email protected]> +M: Alvin Wang <[email protected]> +M: Sam Chen <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/networking/device_drivers/ethernet/nebula-matrix/ +F: drivers/net/ethernet/nebula-matrix/ + NETCONSOLE M: Breno Leitao <[email protected]> S: Maintained
drivers/net/ethernet/Kconfig +1 -0
@@ -130,6 +130,7 @@ config FEALNX source "drivers/net/ethernet/ni/Kconfig" source "drivers/net/ethernet/natsemi/Kconfig" +source "drivers/net/ethernet/nebula-matrix/Kconfig" source "drivers/net/ethernet/netronome/Kconfig" source "drivers/net/ethernet/8390/Kconfig" source "drivers/net/ethernet/nvidia/Kconfig"
drivers/net/ethernet/Makefile +1 -0
@@ -67,6 +67,7 @@ obj-$(CONFIG_NET_VENDOR_MUCSE) += mucse/ obj-$(CONFIG_NET_VENDOR_MYRI) += myricom/ obj-$(CONFIG_FEALNX) += fealnx.o obj-$(CONFIG_NET_VENDOR_NATSEMI) += natsemi/ +obj-$(CONFIG_NET_VENDOR_NEBULA_MATRIX) += nebula-matrix/ obj-$(CONFIG_NET_VENDOR_NETRONOME) += netronome/ obj-$(CONFIG_NET_VENDOR_NI) += ni/ obj-$(CONFIG_NET_VENDOR_NVIDIA) += nvidia/
drivers/net/ethernet/nebula-matrix/Kconfig new file +31 -0
@@ -0,0 +1,31 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Nebula-matrix network device configuration +# + +config NET_VENDOR_NEBULA_MATRIX + bool "Nebula-matrix devices" + default y + help + If you have a network (Ethernet) card belonging to this class, say Y. + Note that the answer to this question doesn't directly affect the + kernel: saying N will just cause the configurator to skip all + the questions about Nebula-matrix cards. If you say Y, you will be asked + for your specific card in the following questions. + +if NET_VENDOR_NEBULA_MATRIX + +config NBL + tristate "Nebula-matrix Ethernet Controller m18110/m18000 support" + depends on PCI && (64BIT || COMPILE_TEST) && !CPU_BIG_ENDIAN + help + This driver supports Nebula-matrix Ethernet Controller m18110/m18000 + Family of devices. + + More specific information on configuring the driver is in + <file:Documentation/networking/device_drivers/ethernet/nebula-matrix/nbl.rst>. + + To compile this driver as a module, choose M here. The module + will be called nbl. + +endif # NET_VENDOR_NEBULA_MATRIX
drivers/net/ethernet/nebula-matrix/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for the Nebula-matrix network device drivers. +# + +obj-$(CONFIG_NBL) += nbl/
drivers/net/ethernet/nebula-matrix/nbl/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2025 Nebula Matrix Limited. + +obj-$(CONFIG_NBL) := nbl.o + +nbl-objs += nbl_main.o
drivers/net/ethernet/nebula-matrix/nbl/nbl_core.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +*/ + +#ifndef _NBL_CORE_H_ +#define _NBL_CORE_H_ + +enum { +NBL_CAP_HAS_NET_BIT , +}; + +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_include.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +*/ + +#ifndef _NBL_INCLUDE_H_ +#define _NBL_INCLUDE_H_ + +#include <linux/types.h> + +/* ------ Basic definitions ------- */ +#define NBL_DRIVER_NAME "nbl" + +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c new file +100 -0
100 lines not on this page · raw message
Signature · 1 line
2.47.3
illusion.wang
maintainerPATCH v23 2/12 net/nebula-matrix: add core driver architecture and HW layer initialization
In reply to illusion.wangFrom: illusion wang <[email protected]>
Add the fundamental driver architecture framework and Leonis hardware layer initialization for NBL NIC family.
- nbl_adapter/nbl_core/nbl_common_info core device context
- PCI probe/remove entry and basic device capability parsing
- 64/32-bit DMA mask fallback and PCI master setup
- Leonis hardware BAR resource request and ioremap logic
This patch establishes the lowest HW layer and core infrastructure, preparing for subsequent device implementations.
--- .../net/ethernet/nebula-matrix/nbl/Makefile | 3 +- .../net/ethernet/nebula-matrix/nbl/nbl_core.h | 18 +++ .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c | 152 ++++++++++++++++++ .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.h | 14 ++ .../nebula-matrix/nbl/nbl_hw/nbl_hw_reg.h | 33 ++++ .../nbl/nbl_include/nbl_def_common.h | 32 ++++ .../nbl/nbl_include/nbl_def_hw.h | 17 ++ .../nbl/nbl_include/nbl_include.h | 9 ++ .../net/ethernet/nebula-matrix/nbl/nbl_main.c | 90 ++++++++++- 9 files changed, 366 insertions(+), 2 deletions(-) create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_reg.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_common.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_hw.h
drivers/net/ethernet/nebula-matrix/nbl/Makefile +2 -1
@@ -3,4 +3,5 @@ obj-$(CONFIG_NBL) := nbl.o -nbl-objs += nbl_main.o +nbl-objs += nbl_hw/nbl_hw_leonis/nbl_hw_leonis.o \ + nbl_main.o
drivers/net/ethernet/nebula-matrix/nbl/nbl_core.h +18 -0
@@ -6,8 +6,26 @@#ifndef _NBL_CORE_H_#define _NBL_CORE_H_ +#include <linux/pci.h> +#include "nbl_include/nbl_include.h" +#include "nbl_include/nbl_def_common.h" +enum {NBL_CAP_HAS_NET_BIT , }; +struct nbl_core { +struct nbl_hw_mgt *hw_mgt; +}; + +struct nbl_adapter { +struct pci_dev *pdev; +struct nbl_core core; +struct nbl_common_info common; +}; + +struct nbl_adapter *nbl_core_init (struct pci_dev *pdev, +struct nbl_init_param *param); +void nbl_core_remove (struct nbl_adapter *adapter); +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c new file +152 -0
152 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +*/ + +#ifndef _NBL_HW_LEONIS_H_ +#define _NBL_HW_LEONIS_H_ + +#include <linux/types.h> + +#include "../../nbl_include/nbl_include.h" +#include "../nbl_hw_reg.h" + +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_reg.h new file +33 -0
@@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +*/ + +#ifndef _NBL_HW_REG_H_ +#define _NBL_HW_REG_H_ + +#include <linux/types.h> + +#include "../nbl_include/nbl_def_hw.h" +#include "../nbl_include/nbl_def_common.h" +#include "../nbl_core.h" + +#define NBL_MEMORY_BAR 0 +#define NBL_MAILBOX_BAR 2 +#define NBL_RDMA_NOTIFY_LEN (8ULL << 10) +#define NBL_REG_NET_ONLY_LEN (8ULL << 10) +/* +* PCI MEMORY BAR total size: 64MiB. +* First 32MiB: module registers + table entry address range. +* Region after 32MiB is unused for ethernet driver. +*/ +#define NBL_HW_REG_SPACE_SIZE (32ULL << 20) + +struct nbl_hw_mgt { +struct nbl_common_info *common; +u8 __iomem *hw_addr; +u8 __iomem *mailbox_bar_hw_addr; +resource_size_t hw_size; +}; + +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_common.h new file +32 -0
@@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +*/ + +#ifndef _NBL_DEF_COMMON_H_ +#define _NBL_DEF_COMMON_H_ + +#include <linux/types.h> +#include <linux/pci.h> +#include <linux/device.h> +#include "nbl_include.h" + +struct nbl_common_info { +struct pci_dev *pdev; +struct device *dev; +u32 msg_enable; +u16 vsi_id; +u8 eth_id; +u8 logic_eth_id; +u8 eth_num; + +u8 function; +u8 devid; +u8 bus; +u8 hw_bus; + +u8 has_ctrl; +u8 has_net; +}; + +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_hw.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +*/ + +#ifndef _NBL_DEF_HW_H_ +#define _NBL_DEF_HW_H_ + +#include <linux/types.h> + +struct nbl_hw_mgt ; +struct nbl_adapter ; + +int nbl_hw_init_leonis (struct nbl_adapter *adapter); +void nbl_hw_remove_leonis (struct nbl_adapter *adapter); + +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_include.h +9 -0
@@ -10,5 +10,14 @@/* ------ Basic definitions ------- */ #define NBL_DRIVER_NAME "nbl" +struct nbl_func_caps { +u32 has_ctrl:1 ; +u32 has_net:1 ; +u32 rsv:30 ; +}; + +struct nbl_init_param { +struct nbl_func_caps caps; +};#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c +89 -1
105 lines not on this page · raw message
Signature · 1 line
2.47.3
Illusion Wang
maintainer回复:[PATCH v23 net-next 02/12] net/nebula-matrix: add core driver architecture and HW layer initialization
Review comments for V22
Quoted 10 lines · On Thu, 23 Jul 2026 12:00:54 +0800 illusion.wang wrote:
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c
Quoted 6 lines
+ err =
dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64));
+ if (err) {drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c +4
-0+dev_dbg (dev,"Configure DMA 64 bit mask failed, err = %d\n" , + err); + dma_32_err =dma_set_mask_and_coherent (dev,DMA_BIT_MASK (32 )); +if (dma_32_err) {Read the documentation for the DMA API,
dma_set_mask_and_coherent()is guaranteed to succeed in some cases..
As documented:dma_set_mask_and_coherent() never return fail when DMA_BIT_MASK(64). Typical error code like::
/* Wrong code */ if (dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64))) dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32))
dma_set_mask_and_coherent() will never return failure when bigger than 32. So typical code like::
/* Recommended code */ if (support_64bit) dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)); else dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
Review comments for V23
Quoted 11 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c line 84
Quoted 5 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c +5
-0+ err =dma_set_mask_and_coherent (dev,DMA_BIT_MASK (64 )); +if (err) { +dev_dbg (dev,"Configure DMA 64 bit mask failed, err = %d\n" , + err); +dma_set_mask_and_coherent (dev,DMA_BIT_MASK (32 ));If the 64-bit mask configuration fails in
nbl_probe(), and this 32-bit fallback also fails, does probe succeed anyway leaving the device with an unconfigured or invalid DMA mask?
Since the return value of the fallbackdma_set_mask_and_coherent()is ignored, the probe path will continue without a valid DMA mask configuration, which could cause subsequent DMA operations to fail or misbehave silently.
Quoted 4 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c line 88
Quoted 4 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c +4
-0+ } +pci_set_master (pdev); + + adapter =nbl_core_init (pdev, ¶m);
So My fix implementation is OK?
ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
if (ret) {
dev_err(&pdev->dev, "Set 64bit DMA mask failed %d, device cannot work\n", ret);
goto err_out;
}...pci_set_master(pdev);
adapter = nbl_core_init(pdev, ¶m);
illusion.wang
maintainerPATCH v23 3/12 net/nebula-matrix: add channel wire opcode enum definitions
In reply to illusion.wangFrom: illusion wang <[email protected]>
Add enum nbl_chan_msg_type into nbl_def_channel.h, defining all PF/VF/firmware channel wire opcodes used for inter-component mailbox communication.
Each enumerator carries an explicit fixed numeric value, acting as stable wire-format message ID shared between driver and firmware.
ABI constraint: New opcodes must only be appended before NBL_CHAN_MSG_MAILBOX_MAX.
Reordering, inserting or deleting existing entries will break cross-version driver-firmware interoperability. Any modification to existing opcode assignments requires coordinated firmware ABI change.
This commit introduces the opcode ID enumeration. Message payload structures and complete channel layer logic will be added in subsequent separate patches.
--- .../nbl/nbl_include/nbl_def_channel.h | 242 ++++++++++++++++++ 1 file changed, 242 insertions(+) create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_channel.h
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_channel.h new file +242 -0
@@ -0,0 +1,242 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +*/ + +#ifndef _NBL_DEF_CHANNEL_H_ +#define _NBL_DEF_CHANNEL_H_ + +/* +* Mailbox wire opcodes +* Every opcode is assigned explicit fixed numeric value, stable wire ABI +* shared between driver and firmware. +* Firmware/driver wire compatibility rule: +* New entries must only be appended before NBL_CHAN_MSG_MAILBOX_MAX. +* Reordering / inserting / deleting existing items will break cross-version +* interoperability. Any change to existing enumerators requires matching +* firmware ABI adjustment. +*/ +enum nbl_chan_msg_type { +NBL_CHAN_MSG_ACK =0 , +NBL_CHAN_MSG_ADD_MACVLAN =1 , +NBL_CHAN_MSG_DEL_MACVLAN =2 , +NBL_CHAN_MSG_ADD_MULTI_RULE =3 , +NBL_CHAN_MSG_DEL_MULTI_RULE =4 , +NBL_CHAN_MSG_SETUP_MULTI_GROUP =5 , +NBL_CHAN_MSG_REMOVE_MULTI_GROUP =6 , +NBL_CHAN_MSG_REGISTER_NET =7 , +NBL_CHAN_MSG_UNREGISTER_NET =8 , +NBL_CHAN_MSG_ALLOC_TXRX_QUEUES =9 , +NBL_CHAN_MSG_FREE_TXRX_QUEUES =10 , +NBL_CHAN_MSG_SETUP_QUEUE =11 , +NBL_CHAN_MSG_REMOVE_ALL_QUEUES =12 , +NBL_CHAN_MSG_CFG_DSCH =13 , +NBL_CHAN_MSG_SETUP_CQS =14 , +NBL_CHAN_MSG_REMOVE_CQS =15 , +NBL_CHAN_MSG_CFG_QDISC_MQPRIO =16 , +NBL_CHAN_MSG_CONFIGURE_MSIX_MAP =17 , +NBL_CHAN_MSG_DESTROY_MSIX_MAP =18 , +NBL_CHAN_MSG_MAILBOX_SET_IRQ =19 , +NBL_CHAN_MSG_GET_GLOBAL_VECTOR =20 , +NBL_CHAN_MSG_GET_VSI_ID =21 , +NBL_CHAN_MSG_SET_PROMISC_MODE =22 , +NBL_CHAN_MSG_GET_FIRMWARE_VERSION =23 , +NBL_CHAN_MSG_GET_QUEUE_ERR_STATS =24 , +NBL_CHAN_MSG_GET_COALESCE =25 , +NBL_CHAN_MSG_SET_COALESCE =26 , +NBL_CHAN_MSG_SET_SPOOF_CHECK_ADDR =27 , +NBL_CHAN_MSG_SET_VF_SPOOF_CHECK =28 , +NBL_CHAN_MSG_GET_RXFH_INDIR_SIZE =29 , +NBL_CHAN_MSG_GET_RXFH_INDIR =30 , +NBL_CHAN_MSG_GET_RXFH_RSS_KEY =31 , +NBL_CHAN_MSG_GET_RXFH_RSS_ALG_SEL =32 , +NBL_CHAN_MSG_GET_HW_CAPS =33 , +NBL_CHAN_MSG_GET_HW_STATE =34 , +NBL_CHAN_MSG_REGISTER_RDMA =35 , +NBL_CHAN_MSG_UNREGISTER_RDMA =36 , +NBL_CHAN_MSG_GET_REAL_HW_ADDR =37 , +NBL_CHAN_MSG_GET_REAL_BDF =38 , +NBL_CHAN_MSG_GRC_PROCESS =39 , +NBL_CHAN_MSG_SET_SFP_STATE =40 , +NBL_CHAN_MSG_SET_ETH_LOOPBACK =41 , +NBL_CHAN_MSG_CHECK_ACTIVE_VF =42 , +NBL_CHAN_MSG_GET_PRODUCT_FLEX_CAP =43 , +NBL_CHAN_MSG_ALLOC_KTLS_TX_INDEX =44 , +NBL_CHAN_MSG_FREE_KTLS_TX_INDEX =45 , +NBL_CHAN_MSG_CFG_KTLS_TX_KEYMAT =46 , +NBL_CHAN_MSG_ALLOC_KTLS_RX_INDEX =47 , +NBL_CHAN_MSG_FREE_KTLS_RX_INDEX =48 , +NBL_CHAN_MSG_CFG_KTLS_RX_KEYMAT =49 , +NBL_CHAN_MSG_CFG_KTLS_RX_RECORD =50 , +NBL_CHAN_MSG_ADD_KTLS_RX_FLOW =51 , +NBL_CHAN_MSG_DEL_KTLS_RX_FLOW =52 , +NBL_CHAN_MSG_ALLOC_IPSEC_TX_INDEX =53 , +NBL_CHAN_MSG_FREE_IPSEC_TX_INDEX =54 , +NBL_CHAN_MSG_ALLOC_IPSEC_RX_INDEX =55 , +NBL_CHAN_MSG_FREE_IPSEC_RX_INDEX =56 , +NBL_CHAN_MSG_CFG_IPSEC_TX_SAD =57 , +NBL_CHAN_MSG_CFG_IPSEC_RX_SAD =58 , +NBL_CHAN_MSG_ADD_IPSEC_TX_FLOW =59 , +NBL_CHAN_MSG_DEL_IPSEC_TX_FLOW =60 , +NBL_CHAN_MSG_ADD_IPSEC_RX_FLOW =61 , +NBL_CHAN_MSG_DEL_IPSEC_RX_FLOW =62 , +NBL_CHAN_MSG_NOTIFY_IPSEC_HARD_EXPIRE =63 , +NBL_CHAN_MSG_GET_MBX_IRQ_NUM =64 , +NBL_CHAN_MSG_CLEAR_FLOW =65 , +NBL_CHAN_MSG_CLEAR_QUEUE =66 , +NBL_CHAN_MSG_GET_ETH_ID =67 , +NBL_CHAN_MSG_SET_OFFLOAD_STATUS =68 , +NBL_CHAN_MSG_INIT_OFLD =69 , +NBL_CHAN_MSG_INIT_CMDQ =70 , +NBL_CHAN_MSG_DESTROY_CMDQ =71 , +NBL_CHAN_MSG_RESET_CMDQ =72 , +NBL_CHAN_MSG_INIT_FLOW =73 , +NBL_CHAN_MSG_DEINIT_FLOW =74 , +NBL_CHAN_MSG_OFFLOAD_FLOW_RULE =75 , +NBL_CHAN_MSG_GET_ACL_SWITCH =76 , +NBL_CHAN_MSG_GET_VSI_GLOBAL_QUEUE_ID =77 , +NBL_CHAN_MSG_INIT_REP =78 , +NBL_CHAN_MSG_GET_LINE_RATE_INFO =79 , +NBL_CHAN_MSG_REGISTER_NET_REP =80 , +NBL_CHAN_MSG_UNREGISTER_NET_REP =81 , +NBL_CHAN_MSG_REGISTER_ETH_REP =82 , +NBL_CHAN_MSG_UNREGISTER_ETH_REP =83 , +NBL_CHAN_MSG_REGISTER_UPCALL_PORT =84 , +NBL_CHAN_MSG_UNREGISTER_UPCALL_PORT =85 , +NBL_CHAN_MSG_GET_PORT_STATE =86 , +NBL_CHAN_MSG_SET_PORT_ADVERTISING =87 , +NBL_CHAN_MSG_GET_MODULE_INFO =88 , +NBL_CHAN_MSG_GET_MODULE_EEPROM =89 , +NBL_CHAN_MSG_GET_LINK_STATE =90 , +NBL_CHAN_MSG_NOTIFY_LINK_STATE =91 , +NBL_CHAN_MSG_GET_QUEUE_CXT =92 , +NBL_CHAN_MSG_CFG_LOG =93 , +NBL_CHAN_MSG_INIT_VDPAQ =94 , +NBL_CHAN_MSG_DESTROY_VDPAQ =95 , +NBL_CHAN_MSG_GET_UPCALL_PORT =96 , +NBL_CHAN_MSG_NOTIFY_ETH_REP_LINK_STATE =97 , +NBL_CHAN_MSG_SET_ETH_MAC_ADDR =98 , +NBL_CHAN_MSG_GET_FUNCTION_ID =99 , +NBL_CHAN_MSG_GET_CHIP_TEMPERATURE =100 , +NBL_CHAN_MSG_DISABLE_HW_FLOW =101 , +NBL_CHAN_MSG_ENABLE_HW_FLOW =102 , +NBL_CHAN_MSG_SET_UPCALL_RULE =103 , +NBL_CHAN_MSG_UNSET_UPCALL_RULE =104 , +NBL_CHAN_MSG_GET_REG_DUMP =105 , +NBL_CHAN_MSG_GET_REG_DUMP_LEN =106 , +NBL_CHAN_MSG_CFG_LAG_HASH_ALGORITHM =107 , +NBL_CHAN_MSG_CFG_LAG_MEMBER_FWD =108 , +NBL_CHAN_MSG_CFG_LAG_MEMBER_LIST =109 , +NBL_CHAN_MSG_CFG_LAG_MEMBER_UP_ATTR =110 , +NBL_CHAN_MSG_ADD_LAG_FLOW =111 , +NBL_CHAN_MSG_DEL_LAG_FLOW =112 , +NBL_CHAN_MSG_SWITCHDEV_INIT_CMDQ =113 , +NBL_CHAN_MSG_SWITCHDEV_DEINIT_CMDQ =114 , +NBL_CHAN_MSG_SET_TC_FLOW_INFO =115 , +NBL_CHAN_MSG_UNSET_TC_FLOW_INFO =116 , +NBL_CHAN_MSG_INIT_ACL =117 , +NBL_CHAN_MSG_UNINIT_ACL =118 , +NBL_CHAN_MSG_CFG_LAG_MCC =119 , +NBL_CHAN_MSG_REGISTER_VSI2Q =120 , +NBL_CHAN_MSG_SETUP_Q2VSI =121 , +NBL_CHAN_MSG_REMOVE_Q2VSI =122 , +NBL_CHAN_MSG_SETUP_RSS =123 , +NBL_CHAN_MSG_REMOVE_RSS =124 , +NBL_CHAN_MSG_GET_REP_QUEUE_INFO =125 , +NBL_CHAN_MSG_CTRL_PORT_LED =126 , +NBL_CHAN_MSG_NWAY_RESET =127 , +NBL_CHAN_MSG_SET_INTL_SUPPRESS_LEVEL =128 , +NBL_CHAN_MSG_GET_ETH_STATS =129 , +NBL_CHAN_MSG_GET_MODULE_TEMPERATURE =130 , +NBL_CHAN_MSG_GET_BOARD_INFO =131 , +NBL_CHAN_MSG_GET_P4_USED =132 , +NBL_CHAN_MSG_GET_VF_BASE_VSI_ID =133 , +NBL_CHAN_MSG_ADD_LLDP_FLOW =134 , +NBL_CHAN_MSG_DEL_LLDP_FLOW =135 , +NBL_CHAN_MSG_CFG_ETH_BOND_INFO =136 , +NBL_CHAN_MSG_CFG_DUPPKT_MCC =137 , +NBL_CHAN_MSG_ADD_ND_UPCALL_FLOW =138 , +NBL_CHAN_MSG_DEL_ND_UPCALL_FLOW =139 , +NBL_CHAN_MSG_GET_BOARD_ID =140 , +NBL_CHAN_MSG_SET_SHAPING_DPORT_VLD =141 , +NBL_CHAN_MSG_SET_DPORT_FC_TH_VLD =142 , +NBL_CHAN_MSG_REGISTER_RDMA_BOND =143 , +NBL_CHAN_MSG_UNREGISTER_RDMA_BOND =144 , +NBL_CHAN_MSG_RESTORE_NETDEV_QUEUE =145 , +NBL_CHAN_MSG_RESTART_NETDEV_QUEUE =146 , +NBL_CHAN_MSG_RESTORE_HW_QUEUE =147 , +NBL_CHAN_MSG_KEEP_ALIVE =148 , +NBL_CHAN_MSG_GET_BASE_MAC_ADDR =149 , +NBL_CHAN_MSG_CFG_BOND_SHAPING =150 , +NBL_CHAN_MSG_CFG_BGID_BACK_PRESSURE =151 , +NBL_CHAN_MSG_ALLOC_KT_BLOCK =152 , +NBL_CHAN_MSG_FREE_KT_BLOCK =153 , +NBL_CHAN_MSG_GET_USER_QUEUE_INFO =154 , +NBL_CHAN_MSG_GET_ETH_BOND_INFO =155 , +NBL_CHAN_MSG_CLEAR_ACCEL_FLOW =156 , +NBL_CHAN_MSG_SET_BRIDGE_MODE =157 , +NBL_CHAN_MSG_GET_VF_FUNCTION_ID =158 , +NBL_CHAN_MSG_NOTIFY_LINK_FORCED =159 , +NBL_CHAN_MSG_SET_PMD_DEBUG =160 , +NBL_CHAN_MSG_REGISTER_FUNC_MAC =161 , +NBL_CHAN_MSG_SET_TX_RATE =162 , +NBL_CHAN_MSG_REGISTER_FUNC_LINK_FORCED =163 , +NBL_CHAN_MSG_GET_LINK_FORCED =164 , +NBL_CHAN_MSG_REGISTER_FUNC_VLAN =165 , +NBL_CHAN_MSG_GET_FD_FLOW =166 , +NBL_CHAN_MSG_GET_FD_FLOW_CNT =167 , +NBL_CHAN_MSG_GET_FD_FLOW_ALL =168 , +NBL_CHAN_MSG_GET_FD_FLOW_MAX =169 , +NBL_CHAN_MSG_REPLACE_FD_FLOW =170 , +NBL_CHAN_MSG_REMOVE_FD_FLOW =171 , +NBL_CHAN_MSG_CFG_FD_FLOW_STATE =172 , +NBL_CHAN_MSG_REGISTER_FUNC_RATE =173 , +NBL_CHAN_MSG_NOTIFY_VLAN =174 , +NBL_CHAN_MSG_GET_XDP_QUEUE_INFO =175 , +NBL_CHAN_MSG_STOP_ABNORMAL_SW_QUEUE =176 , +NBL_CHAN_MSG_STOP_ABNORMAL_HW_QUEUE =177 , +NBL_CHAN_MSG_NOTIFY_RESET_EVENT =178 , +NBL_CHAN_MSG_ACK_RESET_EVENT =179 , +NBL_CHAN_MSG_GET_VF_VSI_ID =180 , +NBL_CHAN_MSG_CONFIGURE_QOS =181 , +NBL_CHAN_MSG_GET_PFC_BUFFER_SIZE =182 , +NBL_CHAN_MSG_SET_PFC_BUFFER_SIZE =183 , +NBL_CHAN_MSG_GET_VF_STATS =184 , +NBL_CHAN_MSG_REGISTER_FUNC_TRUST =185 , +NBL_CHAN_MSG_NOTIFY_TRUST =186 , +NBL_CHAN_MSG_CHECK_VF_IS_ACTIVE =187 , +NBL_CHAN_MSG_GET_ETH_ABNORMAL_STATS =188 , +NBL_CHAN_MSG_GET_ETH_CTRL_STATS =189 , +NBL_CHAN_MSG_GET_PAUSE_STATS =190 , +NBL_CHAN_MSG_GET_ETH_MAC_STATS =191 , +NBL_CHAN_MSG_GET_FEC_STATS =192 , +NBL_CHAN_MSG_CFG_MULTI_MCAST_RULE =193 , +NBL_CHAN_MSG_GET_LINK_DOWN_COUNT =194 , +NBL_CHAN_MSG_GET_LINK_STATUS_OPCODE =195 , +NBL_CHAN_MSG_GET_RMON_STATS =196 , +NBL_CHAN_MSG_REGISTER_PF_NAME =197 , +NBL_CHAN_MSG_GET_PF_NAME =198 , +NBL_CHAN_MSG_CONFIGURE_RDMA_BW =199 , +NBL_CHAN_MSG_SET_RATE_LIMIT =200 , +NBL_CHAN_MSG_SET_TC_WGT =201 , +NBL_CHAN_MSG_REMOVE_QUEUE =202 , +NBL_CHAN_MSG_GET_MIRROR_TABLE_ID =203 , +NBL_CHAN_MSG_CONFIGURE_MIRROR =204 , +NBL_CHAN_MSG_CONFIGURE_MIRROR_TABLE =205 , +NBL_CHAN_MSG_CLEAR_MIRROR_CFG =206 , +NBL_CHAN_MSG_MIRROR_OUTPUTPORT_NOTIFY =207 , +NBL_CHAN_MSG_CHECK_FLOWTABLE_SPEC =208 , +NBL_CHAN_MSG_CHECK_VF_IS_VDPA =209 , +NBL_CHAN_MSG_GET_VDPA_VF_STATS =210 , +NBL_CHAN_MSG_SET_RX_RATE =211 , +NBL_CHAN_MSG_GET_UVN_PKT_DROP_STATS =212 , +NBL_CHAN_MSG_GET_USTORE_PKT_DROP_STATS =213 , +NBL_CHAN_MSG_GET_USTORE_TOTAL_PKT_DROP_STATS =214 , +NBL_CHAN_MSG_SET_WOL =215 , +NBL_CHAN_MSG_INIT_VF_MSIX_MAP =216 , +NBL_CHAN_MSG_GET_ST_NAME =217 , +/* mailbox msg end */ +NBL_CHAN_MSG_MAILBOX_MAX , +}; + +#endif
Signature · 1 line
2.47.3
illusion.wang
maintainerPATCH v23 4/12 net/nebula-matrix: add channel layer
In reply to illusion.wangFrom: illusion wang <[email protected]>
A channel management layer provides a structured approach to handle communication between different components and drivers. Here's a summary of its key functionalities:
1. Message Handling Framework
Message Registration: Functions (nbl_chan_register_msg) allow dynamic registration of message handlers for specific message types, enabling extensible communication protocols.
Message Sending/Acknowledgment: Core functions (nbl_chan_send_msg, nbl_chan_send_ack) handle message transmission. It supports two modes:
fire-and-forget transmission, and synchronous send with ACK waiting. Received ACK messages are processed via nbl_chan_recv_ack_msg. TX slot allocation logic is implemented to limit concurrent outstanding messages; returns -EAGAIN when all waiting slots are occupied.
Hash-Based Handler Lookup: A hash table (handle_hash_tbl) stores message handlers for efficient O(1) lookup by message type. The entire table is removed via nbl_chan_remove_msg_handler during driver teardown; per-message-type unregister is not implemented in this version.
Tx descriptor supports two data formats: small embedded payload inside descriptor, and large payload via external DMA buffer.
2. Channel Types and Queue Management
Mailbox Channel: implemented for inter-PF communication (PF0 <-> other PFs).
Queue Initialization: Functions (nbl_chan_init_queue, nbl_chan_init_tx_queue) allocate resources:
- TX/RX descriptors: dmam_alloc_coherent()
- TX/RX buffer metadata arrays (txq->buf, rxq->buf): devm_kcalloc()
Queue Teardown: nbl_chan_teardown_queue() stops hardware queues, cancels pending work items (clean_task), and waits for in-flight send threads to drain. It does NOT free DMA memory, which is released automatically via devm on driver remove.
IMPORTANT - Resource Lifecycle Design:
DMA memory allocated with dmam_alloc_coherent() is intentionally NOT freed in nbl_chan_teardown_queue(). The queues are allocated once during driver probe and freed only during driver remove. Dynamic per-PF queue teardown and re-creation during runtime is not supported.
Queue Configuration: Hardware-specific queue parameters (e.g., buffer sizes, entry counts) are set via nbl_chan_config_queue, with hardware interactions delegated to hw_ops.
RX completion relies on work_struct clean_task for descriptor processing.
3. Hardware Abstraction Layer (HW Ops)
Hardware-Specific Operations: The nbl_hw_ops structure abstracts hardware interactions: queue configuration (config_mailbox_txq/rxq), tail pointer doorbell updates (update_mailbox_queue_tail_ptr), and PF mailbox routing table configuration.
NOTE: This initial implementation provides interrupt-driven receive path, where actual RX message processing is scheduled into workqueue after interrupt notification. Polling-based mailbox receive is not supported in this patch and will be added in subsequent series.
And the optimization to requeue clean_task inside nbl_chan_clean_queue() when processing budget is exhausted is deferred to follow-up patches.
--- .../net/ethernet/nebula-matrix/nbl/Makefile | 4 +- .../nbl/nbl_channel/nbl_channel.c | 1044 +++++++++++++++++ .../nbl/nbl_channel/nbl_channel.h | 170 +++ .../nebula-matrix/nbl/nbl_common/nbl_common.c | 166 +++ .../nebula-matrix/nbl/nbl_common/nbl_common.h | 29 + .../net/ethernet/nebula-matrix/nbl/nbl_core.h | 7 + .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c | 170 +++ .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.h | 56 + .../nebula-matrix/nbl/nbl_hw/nbl_hw_reg.h | 45 + .../nbl/nbl_include/nbl_def_channel.h | 110 ++ .../nbl/nbl_include/nbl_def_common.h | 15 + .../nbl/nbl_include/nbl_def_hw.h | 19 + .../nbl/nbl_include/nbl_include.h | 13 + .../net/ethernet/nebula-matrix/nbl/nbl_main.c | 7 + 14 files changed, 1854 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_common/nbl_common.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_common/nbl_common.h
drivers/net/ethernet/nebula-matrix/nbl/Makefile +3 -1
@@ -3,5 +3,7 @@ obj-$(CONFIG_NBL) := nbl.o -nbl-objs += nbl_hw/nbl_hw_leonis/nbl_hw_leonis.o \ +nbl-objs += nbl_common/nbl_common.o \ + nbl_channel/nbl_channel.o \ + nbl_hw/nbl_hw_leonis/nbl_hw_leonis.o \ nbl_main.o
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.c new file +1044 -0
1,044 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.h new file +170 -0
170 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_common/nbl_common.c new file +166 -0
166 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_common/nbl_common.h new file +29 -0
@@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +*/ + +#ifndef _NBL_COMMON_H_ +#define _NBL_COMMON_H_ + +#include <linux/types.h> + +#include "../nbl_include/nbl_include.h" +#include "../nbl_include/nbl_def_common.h" + +/* list only need one bucket size */ +#define NBL_HASH_TBL_LIST_BUCKET_SIZE 1 + +struct nbl_hash_tbl_mgt { +struct nbl_hash_tbl_key tbl_key; +struct hlist_head *hash; +u16 node_num; +}; + +struct nbl_hash_entry_node { +struct hlist_node node; +void *key; +void *data; +}; + +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_core.h +7 -0
@@ -14,13 +14,20 @@ enum { NBL_CAP_HAS_NET_BIT, }; +struct nbl_interface { +struct nbl_hw_ops_tbl *hw_ops_tbl; +struct nbl_channel_ops_tbl *channel_ops_tbl; +}; +struct nbl_core {struct nbl_hw_mgt *hw_mgt; +struct nbl_channel_mgt *chan_mgt; };struct nbl_adapter {struct pci_dev *pdev;struct nbl_core core; +struct nbl_interface intf;struct nbl_common_info common; };
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c +170 -0
194 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.h +56 -0
60 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_reg.h +45 -0
63 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_channel.h +110 -0
120 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_common.h +15 -0
@@ -29,4 +29,19 @@ struct nbl_common_info { u8 has_net; }; +struct nbl_hash_tbl_key { +struct device *dev; +u16 key_size; +u16 data_size;/* no include key or node member */ +u16 bucket_size; +u16 resv; +}; + +struct nbl_hash_tbl_mgt * +nbl_common_init_hash_table (struct nbl_hash_tbl_key *key); +void nbl_common_remove_hash_table (struct nbl_hash_tbl_mgt *tbl_mgt); +int nbl_common_alloc_hash_node (struct nbl_hash_tbl_mgt *tbl_mgt,void *key, +void *data,void **out_data); +void *nbl_common_get_hash_node (struct nbl_hash_tbl_mgt *tbl_mgt,void *key); +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_hw.h +19 -0
@@ -10,6 +10,25 @@struct nbl_hw_mgt ;struct nbl_adapter ; +struct nbl_hw_ops { +void (*update_mailbox_queue_tail_ptr)(struct nbl_hw_mgt *hw_mgt, +u16 tail_ptr,u8 txrx); +void (*config_mailbox_rxq)(struct nbl_hw_mgt *hw_mgt, +dma_addr_t dma_addr,int size_bwid); +void (*config_mailbox_txq)(struct nbl_hw_mgt *hw_mgt, +dma_addr_t dma_addr,int size_bwid); +void (*stop_mailbox_rxq)(struct nbl_hw_mgt *hw_mgt); +void (*stop_mailbox_txq)(struct nbl_hw_mgt *hw_mgt); +void (*get_host_pf_mask)(struct nbl_hw_mgt *hw_mgt,u32 *pf_mask); + +void (*cfg_mailbox_qinfo)(struct nbl_hw_mgt *hw_mgt,u16 func_id, +u8 bus,u8 devid,u8 function); +}; + +struct nbl_hw_ops_tbl { +struct nbl_hw_ops *ops; +struct nbl_hw_mgt *priv; +};int nbl_hw_init_leonis (struct nbl_adapter *adapter);void nbl_hw_remove_leonis (struct nbl_adapter *adapter);
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_include.h +13 -0
@@ -10,6 +10,12 @@/* ------ Basic definitions ------- */ #define NBL_DRIVER_NAME "nbl" +#define NBL_MAX_PF 8 +#define NBL_NEXT_ID (id, max) \ + ({ \ + typeof(id) _id = (id); \ + ((_id) == (max) ? 0 : (_id) + 1); \ + })struct nbl_func_caps {u32 has_ctrl:1 ;u32 has_net:1 ;
@@ -20,4 +26,11 @@ struct nbl_init_param { struct nbl_func_caps caps; }; +#define NBL_OPS_CALL (func, para) \ +do { \ + typeof(func) _func = (func); \ + if (_func) \ + _func para; \ +} while (0) +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c +7 -0
@@ -8,6 +8,7 @@#include <linux/module.h> #include <linux/bits.h> #include "nbl_include/nbl_include.h" +#include "nbl_include/nbl_def_channel.h" #include "nbl_include/nbl_def_hw.h" #include "nbl_include/nbl_def_common.h" #include "nbl_core.h"
@@ -38,13 +39,19 @@ struct nbl_adapter *nbl_core_init(struct pci_dev *pdev,if (ret) goto hw_init_fail; + ret =nbl_chan_init_common (adapter); +if (ret) + goto chan_init_fail;return adapter; +chan_init_fail: +nbl_hw_remove_leonis (adapter); hw_init_fail:return ERR_PTR (ret); }void nbl_core_remove (struct nbl_adapter *adapter) { +nbl_chan_remove_common (adapter);nbl_hw_remove_leonis (adapter); }
Signature · 1 line
2.47.3
Jakub Kicinski
maintainerRe: [PATCH v23 net-next 04/12] net/nebula-matrix: add channel layer
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_include.h struct nbl_init_param { · line 34
Quoted 6 lines · On Fri, 31 Jul 2026 17:42:27 +0800 illusion.wang wrote:
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_include.h +6
-0+#define NBL_OPS_CALL (func, para) \ +do { \ + typeof(func) _func = (func); \ + if (_func) \ + _func para; \ +} while (0)
Just spotted in the compiler warning -- this macro is definitely not going to make it upstream. The C coding style of this driver is very much below the upstream bar, please try to get this reviewed by someone with upstream experience, or taste, or both.
illusion.wang
maintainerPATCH v23 5/12 net/nebula-matrix: add common resource implementation
In reply to illusion.wangFrom: illusion wang <[email protected]>
The Resource layer processes the entries/data of various modules within the processing chip to accomplish specific entry management operations, this describes the module business capabilities of the chip and the data it manages.
The resource layer comprises the following sub-modules: common, interrupt, and vsi(txrx,queue not contained this time)
This patch provides the common part, including the conversion relationships among vsi_id, func_id, eth_id, and pf_id. These relationships may be utilized in the upper layer or the resource layer.
Key Assumptions:
- nbl_res_start() initializes VSI/Eth/PF data structures **only for control devices** (common->has_ctrl == true).
- APIs like nbl_res_func_id_to_vsi_id() **are guaranteed to be called only on control devices** by the framework's dispatch layer.
--- .../net/ethernet/nebula-matrix/nbl/Makefile | 2 + .../nebula-matrix/nbl/nbl_common/nbl_common.c | 19 ++ .../net/ethernet/nebula-matrix/nbl/nbl_core.h | 2 + .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c | 58 ++++ .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.h | 14 + .../nbl_hw_leonis/nbl_resource_leonis.c | 299 ++++++++++++++++++ .../nbl_hw_leonis/nbl_resource_leonis.h | 10 + .../nebula-matrix/nbl/nbl_hw/nbl_resource.c | 120 +++++++ .../nebula-matrix/nbl/nbl_hw/nbl_resource.h | 74 +++++ .../nbl/nbl_include/nbl_def_common.h | 19 ++ .../nbl/nbl_include/nbl_def_hw.h | 4 + .../nbl/nbl_include/nbl_def_resource.h | 29 ++ .../nbl/nbl_include/nbl_include.h | 7 + .../net/ethernet/nebula-matrix/nbl/nbl_main.c | 9 + 14 files changed, 666 insertions(+) create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_resource_leonis.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_resource_leonis.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_resource.h
drivers/net/ethernet/nebula-matrix/nbl/Makefile +2 -0
@@ -6,4 +6,6 @@ obj-$(CONFIG_NBL) := nbl.o nbl-objs += nbl_common/nbl_common.o \ nbl_channel/nbl_channel.o \ nbl_hw/nbl_hw_leonis/nbl_hw_leonis.o \ + nbl_hw/nbl_hw_leonis/nbl_resource_leonis.o \ + nbl_hw/nbl_resource.o \ nbl_main.o
drivers/net/ethernet/nebula-matrix/nbl/nbl_common/nbl_common.c +19 -0
@@ -7,6 +7,25 @@#include <linux/jhash.h> #include "nbl_common.h" +/* +* nbl_common_func_id_to_rel_pf_id - convert absolute PF id to relative PF id +* +* Leonis currently uses fixed mgt_pf = 0. This helper maintains unified +* conversion logic for future platforms supporting non-zero management PF. +* Return: 0 on success, -EINVAL if pf_id < common->mgt_pf or rel_pf_id is NULL. +*/ +int nbl_common_func_id_to_rel_pf_id (struct nbl_common_info *common,u32 pf_id, +u32 *rel_pf_id) +{ +if (!rel_pf_id) +return -EINVAL ; + +if (pf_id < common->mgt_pf) +return -EINVAL ; + *rel_pf_id = pf_id - common->mgt_pf; +return 0 ; +} +static u32 nbl_common_calc_hash_key (void *key,u32 key_size,u32 bucket_size) {u32 hash;
drivers/net/ethernet/nebula-matrix/nbl/nbl_core.h +2 -0
@@ -16,11 +16,13 @@ enum {struct nbl_interface {struct nbl_hw_ops_tbl *hw_ops_tbl; +struct nbl_resource_ops_tbl *resource_ops_tbl;struct nbl_channel_ops_tbl *channel_ops_tbl; };struct nbl_core {struct nbl_hw_mgt *hw_mgt; +struct nbl_resource_mgt *res_mgt;struct nbl_channel_mgt *chan_mgt; };
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c +58 -0
90 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.h +14 -0
@@ -67,4 +67,18 @@ struct nbl_mailbox_qinfo_cfg_table {#define NBL_PCIE_HOST_K_PF_MASK_REG (NBL_INTF_HOST_PCIE_BASE + 0x00001004)#define NBL_PCIE_HOST_TL_CFG_BUSDEV (NBL_INTF_HOST_PCIE_BASE + 0x11040) +#define NBL_PCIE_BUS_MASK GENMASK(12, 5) +#define NBL_FW_BOARD_CONFIG 0x200 +#define NBL_FW_BOARD_DW3_OFFSET (NBL_FW_BOARD_CONFIG + 12) +#define NBL_FW_BOARD_DW6_OFFSET (NBL_FW_BOARD_CONFIG + 24) + +#define NBL_FW_BOARD_DW3_PORT_TYPE_MASK BIT(0) +#define NBL_FW_BOARD_DW3_PORT_NUM_MASK GENMASK(7, 1) +#define NBL_FW_BOARD_DW3_PORT_SPEED_MASK GENMASK(9, 8) +#define NBL_FW_BOARD_DW3_GPIO_TYPE_MASK GENMASK(12, 10) +#define NBL_FW_BOARD_DW3_P4_VERSION_MASK GENMASK(13, 13) + +#define NBL_FW_BOARD_DW6_LANE_BITMAP_MASK GENMASK(7, 0) +#define NBL_FW_BOARD_DW6_ETH_BITMAP_MASK GENMASK(15, 8) +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_resource_leonis.c new file +299 -0
299 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_resource_leonis.h new file +10 -0
@@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +*/ + +#ifndef _NBL_RESOURCE_LEONIS_H_ +#define _NBL_RESOURCE_LEONIS_H_ + +#include "../nbl_resource.h" +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.c new file +120 -0
120 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.h new file +74 -0
74 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_common.h +19 -0
@@ -11,6 +11,22 @@#include <linux/device.h> #include "nbl_include.h" +#define NBL_TWO_ETHERNET_PORT 2 +#define NBL_FOUR_ETHERNET_PORT 4 +#define NBL_DEFAULT_VSI_ID_GAP 1024 +#define NBL_TWO_ETHERNET_VSI_ID_GAP 512 +#define NBL_FOUR_ETHERNET_VSI_ID_GAP 256 + +#define NBL_VSI_ID_GAP (m) \ + ({ \ + typeof(m) _m = (m); \ + _m == NBL_FOUR_ETHERNET_PORT ? \ + NBL_FOUR_ETHERNET_VSI_ID_GAP : \ + (_m == NBL_TWO_ETHERNET_PORT ? \ + NBL_TWO_ETHERNET_VSI_ID_GAP : \ + NBL_DEFAULT_VSI_ID_GAP); \ + }) +struct nbl_common_info {struct pci_dev *pdev;struct device *dev;
@@ -24,6 +40,7 @@ struct nbl_common_info {u8 devid;u8 bus;u8 hw_bus; +u16 mgt_pf;u8 has_ctrl;u8 has_net;
@@ -37,6 +54,8 @@ struct nbl_hash_tbl_key {u16 resv; }; +int nbl_common_func_id_to_rel_pf_id (struct nbl_common_info *common,u32 pf_id, +u32 *rel_pf_id);struct nbl_hash_tbl_mgt *nbl_common_init_hash_table (struct nbl_hash_tbl_key *key);void nbl_common_remove_hash_table (struct nbl_hash_tbl_mgt *tbl_mgt);
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_hw.h +4 -0
@@ -20,9 +20,13 @@ struct nbl_hw_ops {void (*stop_mailbox_rxq)(struct nbl_hw_mgt *hw_mgt);void (*stop_mailbox_txq)(struct nbl_hw_mgt *hw_mgt);void (*get_host_pf_mask)(struct nbl_hw_mgt *hw_mgt,u32 *pf_mask); +void (*get_real_bus)(struct nbl_hw_mgt *hw_mgt,u8 *bus);void (*cfg_mailbox_qinfo)(struct nbl_hw_mgt *hw_mgt,u16 func_id,u8 bus,u8 devid,u8 function); +void (*get_fw_eth_map)(struct nbl_hw_mgt *hw_mgt,u32 *eth_map); +void (*get_board_info)(struct nbl_hw_mgt *hw_mgt, +struct nbl_board_port_info *board); };struct nbl_hw_ops_tbl {
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_resource.h new file +29 -0
@@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +*/ + +#ifndef _NBL_DEF_RESOURCE_H_ +#define _NBL_DEF_RESOURCE_H_ + +#include <linux/types.h> + +struct nbl_resource_mgt ; +struct nbl_adapter ; + +struct nbl_resource_ops { +int (*get_vsi_id)(struct nbl_resource_mgt *res_mgt,u16 func_id, +u16 type,u16 *vsi_id); +int (*get_eth_id)(struct nbl_resource_mgt *res_mgt,u16 func_id, +u16 vsi_id,u8 *eth_num,u8 *eth_id, +u8 *logic_eth_id); +}; + +struct nbl_resource_ops_tbl { +struct nbl_resource_ops *ops; +struct nbl_resource_mgt *priv; +}; + +int nbl_res_init_leonis (struct nbl_adapter *adapter); +void nbl_res_remove_leonis (struct nbl_adapter *adapter); +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_include.h +7 -0
@@ -16,6 +16,13 @@typeof (id) _id = (id); \ ((_id) == (max) ?0 : (_id) +1 ); \ }) + +#define NBL_MAX_ETHERNET 4 + +enum { +NBL_VSI_DATA =0 , +}; +struct nbl_func_caps {u32 has_ctrl:1 ;u32 has_net:1 ;
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c +9 -0
@@ -10,6 +10,7 @@#include "nbl_include/nbl_include.h" #include "nbl_include/nbl_def_channel.h" #include "nbl_include/nbl_def_hw.h" +#include "nbl_include/nbl_def_resource.h" #include "nbl_include/nbl_def_common.h" #include "nbl_core.h"
@@ -27,6 +28,7 @@ struct nbl_adapter *nbl_core_init(struct pci_dev *pdev, adapter->pdev = pdev; common = &adapter->common; + common->mgt_pf =0 ; common->pdev = pdev; common->dev = &pdev->dev; common->has_ctrl = param->caps.has_ctrl;
@@ -42,7 +44,13 @@ struct nbl_adapter *nbl_core_init(struct pci_dev *pdev, ret =nbl_chan_init_common (adapter);if (ret) goto chan_init_fail; + + ret =nbl_res_init_leonis (adapter); +if (ret) + goto res_init_fail;return adapter; +res_init_fail: +nbl_chan_remove_common (adapter); chan_init_fail:nbl_hw_remove_leonis (adapter); hw_init_fail:
@@ -51,6 +59,7 @@ struct nbl_adapter *nbl_core_init(struct pci_dev *pdev,void nbl_core_remove (struct nbl_adapter *adapter) { +nbl_res_remove_leonis (adapter);nbl_chan_remove_common (adapter);nbl_hw_remove_leonis (adapter); }
Signature · 1 line
2.47.3
Jakub Kicinski
maintainerRe: [PATCH v23 net-next 05/12] net/nebula-matrix: add common resource implementation
Quoted 13 lines · On Fri, 31 Jul 2026 17:42:28 +0800 illusion.wang wrote:
From: illusion wang <[email protected]>
The Resource layer processes the entries/data of various modules within the processing chip to accomplish specific entry management operations, this describes the module business capabilities of the chip and the data it manages.
The resource layer comprises the following sub-modules: common, interrupt, andvsi(txrx,queue not contained this time)This patch provides the common part, including the conversion relationships among
vsi_id,func_id,eth_id, andpf_id. These relationships may be utilized in the upper layer or the resource layer.
Quoted 7 lines
Key Assumptions:
-nbl_res_start()initializes VSI/Eth/PF data structures **only for control devices** (common->has_ctrl == true).
- APIs likenbl_res_func_id_to_vsi_id()**are guaranteed to be called only on control devices** by the framework's dispatch layer.Signed-off-by illusion wang <[email protected]>
This generates a possibly transient warning when built with W=1
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_resource_leonis.c:68:2: warning: variable 'eth_bitmap' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
68 | NBL_OPS_CALL(hw_ops->get_fw_eth_map,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
69 | (res_mgt->hw_ops_tbl->priv, ð_bitmap));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/../../nbl_include/nbl_include.h:39:6: note: expanded from macro 'NBL_OPS_CALL'
39 | if (_func) \
| ^~~~~
../drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_resource_leonis.c:70:6: note: uninitialized use occurs here
70 | if (eth_bitmap & ~((1 << NBL_MAX_ETHERNET) - 1)) {
| ^~~~~~~~~~
../drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_resource_leonis.c:68:2: note: remove the 'if' if its condition is always true
68 | NBL_OPS_CALL(hw_ops->get_fw_eth_map,
| ^
../drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/../../nbl_include/nbl_include.h:39:2: note: expanded from macro 'NBL_OPS_CALL'
39 | if (_func) \
| ^
../drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_resource_leonis.c:56:16: note: initialize the variable 'eth_bitmap' to silence this warning
56 | u32 eth_bitmap, eth_id;
| ^
| = 0illusion.wang
maintainerPATCH v23 6/12 net/nebula-matrix: add intr resource implementation
In reply to illusion.wangFrom: illusion wang <[email protected]>
Add nbl_interrupt module to manage driver global MSI-X vector indices, and extend hw_ops with callbacks to program vendor-specific internal MSI-X mapping registers, configure MSI-X metadata, and bind interrupts to PF mailbox channels.
Key interfaces:
- configure_msix_map:
Allocates driver global MSI-X indices via separate net/other interrupt bitmaps (interrupt_net_bitmap / interrupt_others_bitmap). Preallocates all required coherent DMA resources first; only tears down old hardware configuration after all new allocations succeed. Programs NBL_PCOMPLETER_FUNCTION_MSIX_MAP with the MSI-X table DMA address and function BDF info. PCI MSI-X vector allocation itself is performed via nbl_dev_alloc_msix_intr() at upper layer.
- destroy_msix_map:
Releases allocated global vector indices, clears hardware MSI-X mappings, frees DMA buffer and interrupt array. A delay is inserted before releasing DMA memory to mitigate potential IOMMU faults caused by in-flight hardware DMA access after MMIO disable.
- set_mailbox_irq:
Enables or disables MSI-X routing for a given PF mailbox by updating NBL_MAILBOX_QINFO_MAP_REG_ARR with the target global vector id.
- configure_msix_info:
Programs PADPT_HOST_MSIX_INFO and PCOMPLETER_HOST_MSIX_FID_TABLE to record function BDF and MSI-X mask enable attribute for each global interrupt vector.
This module manages chip-internal MSI-X routing table and global vector index space. It does NOT invoke kernel PCI MSI-X allocation helpers (pci_alloc_irq_vectors, pci_msix_alloc_irq_at, irq_domain); physical PCI MSI-X vector allocation belongs to separate device layer.
Interrupt manager instance is created during resource startup (nbl_intr_mgt_start) and attached to resource management context.
Note: Mutual exclusion for configure_msix_map, destroy_msix_map, and set_mailbox_irq is enforced by dispatch layer. These routines assume caller holds required locks.
--- .../net/ethernet/nebula-matrix/nbl/Makefile | 1 + .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c | 142 +++++++ .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.h | 42 ++ .../nbl_hw_leonis/nbl_resource_leonis.c | 8 + .../nbl_hw_leonis/nbl_resource_leonis.h | 1 + .../nebula-matrix/nbl/nbl_hw/nbl_interrupt.c | 387 ++++++++++++++++++ .../nebula-matrix/nbl/nbl_hw/nbl_interrupt.h | 21 + .../nebula-matrix/nbl/nbl_hw/nbl_resource.c | 30 ++ .../nebula-matrix/nbl/nbl_hw/nbl_resource.h | 35 ++ .../nbl/nbl_include/nbl_def_hw.h | 10 + .../nbl/nbl_include/nbl_def_resource.h | 6 + .../nbl/nbl_include/nbl_include.h | 1 + 12 files changed, 684 insertions(+) create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_interrupt.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_interrupt.h
drivers/net/ethernet/nebula-matrix/nbl/Makefile +1 -0
@@ -8,4 +8,5 @@ nbl-objs += nbl_common/nbl_common.o \ nbl_hw/nbl_hw_leonis/nbl_hw_leonis.o \ nbl_hw/nbl_hw_leonis/nbl_resource_leonis.o \ nbl_hw/nbl_resource.o \ + nbl_hw/nbl_interrupt.o \ nbl_main.o
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c +142 -0
166 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.h +42 -0
48 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_resource_leonis.c +8 -0
@@ -10,6 +10,9 @@static struct nbl_resource_ops res_ops = { .get_vsi_id = nbl_res_func_id_to_vsi_id, .get_eth_id = nbl_res_get_eth_id, + .configure_msix_map = nbl_res_intr_configure_msix_map, + .destroy_msix_map = nbl_res_intr_destroy_msix_map, + .set_mailbox_irq = nbl_res_intr_set_mailbox_irq, }; static struct nbl_resource_mgt *
@@ -257,7 +260,12 @@ static int nbl_res_start(struct nbl_resource_mgt *res_mgt) ret =nbl_res_ctrl_dev_vsi_info_init (res_mgt);if (ret)return ret; + + ret =nbl_intr_mgt_start (res_mgt); +if (ret) +return ret; } +return 0 ; }
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_resource_leonis.h +1 -0
@@ -7,4 +7,5 @@#define _NBL_RESOURCE_LEONIS_H_#include "../nbl_resource.h" +#include "../nbl_interrupt.h" #endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_interrupt.c new file +387 -0
387 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_interrupt.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +*/ + +#ifndef _NBL_INTERRUPT_H_ +#define _NBL_INTERRUPT_H_ + +#include "nbl_resource.h" + +#define NBL_MSIX_MAP_TABLE_MAX_ENTRIES 1024 +int nbl_res_intr_destroy_msix_map (struct nbl_resource_mgt *res_mgt, +u16 func_id); +int nbl_res_intr_configure_msix_map (struct nbl_resource_mgt *res_mgt, +u16 func_id,u16 num_net_msix, +u16 num_others_msix, +bool net_msix_mask_en); +int nbl_res_intr_set_mailbox_irq (struct nbl_resource_mgt *res_mgt, +u16 func_id,u16 vector_id, +bool enable_msix); +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.c +30 -0
@@ -68,6 +68,36 @@ int nbl_res_vsi_id_to_pf_id(struct nbl_resource_mgt *res_mgt, u16 vsi_id)return -ENOENT ; } +int nbl_res_func_id_to_bdf (struct nbl_resource_mgt *res_mgt,u16 func_id, +u8 *bus,u8 *dev,u8 *function) +{ +struct nbl_common_info *common = res_mgt->common; +struct nbl_sriov_info *sriov_info; +int pfid = func_id; +u8 pf_bus, devfn; +u32 rel_pf_id; +int ret; + +if (!common->has_ctrl || !bus || !dev || !function) +return -EINVAL ; + ret =nbl_common_func_id_to_rel_pf_id (common, pfid, &rel_pf_id); +if (ret) +return ret; +if (rel_pf_id >= res_mgt->resource_info->max_pf) { +dev_err (common->dev,"PF ID %u exceeds maximum supported PF count %u\n" , + pfid, res_mgt->resource_info->max_pf); +return -ERANGE ; + } + sriov_info = res_mgt->resource_info->sriov_info + rel_pf_id; + pf_bus =PCI_BUS_NUM (sriov_info->bdf); + devfn = sriov_info->bdf &0xff ; + *bus = pf_bus; + *dev =PCI_SLOT (devfn); + *function =PCI_FUNC (devfn); + +return 0 ; +} +int nbl_res_get_eth_id (struct nbl_resource_mgt *res_mgt,u16 func_id,u16 vsi_id,u8 *eth_num,u8 *eth_id,u8 *logic_eth_id) {
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.h +35 -0
@@ -17,6 +17,38 @@struct nbl_resource_mgt ; +/* --------- INTERRUPT ---------- */ +#define NBL_MAX_OTHER_INTERRUPT 1024 +#define NBL_MAX_NET_INTERRUPT 4096 +#define NBL_NET_INTR_BASE NBL_MAX_OTHER_INTERRUPT + +#define NBL_MSIX_MAP_VALID_MASK BIT(0) +#define NBL_MSIX_MAP_INDEX_MASK GENMASK(13, 1) +#define NBL_MSIX_MAP_RSV_MASK GENMASK(15, 14) + +struct nbl_msix_map { +__le16 data; +}; + +struct nbl_msix_map_table { +struct nbl_msix_map *base_addr; +dma_addr_t dma; +size_t size; +}; + +struct nbl_func_interrupt_resource_mng { +u16 num_interrupts; +u16 num_net_interrupts; +u16 *interrupts; +struct nbl_msix_map_table msix_map_table; +}; + +struct nbl_interrupt_mgt { + DECLARE_BITMAP(intr_net_bmap, NBL_MAX_NET_INTERRUPT); + DECLARE_BITMAP(intr_other_bmap, NBL_MAX_OTHER_INTERRUPT); +struct nbl_func_interrupt_resource_mng func_intr_res[NBL_MAX_FUNC ]; +}; +/* --------- INFO ---------- */ struct nbl_sriov_info {unsigned int bdf;
@@ -66,8 +98,11 @@ struct nbl_resource_mgt {int nbl_res_vsi_id_to_pf_id (struct nbl_resource_mgt *res_mgt,u16 vsi_id);int nbl_res_func_id_to_vsi_id (struct nbl_resource_mgt *res_mgt,u16 func_id,u16 type,u16 *vsi_id); +int nbl_res_func_id_to_bdf (struct nbl_resource_mgt *res_mgt,u16 func_id, +u8 *bus,u8 *dev,u8 *function);int nbl_res_get_eth_id (struct nbl_resource_mgt *res_mgt,u16 func_id,u16 vsi_id,u8 *eth_num,u8 *eth_id,u8 *logic_eth_id); +int nbl_intr_mgt_start (struct nbl_resource_mgt *res_mgt);int nbl_res_pf_dev_vsi_type_to_hw_vsi_type (struct nbl_resource_mgt *res_mgt,u16 src_type,enum nbl_vsi_serv_type *dst_type);
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_hw.h +10 -0
@@ -11,6 +11,14 @@struct nbl_hw_mgt ;struct nbl_adapter ;struct nbl_hw_ops { +void (*configure_msix_map)(struct nbl_hw_mgt *hw_mgt,u16 func_id, +bool valid,dma_addr_t dma_addr,u8 bus, +u8 devid,u8 function); +void (*configure_msix_info)(struct nbl_hw_mgt *hw_mgt,u16 func_id, +bool valid,u16 interrupt_id,u8 bus, +u8 devid,u8 function, +bool net_msix_mask_en); +void (*flush_write)(struct nbl_hw_mgt *hw_mgt);void (*update_mailbox_queue_tail_ptr)(struct nbl_hw_mgt *hw_mgt,u16 tail_ptr,u8 txrx); void (*config_mailbox_rxq)(struct nbl_hw_mgt *hw_mgt,
@@ -24,6 +32,8 @@ struct nbl_hw_ops {void (*cfg_mailbox_qinfo)(struct nbl_hw_mgt *hw_mgt,u16 func_id,u8 bus,u8 devid,u8 function); +void (*set_mailbox_irq)(struct nbl_hw_mgt *hw_mgt,u16 func_id, +bool enable_msix,u16 global_vec_id);void (*get_fw_eth_map)(struct nbl_hw_mgt *hw_mgt,u32 *eth_map);void (*get_board_info)(struct nbl_hw_mgt *hw_mgt,struct nbl_board_port_info *board);
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_resource.h +6 -0
@@ -12,6 +12,12 @@ struct nbl_resource_mgt;struct nbl_adapter ;struct nbl_resource_ops { +int (*configure_msix_map)(struct nbl_resource_mgt *res_mgt,u16 func_id, +u16 num_net_msix,u16 num_others_msix, +bool net_msix_mask_en); +int (*destroy_msix_map)(struct nbl_resource_mgt *res_mgt,u16 func_id); +int (*set_mailbox_irq)(struct nbl_resource_mgt *res_mgt,u16 func_id, +u16 vector_id,bool enable_msix);int (*get_vsi_id)(struct nbl_resource_mgt *res_mgt,u16 func_id,u16 type,u16 *vsi_id); int (*get_eth_id)(struct nbl_resource_mgt *res_mgt, u16 func_id,
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_include.h +1 -0
@@ -17,6 +17,7 @@ ((_id) == (max) ?0 : (_id) +1 ); \ }) +#define NBL_MAX_FUNC 520#define NBL_MAX_ETHERNET 4enum {
Signature · 1 line
2.47.3
illusion.wang
maintainerPATCH v23 7/12 net/nebula-matrix: add chip-wide hardware init/deinit implementation
In reply to illusion.wangFrom: illusion wang <[email protected]>
Add Leonis chip-wide hardware initialization and deinitialization logic to setup the full datapath pipeline, including packet engines, scheduler, buffer stores, queue manager, port traffic shaping, and flow control, and the driver_status hardware flag consumed by firmware.
HW layer overview:
The HW layer code is highly chip-specific and may benefit from additional review since it cannot be cross-checked against other implementations.
DP sub-init modules (called from nbl_dp_init()):
- dped, uped: Data/User Packet Engine Driver
- dsch: Scheduler core (qid limit init, PSHA enable inside shaping init)
- ustore, dstore: Buffer Store modules
- dvn, uvn: Virtual Descriptor Network modules
- uqm: Queue Manager
- nbl_shaping_init(): Per-port traffic shaping + DSCH PSHA config
Chip init sequence (nbl_hw_init_chip_module()):
1. nbl_dp_init() — All DP sub-modules listed above
2. nbl_intf_init() — Host adapter padpt flow control
- nbl_host_padpt_init() — Host padpt flow control registers
3. nbl_hw_set_driver_status() + nbl_flush_writes()
Chip deinit logic relies on firmware cleanup: only driver_status flag is cleared and flushed; FW releases partial hardware state automatically.
--- .../net/ethernet/nebula-matrix/nbl/Makefile | 1 + .../nebula-matrix/nbl/nbl_hw/nbl_chip.c | 26 + .../nebula-matrix/nbl/nbl_hw/nbl_chip.h | 12 + .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c | 555 ++++++++++++++++++ .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.h | 229 ++++++++ .../nbl_hw_leonis/nbl_resource_leonis.c | 2 + .../nbl_hw_leonis/nbl_resource_leonis.h | 1 + .../nbl/nbl_include/nbl_def_hw.h | 3 + .../nbl/nbl_include/nbl_def_resource.h | 3 + .../nbl/nbl_include/nbl_include.h | 20 + 10 files changed, 852 insertions(+) create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_chip.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_chip.h
drivers/net/ethernet/nebula-matrix/nbl/Makefile +1 -0
@@ -9,4 +9,5 @@ nbl-objs += nbl_common/nbl_common.o \ nbl_hw/nbl_hw_leonis/nbl_resource_leonis.o \ nbl_hw/nbl_resource.o \ nbl_hw/nbl_interrupt.o \ + nbl_hw/nbl_chip.o \ nbl_main.o
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_chip.c new file +26 -0
@@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2025 Nebula Matrix Limited. +*/ +#include <linux/device.h> +#include "nbl_chip.h" + +void nbl_res_chip_deinit_module (struct nbl_resource_mgt *res_mgt) +{ +struct nbl_hw_ops *hw_ops = res_mgt->hw_ops_tbl->ops; + +NBL_OPS_CALL (hw_ops->deinit_module, (res_mgt->hw_ops_tbl->priv)); +} + +int nbl_res_chip_init_module (struct nbl_resource_mgt *res_mgt) +{ +u8 eth_speed = res_mgt->resource_info->board_info.eth_speed; +u8 eth_num = res_mgt->resource_info->board_info.eth_num; +struct nbl_hw_ops *hw_ops = res_mgt->hw_ops_tbl->ops; +struct nbl_hw_mgt *p = res_mgt->hw_ops_tbl->priv; +int ret; + + ret =NBL_OPS_CALL_RET (hw_ops->init_module, (p, eth_speed, eth_num)); + +return ret; +}
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_chip.h new file +12 -0
@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +*/ + +#ifndef _NBL_CHIP_H_ +#define _NBL_CHIP_H_ + +#include "nbl_resource.h" +int nbl_res_chip_init_module (struct nbl_resource_mgt *res_mgt); +void nbl_res_chip_deinit_module (struct nbl_resource_mgt *res_mgt); +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c +555 -0
567 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.h +229 -0
251 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_resource_leonis.c +2 -0
@@ -13,6 +13,8 @@ static struct nbl_resource_ops res_ops = { .configure_msix_map = nbl_res_intr_configure_msix_map, .destroy_msix_map = nbl_res_intr_destroy_msix_map, .set_mailbox_irq = nbl_res_intr_set_mailbox_irq, + .init_module = nbl_res_chip_init_module, + .deinit_module = nbl_res_chip_deinit_module, }; static struct nbl_resource_mgt *
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_resource_leonis.h +1 -0
@@ -8,4 +8,5 @@#include "../nbl_resource.h" #include "../nbl_interrupt.h" +#include "../nbl_chip.h" #endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_hw.h +3 -0
@@ -11,6 +11,9 @@struct nbl_hw_mgt ;struct nbl_adapter ;struct nbl_hw_ops { +int (*init_module)(struct nbl_hw_mgt *hw_mgt,u8 eth_speed,u8 eth_num); +void (*deinit_module)(struct nbl_hw_mgt *hw_mgt); +void (*configure_msix_map)(struct nbl_hw_mgt *hw_mgt,u16 func_id,bool valid,dma_addr_t dma_addr,u8 bus,u8 devid,u8 function);
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_resource.h +3 -0
@@ -12,6 +12,9 @@ struct nbl_resource_mgt;struct nbl_adapter ;struct nbl_resource_ops { +int (*init_module)(struct nbl_resource_mgt *res_mgt); +void (*deinit_module)(struct nbl_resource_mgt *res_mgt); +int (*configure_msix_map)(struct nbl_resource_mgt *res_mgt,u16 func_id,u16 num_net_msix,u16 num_others_msix,bool net_msix_mask_en);
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_include.h +20 -0
@@ -34,6 +34,17 @@ struct nbl_init_param {struct nbl_func_caps caps; }; +/* +* Firmware ABI defines port speed enum fixed, value 0 represents 10G, cannot +* reassign 0 to INVALID for compatibility +*/ +enum nbl_fw_port_speed { +NBL_FW_PORT_SPEED_10G , +NBL_FW_PORT_SPEED_25G , +NBL_FW_PORT_SPEED_50G , +NBL_FW_PORT_SPEED_100G , +}; +#define NBL_OPS_CALL (func, para) \ do { \ typeof(func) _func = (func); \
@@ -41,4 +52,13 @@ do { \_func para; \ } while (0) +/* Optional ops: NULL means not implemented, return 0 = no-op (not an error) */ +#define NBL_OPS_CALL_RET (func, para) \ +({ \ + typeof(func) _func = (func); \ + _func ? _func para : 0; \ +}) + +#define NBL_QUIRK_UVN_PREFETCH_ALIGN BIT(1) +#endif
Signature · 1 line
2.47.3
illusion.wang
maintainerPATCH v23 8/12 net/nebula-matrix: dispatch: add control-level routing core infrastructure
In reply to illusion.wangFrom: illusion wang <[email protected]>
Add base dispatch layer infrastructure for control-level routing:
1. Dispatch management & ops table structures allocation
2. X-macro op table template for uniform dispatch entry registration
3. Control PF / regular PF routing logic via ctrl_lvl bitmask
4. Local chip init/deinit dispatch wrappers (no channel dependency)
Document constraint: init_module/deinit_module only valid on Control PF, caller must guard with has_ctrl to avoid NULL deref.
This patch only provides core routing skeleton, no channel message handling or resource locking logic.
--- .../net/ethernet/nebula-matrix/nbl/Makefile | 1 + .../nbl/nbl_channel/nbl_channel.c | 4 + .../net/ethernet/nebula-matrix/nbl/nbl_core.h | 2 + .../nebula-matrix/nbl/nbl_core/nbl_dispatch.c | 137 ++++++++++++++++++ .../nebula-matrix/nbl/nbl_core/nbl_dispatch.h | 24 +++ .../nbl/nbl_include/nbl_def_channel.h | 26 ++++ .../nbl/nbl_include/nbl_def_dispatch.h | 42 ++++++ .../nbl/nbl_include/nbl_include.h | 2 + .../net/ethernet/nebula-matrix/nbl/nbl_main.c | 8 + 9 files changed, 246 insertions(+) create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dispatch.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dispatch.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_dispatch.h
drivers/net/ethernet/nebula-matrix/nbl/Makefile +1 -0
@@ -10,4 +10,5 @@ nbl-objs += nbl_common/nbl_common.o \ nbl_hw/nbl_resource.o \ nbl_hw/nbl_interrupt.o \ nbl_hw/nbl_chip.o \ + nbl_core/nbl_dispatch.o \ nbl_main.o
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.c +4 -0
@@ -1006,6 +1006,10 @@ int nbl_chan_init_common(struct nbl_adapter *adap)struct nbl_channel_mgt *chan_mgt;int ret; +BUILD_BUG_ON (sizeof (struct nbl_chan_param_cfg_msix_map ) !=8 ); +BUILD_BUG_ON (sizeof (struct nbl_chan_param_set_mailbox_irq ) !=4 ); +BUILD_BUG_ON (sizeof (struct nbl_chan_param_get_vsi_id ) !=4 ); +BUILD_BUG_ON (sizeof (struct nbl_chan_param_get_eth_id ) !=8 ); chan_mgt =nbl_chan_setup_chan_mgt (adap);if (IS_ERR (chan_mgt)) { ret =PTR_ERR (chan_mgt);
drivers/net/ethernet/nebula-matrix/nbl/nbl_core.h +2 -0
@@ -17,12 +17,14 @@ enum {struct nbl_interface {struct nbl_hw_ops_tbl *hw_ops_tbl;struct nbl_resource_ops_tbl *resource_ops_tbl; +struct nbl_dispatch_ops_tbl *dispatch_ops_tbl;struct nbl_channel_ops_tbl *channel_ops_tbl; };struct nbl_core {struct nbl_hw_mgt *hw_mgt;struct nbl_resource_mgt *res_mgt; +struct nbl_dispatch_mgt *disp_mgt;struct nbl_channel_mgt *chan_mgt; };
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dispatch.c new file +137 -0
137 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dispatch.h new file +24 -0
@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +*/ + +#ifndef _NBL_DISPATCH_H_ +#define _NBL_DISPATCH_H_ +#include "../nbl_include/nbl_include.h" +#include "../nbl_include/nbl_def_channel.h" +#include "../nbl_include/nbl_def_hw.h" +#include "../nbl_include/nbl_def_resource.h" +#include "../nbl_include/nbl_def_dispatch.h" +#include "../nbl_include/nbl_def_common.h" +#include "../nbl_core.h" + +struct nbl_dispatch_mgt { +struct nbl_common_info *common; +struct nbl_resource_ops_tbl *res_ops_tbl; +struct nbl_channel_ops_tbl *chan_ops_tbl; +struct nbl_dispatch_ops_tbl *disp_ops_tbl; + DECLARE_BITMAP(ctrl_lvl, NBL_DISP_CTRL_LVL_MAX); +}; + +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_channel.h +26 -0
@@ -258,6 +258,32 @@ enum nbl_chan_state {NBL_CHAN_STATE_NBITS }; +struct nbl_chan_param_cfg_msix_map { +__le16 num_net_msix; +__le16 num_others_msix; +__le16 msix_mask_en; +__le16 rsvd; +}; + +struct nbl_chan_param_set_mailbox_irq { +__le16 vector_id; +u8 enable_msix; +u8 rsvd; +}; + +struct nbl_chan_param_get_vsi_id { +__le16 vsi_id; +__le16 type; +}; + +struct nbl_chan_param_get_eth_id { +__le16 vsi_id; +u8 eth_num; +u8 eth_id; +u8 logic_eth_id; +u8 rsvd[3 ]; +}; +struct nbl_board_port_info {u8 eth_num;u8 eth_speed;
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_dispatch.h new file +42 -0
42 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_include.h +2 -0
@@ -19,6 +19,8 @@#define NBL_MAX_FUNC 520#define NBL_MAX_ETHERNET 4 +/* Used for macros to pass checkpatch */ +#define NBL_NAME (x) xenum {NBL_VSI_DATA =0 ,
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c +8 -0
@@ -11,6 +11,7 @@#include "nbl_include/nbl_def_channel.h" #include "nbl_include/nbl_def_hw.h" #include "nbl_include/nbl_def_resource.h" +#include "nbl_include/nbl_def_dispatch.h" #include "nbl_include/nbl_def_common.h" #include "nbl_core.h"
@@ -48,7 +49,13 @@ struct nbl_adapter *nbl_core_init(struct pci_dev *pdev, ret =nbl_res_init_leonis (adapter);if (ret) goto res_init_fail; + + ret =nbl_disp_init (adapter); +if (ret) + goto disp_init_fail;return adapter; +disp_init_fail: +nbl_res_remove_leonis (adapter); res_init_fail:nbl_chan_remove_common (adapter); chan_init_fail:
@@ -59,6 +66,7 @@ struct nbl_adapter *nbl_core_init(struct pci_dev *pdev,void nbl_core_remove (struct nbl_adapter *adapter) { +nbl_disp_remove (adapter);nbl_res_remove_leonis (adapter);nbl_chan_remove_common (adapter);nbl_hw_remove_leonis (adapter);
Signature · 1 line
2.47.3
illusion.wang
maintainerPATCH v23 9/12 net/nebula-matrix: dispatch: add cross-version channel message framework
In reply to illusion.wangFrom: illusion wang <[email protected]>
Implement bidirectional channel request/response RPC handlers for 5 dispatch resource operations: get_vsi_id, get_eth_id, configure_msix_map, destroy_msix_map, set_mailbox_irq.
- Extend X-macro NBL_DISP_OPS_TBL to pair local dispatch entry points with cross-PF mailbox request/response callbacks.
- Add registration helper nbl_disp_setup_msg() to auto-register channel response handlers for ops with valid msg_type.
- Introduce NBL_CHAN_RESP_UNIMPLEMENTED dedicated error code for missing resource ops implementation on remote PF.
- Add dev_err logging when sending RPC ACK back to remote PF fails.
The existing init_module/deinit_module dispatch entries use msg_type = -1, so they do not register any mailbox channel handlers and are excluded from RPC logic.
- Separate local channel transmission errors and remote RPC wire response codes:
The channel layer returns ACK header err via nbl_chan_send_msg() when wait_ack=1. Translate wire protocol defined remote codes NBL_CHAN_RESP_* to standard kernel errno at dispatch request wrapper to avoid semantic confusion between wire handshake values and system error numbers exposed to upper layers.
- Collapse all fine-grained resource operation sub-errors into generic NBL_CHAN_RESP_ERR on wire to keep message payload layout unchanged and maintain backward compatibility with legacy firmware.
- Fix unimplemented ops check order in response handler to prevent NULL pointer invocation of resource ops.
Add input sanitization for mailbox response handlers:
The driver maintains cross-version interoperability; older peers may send truncated payloads. Existing min_t() + zero-init local param logic absorbs partial messages and zero-fills missing fields. To mitigate risk:
1. Allow truncated payloads (0 < data_len < sizeof(param)) for backward compatibility, continue zero-filling missing fields.
2. Reject data_len == 0 messages entirely, avoid invoking resource ops with all-zero initialized parameters.nbl_disp_chan_destroy_msix_map_resp carries no input payload and skips payload length validation.
Note: Serialization mutex protecting concurrent MSIX map and mailbox irq hardware operations will be added in a separate subsequent patch.
--- .../nebula-matrix/nbl/nbl_core/nbl_dispatch.c | 473 ++++++++++++++++++ 1 file changed, 473 insertions(+)
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dispatch.c +473 -0
@@ -6,6 +6,158 @@#include <linux/pci.h> #include "nbl_dispatch.h" +static int nbl_disp_chan_get_vsi_id_req (struct nbl_dispatch_mgt *disp_mgt, +u16 type,u16 *vsi_id) +{ +struct nbl_channel_ops *chan_ops = disp_mgt->chan_ops_tbl->ops; +struct nbl_common_info *common = disp_mgt->common; +struct nbl_chan_param_get_vsi_id result = {0 }; +struct nbl_chan_param_get_vsi_id param = {0 }; +struct nbl_chan_send_info chan_send; +int ret; + + param.type =cpu_to_le16 (type); + +nbl_chan_fill_send_info (&chan_send, common->mgt_pf, +NBL_CHAN_MSG_GET_VSI_ID , + ¶m,sizeof (param), &result, +sizeof (result),1 ); + ret = chan_ops->send_msg (disp_mgt->chan_ops_tbl->priv, &chan_send); +switch (ret) { +case NBL_CHAN_RESP_UNIMPLEMENTED : +return -EOPNOTSUPP ; +case NBL_CHAN_RESP_ERR : +return -EREMOTEIO ; +case NBL_CHAN_RESP_OK : +break ; +default : +return ret; + } + *vsi_id =le16_to_cpu (result.vsi_id); +return 0 ; +} + +static void nbl_disp_chan_get_vsi_id_resp (void *priv,u16 src_id,u16 msg_id, +void *data,u32 data_len) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_channel_ops *chan_ops = disp_mgt->chan_ops_tbl->ops; +struct nbl_resource_ops *res_ops = disp_mgt->res_ops_tbl->ops; +struct nbl_resource_mgt *p = disp_mgt->res_ops_tbl->priv; +struct device *dev = disp_mgt->common->dev; +struct nbl_chan_param_get_vsi_id result = {0 }; +struct nbl_chan_param_get_vsi_id param = {0 }; +struct nbl_chan_ack_info chan_ack; +int err =NBL_CHAN_RESP_OK ; +u16 vsi_id =0 ; +int copy_len; +int ret; + +if (data_len ==0 ) { + err =NBL_CHAN_RESP_ERR ; + goto ack_out; + } + copy_len =min_t (size_t, data_len,sizeof (param)); +memcpy (¶m, data, copy_len); +if (!res_ops->get_vsi_id) { + err =NBL_CHAN_RESP_UNIMPLEMENTED ; + }else { + ret =NBL_OPS_CALL_RET (res_ops->get_vsi_id, + (p, src_id,le16_to_cpu (param.type), + &vsi_id)); +if (ret) + err =NBL_CHAN_RESP_ERR ; + } + result.vsi_id =cpu_to_le16 (vsi_id); +ack_out: +nbl_chan_fill_ack_info (&chan_ack, src_id, +NBL_CHAN_MSG_GET_VSI_ID , msg_id, err, + &result,sizeof (result)); + ret = chan_ops->send_ack (disp_mgt->chan_ops_tbl->priv, &chan_ack); +if (ret) +dev_err (dev, +"channel send ack failed with ret: %d, msg_type: %d\n" , + ret,NBL_CHAN_MSG_GET_VSI_ID ); +} + +static int nbl_disp_chan_get_eth_id_req (struct nbl_dispatch_mgt *disp_mgt, +u16 vsi_id,u8 *eth_num,u8 *eth_id, +u8 *logic_eth_id) +{ +struct nbl_channel_ops *chan_ops = disp_mgt->chan_ops_tbl->ops; +struct nbl_common_info *common = disp_mgt->common; +struct nbl_chan_param_get_eth_id result = {0 }; +struct nbl_chan_param_get_eth_id param = {0 }; +struct nbl_chan_send_info chan_send; +int ret; + + param.vsi_id =cpu_to_le16 (vsi_id); + +nbl_chan_fill_send_info (&chan_send, common->mgt_pf, +NBL_CHAN_MSG_GET_ETH_ID , + ¶m,sizeof (param), &result, +sizeof (result),1 ); + ret = chan_ops->send_msg (disp_mgt->chan_ops_tbl->priv, &chan_send); +switch (ret) { +case NBL_CHAN_RESP_UNIMPLEMENTED : +return -EOPNOTSUPP ; +case NBL_CHAN_RESP_ERR : +return -EREMOTEIO ; +case NBL_CHAN_RESP_OK : +break ; +default : +return ret; + } + *eth_num = result.eth_num; + *eth_id = result.eth_id; + *logic_eth_id = result.logic_eth_id; + +return 0 ; +} + +static void nbl_disp_chan_get_eth_id_resp (void *priv,u16 src_id,u16 msg_id, +void *data,u32 data_len) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_channel_ops *chan_ops = disp_mgt->chan_ops_tbl->ops; +struct nbl_resource_ops *res_ops = disp_mgt->res_ops_tbl->ops; +struct nbl_resource_mgt *p = disp_mgt->res_ops_tbl->priv; +struct nbl_chan_param_get_eth_id result = {0 }; +struct nbl_chan_param_get_eth_id param = {0 }; +struct device *dev = disp_mgt->common->dev; +struct nbl_chan_ack_info chan_ack; +int err =NBL_CHAN_RESP_OK ; +int copy_len; +int ret; + +if (data_len ==0 ) { + err =NBL_CHAN_RESP_ERR ; + goto ack_out; + } + copy_len =min_t (size_t, data_len,sizeof (param)); +memcpy (¶m, data, copy_len); + +if (!res_ops->get_eth_id) { + err =NBL_CHAN_RESP_UNIMPLEMENTED ; + }else { + ret =NBL_OPS_CALL_RET (res_ops->get_eth_id, + (p, src_id,le16_to_cpu (param.vsi_id), + &result.eth_num, &result.eth_id, + &result.logic_eth_id)); +if (ret) + err =NBL_CHAN_RESP_ERR ; + } +ack_out: +nbl_chan_fill_ack_info (&chan_ack, src_id, +NBL_CHAN_MSG_GET_ETH_ID , msg_id, err, + &result,sizeof (result)); + ret = chan_ops->send_ack (disp_mgt->chan_ops_tbl->priv, &chan_ack); +if (ret) +dev_err (dev, +"channel send ack failed with ret: %d, msg_type: %d\n" , + ret,NBL_CHAN_MSG_GET_ETH_ID ); +} +static void nbl_disp_deinit_module (struct nbl_dispatch_mgt *disp_mgt) {struct nbl_resource_ops *res_ops = disp_mgt->res_ops_tbl->ops;
@@ -22,6 +174,264 @@ static int nbl_disp_init_module(struct nbl_dispatch_mgt *disp_mgt)return NBL_OPS_CALL_RET (res_ops->init_module, (p)); } +static int nbl_disp_configure_msix_map (struct nbl_dispatch_mgt *disp_mgt, +u16 num_net_msix,u16 num_others_msix, +bool net_msix_mask_en) +{ +struct nbl_resource_ops *res_ops = disp_mgt->res_ops_tbl->ops; +struct nbl_resource_mgt *p = disp_mgt->res_ops_tbl->priv; +struct nbl_common_info *common = disp_mgt->common; + +return NBL_OPS_CALL_RET (res_ops->configure_msix_map, (p, + common->mgt_pf, num_net_msix, + num_others_msix, net_msix_mask_en)); +} + +static int +nbl_disp_chan_configure_msix_map_req (struct nbl_dispatch_mgt *disp_mgt, +u16 num_net_msix,u16 num_others_msix, +bool net_msix_mask_en) +{ +struct nbl_channel_ops *chan_ops = disp_mgt->chan_ops_tbl->ops; +struct nbl_common_info *common = disp_mgt->common; +struct nbl_chan_param_cfg_msix_map param = {0 }; +struct nbl_chan_send_info chan_send; +int ret; + + param.num_net_msix =cpu_to_le16 (num_net_msix); + param.num_others_msix =cpu_to_le16 (num_others_msix); + param.msix_mask_en =cpu_to_le16 (!!net_msix_mask_en); + +nbl_chan_fill_send_info (&chan_send, common->mgt_pf, +NBL_CHAN_MSG_CONFIGURE_MSIX_MAP , + ¶m,sizeof (param), +NULL ,0 ,1 ); + ret = chan_ops->send_msg (disp_mgt->chan_ops_tbl->priv, &chan_send); +switch (ret) { +case NBL_CHAN_RESP_UNIMPLEMENTED : +return -EOPNOTSUPP ; +case NBL_CHAN_RESP_ERR : +return -EREMOTEIO ; +case NBL_CHAN_RESP_OK : +return ret; +default : +return ret; + } +} + +static void nbl_disp_chan_configure_msix_map_resp (void *priv,u16 src_id, +u16 msg_id,void *data, +u32 data_len) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_channel_ops *chan_ops = disp_mgt->chan_ops_tbl->ops; +struct nbl_resource_ops *res_ops = disp_mgt->res_ops_tbl->ops; +struct nbl_resource_mgt *p = disp_mgt->res_ops_tbl->priv; +struct device *dev = disp_mgt->common->dev; +struct nbl_chan_param_cfg_msix_map param = {0 }; +struct nbl_chan_ack_info chan_ack; +int err =NBL_CHAN_RESP_OK ; +int copy_len; +int ret; + +if (data_len ==0 ) { + err =NBL_CHAN_RESP_ERR ; + goto ack_out; + } + copy_len =min_t (size_t, data_len,sizeof (param)); +memcpy (¶m, data, copy_len); +if (!res_ops->configure_msix_map) { + err =NBL_CHAN_RESP_UNIMPLEMENTED ; + }else { + ret =NBL_OPS_CALL_RET (res_ops->configure_msix_map, + (p, src_id, +le16_to_cpu (param.num_net_msix), +le16_to_cpu (param.num_others_msix), + !!le16_to_cpu (param.msix_mask_en))); +if (ret) + err =NBL_CHAN_RESP_ERR ; + } +ack_out: +nbl_chan_fill_ack_info (&chan_ack, src_id, +NBL_CHAN_MSG_CONFIGURE_MSIX_MAP , msg_id, + err,NULL ,0 ); + ret = chan_ops->send_ack (disp_mgt->chan_ops_tbl->priv, &chan_ack); +if (ret) +dev_err (dev, +"channel send ack failed with ret: %d, msg_type: %d\n" , + ret,NBL_CHAN_MSG_CONFIGURE_MSIX_MAP ); +} + +static int nbl_disp_chan_destroy_msix_map_req (struct nbl_dispatch_mgt *disp_mgt) +{ +struct nbl_channel_ops *chan_ops = disp_mgt->chan_ops_tbl->ops; +struct nbl_common_info *common = disp_mgt->common; +struct nbl_chan_send_info chan_send; +int ret; + +nbl_chan_fill_send_info (&chan_send, common->mgt_pf, +NBL_CHAN_MSG_DESTROY_MSIX_MAP , +NULL ,0 ,NULL ,0 ,1 ); + ret = chan_ops->send_msg (disp_mgt->chan_ops_tbl->priv, &chan_send); +switch (ret) { +case NBL_CHAN_RESP_UNIMPLEMENTED : +return -EOPNOTSUPP ; +case NBL_CHAN_RESP_ERR : +return -EREMOTEIO ; +case NBL_CHAN_RESP_OK : +return ret; +default : +return ret; + } +} + +static void nbl_disp_chan_destroy_msix_map_resp (void *priv,u16 src_id, +u16 msg_id,void *data, +u32 data_len) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_channel_ops *chan_ops = disp_mgt->chan_ops_tbl->ops; +struct nbl_resource_ops *res_ops = disp_mgt->res_ops_tbl->ops; +struct nbl_resource_mgt *p = disp_mgt->res_ops_tbl->priv; +struct device *dev = disp_mgt->common->dev; +struct nbl_chan_ack_info chan_ack; +int err =NBL_CHAN_RESP_OK ; +int ret; + +if (!res_ops->destroy_msix_map) { + err =NBL_CHAN_RESP_UNIMPLEMENTED ; + }else { + ret =NBL_OPS_CALL_RET (res_ops->destroy_msix_map, (p, src_id)); +if (ret) + err =NBL_CHAN_RESP_ERR ; + } + +nbl_chan_fill_ack_info (&chan_ack, src_id, +NBL_CHAN_MSG_DESTROY_MSIX_MAP , msg_id, + err,NULL ,0 ); + ret = chan_ops->send_ack (disp_mgt->chan_ops_tbl->priv, &chan_ack); +if (ret) +dev_err (dev, +"channel send ack failed with ret: %d, msg_type: %d\n" , + ret,NBL_CHAN_MSG_DESTROY_MSIX_MAP ); +} + +static int nbl_disp_chan_set_mailbox_irq_req (struct nbl_dispatch_mgt *disp_mgt, +u16 vector_id,bool enable_msix) +{ +struct nbl_channel_ops *chan_ops = disp_mgt->chan_ops_tbl->ops; +struct nbl_chan_param_set_mailbox_irq param = {0 }; +struct nbl_common_info *common = disp_mgt->common; +struct nbl_chan_send_info chan_send; +int ret; + + param.vector_id =cpu_to_le16 (vector_id); + param.enable_msix = !!enable_msix; + +nbl_chan_fill_send_info (&chan_send, common->mgt_pf, +NBL_CHAN_MSG_MAILBOX_SET_IRQ , + ¶m,sizeof (param),NULL ,0 ,1 ); + ret = chan_ops->send_msg (disp_mgt->chan_ops_tbl->priv, &chan_send); +switch (ret) { +case NBL_CHAN_RESP_UNIMPLEMENTED : +return -EOPNOTSUPP ; +case NBL_CHAN_RESP_ERR : +return -EREMOTEIO ; +case NBL_CHAN_RESP_OK : +return ret; +default : +return ret; + } +} + +static void nbl_disp_chan_set_mailbox_irq_resp (void *priv,u16 src_id, +u16 msg_id,void *data, +u32 data_len) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_channel_ops *chan_ops = disp_mgt->chan_ops_tbl->ops; +struct nbl_resource_ops *res_ops = disp_mgt->res_ops_tbl->ops; +struct nbl_resource_mgt *p = disp_mgt->res_ops_tbl->priv; +struct nbl_chan_param_set_mailbox_irq param = {0 }; +struct device *dev = disp_mgt->common->dev; +struct nbl_chan_ack_info chan_ack; +int err =NBL_CHAN_RESP_OK ; +bool enable_msix; +u16 vector_id; +int copy_len; +int ret; + +if (data_len ==0 ) { + err =NBL_CHAN_RESP_ERR ; + goto ack_out; + } + copy_len =min_t (size_t, data_len,sizeof (param)); +memcpy (¶m, data, copy_len); + vector_id =le16_to_cpu (param.vector_id); + enable_msix = !!param.enable_msix; +if (!res_ops->set_mailbox_irq) { + err =NBL_CHAN_RESP_UNIMPLEMENTED ; + }else { + ret =NBL_OPS_CALL_RET (res_ops->set_mailbox_irq, + (p, src_id, vector_id, enable_msix)); +if (ret) + err =NBL_CHAN_RESP_ERR ; + } +ack_out: +nbl_chan_fill_ack_info (&chan_ack, src_id, +NBL_CHAN_MSG_MAILBOX_SET_IRQ , msg_id, + err,NULL ,0 ); + ret = chan_ops->send_ack (disp_mgt->chan_ops_tbl->priv, &chan_ack); +if (ret) +dev_err (dev, +"channel send ack failed with ret: %d, msg_type: %d\n" , + ret,NBL_CHAN_MSG_MAILBOX_SET_IRQ ); +} + +static int nbl_disp_destroy_msix_map (struct nbl_dispatch_mgt *disp_mgt) +{ +struct nbl_resource_ops *res_ops = disp_mgt->res_ops_tbl->ops; +struct nbl_resource_mgt *p = disp_mgt->res_ops_tbl->priv; +struct nbl_common_info *common = disp_mgt->common; + +return NBL_OPS_CALL_RET (res_ops->destroy_msix_map, (p, + common->mgt_pf)); +} + +static int nbl_disp_set_mailbox_irq (struct nbl_dispatch_mgt *disp_mgt, +u16 vector_id,bool enable_msix) +{ +struct nbl_resource_ops *res_ops = disp_mgt->res_ops_tbl->ops; +struct nbl_resource_mgt *p = disp_mgt->res_ops_tbl->priv; +struct nbl_common_info *common = disp_mgt->common; + +return NBL_OPS_CALL_RET (res_ops->set_mailbox_irq, (p, + common->mgt_pf, vector_id, enable_msix)); +} + +static int nbl_disp_get_vsi_id (struct nbl_dispatch_mgt *disp_mgt,u16 type, +u16 *vsi_id) +{ +struct nbl_resource_ops *res_ops = disp_mgt->res_ops_tbl->ops; +struct nbl_resource_mgt *p = disp_mgt->res_ops_tbl->priv; +struct nbl_common_info *common = disp_mgt->common; + +return NBL_OPS_CALL_RET (res_ops->get_vsi_id, + (p, common->mgt_pf, type, vsi_id)); +} + +static int nbl_disp_get_eth_id (struct nbl_dispatch_mgt *disp_mgt,u16 vsi_id, +u8 *eth_num,u8 *eth_id,u8 *logic_eth_id) +{ +struct nbl_resource_ops *res_ops = disp_mgt->res_ops_tbl->ops; +struct nbl_resource_mgt *p = disp_mgt->res_ops_tbl->priv; +struct nbl_common_info *common = disp_mgt->common; + +return NBL_OPS_CALL_RET (res_ops->get_eth_id, + (p, common->mgt_pf, vsi_id, eth_num, eth_id, + logic_eth_id)); +} +/* NBL_DISP_SET_OPS(disp_op_name, func, ctrl_lvl, msg_type, msg_req, msg_resp) * ctrl_lvl is to define when this disp_op should go directly to res_op, * not sending a channel msg.
@@ -38,7 +448,62 @@ do { \NBL_DISP_SET_OPS (deinit_module, \ nbl_disp_deinit_module, \NBL_DISP_CTRL_LVL_MGT ,-1 ,NULL ,NULL ); \ +NBL_DISP_SET_OPS (configure_msix_map, \ + nbl_disp_configure_msix_map, \ +NBL_DISP_CTRL_LVL_MGT , \ +NBL_CHAN_MSG_CONFIGURE_MSIX_MAP , \ + nbl_disp_chan_configure_msix_map_req, \ + nbl_disp_chan_configure_msix_map_resp); \ +NBL_DISP_SET_OPS (destroy_msix_map, nbl_disp_destroy_msix_map, \ +NBL_DISP_CTRL_LVL_MGT , \ +NBL_CHAN_MSG_DESTROY_MSIX_MAP , \ + nbl_disp_chan_destroy_msix_map_req, \ + nbl_disp_chan_destroy_msix_map_resp); \ +NBL_DISP_SET_OPS (set_mailbox_irq, \ + nbl_disp_set_mailbox_irq, \ +NBL_DISP_CTRL_LVL_MGT , \ +NBL_CHAN_MSG_MAILBOX_SET_IRQ , \ + nbl_disp_chan_set_mailbox_irq_req, \ + nbl_disp_chan_set_mailbox_irq_resp); \ +NBL_DISP_SET_OPS (get_vsi_id, nbl_disp_get_vsi_id, \ +NBL_DISP_CTRL_LVL_MGT ,NBL_CHAN_MSG_GET_VSI_ID ,\ + nbl_disp_chan_get_vsi_id_req, \ + nbl_disp_chan_get_vsi_id_resp); \ +NBL_DISP_SET_OPS (get_eth_id, nbl_disp_get_eth_id, \ +NBL_DISP_CTRL_LVL_MGT ,NBL_CHAN_MSG_GET_ETH_ID ,\ + nbl_disp_chan_get_eth_id_req, \ + nbl_disp_chan_get_eth_id_resp); \ +}while (0 ) + +/* Structure starts here, adding an op should not modify anything below */ +static int nbl_disp_setup_msg(struct nbl_dispatch_mgt *disp_mgt) +{ +struct nbl_dispatch_ops *disp_ops = disp_mgt->disp_ops_tbl->ops; +struct nbl_channel_ops *chan_ops = disp_mgt->chan_ops_tbl->ops; +struct nbl_channel_mgt *p = disp_mgt->chan_ops_tbl->priv; +int ret =0 ; +int _ret; + +#define NBL_DISP_SET_OPS (disp_op, func, ctrl, msg_type, msg_req, resp) \ +do { \ + typeof(msg_type) _msg_type = (msg_type); \ + typeof(ctrl) _ctrl_lvl = (ctrl); \ + (void)(disp_ops->NBL_NAME(disp_op)); \ + (void)(func); \ + (void)(msg_req); \ + (void)_ctrl_lvl; \ + if (_msg_type >= 0) { \ + _ret = chan_ops->register_msg(p, _msg_type, resp, disp_mgt);\ + if (_ret < 0 && !ret) \ + ret = _ret; \ + } \ } while (0) +NBL_DISP_OPS_TBL ; +#undef NBL_DISP_SET_OPS +if (ret) + chan_ops->unregister_all_msg (p); +return ret; +}/* Ctrl lvl means that if a certain level is set, then all disp_ops that * declared this lvl will go directly to res_ops, rather than send a
@@ -126,6 +591,10 @@ int nbl_disp_init(struct nbl_adapter *adapter) adapter->core.disp_mgt = disp_mgt; adapter->intf.dispatch_ops_tbl = disp_ops_tbl; + ret =nbl_disp_setup_msg (disp_mgt); +if (ret) +return ret; +if (common->has_ctrl)nbl_disp_setup_ctrl_lvl (disp_mgt,NBL_DISP_CTRL_LVL_MGT );
@@ -134,4 +603,8 @@ int nbl_disp_init(struct nbl_adapter *adapter)void nbl_disp_remove (struct nbl_adapter *adapter) { +/* +* All message handlers will be cleaned up inside channel layer +* nbl_chan_remove_common() at final device tear-down +*/ }
Signature · 1 line
2.47.3
illusion.wang
maintainerPATCH v23 10/12 net/nebula-matrix: dispatch: add mutual exclusion lock for shared hardware resource ops
In reply to illusion.wangFrom: illusion wang <[email protected]>
Add ops_mutex_lock to serialize concurrent hardware-modifying dispatch resource operations, preventing race conditions between PF local calls and remote mailbox message handlers that manipulate MSI-X mapping and mailbox IRQ state.
1. Introduce disp_mgt->ops_mutex_lock, initialized via devm_mutex_init at disp_mgt allocation time; symmetrically destroyed automatically by devres on device detach, eliminating double mutex_destroy risk.
2. Add NBL_OPS_CALL_LOCK_RET macro to wrap hardware-modifying ops with exclusive lock protection for unified locking semantics.
3. Wrap configure_msix_map / destroy_msix_map / set_mailbox_irq with ops_mutex_lock; these ops mutate shared MSI-X and IRQ hardware state and can race between local PF control paths and cross-PF mailbox RPCs.
The read-only get_vsi_id / get_eth_id routines only consume static init-time metadata with no concurrent writers, so they require no locking.
--- .../nebula-matrix/nbl/nbl_core/nbl_dispatch.c | 46 +++++++++++++------ .../nebula-matrix/nbl/nbl_core/nbl_dispatch.h | 16 +++++++ 2 files changed, 47 insertions(+), 15 deletions(-)
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dispatch.c +31 -15
@@ -3,6 +3,7 @@* Copyright (c) 2025 Nebula Matrix Limited. */ #include <linux/device.h> +#include <linux/mutex.h> #include <linux/pci.h> #include "nbl_dispatch.h"
@@ -182,9 +183,9 @@ static int nbl_disp_configure_msix_map(struct nbl_dispatch_mgt *disp_mgt,struct nbl_resource_mgt *p = disp_mgt->res_ops_tbl->priv;struct nbl_common_info *common = disp_mgt->common; -return NBL_OPS_CALL_RET (res_ops->configure_msix_map, (p, - common->mgt_pf, num_net_msix, - num_others_msix, net_msix_mask_en)); +return NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->configure_msix_map, p, + common->mgt_pf, num_net_msix, + num_others_msix, net_msix_mask_en); } static int
@@ -243,11 +244,12 @@ static void nbl_disp_chan_configure_msix_map_resp(void *priv, u16 src_id,if (!res_ops->configure_msix_map) { err =NBL_CHAN_RESP_UNIMPLEMENTED ; }else { - ret =NBL_OPS_CALL_RET (res_ops->configure_msix_map, - (p, src_id, -le16_to_cpu (param.num_net_msix), -le16_to_cpu (param.num_others_msix), - !!le16_to_cpu (param.msix_mask_en))); + ret =NBL_OPS_CALL_LOCK_RET (disp_mgt, + res_ops->configure_msix_map, p, + src_id, +le16_to_cpu (param.num_net_msix), +le16_to_cpu (param.num_others_msix), + !!le16_to_cpu (param.msix_mask_en));if (ret) err =NBL_CHAN_RESP_ERR ; }
@@ -301,7 +303,8 @@ static void nbl_disp_chan_destroy_msix_map_resp(void *priv, u16 src_id,if (!res_ops->destroy_msix_map) { err =NBL_CHAN_RESP_UNIMPLEMENTED ; }else { - ret =NBL_OPS_CALL_RET (res_ops->destroy_msix_map, (p, src_id)); + ret =NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->destroy_msix_map, + p, src_id);if (ret) err =NBL_CHAN_RESP_ERR ; }
@@ -372,8 +375,8 @@ static void nbl_disp_chan_set_mailbox_irq_resp(void *priv, u16 src_id,if (!res_ops->set_mailbox_irq) { err =NBL_CHAN_RESP_UNIMPLEMENTED ; }else { - ret =NBL_OPS_CALL_RET (res_ops->set_mailbox_irq, - (p, src_id, vector_id, enable_msix)); + ret =NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->set_mailbox_irq, + p, src_id, vector_id, enable_msix);if (ret) err =NBL_CHAN_RESP_ERR ; }
@@ -394,8 +397,8 @@ static int nbl_disp_destroy_msix_map(struct nbl_dispatch_mgt *disp_mgt)struct nbl_resource_mgt *p = disp_mgt->res_ops_tbl->priv;struct nbl_common_info *common = disp_mgt->common; -return NBL_OPS_CALL_RET (res_ops->destroy_msix_map, (p, - common->mgt_pf)); +return NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->destroy_msix_map, p, + common->mgt_pf); } static int nbl_disp_set_mailbox_irq(struct nbl_dispatch_mgt *disp_mgt,
@@ -405,8 +408,8 @@ static int nbl_disp_set_mailbox_irq(struct nbl_dispatch_mgt *disp_mgt,struct nbl_resource_mgt *p = disp_mgt->res_ops_tbl->priv;struct nbl_common_info *common = disp_mgt->common; -return NBL_OPS_CALL_RET (res_ops->set_mailbox_irq, (p, - common->mgt_pf, vector_id, enable_msix)); +return NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->set_mailbox_irq, p, + common->mgt_pf, vector_id, enable_msix); } static int nbl_disp_get_vsi_id(struct nbl_dispatch_mgt *disp_mgt, u16 type,
@@ -532,12 +535,16 @@ nbl_disp_setup_disp_mgt(struct nbl_common_info *common) {struct nbl_dispatch_mgt *disp_mgt;struct device *dev = common->dev; +int err; disp_mgt =devm_kzalloc (dev,sizeof (*disp_mgt),GFP_KERNEL );if (!disp_mgt)return ERR_PTR (-ENOMEM ); disp_mgt->common = common; + err =devm_mutex_init (common->dev, &disp_mgt->ops_mutex_lock); +if (err) +return ERR_PTR (err);return disp_mgt; }
@@ -598,6 +605,15 @@ int nbl_disp_init(struct nbl_adapter *adapter)if (common->has_ctrl)nbl_disp_setup_ctrl_lvl (disp_mgt,NBL_DISP_CTRL_LVL_MGT ); +/* +* For non-control PF with network capability, enable net control +* level. +* All dispatch ops declared with NBL_DISP_CTRL_LVL_MGT fall back +* to remote mailbox msg_req handlers when MGT bit is not set. +*/ +if (common->has_net) +nbl_disp_setup_ctrl_lvl (disp_mgt,NBL_DISP_CTRL_LVL_NET ); +return 0 ; }
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dispatch.h +16 -0
@@ -13,12 +13,28 @@#include "../nbl_include/nbl_def_common.h" #include "../nbl_core.h" +#define NBL_OPS_CALL_LOCK_RET (disp_mgt, func, ...) \ +({ \ + typeof(disp_mgt) _disp_mgt = (disp_mgt); \ + typeof(func) _func = (func); \ + typeof(_func(__VA_ARGS__)) _ret = 0; \ + \ + if (_func) { \ + mutex_lock(&_disp_mgt->ops_mutex_lock); \ + _ret = _func(__VA_ARGS__); \ + mutex_unlock(&_disp_mgt->ops_mutex_lock); \ + } \ + _ret; \ +}) +struct nbl_dispatch_mgt {struct nbl_common_info *common;struct nbl_resource_ops_tbl *res_ops_tbl;struct nbl_channel_ops_tbl *chan_ops_tbl;struct nbl_dispatch_ops_tbl *disp_ops_tbl; DECLARE_BITMAP(ctrl_lvl, NBL_DISP_CTRL_LVL_MAX); +/* use for the caller not in interrupt */ +struct mutex ops_mutex_lock; };#endif
Signature · 1 line
2.47.3
illusion.wang
maintainerPATCH v23 11/12 net/nebula-matrix: add common/ctrl dev init/remove operation
In reply to illusion.wangFrom: illusion wang <[email protected]>
Add nbl_dev_setup_common_dev() and nbl_dev_setup_ctrl_dev() initialization helpers with paired teardown routines, and hook them into nbl_dev_init / nbl_dev_remove.
Mailbox message processing is implemented via work_struct. This task registration framework is reused for interrupt-driven receive now, and can be shared with polling receive mode introduced in follow-up patches.
Extend channel send logic with polling ACK fallback path. During early device initialization before interrupts are enabled, synchronous mailbox requests rely on polling to wait for firmware ACK, avoiding silent success and uninitialized variable reads when NBL_CHAN_INTERRUPT_READY is not yet set.
Chip core hardware initialization is fully handled by firmware during power-on; the driver only configures functional table entries and registers after hardware is ready. Thus invoking nbl_dev_setup_common_dev() before ctrl dev setup does not trigger hardware faults, all register accesses are safe.
Teardown order explanation:
1. Remove ctrl dev first: notify firmware to clean all per-PF hardware state including qinfo registers via driver status flag.
2. Then tear down common device queue resources.
Firmware cleanup ensures qinfo registers are valid during subsequent common dev deinit writes, avoiding PCIe master abort or hardware access panics.
--- .../net/ethernet/nebula-matrix/nbl/Makefile | 1 + .../nbl/nbl_channel/nbl_channel.c | 72 +++++- .../nbl/nbl_channel/nbl_channel.h | 3 + .../nebula-matrix/nbl/nbl_common/nbl_common.c | 21 ++ .../net/ethernet/nebula-matrix/nbl/nbl_core.h | 1 + .../nebula-matrix/nbl/nbl_core/nbl_dev.c | 238 ++++++++++++++++++ .../nebula-matrix/nbl/nbl_core/nbl_dev.h | 57 +++++ .../nbl/nbl_include/nbl_def_common.h | 3 + .../nbl/nbl_include/nbl_def_dev.h | 14 ++ .../net/ethernet/nebula-matrix/nbl/nbl_main.c | 9 + 10 files changed, 418 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_dev.h
drivers/net/ethernet/nebula-matrix/nbl/Makefile +1 -0
@@ -11,4 +11,5 @@ nbl-objs += nbl_common/nbl_common.o \ nbl_hw/nbl_interrupt.o \ nbl_hw/nbl_chip.o \ nbl_core/nbl_dispatch.o \ + nbl_core/nbl_dev.o \ nbl_main.o
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.c +71 -1
108 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.h +3 -0
@@ -24,6 +24,9 @@#define NBL_CHAN_TX_WAIT_US 100#define NBL_CHAN_TX_WAIT_US_MAX 120#define NBL_CHAN_TX_WAIT_TIMES 100 +#define NBL_CHAN_TX_WAIT_ACK_US_MIN 1000 +#define NBL_CHAN_TX_WAIT_ACK_US_MAX 1200 +#define NBL_CHAN_TX_WAIT_ACK_TIMES 5000#define NBL_CHAN_QUEUE_LEN 256#define NBL_CHAN_BUF_LEN 4096#define NBL_CHAN_TX_DESC_EMBEDDED_DATA_LEN 16
drivers/net/ethernet/nebula-matrix/nbl/nbl_common/nbl_common.c +21 -0
@@ -7,6 +7,27 @@#include <linux/jhash.h> #include "nbl_common.h" +void nbl_common_destroy_wq (struct nbl_common_info *common) +{ +destroy_workqueue (common->wq); +} + +int nbl_common_create_wq (struct nbl_common_info *common) +{ +char wq_name[32 ]; + +snprintf (wq_name,sizeof (wq_name),"nbl_wq_%s" ,pci_name (common->pdev)); + common->wq =alloc_workqueue ("%s" ,WQ_UNBOUND ,0 , wq_name); +if (!common->wq) { +pr_err ("Failed to create workqueue nbl_wq\n" ); + goto alloc_wq_failed; + } + +return 0 ; +alloc_wq_failed: +return -ENOMEM ; +} +/* * nbl_common_func_id_to_rel_pf_id - convert absolute PF id to relative PF id *
drivers/net/ethernet/nebula-matrix/nbl/nbl_core.h +1 -0
@@ -25,6 +25,7 @@ struct nbl_core {struct nbl_hw_mgt *hw_mgt;struct nbl_resource_mgt *res_mgt;struct nbl_dispatch_mgt *disp_mgt; +struct nbl_dev_mgt *dev_mgt;struct nbl_channel_mgt *chan_mgt; };
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.c new file +238 -0
238 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.h new file +57 -0
57 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_common.h +3 -0
@@ -28,6 +28,7 @@ })struct nbl_common_info { +struct workqueue_struct *wq;struct pci_dev *pdev;struct device *dev;u32 msg_enable;
@@ -54,6 +55,8 @@ struct nbl_hash_tbl_key {u16 resv; }; +void nbl_common_destroy_wq (struct nbl_common_info *common); +int nbl_common_create_wq (struct nbl_common_info *common);int nbl_common_func_id_to_rel_pf_id (struct nbl_common_info *common,u32 pf_id,u32 *rel_pf_id); struct nbl_hash_tbl_mgt *
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_dev.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +*/ + +#ifndef _NBL_DEF_DEV_H_ +#define _NBL_DEF_DEV_H_ + +struct nbl_adapter ; + +int nbl_dev_init (struct nbl_adapter *adapter); +void nbl_dev_remove (struct nbl_adapter *adapter); + +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c +9 -0
@@ -12,6 +12,7 @@#include "nbl_include/nbl_def_hw.h" #include "nbl_include/nbl_def_resource.h" #include "nbl_include/nbl_def_dispatch.h" +#include "nbl_include/nbl_def_dev.h" #include "nbl_include/nbl_def_common.h" #include "nbl_core.h"
@@ -53,7 +54,14 @@ struct nbl_adapter *nbl_core_init(struct pci_dev *pdev, ret =nbl_disp_init (adapter);if (ret) goto disp_init_fail; + + ret =nbl_dev_init (adapter); +if (ret) + goto dev_init_fail;return adapter; + +dev_init_fail: +nbl_disp_remove (adapter); disp_init_fail:nbl_res_remove_leonis (adapter); res_init_fail:
@@ -66,6 +74,7 @@ struct nbl_adapter *nbl_core_init(struct pci_dev *pdev,void nbl_core_remove (struct nbl_adapter *adapter) { +nbl_dev_remove (adapter);nbl_disp_remove (adapter);nbl_res_remove_leonis (adapter);nbl_chan_remove_common (adapter);
Signature · 1 line
2.47.3
illusion.wang
maintainerPATCH v23 12/12 net/nebula-matrix: add common dev start/stop operation
In reply to illusion.wangFrom: illusion wang <[email protected]>
Add device start/stop helper functions to manage MSI-X vector mapping, mailbox interrupt resource initialization and deinitialization. Create unbound global workqueue for mailbox task scheduling; this shared work infrastructure supports both current interrupt-driven receive and future polling receive path.
This patch implements complete startup and shutdown flow for common device resources:
1. Add nbl_dev_start() to finish device startup procedure:
- Configure hardware MSI-X mapping table for different interrupt types
- Allocate required MSI-X irq vectors via pci_alloc_irq_vectors
- Request mailbox IRQ; interrupt handler schedules mailbox processing work
- Enable hardware mailbox interrupt and mark channel interrupt ready
2. Add nbl_dev_stop() to tear down device resources safely in strict order:
- Update software channel state first to switch to polling, then mask hardware interrupt to avoid stale ACK handling
- Free mailbox IRQ handler and release MSI-X vector resources
- Destroy hardware MSI-X mapping table
Extend channel TX waiting logic with polling fallback and shutdown detection. When interrupt path is disabled, send routines rely on active polling to wait for message ACK, preventing deadlock during device stop.
Hook nbl_core_start() / nbl_core_stop() into PCI probe and remove paths.
--- .../net/ethernet/nebula-matrix/nbl/nbl_core.h | 2 + .../nebula-matrix/nbl/nbl_core/nbl_dev.c | 259 ++++++++++++++++++ .../nbl/nbl_include/nbl_def_dev.h | 2 + .../net/ethernet/nebula-matrix/nbl/nbl_main.c | 21 +- 4 files changed, 283 insertions(+), 1 deletion(-)
drivers/net/ethernet/nebula-matrix/nbl/nbl_core.h +2 -0
@@ -39,5 +39,7 @@ struct nbl_adapter {struct nbl_adapter *nbl_core_init (struct pci_dev *pdev,struct nbl_init_param *param);void nbl_core_remove (struct nbl_adapter *adapter); +int nbl_core_start (struct nbl_adapter *adapter); +void nbl_core_stop (struct nbl_adapter *adapter);#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.c +259 -0
280 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_dev.h +2 -0
@@ -10,5 +10,7 @@ struct nbl_adapter;int nbl_dev_init (struct nbl_adapter *adapter);void nbl_dev_remove (struct nbl_adapter *adapter); +int nbl_dev_start (struct nbl_adapter *adapter); +void nbl_dev_stop (struct nbl_adapter *adapter);#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c +20 -1
@@ -16,6 +16,16 @@#include "nbl_include/nbl_def_common.h" #include "nbl_core.h" +int nbl_core_start (struct nbl_adapter *adapter) +{ +return nbl_dev_start (adapter); +} + +void nbl_core_stop (struct nbl_adapter *adapter) +{ +nbl_dev_stop (adapter); +} +struct nbl_adapter *nbl_core_init (struct pci_dev *pdev,struct nbl_init_param *param) {
@@ -125,7 +135,14 @@ static int nbl_probe(struct pci_dev *pdev, goto adapter_init_err; }pci_set_drvdata (pdev, adapter); + err =nbl_core_start (adapter); +if (err) + goto core_start_err; +return 0 ; +core_start_err: +pci_set_drvdata (pdev,NULL ); +nbl_core_remove (adapter); adapter_init_err:pci_clear_master (pdev);return err;
@@ -135,8 +152,10 @@ static void nbl_remove(struct pci_dev *pdev) {struct nbl_adapter *adapter =pci_get_drvdata (pdev); -if (adapter) +if (adapter) { +nbl_core_stop (adapter);nbl_core_remove (adapter); + }pci_clear_master (pdev); }
Signature · 1 line
2.47.3