nbl driver for Nebulamatrix NICs
Subsystems (4)
illusion.wang
maintainerv20 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.
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 v19->v20
Link to v19:https://lore.kernel.org/netdev/[email protected]/ AI review issues
changes v18->v19
Link to v18:https://lore.kernel.org/netdev/[email protected]/ AI review issues
changes v17->v18
Link to v17:https://lore.kernel.org/netdev/[email protected]/ AI review issues
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 (10):
net/nebula-matrix: add minimum nbl build framework net/nebula-matrix: add our driver architecture net/nebula-matrix: channel msg value and msg struct net/nebula-matrix: add channel layer net/nebula-matrix: add common resource implementation net/nebula-matrix: add intr resource implementation net/nebula-matrix: add vsi resource implementation net/nebula-matrix: add Dispatch layer implementation 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 | 34 + drivers/net/ethernet/nebula-matrix/Makefile | 6 + .../net/ethernet/nebula-matrix/nbl/Makefile | 15 + .../nbl/nbl_channel/nbl_channel.c | 1099 +++++++++++++++++ .../nbl/nbl_channel/nbl_channel.h | 167 +++ .../nebula-matrix/nbl/nbl_common/nbl_common.c | 217 ++++ .../nebula-matrix/nbl/nbl_common/nbl_common.h | 33 + .../net/ethernet/nebula-matrix/nbl/nbl_core.h | 58 + .../nebula-matrix/nbl/nbl_core/nbl_dev.c | 478 +++++++ .../nebula-matrix/nbl/nbl_core/nbl_dev.h | 58 + .../nebula-matrix/nbl/nbl_core/nbl_dispatch.c | 525 ++++++++ .../nebula-matrix/nbl/nbl_core/nbl_dispatch.h | 43 + .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c | 913 ++++++++++++++ .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.h | 368 ++++++ .../nbl_hw_leonis/nbl_resource_leonis.c | 287 +++++ .../nbl_hw_leonis/nbl_resource_leonis.h | 12 + .../nebula-matrix/nbl/nbl_hw/nbl_hw_reg.h | 74 ++ .../nebula-matrix/nbl/nbl_hw/nbl_interrupt.c | 267 ++++ .../nebula-matrix/nbl/nbl_hw/nbl_interrupt.h | 21 + .../nebula-matrix/nbl/nbl_hw/nbl_resource.c | 143 +++ .../nebula-matrix/nbl/nbl_hw/nbl_resource.h | 111 ++ .../nebula-matrix/nbl/nbl_hw/nbl_vsi.c | 26 + .../nebula-matrix/nbl/nbl_hw/nbl_vsi.h | 12 + .../nbl/nbl_include/nbl_def_channel.h | 360 ++++++ .../nbl/nbl_include/nbl_def_common.h | 81 ++ .../nbl/nbl_include/nbl_def_dev.h | 16 + .../nbl/nbl_include/nbl_def_dispatch.h | 42 + .../nbl/nbl_include/nbl_def_hw.h | 54 + .../nbl/nbl_include/nbl_def_resource.h | 38 + .../nbl/nbl_include/nbl_include.h | 79 ++ .../nbl/nbl_include/nbl_product_base.h | 19 + .../net/ethernet/nebula-matrix/nbl/nbl_main.c | 302 +++++ 37 files changed, 5999 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_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_hw/nbl_vsi.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_vsi.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_include/nbl_product_base.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c
Signature · 1 line
2.47.3
illusion.wang
maintainerPATCH v20 1/10 net/nebula-matrix: add minimum nbl build framework
From: illusion wang <[email protected]>
1.Add nbl min build infrastructure for nbl driver.
2.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 | 34 ++++++ drivers/net/ethernet/nebula-matrix/Makefile | 6 ++ .../net/ethernet/nebula-matrix/nbl/Makefile | 6 ++ .../net/ethernet/nebula-matrix/nbl/nbl_core.h | 15 +++ .../nbl/nbl_include/nbl_include.h | 14 +++ .../net/ethernet/nebula-matrix/nbl/nbl_main.c | 100 ++++++++++++++++++ 11 files changed, 216 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/ + +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
@@ -18599,6 +18599,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 +34 -0
@@ -0,0 +1,34 @@ +# 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. For more information about this product, go to + the product description with smart NIC: + + <http://www.nebula-matrix.com> + + 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 +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +*/ + +#ifndef _NBL_CORE_H_ +#define _NBL_CORE_H_ + +enum { +NBL_CAP_HAS_CTRL_BIT , +NBL_CAP_HAS_NET_BIT , +NBL_CAP_IS_LEONIS_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 v20 2/10 net/nebula-matrix: add our driver architecture
In reply to illusion.wangFrom: illusion wang <[email protected]>
This commit introduces the baseline driver architecture for the nebula-matrix networking device. It establishes the Hardware, Channel, Resource, Dispatch, and Device layers for device management.
our driver architecture:
Hardware (HW), Channel, Resource, Dispatch, and Device Layer Struct Initialization/Deinitialization, and Operation Set Registration/ Unregistration
Our driver architecture is relatively complex because the code is highly reusable and designed to support multiple features. Additionally, the codebase supports multiple chip variants, each with distinct hardware-software interactions.
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
--- .../net/ethernet/nebula-matrix/nbl/Makefile | 7 +- .../nbl/nbl_channel/nbl_channel.c | 78 +++++++ .../nbl/nbl_channel/nbl_channel.h | 29 +++ .../net/ethernet/nebula-matrix/nbl/nbl_core.h | 43 ++++ .../nebula-matrix/nbl/nbl_core/nbl_dev.c | 56 +++++ .../nebula-matrix/nbl/nbl_core/nbl_dev.h | 27 +++ .../nebula-matrix/nbl/nbl_core/nbl_dispatch.c | 78 +++++++ .../nebula-matrix/nbl/nbl_core/nbl_dispatch.h | 25 +++ .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c | 144 +++++++++++++ .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.h | 14 ++ .../nbl_hw_leonis/nbl_resource_leonis.c | 87 ++++++++ .../nbl_hw_leonis/nbl_resource_leonis.h | 10 + .../nebula-matrix/nbl/nbl_hw/nbl_hw_reg.h | 73 +++++++ .../nebula-matrix/nbl/nbl_hw/nbl_resource.h | 31 +++ .../nbl/nbl_include/nbl_def_channel.h | 26 +++ .../nbl/nbl_include/nbl_def_common.h | 34 +++ .../nbl/nbl_include/nbl_def_dev.h | 16 ++ .../nbl/nbl_include/nbl_def_dispatch.h | 29 +++ .../nbl/nbl_include/nbl_def_hw.h | 22 ++ .../nbl/nbl_include/nbl_def_resource.h | 22 ++ .../nbl/nbl_include/nbl_include.h | 16 ++ .../nbl/nbl_include/nbl_product_base.h | 19 ++ .../net/ethernet/nebula-matrix/nbl/nbl_main.c | 202 ++++++++++++++++++ 23 files changed, 1087 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_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_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_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_product_base.h
drivers/net/ethernet/nebula-matrix/nbl/Makefile +6 -1
@@ -3,4 +3,9 @@ obj-$(CONFIG_NBL) := nbl.o -nbl-objs += nbl_main.o +nbl-objs += nbl_channel/nbl_channel.o \ + nbl_hw/nbl_hw_leonis/nbl_hw_leonis.o \ + nbl_hw/nbl_hw_leonis/nbl_resource_leonis.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 new file +78 -0
78 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.h new file +29 -0
@@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +*/ + +#ifndef _NBL_CHANNEL_H_ +#define _NBL_CHANNEL_H_ + +#include <linux/types.h> + +#include "../nbl_include/nbl_include.h" +#include "../nbl_include/nbl_product_base.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" + +struct nbl_chan_info { +u8 chan_type; +}; + +struct nbl_channel_mgt { +struct nbl_common_info *common; +struct nbl_hw_ops_tbl *hw_ops_tbl; +struct nbl_chan_info *chan_info[NBL_CHAN_TYPE_MAX ]; +struct nbl_hash_tbl_mgt *handle_hash_tbl; +}; + +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_core.h +43 -0
53 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.c new file +56 -0
56 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +*/ + +#ifndef _NBL_DEV_H_ +#define _NBL_DEV_H_ + +#include <linux/types.h> + +#include "../nbl_include/nbl_include.h" +#include "../nbl_include/nbl_product_base.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_dev.h" +#include "../nbl_include/nbl_def_common.h" +#include "../nbl_core.h" + +struct nbl_dev_mgt { +struct nbl_common_info *common; +struct nbl_dispatch_ops_tbl *disp_ops_tbl; +struct nbl_channel_ops_tbl *chan_ops_tbl; +}; + +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dispatch.c new file +78 -0
78 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dispatch.h new file +25 -0
@@ -0,0 +1,25 @@ +/* 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_product_base.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_hw/nbl_hw_leonis/nbl_hw_leonis.c new file +144 -0
144 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_leonis/nbl_resource_leonis.c new file +87 -0
87 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_hw_reg.h new file +73 -0
73 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.h new file +31 -0
@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +*/ + +#ifndef _NBL_RESOURCE_H_ +#define _NBL_RESOURCE_H_ + +#include <linux/types.h> + +#include "../nbl_include/nbl_include.h" +#include "../nbl_include/nbl_product_base.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" + +struct nbl_resource_info { +void *reserved;/* placeholder to be replaced in the future*/ +}; + +struct nbl_resource_mgt { +struct nbl_common_info *common; +struct nbl_resource_info *resource_info; +struct nbl_channel_ops_tbl *chan_ops_tbl; +struct nbl_hw_ops_tbl *hw_ops_tbl; +struct nbl_interrupt_mgt *intr_mgt; +}; + +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_channel.h new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +*/ + +#ifndef _NBL_DEF_CHANNEL_H_ +#define _NBL_DEF_CHANNEL_H_ + +struct nbl_channel_mgt ; +struct nbl_adapter ; +enum nbl_channel_type { +NBL_CHAN_TYPE_MAILBOX , +NBL_CHAN_TYPE_MAX +}; + +struct nbl_channel_ops { +}; + +struct nbl_channel_ops_tbl { +struct nbl_channel_ops *ops; +struct nbl_channel_mgt *priv; +}; + +int nbl_chan_init_common (struct nbl_adapter *adapter); +void nbl_chan_remove_common (struct nbl_adapter *adapter); +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_common.h new file +34 -0
@@ -0,0 +1,34 @@ +/* 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; +u16 mgt_pf; + +enum nbl_product_type product_type; +u8 has_ctrl; +u8 has_net; +}; + +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_dev.h new file +16 -0
@@ -0,0 +1,16 @@ +/* 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); +int nbl_dev_start (struct nbl_adapter *adapter); +void nbl_dev_stop (struct nbl_adapter *adapter); + +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_dispatch.h new file +29 -0
@@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +*/ + +#ifndef _NBL_DEF_DISPATCH_H_ +#define _NBL_DEF_DISPATCH_H_ + +struct nbl_dispatch_mgt ; +struct nbl_adapter ; +enum { +NBL_DISP_CTRL_LVL_NEVER =0 , +NBL_DISP_CTRL_LVL_MGT , +NBL_DISP_CTRL_LVL_NET , +NBL_DISP_CTRL_LVL_MAX , +}; + +struct nbl_dispatch_ops { +void *reserved;/* placeholder to be replaced in the future*/ +}; + +struct nbl_dispatch_ops_tbl { +struct nbl_dispatch_ops *ops; +struct nbl_dispatch_mgt *priv; +}; + +int nbl_disp_init (struct nbl_adapter *adapter); +void nbl_disp_remove (struct nbl_adapter *adapter); +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_hw.h new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +*/ + +#ifndef _NBL_DEF_HW_H_ +#define _NBL_DEF_HW_H_ + +struct nbl_hw_mgt ; +struct nbl_adapter ; +struct nbl_hw_ops { +}; + +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); + +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_resource.h new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +*/ + +#ifndef _NBL_DEF_RESOURCE_H_ +#define _NBL_DEF_RESOURCE_H_ + +struct nbl_resource_mgt ; +struct nbl_adapter ; + +struct nbl_resource_ops { +}; + +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 +16 -0
@@ -11,4 +11,20 @@/* ------ Basic definitions ------- */ #define NBL_DRIVER_NAME "nbl" +enum nbl_product_type { +NBL_LEONIS_TYPE , +NBL_PRODUCT_MAX , +}; + +struct nbl_func_caps { +u32 has_ctrl:1 ; +u32 has_net:1 ; +u32 rsv:30 ; +}; + +struct nbl_init_param { +struct nbl_func_caps caps; +enum nbl_product_type product_type; +}; +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_product_base.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +*/ + +#ifndef _NBL_DEF_PRODUCT_BASE_H_ +#define _NBL_DEF_PRODUCT_BASE_H_ + +struct nbl_adapter ; +struct nbl_product_base_ops { +int (*hw_init)(struct nbl_adapter *p); +void (*hw_remove)(struct nbl_adapter *p); +int (*res_init)(struct nbl_adapter *p); +void (*res_remove)(struct nbl_adapter *p); +int (*chan_init)(struct nbl_adapter *p); +void (*chan_remove)(struct nbl_adapter *p); +}; + +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c +202 -0
217 lines not on this page · raw message
Signature · 1 line
2.47.3
illusion.wang
maintainerPATCH v20 3/10 net/nebula-matrix: channel msg value and msg struct
In reply to illusion.wangFrom: illusion wang <[email protected]>
The msg ID values are derived from enum ordinal and serve as wire opcodes. The set is stable and must not be reordered or extended without a wire-format change.
--- .../nbl/nbl_include/nbl_def_channel.h | 225 ++++++++++++++++++ 1 file changed, 225 insertions(+)
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_channel.h +225 -0
@@ -6,8 +6,233 @@#ifndef _NBL_DEF_CHANNEL_H_#define _NBL_DEF_CHANNEL_H_ +#include <linux/types.h> +struct nbl_channel_mgt ;struct nbl_adapter ; +enum nbl_chan_msg_type { +NBL_CHAN_MSG_ACK , +NBL_CHAN_MSG_ADD_MACVLAN , +NBL_CHAN_MSG_DEL_MACVLAN , +NBL_CHAN_MSG_ADD_MULTI_RULE , +NBL_CHAN_MSG_DEL_MULTI_RULE , +NBL_CHAN_MSG_SETUP_MULTI_GROUP , +NBL_CHAN_MSG_REMOVE_MULTI_GROUP , +NBL_CHAN_MSG_REGISTER_NET , +NBL_CHAN_MSG_UNREGISTER_NET , +NBL_CHAN_MSG_ALLOC_TXRX_QUEUES , +NBL_CHAN_MSG_FREE_TXRX_QUEUES , +NBL_CHAN_MSG_SETUP_QUEUE , +NBL_CHAN_MSG_REMOVE_ALL_QUEUES , +NBL_CHAN_MSG_CFG_DSCH , +NBL_CHAN_MSG_SETUP_CQS , +NBL_CHAN_MSG_REMOVE_CQS , +NBL_CHAN_MSG_CFG_QDISC_MQPRIO , +NBL_CHAN_MSG_CONFIGURE_MSIX_MAP , +NBL_CHAN_MSG_DESTROY_MSIX_MAP , +NBL_CHAN_MSG_MAILBOX_SET_IRQ , +NBL_CHAN_MSG_GET_GLOBAL_VECTOR , +NBL_CHAN_MSG_GET_VSI_ID , +NBL_CHAN_MSG_SET_PROMISC_MODE , +NBL_CHAN_MSG_GET_FIRMWARE_VERSION , +NBL_CHAN_MSG_GET_QUEUE_ERR_STATS , +NBL_CHAN_MSG_GET_COALESCE , +NBL_CHAN_MSG_SET_COALESCE , +NBL_CHAN_MSG_SET_SPOOF_CHECK_ADDR , +NBL_CHAN_MSG_SET_VF_SPOOF_CHECK , +NBL_CHAN_MSG_GET_RXFH_INDIR_SIZE , +NBL_CHAN_MSG_GET_RXFH_INDIR , +NBL_CHAN_MSG_GET_RXFH_RSS_KEY , +NBL_CHAN_MSG_GET_RXFH_RSS_ALG_SEL , +NBL_CHAN_MSG_GET_HW_CAPS , +NBL_CHAN_MSG_GET_HW_STATE , +NBL_CHAN_MSG_REGISTER_RDMA , +NBL_CHAN_MSG_UNREGISTER_RDMA , +NBL_CHAN_MSG_GET_REAL_HW_ADDR , +NBL_CHAN_MSG_GET_REAL_BDF , +NBL_CHAN_MSG_GRC_PROCESS , +NBL_CHAN_MSG_SET_SFP_STATE , +NBL_CHAN_MSG_SET_ETH_LOOPBACK , +NBL_CHAN_MSG_CHECK_ACTIVE_VF , +NBL_CHAN_MSG_GET_PRODUCT_FLEX_CAP , +NBL_CHAN_MSG_ALLOC_KTLS_TX_INDEX , +NBL_CHAN_MSG_FREE_KTLS_TX_INDEX , +NBL_CHAN_MSG_CFG_KTLS_TX_KEYMAT , +NBL_CHAN_MSG_ALLOC_KTLS_RX_INDEX , +NBL_CHAN_MSG_FREE_KTLS_RX_INDEX , +NBL_CHAN_MSG_CFG_KTLS_RX_KEYMAT , +NBL_CHAN_MSG_CFG_KTLS_RX_RECORD , +NBL_CHAN_MSG_ADD_KTLS_RX_FLOW , +NBL_CHAN_MSG_DEL_KTLS_RX_FLOW , +NBL_CHAN_MSG_ALLOC_IPSEC_TX_INDEX , +NBL_CHAN_MSG_FREE_IPSEC_TX_INDEX , +NBL_CHAN_MSG_ALLOC_IPSEC_RX_INDEX , +NBL_CHAN_MSG_FREE_IPSEC_RX_INDEX , +NBL_CHAN_MSG_CFG_IPSEC_TX_SAD , +NBL_CHAN_MSG_CFG_IPSEC_RX_SAD , +NBL_CHAN_MSG_ADD_IPSEC_TX_FLOW , +NBL_CHAN_MSG_DEL_IPSEC_TX_FLOW , +NBL_CHAN_MSG_ADD_IPSEC_RX_FLOW , +NBL_CHAN_MSG_DEL_IPSEC_RX_FLOW , +NBL_CHAN_MSG_NOTIFY_IPSEC_HARD_EXPIRE , +NBL_CHAN_MSG_GET_MBX_IRQ_NUM , +NBL_CHAN_MSG_CLEAR_FLOW , +NBL_CHAN_MSG_CLEAR_QUEUE , +NBL_CHAN_MSG_GET_ETH_ID , +NBL_CHAN_MSG_SET_OFFLOAD_STATUS , +NBL_CHAN_MSG_INIT_OFLD , +NBL_CHAN_MSG_INIT_CMDQ , +NBL_CHAN_MSG_DESTROY_CMDQ , +NBL_CHAN_MSG_RESET_CMDQ , +NBL_CHAN_MSG_INIT_FLOW , +NBL_CHAN_MSG_DEINIT_FLOW , +NBL_CHAN_MSG_OFFLOAD_FLOW_RULE , +NBL_CHAN_MSG_GET_ACL_SWITCH , +NBL_CHAN_MSG_GET_VSI_GLOBAL_QUEUE_ID , +NBL_CHAN_MSG_INIT_REP , +NBL_CHAN_MSG_GET_LINE_RATE_INFO , +NBL_CHAN_MSG_REGISTER_NET_REP , +NBL_CHAN_MSG_UNREGISTER_NET_REP , +NBL_CHAN_MSG_REGISTER_ETH_REP , +NBL_CHAN_MSG_UNREGISTER_ETH_REP , +NBL_CHAN_MSG_REGISTER_UPCALL_PORT , +NBL_CHAN_MSG_UNREGISTER_UPCALL_PORT , +NBL_CHAN_MSG_GET_PORT_STATE , +NBL_CHAN_MSG_SET_PORT_ADVERTISING , +NBL_CHAN_MSG_GET_MODULE_INFO , +NBL_CHAN_MSG_GET_MODULE_EEPROM , +NBL_CHAN_MSG_GET_LINK_STATE , +NBL_CHAN_MSG_NOTIFY_LINK_STATE , +NBL_CHAN_MSG_GET_QUEUE_CXT , +NBL_CHAN_MSG_CFG_LOG , +NBL_CHAN_MSG_INIT_VDPAQ , +NBL_CHAN_MSG_DESTROY_VDPAQ , +NBL_CHAN_MSG_GET_UPCALL_PORT , +NBL_CHAN_MSG_NOTIFY_ETH_REP_LINK_STATE , +NBL_CHAN_MSG_SET_ETH_MAC_ADDR , +NBL_CHAN_MSG_GET_FUNCTION_ID , +NBL_CHAN_MSG_GET_CHIP_TEMPERATURE , +NBL_CHAN_MSG_DISABLE_HW_FLOW , +NBL_CHAN_MSG_ENABLE_HW_FLOW , +NBL_CHAN_MSG_SET_UPCALL_RULE , +NBL_CHAN_MSG_UNSET_UPCALL_RULE , +NBL_CHAN_MSG_GET_REG_DUMP , +NBL_CHAN_MSG_GET_REG_DUMP_LEN , +NBL_CHAN_MSG_CFG_LAG_HASH_ALGORITHM , +NBL_CHAN_MSG_CFG_LAG_MEMBER_FWD , +NBL_CHAN_MSG_CFG_LAG_MEMBER_LIST , +NBL_CHAN_MSG_CFG_LAG_MEMBER_UP_ATTR , +NBL_CHAN_MSG_ADD_LAG_FLOW , +NBL_CHAN_MSG_DEL_LAG_FLOW , +NBL_CHAN_MSG_SWITCHDEV_INIT_CMDQ , +NBL_CHAN_MSG_SWITCHDEV_DEINIT_CMDQ , +NBL_CHAN_MSG_SET_TC_FLOW_INFO , +NBL_CHAN_MSG_UNSET_TC_FLOW_INFO , +NBL_CHAN_MSG_INIT_ACL , +NBL_CHAN_MSG_UNINIT_ACL , +NBL_CHAN_MSG_CFG_LAG_MCC , +NBL_CHAN_MSG_REGISTER_VSI2Q , +NBL_CHAN_MSG_SETUP_Q2VSI , +NBL_CHAN_MSG_REMOVE_Q2VSI , +NBL_CHAN_MSG_SETUP_RSS , +NBL_CHAN_MSG_REMOVE_RSS , +NBL_CHAN_MSG_GET_REP_QUEUE_INFO , +NBL_CHAN_MSG_CTRL_PORT_LED , +NBL_CHAN_MSG_NWAY_RESET , +NBL_CHAN_MSG_SET_INTL_SUPPRESS_LEVEL , +NBL_CHAN_MSG_GET_ETH_STATS , +NBL_CHAN_MSG_GET_MODULE_TEMPERATURE , +NBL_CHAN_MSG_GET_BOARD_INFO , +NBL_CHAN_MSG_GET_P4_USED , +NBL_CHAN_MSG_GET_VF_BASE_VSI_ID , +NBL_CHAN_MSG_ADD_LLDP_FLOW , +NBL_CHAN_MSG_DEL_LLDP_FLOW , +NBL_CHAN_MSG_CFG_ETH_BOND_INFO , +NBL_CHAN_MSG_CFG_DUPPKT_MCC , +NBL_CHAN_MSG_ADD_ND_UPCALL_FLOW , +NBL_CHAN_MSG_DEL_ND_UPCALL_FLOW , +NBL_CHAN_MSG_GET_BOARD_ID , +NBL_CHAN_MSG_SET_SHAPING_DPORT_VLD , +NBL_CHAN_MSG_SET_DPORT_FC_TH_VLD , +NBL_CHAN_MSG_REGISTER_RDMA_BOND , +NBL_CHAN_MSG_UNREGISTER_RDMA_BOND , +NBL_CHAN_MSG_RESTORE_NETDEV_QUEUE , +NBL_CHAN_MSG_RESTART_NETDEV_QUEUE , +NBL_CHAN_MSG_RESTORE_HW_QUEUE , +NBL_CHAN_MSG_KEEP_ALIVE , +NBL_CHAN_MSG_GET_BASE_MAC_ADDR , +NBL_CHAN_MSG_CFG_BOND_SHAPING , +NBL_CHAN_MSG_CFG_BGID_BACK_PRESSURE , +NBL_CHAN_MSG_ALLOC_KT_BLOCK , +NBL_CHAN_MSG_FREE_KT_BLOCK , +NBL_CHAN_MSG_GET_USER_QUEUE_INFO , +NBL_CHAN_MSG_GET_ETH_BOND_INFO , +NBL_CHAN_MSG_CLEAR_ACCEL_FLOW , +NBL_CHAN_MSG_SET_BRIDGE_MODE , +NBL_CHAN_MSG_GET_VF_FUNCTION_ID , +NBL_CHAN_MSG_NOTIFY_LINK_FORCED , +NBL_CHAN_MSG_SET_PMD_DEBUG , +NBL_CHAN_MSG_REGISTER_FUNC_MAC , +NBL_CHAN_MSG_SET_TX_RATE , +NBL_CHAN_MSG_REGISTER_FUNC_LINK_FORCED , +NBL_CHAN_MSG_GET_LINK_FORCED , +NBL_CHAN_MSG_REGISTER_FUNC_VLAN , +NBL_CHAN_MSG_GET_FD_FLOW , +NBL_CHAN_MSG_GET_FD_FLOW_CNT , +NBL_CHAN_MSG_GET_FD_FLOW_ALL , +NBL_CHAN_MSG_GET_FD_FLOW_MAX , +NBL_CHAN_MSG_REPLACE_FD_FLOW , +NBL_CHAN_MSG_REMOVE_FD_FLOW , +NBL_CHAN_MSG_CFG_FD_FLOW_STATE , +NBL_CHAN_MSG_REGISTER_FUNC_RATE , +NBL_CHAN_MSG_NOTIFY_VLAN , +NBL_CHAN_MSG_GET_XDP_QUEUE_INFO , +NBL_CHAN_MSG_STOP_ABNORMAL_SW_QUEUE , +NBL_CHAN_MSG_STOP_ABNORMAL_HW_QUEUE , +NBL_CHAN_MSG_NOTIFY_RESET_EVENT , +NBL_CHAN_MSG_ACK_RESET_EVENT , +NBL_CHAN_MSG_GET_VF_VSI_ID , +NBL_CHAN_MSG_CONFIGURE_QOS , +NBL_CHAN_MSG_GET_PFC_BUFFER_SIZE , +NBL_CHAN_MSG_SET_PFC_BUFFER_SIZE , +NBL_CHAN_MSG_GET_VF_STATS , +NBL_CHAN_MSG_REGISTER_FUNC_TRUST , +NBL_CHAN_MSG_NOTIFY_TRUST , +NBL_CHAN_MSG_CHECK_VF_IS_ACTIVE , +NBL_CHAN_MSG_GET_ETH_ABNORMAL_STATS , +NBL_CHAN_MSG_GET_ETH_CTRL_STATS , +NBL_CHAN_MSG_GET_PAUSE_STATS , +NBL_CHAN_MSG_GET_ETH_MAC_STATS , +NBL_CHAN_MSG_GET_FEC_STATS , +NBL_CHAN_MSG_CFG_MULTI_MCAST_RULE , +NBL_CHAN_MSG_GET_LINK_DOWN_COUNT , +NBL_CHAN_MSG_GET_LINK_STATUS_OPCODE , +NBL_CHAN_MSG_GET_RMON_STATS , +NBL_CHAN_MSG_REGISTER_PF_NAME , +NBL_CHAN_MSG_GET_PF_NAME , +NBL_CHAN_MSG_CONFIGURE_RDMA_BW , +NBL_CHAN_MSG_SET_RATE_LIMIT , +NBL_CHAN_MSG_SET_TC_WGT , +NBL_CHAN_MSG_REMOVE_QUEUE , +NBL_CHAN_MSG_GET_MIRROR_TABLE_ID , +NBL_CHAN_MSG_CONFIGURE_MIRROR , +NBL_CHAN_MSG_CONFIGURE_MIRROR_TABLE , +NBL_CHAN_MSG_CLEAR_MIRROR_CFG , +NBL_CHAN_MSG_MIRROR_OUTPUTPORT_NOTIFY , +NBL_CHAN_MSG_CHECK_FLOWTABLE_SPEC , +NBL_CHAN_MSG_CHECK_VF_IS_VDPA , +NBL_CHAN_MSG_GET_VDPA_VF_STATS , +NBL_CHAN_MSG_SET_RX_RATE , +NBL_CHAN_MSG_GET_UVN_PKT_DROP_STATS , +NBL_CHAN_MSG_GET_USTORE_PKT_DROP_STATS , +NBL_CHAN_MSG_GET_USTORE_TOTAL_PKT_DROP_STATS , +NBL_CHAN_MSG_SET_WOL , +NBL_CHAN_MSG_INIT_VF_MSIX_MAP , +NBL_CHAN_MSG_GET_ST_NAME , +/* mailbox msg end */ +NBL_CHAN_MSG_MAILBOX_MAX , +}; +enum nbl_channel_type {NBL_CHAN_TYPE_MAILBOX , NBL_CHAN_TYPE_MAX
Signature · 1 line
2.47.3
illusion.wang
maintainerPATCH v20 4/10 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, including asynchronous operations with acknowledgment (ACK) support. Received ACKs are processed via nbl_chan_recv_ack_msg.
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 removal is not implemented in this version).
2. Channel Types and Queue Management
Mailbox Channel: For direct communication between PF0 and Other PF.
Queue Initialization: Functions (nbl_chan_init_queue, nbl_chan_init_tx_queue) allocate resources:
- TX descriptors: dmam_alloc_coherent()
- RX descriptors: dmam_alloc_coherent()
- TX/RX buffer metadata arrays (txq->buf, rxq->buf): devm_kcalloc()
Queue Teardown: nbl_chan_teardown_queue() stops queues, cancels pending work items (clean_task), and destroys mutexes. 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 (when all devm_ resources are released). This assumes queues are NOT dynamically torn down and recreated per-PF during normal operation.
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.
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 updates (update_mailbox_queue_tail_ptr).
--- .../net/ethernet/nebula-matrix/nbl/Makefile | 3 +- .../nbl/nbl_channel/nbl_channel.c | 1022 ++++++++++++++++- .../nbl/nbl_channel/nbl_channel.h | 138 +++ .../nebula-matrix/nbl/nbl_common/nbl_common.c | 193 ++++ .../nebula-matrix/nbl/nbl_common/nbl_common.h | 33 + .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c | 146 +++ .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.h | 56 + .../nebula-matrix/nbl/nbl_hw/nbl_hw_reg.h | 1 + .../nbl/nbl_include/nbl_def_channel.h | 83 ++ .../nbl/nbl_include/nbl_def_common.h | 26 + .../nbl/nbl_include/nbl_def_hw.h | 27 + .../nbl/nbl_include/nbl_include.h | 6 + 12 files changed, 1730 insertions(+), 4 deletions(-) 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 +2 -1
@@ -3,7 +3,8 @@ obj-$(CONFIG_NBL) := nbl.o -nbl-objs += nbl_channel/nbl_channel.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_core/nbl_dispatch.o \
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.c +1019 -3
1,074 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.h +138 -0
146 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_common/nbl_common.c new file +193 -0
193 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_common/nbl_common.h new file +33 -0
@@ -0,0 +1,33 @@ +/* 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_common_wq_mgt { +struct workqueue_struct *ctrl_dev_wq; +}; + +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_hw/nbl_hw_leonis/nbl_hw_leonis.c +146 -0
161 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 +1 -0
@@ -26,6 +26,7 @@ struct nbl_hw_mgt {u8 __iomem *mailbox_bar_hw_addr;u64 notify_offset;resource_size_t hw_size; +spinlock_t reg_lock;/* Protect reg access */ };static inline u32 rd32 (u8 __iomem *addr,u64 reg)
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_channel.h +83 -0
101 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_common.h +26 -0
@@ -11,6 +11,8 @@#include <linux/device.h> #include "nbl_include.h" +struct nbl_hash_tbl_mgt ; +struct nbl_common_info {struct pci_dev *pdev;struct device *dev;
@@ -31,4 +33,28 @@ 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_del_key { +void *action_priv; +void (*action_func)(void *priv,void *key,void *data); +}; + +u32 nbl_common_pf_id_subtraction_mgtpf_id (struct nbl_common_info *common, +u32 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, +struct nbl_hash_tbl_del_key *key); +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 +27 -0
@@ -6,9 +6,36 @@#ifndef _NBL_DEF_HW_H_#define _NBL_DEF_HW_H_ +#include <linux/types.h> +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 (*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); +u32 (*get_host_pf_mask)(struct nbl_hw_mgt *hw_mgt); +u8 (*get_real_bus)(struct nbl_hw_mgt *hw_mgt); + +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); +u32 (*get_fw_eth_map)(struct nbl_hw_mgt *hw_mgt); +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_include.h +6 -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); \ + })enum nbl_product_type {NBL_LEONIS_TYPE ,
Signature · 1 line
2.47.3
Paolo Abeni
maintainerRe: [PATCH v20 net-next 04/10] net/nebula-matrix: add channel layer
From: AI Reviewer <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://sashiko.dev/
---
Subject: net/nebula-matrix: add channel layer
This patch introduces a channel management layer for structured communication between components and drivers. It implements message registration, sending, and acknowledgment via hardware mailbox queues.
Quoted 4 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.c +0
-0
[ ... ]
Quoted 1 line
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.c +0
-0@@ -2,12 +2,997 @@
[ ... ]
Quoted 3 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.c +3
-0+static int nbl_chan_teardown_queue (struct nbl_channel_mgt *chan_mgt, +u8 chan_type) +{
[ ... ]
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.c line 317
Quoted 12 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.c +12
-0+/* +* Lock and unlock to ensure all in-flight callers have released the +* lock. After unlock returns, we're guaranteed no other thread is +* using the lock, so it's safe to destroy it. +*/ +mutex_lock (&chan_info->txq_lock); +mutex_unlock (&chan_info->txq_lock); +wait_for_completion (&chan_info->teardown_done); +mutex_destroy (&chan_info->txq_lock); + +return 0 ; +}
[Severity: High]
Does this code deadlock or fail to synchronize?
Because nbl_chan_send_msg() calls complete(&chan_info->teardown_done) on every exit path, it increments the completion counter for every message sent. If no messages were ever sent, the counter is 0 and this wait_for_completion() will block forever.
If messages were sent, the counter is greater than 0, so this returns immediately without waiting for active senders. It then destroys txq_lock while other threads might still be using it, which can cause a use-after-free or lock corruption.
[ ... ]
Quoted 4 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.c +4
-0+static int nbl_chan_update_txqueue (struct nbl_channel_mgt *chan_mgt, +struct nbl_chan_info *chan_info, +struct nbl_chan_tx_param *param) +{
[ ... ]
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.c line 377
Quoted 12 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.c +12
-0+if (param->arg_len >NBL_CHAN_TX_DESC_EMBEDDED_DATA_LEN ) { +memcpy (tx_buf->va, param->arg, param->arg_len); + tx_desc->buf_addr =cpu_to_le64 (tx_buf->pa); + tx_desc->buf_len =cpu_to_le16 (param->arg_len); + tx_desc->data_len =0 ; +memset (tx_desc->data,0 ,sizeof (tx_desc->data)); + }else { +memset (tx_desc->data,0 ,sizeof (tx_desc->data)); +memcpy (tx_desc->data, param->arg, param->arg_len); + tx_desc->buf_len =0 ; + tx_desc->data_len =cpu_to_le16 (param->arg_len); + }
[Severity: High]
Does this code leak host physical memory addresses to the receiving endpoint?
In the else branch (when embedding data), tx_desc->buf_addr is not cleared. Since the TX descriptor ring is reused circularly, if this slot previously held a large message, buf_addr still contains the physical DMA address of the host's buffer.
This leaked physical address is written to memory shared with the receiving endpoint, potentially crossing a security boundary.
[ ... ]
Quoted 3 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.c +3
-0+static void nbl_chan_clean_queue (struct nbl_channel_mgt *chan_mgt, +struct nbl_chan_info *chan_info) +{
[ ... ]
Quoted 1 line
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.c +1
-0+while (le16_to_cpu (rx_desc->flags) &BIT (NBL_CHAN_RX_DESC_USED )) {
[ ... ]
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.c line 681
Quoted 5 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.c +5
-0+if (--budget ==0 ) +break ; + } + rxq->next_to_clean = next_to_clean; +}
[Severity: High]
Can this permanently stall the RX queue?
The loop exits when the budget is exhausted, but nbl_chan_clean_queue() returns void and doesn't indicate that more packets remain.
The workqueue handler does not check if the RX queue was completely drained and won't reschedule the work item. If the ring wasn't completely drained, edge-triggered MSI-X interrupts won't fire again until a new packet arrives, leading to a stalled queue and missed messages.
[ ... ]
Quoted 3 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.c +3
-0+static int nbl_chan_send_msg (struct nbl_channel_mgt *chan_mgt, +struct nbl_chan_send_info *chan_send) +{
[ ... ]
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.c line 821
Quoted 4 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.c +4
-0+if (!chan_send->ack) { +complete (&chan_info->teardown_done); +return 0 ; + }
[Severity: High]
Is it intentional to call complete(&chan_info->teardown_done) here and on all other exit paths of nbl_chan_send_msg()?
This increments the completion counter on every message sent, which breaks the synchronization in nbl_chan_teardown_queue() (as mentioned above).
[ ... ]
Signature · 1 line
This is an AI-generated review.
illusion.wang
maintainerPATCH v20 5/10 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 | 1 + .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c | 47 +++++ .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.h | 14 ++ .../nbl_hw_leonis/nbl_resource_leonis.c | 190 ++++++++++++++++++ .../nebula-matrix/nbl/nbl_hw/nbl_resource.c | 143 +++++++++++++ .../nebula-matrix/nbl/nbl_hw/nbl_resource.h | 49 ++++- .../nbl/nbl_include/nbl_def_common.h | 15 ++ .../nbl/nbl_include/nbl_def_resource.h | 16 ++ .../nbl/nbl_include/nbl_include.h | 8 + 9 files changed, 482 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.c
drivers/net/ethernet/nebula-matrix/nbl/Makefile +1 -0
@@ -7,6 +7,7 @@ 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_core/nbl_dispatch.o \ nbl_core/nbl_dev.o \ nbl_main.o
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c +47 -0
79 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 +190 -0
207 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.c new file +143 -0
143 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.h +48 -1
60 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_common.h +15 -0
@@ -12,6 +12,21 @@#include "nbl_include.h" struct nbl_hash_tbl_mgt ; +#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;
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_resource.h +16 -0
@@ -6,10 +6,26 @@#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 (*init_chip_module)(struct nbl_resource_mgt *res_mgt); +void (*deinit_chip_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); +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, +u16 vsi_id,u8 *eth_num,u8 *eth_id, +u8 *logic_eth_id); }; struct nbl_resource_ops_tbl {
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_include.h +8 -0
@@ -17,11 +17,19 @@ ((_id) == (max) ?0 : (_id) +1 ); \ }) +#define NBL_MAX_FUNC 520 +#define NBL_MAX_ETHERNET 4 +enum nbl_product_type {NBL_LEONIS_TYPE ,NBL_PRODUCT_MAX , }; +enum { +NBL_VSI_DATA =0 , +NBL_VSI_MAX , +}; +struct nbl_func_caps {u32 has_ctrl:1 ;u32 has_net:1 ;
Signature · 1 line
2.47.3
Paolo Abeni
maintainerRe: [PATCH v20 net-next 05/10] net/nebula-matrix: add common resource implementation
From: AI Reviewer <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://sashiko.dev/
---net/nebula-matrix: add common resource implementation
The patch adds the common part of the resource layer for the Nebula Matrix driver, including conversion relationships among vsi_id, func_id, eth_id, and pf_id.
Quoted 5 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.c new file +0
-0
[ ... ]
Quoted 3 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.c new file +3
-0+int nbl_res_func_id_to_vsi_id (struct nbl_resource_mgt *res_mgt,u16 func_id, +u16 type,u16 *vsi_id) +{
[ ... ]
Quoted 4 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.c new file +4
-0+nbl_res_pf_dev_vsi_type_to_hw_vsi_type (type, &dst_type); + *vsi_id = vsi_info->serv_info[diff][dst_type].base_id; +return 0 ; +}
[ ... ]
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.c line 140
Quoted 9 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.c new file +9
-0+void nbl_res_pf_dev_vsi_type_to_hw_vsi_type (u16 src_type, +enum nbl_vsi_serv_type *dst_type) +{ +switch (src_type) { +case NBL_VSI_DATA : + *dst_type =NBL_VSI_SERV_PF_DATA_TYPE ; +break ; +default : +WARN_ON_ONCE (1 );
[Severity: High]
Can a malicious or buggy Virtual Function (VF) trigger this warning by passing an invalid type?
Because nbl_res_pf_dev_vsi_type_to_hw_vsi_type() returns void, it cannot propagate an error back to the caller. When an invalid type is processed, nbl_res_func_id_to_vsi_id() silently defaults to NBL_VSI_SERV_PF_DATA_TYPE and returns 0 for success.
Should this function return an error code so that nbl_res_func_id_to_vsi_id() can properly reject the invalid type instead of reporting a false success?
Quoted 3 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.c new file +3
-0+break ; + } +}
Signature · 1 line
This is an AI-generated review.
illusion.wang
maintainerPATCH v20 6/10 net/nebula-matrix: add intr resource implementation
In reply to illusion.wangFrom: illusion wang <[email protected]>
This patch adds the nbl_interrupt module for management of driver-private MSI-X indices, plus hw_ops callbacks to program the function MSI-X mapping registers, configure MSI-X info, and enable mailbox interrupts.
Key interfaces:
- configure_msix_map: Allocates driver-private global MSI-X indices
(interrupt_net_bitmap / interrupt_others_bitmap) and programs the hardware MSI-X mapping registers (NBL_PCOMPLETER_FUNCTION_MSIX_MAP). The actual PCI MSI-X vector allocation is done by nbl_dev_alloc_msix_intr().
- destroy_msix_map: Releases MSI-X indices and tears down the mapping.
- set_mailbox_irq: Enables/disables a specific mailbox interrupt.
- configure_msix_info: Programs PADPT_HOST_MSIX_INFO and
PCOMPLETER_HOST_MSIX_FID_TABLE.
The patch does not use kernel MSI-X allocation primitives (pci_alloc_irq_vectors, pci_msix_alloc_irq_at, irq_domain). It manages a driver-private global index space and programs vendor-specific MSI-X mapping registers.
Note: Mutual exclusion for configure_msix_map, destroy_msix_map, and enable_mailbox_irq is handled by the dispatch layer; these functions assume the caller already holds the necessary lock.
--- .../net/ethernet/nebula-matrix/nbl/Makefile | 1 + .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c | 92 ++++++ .../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 | 267 ++++++++++++++++++ .../nebula-matrix/nbl/nbl_hw/nbl_interrupt.h | 21 ++ .../nebula-matrix/nbl/nbl_hw/nbl_resource.h | 33 +++ .../nbl/nbl_include/nbl_def_hw.h | 1 + .../nbl/nbl_include/nbl_include.h | 2 + 10 files changed, 468 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,6 +8,7 @@ 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_core/nbl_dispatch.o \ nbl_core/nbl_dev.o \ nbl_main.o
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c +92 -0
110 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 *
@@ -236,7 +239,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 +267 -0
267 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.h +33 -0
@@ -18,6 +18,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(interrupt_net_bitmap, NBL_MAX_NET_INTERRUPT); + DECLARE_BITMAP(interrupt_others_bitmap, NBL_MAX_OTHER_INTERRUPT); +struct nbl_func_interrupt_resource_mng func_intr_res[NBL_MAX_FUNC ]; +}; +/* --------- INFO ---------- */ struct nbl_sriov_info {unsigned int bdf;
@@ -73,6 +105,7 @@ 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);void nbl_res_pf_dev_vsi_type_to_hw_vsi_type (u16 src_type,enum nbl_vsi_serv_type *dst_type);#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_hw.h +1 -0
@@ -18,6 +18,7 @@ struct nbl_hw_ops { 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,
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_product_type {NBL_LEONIS_TYPE ,
Signature · 1 line
2.47.3
Paolo Abeni
maintainerRe: [PATCH v20 net-next 06/10] net/nebula-matrix: add intr resource implementation
From: AI Reviewer <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://sashiko.dev/
---net/nebula-matrix: add intr resource implementation
This patch adds the nbl_interrupt module for management of driver-private MSI-X indices. It adds hw_ops callbacks to program the function MSI-X mapping registers, configure MSI-X info, and enable mailbox interrupts.
Quoted 6 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_interrupt.c new file +0
-0@@ -0,0 +1,267 @@
[ ... ]
Quoted 11 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_interrupt.c new file +11
-0+/* +* This function tears down the MSI-X mapping for a function by clearing the +* interrupt bitmaps, disabling MSI-X via HW callbacks, and resetting the +* bookkeeping state. The DMA buffer and interrupts[] array are intentionally +* left allocated for potential reuse on reset/hot-add paths. Caller must +* ensure this is only invoked when the HW cannot issue in-flight DMA to +* the region (IRQs already freed or not yet configured). +*/ +int nbl_res_intr_destroy_msix_map (struct nbl_resource_mgt *res_mgt, +u16 func_id) +{
[ ... ]
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_interrupt.c line 68
Quoted 12 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_interrupt.c new file +12
-0+/* use ctrl dev bdf */ + hw_ops->configure_msix_map (res_mgt->hw_ops_tbl->priv, func_id, false,0 , +0 ,0 ,0 ); + + intr_mgt->func_intr_res[func_id].interrupts =NULL ; + intr_mgt->func_intr_res[func_id].num_interrupts =0 ; + intr_mgt->func_intr_res[func_id].msix_map_table.base_addr =NULL ; + intr_mgt->func_intr_res[func_id].msix_map_table.size =0 ; + hw_ops->flush_write (res_mgt->hw_ops_tbl->priv); + +return 0 ; +}
[Severity: High]
Does this code leak the devm-managed resources? The comment mentions that the DMA buffer and interrupts array are left allocated for potential reuse, but the pointers are set to NULL here. This causes the pointers to be lost so they cannot be reused or explicitly freed later.
Because nbl_res_intr_configure_msix_map() unconditionally allocates new devres memory on every call, won't this cause the devres list to accumulate leaked allocations (dmam_alloc_coherent and devm_kcalloc) each time the device is reset or a VF is reconfigured?
[ ... ]
Quoted 5 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_interrupt.c new file +5
-0+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) +{
[ ... ]
Quoted 15 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_interrupt.c new file +15
-0+nbl_res_intr_destroy_msix_map (res_mgt, func_id); + + msix_map_table = &intr_mgt->func_intr_res[func_id].msix_map_table; +WARN_ON (msix_map_table->base_addr); + msix_map_table->size = +sizeof (struct nbl_msix_map ) *NBL_MSIX_MAP_TABLE_MAX_ENTRIES ; +/* HW indexes the MSI-X map table with a fixed stride of 1024 entries, +* so we must allocate the full table even if fewer vectors are used. +*/ + msix_map_table->base_addr =dmam_alloc_coherent (dev, + msix_map_table->size, + &msix_map_table->dma, +GFP_KERNEL ); +if (!msix_map_table->base_addr) { +dev_err (dev,"Allocate DMA memory for function msix map table failed\n" );
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_interrupt.c line 140
Quoted 10 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_interrupt.c new file +10
-0+ msix_map_table->size =0 ; +return -ENOMEM ; + } + + interrupts =devm_kcalloc (dev, requested,sizeof (interrupts[0 ]), +GFP_KERNEL ); +if (!interrupts) { + ret = -ENOMEM ; + goto alloc_interrupts_err; + }
[Severity: High]
If devm_kcalloc() fails, the goto alloc_interrupts_err path bypasses clearing msix_map_table->base_addr and size.
While nbl_res_intr_destroy_msix_map() clears it unconditionally on the next call, doesn't this leave the internal state inconsistent by keeping base_addr populated when interrupts is NULL?
[ ... ]
Quoted 19 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_interrupt.c new file +19
-0+get_interrupt_err: +while (i--) { + intr_index = interrupts[i]; +if (intr_index >=NBL_NET_INTR_BASE ) +clear_bit (intr_index -NBL_NET_INTR_BASE , + intr_mgt->interrupt_net_bitmap); +else +clear_bit (intr_index, + intr_mgt->interrupt_others_bitmap); + } + + intr_mgt->func_intr_res[func_id].num_interrupts =0 ; + intr_mgt->func_intr_res[func_id].interrupts =NULL ; + intr_mgt->func_intr_res[func_id].num_net_interrupts =0 ; + intr_mgt->func_intr_res[func_id].msix_map_table.base_addr =NULL ; + intr_mgt->func_intr_res[func_id].msix_map_table.size =0 ; +alloc_interrupts_err: +return ret; +}
Signature · 1 line
This is an AI-generated review.
illusion.wang
maintainerPATCH v20 7/10 net/nebula-matrix: add vsi resource implementation
In reply to illusion.wangFrom: illusion wang <[email protected]>
This patch adds the VSI (Virtual Station Interface) resource implementation for the Nebula Matrix Leonis hardware.
This driver only supports little-endian architecture
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, ustore, dstore: Scheduling and Store modules
- dvn, uvn, uqm: Virtual Network and Queue Management
- nbl_shaping_init(): Traffic shaping configuration
Chip init sequence (nbl_hw_init_chip_module()):
1. nbl_dp_init() — All DP sub-modules above
2. nbl_intf_init() — Host adapter padpt flow control
- nbl_host_padpt_init() — Host padpt flow control registers
3. nbl_write_all_regs() — Bulk P4 register data loading
4. nbl_hw_set_driver_status() + nbl_flush_writes()
--- .../net/ethernet/nebula-matrix/nbl/Makefile | 1 + .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c | 484 ++++++++++++++++++ .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.h | 242 +++++++++ .../nbl_hw_leonis/nbl_resource_leonis.c | 2 + .../nbl_hw_leonis/nbl_resource_leonis.h | 1 + .../nebula-matrix/nbl/nbl_hw/nbl_vsi.c | 26 + .../nebula-matrix/nbl/nbl_hw/nbl_vsi.h | 12 + .../nbl/nbl_include/nbl_def_hw.h | 4 + .../nbl/nbl_include/nbl_include.h | 12 + 9 files changed, 784 insertions(+) create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_vsi.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_vsi.h
drivers/net/ethernet/nebula-matrix/nbl/Makefile +1 -0
@@ -9,6 +9,7 @@ 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_vsi.o \ nbl_core/nbl_dispatch.o \ nbl_core/nbl_dev.o \ nbl_main.o
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c +484 -0
496 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.h +242 -0
264 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_chip_module = nbl_res_vsi_init_chip_module, + .deinit_chip_module = nbl_res_vsi_deinit_chip_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_vsi.h" #endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_vsi.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_vsi.h" + +void nbl_res_vsi_deinit_chip_module (struct nbl_resource_mgt *res_mgt) +{ +struct nbl_hw_ops *hw_ops = res_mgt->hw_ops_tbl->ops; + + hw_ops->deinit_chip_module (res_mgt->hw_ops_tbl->priv); +} + +int nbl_res_vsi_init_chip_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 = hw_ops->init_chip_module (p, eth_speed, eth_num); + +return ret; +}
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_vsi.h new file +12 -0
@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +*/ + +#ifndef _NBL_VSI_H_ +#define _NBL_VSI_H_ + +#include "nbl_resource.h" +int nbl_res_vsi_init_chip_module (struct nbl_resource_mgt *res_mgt); +void nbl_res_vsi_deinit_chip_module (struct nbl_resource_mgt *res_mgt); +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_hw.h +4 -0
@@ -11,6 +11,10 @@struct nbl_hw_mgt ;struct nbl_adapter ;struct nbl_hw_ops { +int (*init_chip_module)(struct nbl_hw_mgt *hw_mgt,u8 eth_speed, +u8 eth_num); +void (*deinit_chip_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_include.h +12 -0
@@ -43,4 +43,16 @@ struct nbl_init_param { enum nbl_product_type product_type; }; +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 , +}; + +enum nbl_performance_mode { +NBL_QUIRKS_NO_TOE , +NBL_QUIRKS_UVN_PREFETCH_ALIGN , +}; +#endif
Signature · 1 line
2.47.3
illusion.wang
maintainerPATCH v20 8/10 net/nebula-matrix: add Dispatch layer implementation
In reply to illusion.wangFrom: illusion wang <[email protected]>
This patch introduces a control-level routing mechanism for the Dispatch layer, supporting direct and channel routing paths based on declared control levels.
Routing is controlled by two components:
1. Interface-declared control levels (per operation) Each operation interface declares its required control level:
- NBL_DISP_CTRL_LVL_MGT: management operations
- NBL_DISP_CTRL_LVL_NET: network operations
2. Upper-layer configured control levels (per PF driver) The PF driver configures which control levels use the direct path via nbl_disp_init().
Current state:
- Regular PF: configures NET_LVL at Dispatch layer. NBL_DISP_CTRL_LVL_NET is wired in nbl_disp_init() but not yet used by any operation. All operations declare ctrl=NBL_DISP_CTRL_LVL_MGT, so they all fall through to the CTRL_LVL_MGT branch and use the channel path. The direct path for NET_LVL is reserved for future high-performance network operations.
- Management PF: configures both NET_LVL and CTRL_LVL. Since every operation declares ctrl=NBL_DISP_CTRL_LVL_MGT, test_bit(MGT, ctrl_lvl) is true for every op, so all ops resolve to func (direct path), not msg_req (channel path).
Future work:
Update NBL_DISP_OPS_TBL to declare ctrl=NBL_DISP_CTRL_LVL_NET for network operations, enabling direct path routing.
Message Handling Framework:
Message structs follow strict compatibility rules: fields can only be appended on new DWs, never removed; array member lengths are fixed. When extending request structs, the response handler declares a new stack variable of the updated struct, initializes new fields to invalid values, and performs min-copy. This is intentional per our compatibility design (see nbl_def_channel.h). The responder may run an older version than the requestor, so data_len < sizeof(param) is expected and handled by min-copy + zero-fill. Rejecting short responses would break cross-version interop.
The Channel path is used by all current operations. This design allows the framework to be extended later to support direct HW access for high-performance network operations without changing the channel layer or existing control-plane operations.
Resource Layer Locking Strategy (related to this patch):
Mutex protection in nbl_dispatch_mgt:
- configure_msix_map(): LOCKED (via NBL_OPS_CALL_LOCK_RET) - destroy_msix_map(): LOCKED - set_mailbox_irq(): LOCKED - init_chip_module(): UNLOCKED - deinit_chip_module(): UNLOCKED - get_vsi_id(): UNLOCKED - get_eth_id(): UNLOCKED
Design rationale for unlocked call sites:
1. init_chip_module() / deinit_chip_module():
- Called ONLY from control path (PF0)
- These are init/teardown functions that run sequentially
- No concurrent access possible because:
a) Called during driver probe/remove
b) Only one control device exists
- Safe to call without mutex
2. get_vsi_id() / get_eth_id():
- These are READ-ONLY operations
- They only query existing state, never modify it
- Even if called concurrently with locked operations:
a) Reading shared state without lock is safe on most architectures (torn reads are acceptable for IDs)
b) The locked operations that MODIFY state are:
- configure_msix_map (allocates resources)
- destroy_msix_map (frees resources)
- set_mailbox_irq (modifies hw state)
c) Reading while writing is safe if:
- Writer holds lock (prevents concurrent writes)
- Reader doesn't care about torn reads (IDs are atomic)
Mutex purpose:
The ops_mutex_lock protects MODIFY operations on shared resource state (MSI-X map allocation, hardware configuration). It does NOT protect read-only queries or ctrl-path init/teardown.
This is a deliberate design choice: locking only the critical sections minimizes contention while maintaining safety for the common case (concurrent reads).
--- .../nbl/nbl_channel/nbl_channel.c | 5 + .../nebula-matrix/nbl/nbl_core/nbl_dispatch.c | 447 ++++++++++++++++++ .../nebula-matrix/nbl/nbl_core/nbl_dispatch.h | 18 + .../nbl/nbl_include/nbl_def_channel.h | 26 + .../nbl/nbl_include/nbl_def_dispatch.h | 15 +- .../nbl/nbl_include/nbl_include.h | 21 + 6 files changed, 531 insertions(+), 1 deletion(-)
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.c +5 -0
@@ -1053,6 +1053,11 @@ 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 ); +BUILD_BUG_ON (sizeof (struct nbl_board_port_info ) !=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/nbl_dispatch.c +447 -0
462 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dispatch.h +18 -0
@@ -14,12 +14,30 @@#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; \ + \ + mutex_lock(&_disp_mgt->ops_mutex_lock); \ + \ + if (_func) \ + _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
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_channel.h +26 -0
@@ -271,6 +271,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 +14 -1
@@ -6,6 +6,8 @@#ifndef _NBL_DEF_DISPATCH_H_#define _NBL_DEF_DISPATCH_H_ +#include <linux/types.h> +struct nbl_dispatch_mgt ;struct nbl_adapter ; enum {
@@ -16,7 +18,18 @@ enum { };struct nbl_dispatch_ops { -void *reserved;/* placeholder to be replaced in the future*/ +int (*init_chip_module)(struct nbl_dispatch_mgt *disp_mgt); +void (*deinit_chip_module)(struct nbl_dispatch_mgt *disp_mgt); +int (*configure_msix_map)(struct nbl_dispatch_mgt *disp_mgt, +u16 num_net_msix,u16 num_others_msix, +bool net_msix_mask_en); +int (*destroy_msix_map)(struct nbl_dispatch_mgt *disp_mgt); +int (*set_mailbox_irq)(struct nbl_dispatch_mgt *disp_mgt, +u16 vector_id,bool enable_msix); +int (*get_vsi_id)(struct nbl_dispatch_mgt *disp_mgt,u16 type, +u16 *vsi_id); +int (*get_eth_id)(struct nbl_dispatch_mgt *disp_mgt,u16 vsi_id, +u8 *eth_num,u8 *eth_id,u8 *logic_eth_id); };struct nbl_dispatch_ops_tbl {
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_include.h +21 -0
@@ -50,6 +50,27 @@ enum nbl_fw_port_speed { NBL_FW_PORT_SPEED_100G, }; +#define NBL_OPS_CALL (func, para) \ +do { \ + typeof(func) _func = (func); \ + if (_func) \ + _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; \ +}) + +/* Optional ops with lock: NULL = not implemented, 0 = handled (no-op) */ +#define NBL_OPS_CALL_RET_PTR (func, para) \ +({ \ + typeof(func) _func = (func); \ + _func ? _func para : NULL; \ +}) +enum nbl_performance_mode {NBL_QUIRKS_NO_TOE ,NBL_QUIRKS_UVN_PREFETCH_ALIGN ,
Signature · 1 line
2.47.3
Paolo Abeni
maintainerRe: [PATCH v20 net-next 08/10] net/nebula-matrix: add Dispatch layer implementation
From: AI Reviewer <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://sashiko.dev/
---net/nebula-matrix: add Dispatch layer implementation
This patch introduces a control-level routing mechanism for the Dispatch layer, supporting direct and channel routing paths based on declared control levels. It establishes the message handling framework and sets up the resource layer locking strategy for operations like MSI-X configuration.
Quoted 4 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dispatch.c +0
-0
[ ... ]
Quoted 11 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dispatch.c +11
-0+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;
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dispatch.c line 197
Quoted 10 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dispatch.c +10
-0+int err =NBL_CHAN_RESP_OK ; +int copy_len; +int ret; + + copy_len = data_len <sizeof (param) ? data_len :sizeof (param); +memcpy (¶m, data, copy_len); + 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));
[Severity: High]
This is a pre-existing issue, but does exposing this configuration via channel messages allow a VM to trigger an unbounded memory leak?
Looking at the underlying nbl_res_intr_configure_msix_map() implementation, it allocates device-managed memory for the MSI-X map table:
nbl_res_intr_configure_msix_map() {
...
msix_map_table->base_addr = dmam_alloc_coherent(dev,
msix_map_table->size,
&msix_map_table->dma,
GFP_KERNEL);
...
}However, prior to this allocation, it appears to call nbl_res_intr_destroy_msix_map(), which merely clears the pointer without freeing the previously allocated memory:
nbl_res_intr_destroy_msix_map() {
...
intr_mgt->func_intr_res[func_id].msix_map_table.base_addr = NULL;
...
}Since this patch wires up nbl_disp_chan_configure_msix_map_resp() to process NBL_CHAN_MSG_CONFIGURE_MSIX_MAP channel messages from untrusted VMs, could a compromised VM repeatedly send these messages to exhaust host memory and DMA mapping space?
Quoted 11 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dispatch.c +11
-0+if (ret) + err =NBL_CHAN_RESP_ERR ; + +NBL_CHAN_ACK (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 ); +}
Signature · 1 line
This is an AI-generated review.
illusion.wang
maintainerPATCH v20 9/10 net/nebula-matrix: add common/ctrl dev init/remove operation
In reply to illusion.wangFrom: illusion wang <[email protected]>
This patch adds nbl_dev_setup_common_dev and nbl_dev_setup_ctrl_dev helpers, plus matching teardown paths, and wires them into nbl_dev_init / nbl_dev_remove.
Common Device Setup: nbl_dev_setup_common_dev configures mailbox queues, registers cleanup tasks, and initializes MSI-X interrupt counters. It also populates the parent nbl_common_info struct (vsi_id, eth_num, eth_id, logic_eth_id) via the dispatch ops.
Control Device Setup (optional): nbl_dev_setup_ctrl_dev initializes the chip and configures the mailbox channel qinfo.
--- .../nebula-matrix/nbl/nbl_core/nbl_dev.c | 170 ++++++++++++++++++ .../nebula-matrix/nbl/nbl_core/nbl_dev.h | 31 ++++ 2 files changed, 201 insertions(+)
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.c +170 -0
@@ -6,6 +6,158 @@#include <linux/pci.h> #include "nbl_dev.h" +static void nbl_dev_init_msix_cnt (struct nbl_dev_mgt *dev_mgt) +{ +struct nbl_dev_common *dev_common = dev_mgt->common_dev; +struct nbl_msix_info *msix_info = &dev_common->msix_info; + + msix_info->serv_info[NBL_MSIX_MAILBOX_TYPE ].num =1 ; +} + +/* ---------- Channel config ---------- */ +static void nbl_dev_setup_chan_qinfo (struct nbl_dev_mgt *dev_mgt,u8 chan_type) +{ +struct nbl_channel_ops *chan_ops = dev_mgt->chan_ops_tbl->ops; +struct nbl_channel_mgt *priv = dev_mgt->chan_ops_tbl->priv; + +if (!chan_ops->check_queue_exist (priv, chan_type)) +return ; + + chan_ops->cfg_chan_qinfo_map_table (priv); +} + +static int nbl_dev_setup_chan_queue (struct nbl_dev_mgt *dev_mgt,u8 chan_type) +{ +struct nbl_channel_ops *chan_ops = dev_mgt->chan_ops_tbl->ops; +struct nbl_channel_mgt *priv = dev_mgt->chan_ops_tbl->priv; +int ret =0 ; + +if (chan_ops->check_queue_exist (priv, chan_type)) + ret = chan_ops->setup_queue (priv, chan_type); + +return ret; +} + +static int nbl_dev_remove_chan_queue (struct nbl_dev_mgt *dev_mgt,u8 chan_type) +{ +struct nbl_channel_ops *chan_ops = dev_mgt->chan_ops_tbl->ops; +struct nbl_channel_mgt *priv = dev_mgt->chan_ops_tbl->priv; +int ret =0 ; + +if (chan_ops->check_queue_exist (priv, chan_type)) + ret = chan_ops->teardown_queue (priv, chan_type); + +return ret; +} + +static void nbl_dev_register_chan_task (struct nbl_dev_mgt *dev_mgt, +u8 chan_type,struct work_struct *task) +{ +struct nbl_channel_ops *chan_ops = dev_mgt->chan_ops_tbl->ops; + +if (chan_ops->check_queue_exist (dev_mgt->chan_ops_tbl->priv, chan_type)) + chan_ops->register_chan_task (dev_mgt->chan_ops_tbl->priv, + chan_type, task); +} + +/* ---------- Tasks config ---------- */ +static void nbl_dev_clean_mailbox_task (struct work_struct *work) +{ +struct nbl_dev_common *common_dev = + container_of(work, struct nbl_dev_common, clean_mbx_task); +struct nbl_dev_mgt *dev_mgt = common_dev->dev_mgt; +struct nbl_channel_ops *chan_ops = dev_mgt->chan_ops_tbl->ops; + + chan_ops->clean_queue_subtask (dev_mgt->chan_ops_tbl->priv, +NBL_CHAN_TYPE_MAILBOX ); +} + +/* ---------- Dev init process ---------- */ +static int nbl_dev_setup_common_dev (struct nbl_adapter *adapter) +{ +struct nbl_dev_mgt *dev_mgt = adapter->core.dev_mgt; +struct nbl_dispatch_ops *disp_ops = dev_mgt->disp_ops_tbl->ops; +struct nbl_dispatch_mgt *priv = dev_mgt->disp_ops_tbl->priv; +struct nbl_common_info *common = dev_mgt->common; +struct nbl_dev_common *common_dev; +int ret; + + common_dev =devm_kzalloc (&adapter->pdev->dev,sizeof (*common_dev), +GFP_KERNEL ); +if (!common_dev) +return -ENOMEM ; + common_dev->dev_mgt = dev_mgt; + + ret =nbl_dev_setup_chan_queue (dev_mgt,NBL_CHAN_TYPE_MAILBOX ); +if (ret) +return ret; + +INIT_WORK (&common_dev->clean_mbx_task, nbl_dev_clean_mailbox_task); + ret = disp_ops->get_vsi_id (priv,NBL_VSI_DATA , &common->vsi_id); +if (ret) + goto err_cleanup; + ret = disp_ops->get_eth_id (priv, common->vsi_id, &common->eth_num, + &common->eth_id, &common->logic_eth_id); +if (ret) + goto err_cleanup; +nbl_dev_register_chan_task (dev_mgt,NBL_CHAN_TYPE_MAILBOX , + &common_dev->clean_mbx_task); + + dev_mgt->common_dev = common_dev; +nbl_dev_init_msix_cnt (dev_mgt); + +return 0 ; +err_cleanup: +nbl_dev_remove_chan_queue (dev_mgt,NBL_CHAN_TYPE_MAILBOX ); +return ret; +} + +static void nbl_dev_remove_common_dev (struct nbl_adapter *adapter) +{ +struct nbl_dev_mgt *dev_mgt = adapter->core.dev_mgt; +struct nbl_dev_common *common_dev = dev_mgt->common_dev; + +if (!common_dev) +return ; +nbl_dev_register_chan_task (dev_mgt,NBL_CHAN_TYPE_MAILBOX ,NULL ); +cancel_work_sync (&common_dev->clean_mbx_task); +nbl_dev_remove_chan_queue (dev_mgt,NBL_CHAN_TYPE_MAILBOX ); +} + +static int nbl_dev_setup_ctrl_dev (struct nbl_adapter *adapter) +{ +struct nbl_dev_mgt *dev_mgt = adapter->core.dev_mgt; +struct nbl_dispatch_ops *disp_ops = dev_mgt->disp_ops_tbl->ops; +int ret; + + ret = disp_ops->init_chip_module (dev_mgt->disp_ops_tbl->priv); +if (ret) +return ret; + +nbl_dev_setup_chan_qinfo (dev_mgt,NBL_CHAN_TYPE_MAILBOX ); + +return 0 ; +} + +/* +* This is intentional. The qinfo registers are managed by the chip +* firmware, not by the driver. Setting driver status to false is the +* designed teardown mechanism — it notifies the firmware, which then +* performs its own cleanup of all per-PF state including the qinfo +* registers. +* An inverse helper would duplicate work that the firmware already +* does, and would add error-path complexity for no benefit. We keep +* the deinit path minimal and rely on the firmware cleanup for +* correctness, including in abnormal reset scenarios. +*/ +static void nbl_dev_remove_ctrl_dev (struct nbl_adapter *adapter) +{ +struct nbl_dev_mgt *dev_mgt = adapter->core.dev_mgt; +struct nbl_dispatch_ops *disp_ops = dev_mgt->disp_ops_tbl->ops; + + disp_ops->deinit_chip_module (dev_mgt->disp_ops_tbl->priv); +} +static struct nbl_dev_mgt *nbl_dev_setup_dev_mgt (struct nbl_common_info *common) {struct nbl_dev_mgt *dev_mgt;
@@ -38,11 +190,29 @@ int nbl_dev_init(struct nbl_adapter *adapter) dev_mgt->chan_ops_tbl = chan_ops_tbl; adapter->core.dev_mgt = dev_mgt; + ret =nbl_dev_setup_common_dev (adapter); +if (ret) +return ret; + +if (common->has_ctrl) { + ret =nbl_dev_setup_ctrl_dev (adapter); +if (ret) + goto setup_ctrl_dev_fail; + } +return 0 ; +setup_ctrl_dev_fail: +nbl_dev_remove_common_dev (adapter); +return ret; }void nbl_dev_remove (struct nbl_adapter *adapter) { +struct nbl_common_info *common = &adapter->common; + +if (common->has_ctrl) +nbl_dev_remove_ctrl_dev (adapter); +nbl_dev_remove_common_dev (adapter); }/* ---------- Dev start process ---------- */
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.h +31 -0
@@ -18,10 +18,41 @@#include "../nbl_include/nbl_def_common.h" #include "../nbl_core.h" +#define NBL_STRING_NAME_LEN 32 + +enum nbl_msix_serv_type { +/* virtio_dev has a config vector_id, and the vector_id need is 0 */ +NBL_MSIX_VIRTIO_TYPE =0 , +NBL_MSIX_NET_TYPE , +NBL_MSIX_MAILBOX_TYPE , +NBL_MSIX_TYPE_MAX +}; + +struct nbl_msix_serv_info { +char irq_name[NBL_STRING_NAME_LEN ]; +u16 num; +u16 base_vector_id; +/* true: hw report msix, hw need to mask actively */ +bool hw_self_mask_en; +}; + +struct nbl_msix_info { +struct nbl_msix_serv_info serv_info[NBL_MSIX_TYPE_MAX ]; +}; + +struct nbl_dev_common { +struct nbl_dev_mgt *dev_mgt; +struct nbl_msix_info msix_info; +char mailbox_name[NBL_STRING_NAME_LEN ]; +/* for ctrl-dev/net-dev mailbox recv msg */ +struct work_struct clean_mbx_task; +}; +struct nbl_dev_mgt {struct nbl_common_info *common;struct nbl_dispatch_ops_tbl *disp_ops_tbl;struct nbl_channel_ops_tbl *chan_ops_tbl; +struct nbl_dev_common *common_dev; };#endif
Signature · 1 line
2.47.3
Paolo Abeni
maintainerRe: [PATCH v20 net-next 09/10] net/nebula-matrix: add common/ctrl dev init/remove operation
From: AI Reviewer <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://sashiko.dev/
---net/nebula-matrix: add common/ctrl dev init/remove operation
This patch adds nbl_dev_setup_common_dev and nbl_dev_setup_ctrl_dev helpers, plus matching teardown paths, and wires them into nbl_dev_init and nbl_dev_remove.
Quoted 4 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.c +0
-0
[ ... ]
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.c int nbl_dev_init(struct nbl_adapter *adapter) · line 192
Quoted 4 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.c +0
-0@@ -38,11 +190,29 @@ int nbl_dev_init(struct nbl_adapter *adapter) dev_mgt->chan_ops_tbl = chan_ops_tbl; adapter->core.dev_mgt = dev_mgt;
[Severity: High]
Does this initialize the common device components before the chip is actually initialized?
If nbl_dev_setup_common_dev() configures queues (which accesses hardware) before the hardware is brought up via nbl_dev_setup_ctrl_dev(), could writing to those queue registers cause hardware faults?
Quoted 8 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.c +8
-0+ ret =nbl_dev_setup_common_dev (adapter); +if (ret) +return ret; + +if (common->has_ctrl) { + ret =nbl_dev_setup_ctrl_dev (adapter); +if (ret) + goto setup_ctrl_dev_fail;
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.c int nbl_dev_init(struct nbl_adapter *adapter)
Quoted 10 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.c +4
-0+ }return 0 ; +setup_ctrl_dev_fail: +nbl_dev_remove_common_dev (adapter); +return ret; }void nbl_dev_remove (struct nbl_adapter *adapter) {
[Severity: High]
Are the teardown operations in the correct order here?
The comment in nbl_dev_remove_ctrl_dev() mentions that setting the driver status to false triggers the firmware to clean up the qinfo registers.
If nbl_dev_remove_ctrl_dev() deinitializes the chip first, will the subsequent call to nbl_dev_remove_common_dev() attempt to tear down the queues by writing directly to those deactivated qinfo registers?
Could this lead to PCIe master aborts or panics during driver unbind?
Quoted 8 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.c +5
-0+struct nbl_common_info *common = &adapter->common; + +if (common->has_ctrl) +nbl_dev_remove_ctrl_dev (adapter); +nbl_dev_remove_common_dev (adapter); }/* ---------- Dev start process ---------- */
Signature · 1 line
This is an AI-generated review.
illusion.wang
maintainerPATCH v20 10/10 net/nebula-matrix: add common dev start/stop operation
In reply to illusion.wangFrom: illusion wang <[email protected]>
This patch wires up nbl_dev_start() and nbl_dev_stop() to configure the MSI-X map, allocate vectors, and request/enable the mailbox IRQ. It also adds a workqueue in nbl_dev_init() for the new IRQ handler.
--- .../nebula-matrix/nbl/nbl_common/nbl_common.c | 24 ++ .../nebula-matrix/nbl/nbl_core/nbl_dev.c | 256 +++++++++++++++++- .../nbl/nbl_include/nbl_def_common.h | 6 + 3 files changed, 284 insertions(+), 2 deletions(-)
drivers/net/ethernet/nebula-matrix/nbl/nbl_common/nbl_common.c +24 -0
@@ -6,6 +6,30 @@#include <linux/device.h> #include "nbl_common.h" +void nbl_common_queue_work (struct nbl_common_info *common, +struct work_struct *task) +{ +queue_work (common->wq, task); +} + +void nbl_common_destroy_wq (struct nbl_common_info *common) +{ +destroy_workqueue (common->wq); +} + +int nbl_common_create_wq (struct nbl_common_info *common) +{ + common->wq =alloc_workqueue ("nbl_wq" ,WQ_UNBOUND ,0 ); +if (!common->wq) { +pr_err ("Failed to create workqueue nbl_wq\n" ); + goto alloc_wq_failed; + } + +return 0 ; +alloc_wq_failed: +return -ENOMEM ; +} +u32 nbl_common_pf_id_subtraction_mgtpf_id (struct nbl_common_info *common,u32 pf_id) {
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.c +254 -2
302 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_common.h +6 -0
@@ -29,6 +29,7 @@ struct nbl_hash_tbl_mgt; })struct nbl_common_info { +struct workqueue_struct *wq;struct pci_dev *pdev;struct device *dev;u32 msg_enable;
@@ -61,6 +62,11 @@ struct nbl_hash_tbl_del_key {void (*action_func)(void *priv,void *key,void *data); }; +void nbl_common_queue_work (struct nbl_common_info *common, +struct work_struct *task); + +void nbl_common_destroy_wq (struct nbl_common_info *common); +int nbl_common_create_wq (struct nbl_common_info *common);u32 nbl_common_pf_id_subtraction_mgtpf_id (struct nbl_common_info *common,u32 pf_id);
Signature · 1 line
2.47.3
Paolo Abeni
maintainerRe: [PATCH v20 net-next 10/10] net/nebula-matrix: add common dev start/stop operation
From: AI Reviewer <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://sashiko.dev/
---net/nebula-matrix: add common dev start/stop operation
This patch wires up nbl_dev_start() and nbl_dev_stop() to configure the MSI-X map, allocate vectors, and request/enable the mailbox IRQ. It also adds a workqueue in nbl_dev_init() for the new IRQ handler.
(Note: Due to recitation restrictions, the standard inline diff quoting format has been replaced with a free-form summary of the findings below.)
[Severity: High]
In drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.c, looking at nbl_dev_configure_msix_map(), the loop that calculates msix_not_net_num explicitly starts at NBL_MSIX_MAILBOX_TYPE.
Does this calculation omit NBL_MSIX_VIRTIO_TYPE entirely?
If the virtio type is skipped, will the hardware map table lack sufficient entries, potentially leading to memory corruption or an inability to map VIRTIO interrupts since disp_ops->configure_msix_map() is called with an undersized sum?
[Severity: High]
This is a pre-existing issue, but it is exposed by wiring up the new dynamic start and stop paths in this patch.
In drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_interrupt.c, looking at nbl_res_intr_destroy_msix_map(), it sets msix_map_table->base_addr and the interrupts pointers to NULL, but does not appear to free the device-managed allocations created by dmam_alloc_coherent() and devm_kcalloc().
When nbl_dev_start() subsequently calls nbl_res_intr_configure_msix_map(), it will allocate entirely new buffers because the old pointers were lost. Could this introduce a persistent memory and DMA space leak on every start/stop cycle, such as when bringing the network interface up and down?
Signature · 1 line
This is an AI-generated review.