nbl driver for Nebulamatrix NICs
Subsystems (5)
illusion.wang
maintainerv3 cover nbl driver for Nebulamatrix NICs
The patch series add the nbl driver, which will support nebula-matrix 18100 and 18110 series of network cards.
This submission is the first phase. which only supports the PF-based Ethernet transmit and receive functionality. Once this is merged. will submit addition patches to implement support for other features. such as ethtool support, flow management, adminq msg, vf support, debugfs support and etc.
chanages 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 (15):
net/nebula-matrix: add minimum nbl build framework net/nebula-matrix: add our driver architecture net/nebula-matrix: add machine-generated headers and chip definitions net/nebula-matrix: add channel layer implementation and the
corresponding hw interfaces
net/nebula-matrix: add resource layer common part implementation net/nebula-matrix: add intr resource implementation net/nebula-matrix: add queue resource implementation net/nebula-matrix: add vsi resource implementation net/nebula-matrix: add txrx resource interfaces and tx func net/nebula-matrix: add txrx interrupt handling logic net/nebula-matrix: add Dispatch layer implementation net/nebula-matrix: add common/ctrl dev init/reinit operation net/nebula-matrix: add net dev init/reinit operation net/nebula-matrix: add common dev start/stop operation net/nebula-matrix: add net dev start/stop operation
.../ethernet/nebula-matrix/m18100.rst | 47 + MAINTAINERS | 10 + drivers/net/ethernet/Kconfig | 1 + drivers/net/ethernet/Makefile | 1 + drivers/net/ethernet/nebula-matrix/Kconfig | 37 + drivers/net/ethernet/nebula-matrix/Makefile | 6 + .../net/ethernet/nebula-matrix/nbl/Makefile | 26 + .../nbl/nbl_channel/nbl_channel.c | 1289 ++++++ .../nbl/nbl_channel/nbl_channel.h | 177 + .../nebula-matrix/nbl/nbl_common/nbl_common.c | 302 ++ .../nebula-matrix/nbl/nbl_common/nbl_common.h | 29 + .../net/ethernet/nebula-matrix/nbl/nbl_core.h | 130 + .../nebula-matrix/nbl/nbl_core/nbl_dev.c | 1369 ++++++ .../nebula-matrix/nbl/nbl_core/nbl_dev.h | 131 + .../nebula-matrix/nbl/nbl_core/nbl_dispatch.c | 1977 +++++++++ .../nebula-matrix/nbl/nbl_core/nbl_dispatch.h | 76 + .../nebula-matrix/nbl/nbl_core/nbl_service.c | 1256 ++++++ .../nebula-matrix/nbl/nbl_core/nbl_service.h | 132 + .../nebula-matrix/nbl/nbl_hw/nbl_hw.h | 172 + .../nbl_hw/nbl_hw_leonis/base/nbl_datapath.h | 11 + .../nbl_hw_leonis/base/nbl_datapath_dped.h | 2152 +++++++++ .../nbl_hw_leonis/base/nbl_datapath_dstore.h | 929 ++++ .../nbl_hw_leonis/base/nbl_datapath_ucar.h | 414 ++ .../nbl/nbl_hw/nbl_hw_leonis/base/nbl_ppe.h | 10 + .../nbl_hw/nbl_hw_leonis/base/nbl_ppe_epro.h | 665 +++ .../nbl_hw/nbl_hw_leonis/base/nbl_ppe_ipro.h | 1397 ++++++ .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c | 1882 ++++++++ .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.h | 1142 +++++ .../nbl_hw/nbl_hw_leonis/nbl_hw_leonis_regs.c | 3903 +++++++++++++++++ .../nbl_hw/nbl_hw_leonis/nbl_hw_leonis_regs.h | 12 + .../nbl_hw/nbl_hw_leonis/nbl_queue_leonis.c | 1129 +++++ .../nbl_hw/nbl_hw_leonis/nbl_queue_leonis.h | 15 + .../nbl_hw_leonis/nbl_resource_leonis.c | 582 +++ .../nbl_hw_leonis/nbl_resource_leonis.h | 25 + .../nebula-matrix/nbl/nbl_hw/nbl_hw_reg.h | 139 + .../nebula-matrix/nbl/nbl_hw/nbl_interrupt.c | 314 ++ .../nebula-matrix/nbl/nbl_hw/nbl_interrupt.h | 13 + .../nebula-matrix/nbl/nbl_hw/nbl_queue.c | 60 + .../nebula-matrix/nbl/nbl_hw/nbl_queue.h | 11 + .../nebula-matrix/nbl/nbl_hw/nbl_resource.c | 299 ++ .../nebula-matrix/nbl/nbl_hw/nbl_resource.h | 439 ++ .../nebula-matrix/nbl/nbl_hw/nbl_txrx.c | 1984 +++++++++ .../nebula-matrix/nbl/nbl_hw/nbl_txrx.h | 184 + .../nebula-matrix/nbl/nbl_hw/nbl_vsi.c | 120 + .../nebula-matrix/nbl/nbl_hw/nbl_vsi.h | 12 + .../nbl/nbl_include/nbl_def_channel.h | 481 ++ .../nbl/nbl_include/nbl_def_common.h | 165 + .../nbl/nbl_include/nbl_def_dev.h | 28 + .../nbl/nbl_include/nbl_def_dispatch.h | 92 + .../nbl/nbl_include/nbl_def_hw.h | 105 + .../nbl/nbl_include/nbl_def_resource.h | 93 + .../nbl/nbl_include/nbl_def_service.h | 80 + .../nbl/nbl_include/nbl_include.h | 326 ++ .../nbl/nbl_include/nbl_product_base.h | 20 + .../net/ethernet/nebula-matrix/nbl/nbl_main.c | 352 ++ 55 files changed, 26753 insertions(+) create mode 100644 Documentation/networking/device_drivers/ethernet/nebula-matrix/m18100.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_core/nbl_service.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_service.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/base/nbl_datapath.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/base/nbl_datapath_dped.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/base/nbl_datapath_dstore.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/base/nbl_datapath_ucar.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/base/nbl_ppe.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/base/nbl_ppe_epro.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/base/nbl_ppe_ipro.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_hw_leonis_regs.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis_regs.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_queue_leonis.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_queue_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_queue.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_queue.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_txrx.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_txrx.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_def_service.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 v3 1/15 net/nebula-matrix: add minimum nbl build framework
1.Add nbl min build infrastructure for nbl driver.
2.Implemented the framework of pci device initialization.
--- .../ethernet/nebula-matrix/m18100.rst | 47 ++++++++ MAINTAINERS | 10 ++ drivers/net/ethernet/Kconfig | 1 + drivers/net/ethernet/Makefile | 1 + drivers/net/ethernet/nebula-matrix/Kconfig | 37 ++++++ drivers/net/ethernet/nebula-matrix/Makefile | 6 + .../net/ethernet/nebula-matrix/nbl/Makefile | 11 ++ .../net/ethernet/nebula-matrix/nbl/nbl_core.h | 27 +++++ .../nbl/nbl_include/nbl_include.h | 23 ++++ .../net/ethernet/nebula-matrix/nbl/nbl_main.c | 113 ++++++++++++++++++ 10 files changed, 276 insertions(+) create mode 100644 Documentation/networking/device_drivers/ethernet/nebula-matrix/m18100.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/nebula-matrix/m18100.rst new file +47 -0
@@ -0,0 +1,47 @@ +.. SPDX-License-Identifier: GPL-2.0 + +============================================================ +Linux Base Driver for Nebula-matrix M18100-NIC family +============================================================ + +Overview: +========= +M18100-NIC is a series of network interface card for the Data Center Area. + +The driver supports link-speed 100GbE/25GE/10GE. + +M18100-NIC devices support MSI-X interrupt vector for each Tx/Rx queue and +interrupt moderation. + +M18100-NIC devices support also various offload features such as checksum offload, +Receive-Side Scaling(RSS). + +Supported PCI vendor ID/device IDs: +=================================== + +1f0f:3403 - M18110 Family PF +1f0f:3404 - M18110 Lx Family PF +1f0f:3405 - M18110 Family BASE-T PF +1f0f:3406 - M18110 Lx Family BASE-T PF +1f0f:3407 - M18110 Family OCP PF +1f0f:3408 - M18110 Lx Family OCP PF +1f0f:3409 - M18110 Family BASE-T OCP PF +1f0f:340a - M18110 Lx Family BASE-T OCP PF +1f0f:340b - M18100 Family PF +1f0f:340c - M18100 Lx Family PF +1f0f:340d - M18100 Family BASE-T PF +1f0f:340e - M18100 Lx Family BASE-T PF +1f0f:340f - M18100 Family OCP PF +1f0f:3410 - M18100 Lx Family OCP PF +1f0f:3411 - M18100 Family BASE-T OCP PF +1f0f:3412 - M18100 Lx Family BASE-T OCP PF + +Support +======= + +For more information about M18100-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
@@ -18018,6 +18018,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: llusion.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
@@ -131,6 +131,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/neterion/Kconfig" source "drivers/net/ethernet/netronome/Kconfig" source "drivers/net/ethernet/8390/Kconfig"
drivers/net/ethernet/Makefile +1 -0
@@ -68,6 +68,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_NETERION) += neterion/ obj-$(CONFIG_NET_VENDOR_NETRONOME) += netronome/ obj-$(CONFIG_NET_VENDOR_NI) += ni/
drivers/net/ethernet/nebula-matrix/Kconfig new file +37 -0
@@ -0,0 +1,37 @@ +# 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_CORE + tristate "Nebula-matrix Ethernet Controller m18100 Family support" + depends on 64BIT && PCI + default m + select PAGE_POOL + help + This driver supports Nebula-matrix Ethernet Controller m18100 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/m18100.rst>. + + To compile this driver as a module, choose M here. The module + will be called nbl_core. + +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_CORE) += nbl/
drivers/net/ethernet/nebula-matrix/nbl/Makefile new file +11 -0
@@ -0,0 +1,11 @@ +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2025 Nebula Matrix Limited. +# Author: + +obj-$(CONFIG_NBL_CORE) := nbl_core.o + +nbl_core-objs += nbl_main.o + +# Provide include files +ccflags-y += -I$(srctree)/drivers/net/ethernet/nebula-matrix/nbl/nbl_include/ +ccflags-y += -I$(srctree)/drivers/net/ethernet/nebula-matrix/nbl/
drivers/net/ethernet/nebula-matrix/nbl/nbl_core.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0*/ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +* Author: +*/ + +#ifndef _NBL_CORE_H_ +#define _NBL_CORE_H_ + +#include <linux/pci.h> +#include "nbl_include.h" +#define NBL_CAP_TEST_BIT (val, loc) (((val) >> (loc)) & 0x1) + +#define NBL_CAP_IS_CTRL (val) NBL_CAP_TEST_BIT(val, NBL_CAP_HAS_CTRL_BIT) +#define NBL_CAP_IS_NET (val) NBL_CAP_TEST_BIT(val, NBL_CAP_HAS_NET_BIT) +#define NBL_CAP_IS_NIC (val) NBL_CAP_TEST_BIT(val, NBL_CAP_IS_NIC_BIT) +#define NBL_CAP_IS_OCP (val) NBL_CAP_TEST_BIT(val, NBL_CAP_IS_OCP_BIT) +#define NBL_CAP_IS_LEONIS (val) NBL_CAP_TEST_BIT(val, NBL_CAP_IS_LEONIS_BIT) + +enum { +NBL_CAP_HAS_CTRL_BIT =0 , +NBL_CAP_HAS_NET_BIT , +NBL_CAP_IS_NIC_BIT , +NBL_CAP_IS_LEONIS_BIT , +NBL_CAP_IS_OCP_BIT , +}; +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_include.h new file +23 -0
@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0*/ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +* Author: +*/ + +#ifndef _NBL_INCLUDE_H_ +#define _NBL_INCLUDE_H_ + +#include <linux/types.h> + +/* ------ Basic definitions ------- */ +#define NBL_DRIVER_NAME "nbl_core" + +struct nbl_func_caps { +u32 has_ctrl:1 ; +u32 has_net:1 ; +u32 is_nic:1 ; +u32 is_ocp:1 ; +u32 rsv:28 ; +}; + +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c new file +113 -0
113 lines not on this page · raw message
Signature · 1 line
2.47.3
Randy Dunlap
reviewerRe: [PATCH v3 net-next 01/15] net/nebula-matrix: add minimum nbl build framework
Hi--
Quoted 33 lines · illusion.wang
drivers/net/ethernet/nebula-matrix/Kconfig new file +27
-0@@ -0,0 +1,37 @@ +# 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_CORE + tristate "Nebula-matrix Ethernet Controller m18100 Family support" + depends on 64BIT && PCI + default m + select PAGE_POOL + help + This driver supports Nebula-matrix Ethernet Controller m18100 Family of + devices. For more information about this product, go to the product + description with smart NIC:
drivers/net/ethernet/nebula-matrix/Kconfig line 37
Quoted 10 lines
drivers/net/ethernet/nebula-matrix/Kconfig new file +10
-0+ + <http://www.nebula-matrix.com> + + More specific information on configuring the driver is in + <file:Documentation/networking/device_drivers/ethernet/nebula-matrix/m18100.rst>. + + To compile this driver as a module, choose M here. The module + will be called nbl_core. + +endif # NET_VENDOR_NEBULA_MATRIX
There are lots of spaces used here for indentation.
Please see Documentation/process/coding-style.rst, section
10) Kconfig configuration files, for the correct indentation style for Kconfig files.
Signature · 1 line
~Randy
Re: [PATCH v3 net-next 01/15] net/nebula-matrix: add minimum nbl build framework
In reply to illusion.wangdrivers/net/ethernet/nebula-matrix/Kconfig line 27
Quoted 9 lines
drivers/net/ethernet/nebula-matrix/Kconfig new file +9
-0+config NBL_CORE + tristate "Nebula-matrix Ethernet Controller m18100 Family support" + depends on 64BIT && PCI + default m + select PAGE_POOL + help + This driver supports Nebula-matrix Ethernet Controller m18100 Family of + devices. For more information about this product, go to the product + description with smart NIC:
_CORE is a bit unusual for a driver. CORE is generally a library which is shared by a number of drivers. It does not have a tristate string, it is just selected by the drivers which need it.
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c line 15
Quoted 6 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c new file +6
-0+static int nbl_probe (struct pci_dev *pdev, +const struct pci_device_id __always_unused *id) +{ +struct device *dev = &pdev->dev; + +dev_dbg (dev,"nbl probe ok!\n" );
Please don't have pointless debug messages. If your driver does not even probe, you should not be submitting it.
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c line 24
Quoted 9 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c new file +9
-0+return 0 ; +} + +static void nbl_remove (struct pci_dev *pdev) +{ +dev_dbg (&pdev->dev,"nbl remove OK!\n" ); +} + +#define NBL_VENDOR_ID (0x1F0F)
Andrew
---
pw-bot: cr
Illusion Wang
maintainer回复:[PATCH v3 net-next 01/15] net/nebula-matrix: add minimum nbl build framework
Quoted 5 lines
_COREis a bit unusual for a driver. CORE is generally a library which is shared by a number of drivers. It does not have a tristate string, it is just selected by the drivers which need it.
Thank you for your feedback on the NBL_CORE configuration option. We appreciate your guidance on adhering to Linux kernel naming conventions.
Why NBL_CORE?
The driver is designed to support two distinct functionalities for the Nebula-matrix m18100 Ethernet controller:
1.Standard Ethernet/NIC functionality (via the main driver module). 2.Auxiliary device (auxiliary driver) for RDMA (exposed through auxiliary_device). 4.MDEV-based SR-IOV/VF emulation (for native device splitting).
Since shared logic (e.g., PCIe resource management, MMIO access, interrupt handling, and common hardware abstractions) is required across both the main driver and auxiliary/RDMA driver, we opted for a _CORE suffix to indicate:
Reusability: The module provides foundational code used by multiple sub-drivers (main NIC + auxiliary RDMA).
Modularity: Future extensions (e.g., additional auxiliary devices) can reuse the same core infrastructure.
So it serves a similar purpose to mlx5_core (Mellanox), where a central module handles hardware-specific operations for multiple sub-drivers.
illusion.wang
------------------------------------------------------------------
发件人:Andrew Lunn <[email protected]>
发送时间:2026年1月23日(周五) 11:27
收件人:Illusion Wang<[email protected]>; y<[email protected]>
抄 送:Dimon<[email protected]>; Alvin<[email protected]>; Sam<[email protected]>; netdev<[email protected]>; "andrew+netdev"<[email protected]>; corbet<[email protected]>; kuba<[email protected]>; "linux-doc"<[email protected]>; lorenzo<[email protected]>; pabeni<[email protected]>; horms<[email protected]>; "vadim.fedorenko"<[email protected]>; "lukas.bulwahn"<[email protected]>; hawk<[email protected]>; ast<[email protected]>; bpf<[email protected]>; sdf<[email protected]>; daniel<[email protected]>; "john.fastabend"<[email protected]>; edumazet<[email protected]>; open list<[email protected]> 主 题:Re: [PATCH v3 net-next 01/15] net/nebula-matrix: add minimum nbl build framework
Quoted 9 lines
+config
NBL_CORE
+ tristate "Nebula-matrix Ethernet Controller m18100 Family support" + depends on 64BIT && PCI
+ default m
+ selectPAGE_POOL
+ help
+ This driver supports Nebula-matrix Ethernet Controller m18100 Family of + devices. For more information about this product, go to the product + description with smart NIC:
_CORE is a bit unusual for a driver. CORE is generally a library which is shared by a number of drivers. It does not have a tristate string, it is just selected by the drivers which need it.
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c line 15
Quoted 6 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c new file +6
-0+static int nbl_probe (struct pci_dev *pdev, + const struct pci_device_id __always_unused *id) +{ +struct device *dev = &pdev->dev; + +dev_dbg (dev,"nbl probe ok!\n" );
Please don't have pointless debug messages. If your driver does not even probe, you should not be submitting it.
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c line 24
Quoted 9 lines
+ return 0;
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c new file +8
-0+} + +static void nbl_remove (struct pci_dev *pdev) +{ +dev_dbg (&pdev->dev,"nbl remove OK!\n" ); +} + +#define NBL_VENDOR_ID (0x1F0F)
Andrew
---
pw-bot: cr
A message that is not in the archive (sent off-list or not yet received): ad0a6f0f-3ce3-4f38-b27d-2f121511d6e3.illusion.wang@nebula-matrix.com
Re: 回复:[PATCH v3 net-next 01/15] net/nebula-matrix: add minimum nbl build framework
Quoted 12 lines · Illusion Wang
Quoted 4 lines
_COREis a bit unusual for a driver. CORE is generally a library which is shared by a number of drivers. It does not have a tristate string, it is just selected by the drivers which need it.Thank you for your feedback on the
NBL_COREconfiguration option. We appreciate your guidance on adhering to Linux kernel naming conventions.Why
NBL_CORE?
The driver is designed to support two distinct functionalities for the Nebula-matrix m18100 Ethernet controller:
Quoted 7 lines
1.Standard Ethernet/NIC functionality (via the main driver module). 2.Auxiliary device (auxiliary driver) for RDMA (exposed through
auxiliary_device).
4.MDEV-based SR-IOV/VF emulation (for native device splitting). Since shared logic (e.g., PCIe resource management, MMIO access, interrupt handling, and common hardware abstractions) is required across both the main driver and auxiliary/RDMA driver, we opted for a_COREsuffix to indicate:
You can split this two ways:
A true core, which does not provide any devices, just core functions to access the hardware. Then layered on top if this you have kernel modules with provide Ethernet, RDMA, MDEV etc. Such kernel modules would then depend on the core, using Kconfig primitives. And the core itself would not have a tri-state string, since on its own it is useless.
Or
If the core always provides Ethernet, call it an Ethernet driver, not core. The other kernel modules would then depends on having the Ethernet driver, using Kconfig primitives.
This all about naming, not architecture. Splitting it up into multiple kernel modules is good, but your naming and descriptions of what these modules do matters.
Andrew
Sam
maintainer回复:回复:[PATCH v3 net-next 01/15] net/nebula-matrix: add minimum nbl build framework
Thank you for your feedback. I understand what you mean.The reasons why we cannot change the module name now are as follows:
Our driver has already been integrated into multiple communities, and the module name is nbl_core. Many customers have already deployed it. If we change the name, there will be a critical problem of conflict between the two modules during subsequent online driver upgrades.
PS: Our card's functionality is comparable to Mellanox CX, and the design
of nbl_core was initially based on their design principles.
------------------------------------------------------------------
发件人:Andrew Lunn <[email protected]>
发送时间:2026年1月29日(周四) 21:18
收件人:Illusion Wang<[email protected]>
抄 送:y<[email protected]>; Dimon<[email protected]>; Alvin<[email protected]>; Sam<[email protected]>; netdev<[email protected]>; "andrew+netdev"<[email protected]>; corbet<[email protected]>; kuba<[email protected]>; "linux-doc"<[email protected]>; lorenzo<[email protected]>; pabeni<[email protected]>; horms<[email protected]>; "vadim.fedorenko"<[email protected]>; "lukas.bulwahn"<[email protected]>; hawk<[email protected]>; ast<[email protected]>; bpf<[email protected]>; sdf<[email protected]>; daniel<[email protected]>; "john.fastabend"<[email protected]>; edumazet<[email protected]>; open list<[email protected]> 主 题:Re: 回复:[PATCH v3 net-next 01/15] net/nebula-matrix: add minimum nbl build framework
Quoted 12 lines · Illusion Wang
Quoted 4 lines
_COREis a bit unusual for a driver. CORE is generally a library which is shared by a number of drivers. It does not have a tristate string, it is just selected by the drivers which need it.Thank you for your feedback on the
NBL_COREconfiguration option. We appreciate your guidance on adhering to Linux kernel naming conventions.Why
NBL_CORE?
The driver is designed to support two distinct functionalities for the Nebula-matrix m18100 Ethernet controller:
Quoted 7 lines
1.Standard Ethernet/NIC functionality (via the main driver module). 2.Auxiliary device (auxiliary driver) for RDMA (exposed through
auxiliary_device).
4.MDEV-based SR-IOV/VF emulation (for native device splitting). Since shared logic (e.g., PCIe resource management, MMIO access, interrupt handling, and common hardware abstractions) is required across both the main driver and auxiliary/RDMA driver, we opted for a_COREsuffix to indicate:
You can split this two ways:
A true core, which does not provide any devices, just core functions to access the hardware. Then layered on top if this you have kernel modules with provide Ethernet, RDMA, MDEV etc. Such kernel modules would then depend on the core, using Kconfig primitives. And the core itself would not have a tri-state string, since on its own it is useless.
Or
If the core always provides Ethernet, call it an Ethernet driver, not core. The other kernel modules would then depends on having the Ethernet driver, using Kconfig primitives.
This all about naming, not architecture. Splitting it up into multiple kernel modules is good, but your naming and descriptions of what these modules do matters.
Andrew
Re: 回复:回复:[PATCH v3 net-next 01/15] net/nebula-matrix: add minimum nbl build framework
Quoted 6 lines · Sam
Thank you for your feedback. I understand what you mean.The reasons why we cannot change the module name now are as follows:
Our driver has already been integrated into multiple communities, and the module name isnbl_core. Many customers have already deployed it. If we change the name, there will be a critical problem of conflict between the two modules during subsequent online driver upgrades.
To a large extent, mainline does not care about your vendor driver, and it does not care about any compatibility issues between your vendor driver and mainline.
I've not looked at your driver in detail yet so i cannot comment on your driver in particular. But we often see vendor drivers do things mainline does not allow. Custom ioctl handlers, files in /sys, write APIs in debugfs, statistic counters wrongly grouped, etc. In a vendor driver this is O.K, this is all open source, you are free to do what you want. But when it comes to mainline, you have to keep to the mainline rules. Such code will need to be removed, or reworked, breaking compatibility with your vendor driver.
So it can be advantages to have different names, it then become clear if a customer is using the vendor driver, or is using mainline.
Andrew
Sam
maintainer回复:回复:回复:[PATCH v3 net-next 01/15] net/nebula-matrix: add minimum nbl build framework
Thank you for your feedback. You might have misunderstood me. Our difficulties lie in the following:
1. Assuming only the mainline version changes the name (Assume name "nbl"), and our regularly released driver doesn't change its name, then when customers upgrade to a new kernel (containing the "nbl" driver), and then want to update our regularly released driver (named "nbl_core"), the module (ko) conflict will occur.
2. If both our mainline and regularly released drivers change their names, then customers who are already using the "nbl_core" driver will also encounter conflict issues when updating to the new driver "nbl".
Is it possible to do this: our net driver is also modified to be a driver based
on the auxiliary bus, while the PCIe driver only handles PCIe-related processing,
and these two drivers share a single kernel module (ko), namely "nbl_core"?
------------------------------------------------------------------
发件人:Andrew Lunn <[email protected]>
发送时间:2026年1月30日(周五) 11:04
收件人:Sam<[email protected]>
抄 送:Illusion Wang<[email protected]>; Dimon<[email protected]>; Alvin<[email protected]>; netdev<[email protected]>; "andrew+netdev"<[email protected]>; corbet<[email protected]>; kuba<[email protected]>; "linux-doc"<[email protected]>; lorenzo<[email protected]>; pabeni<[email protected]>; horms<[email protected]>; "vadim.fedorenko"<[email protected]>; "lukas.bulwahn"<[email protected]>; hawk<[email protected]>; ast<[email protected]>; bpf<[email protected]>; sdf<[email protected]>; daniel<[email protected]>; "john.fastabend"<[email protected]>; edumazet<[email protected]>; open list<[email protected]> 主 题:Re: 回复:回复:[PATCH v3 net-next 01/15] net/nebula-matrix: add minimum nbl build framework
Quoted 6 lines · Sam
Thank you for your feedback. I understand what you mean.The reasons why we cannot change the module name now are as follows:
Our driver has already been integrated into multiple communities, and the module name isnbl_core. Many customers have already deployed it. If we change the name, there will be a critical problem of conflict between the two modules during subsequent online driver upgrades.
To a large extent, mainline does not care about your vendor driver, and it does not care about any compatibility issues between your vendor driver and mainline.
I've not looked at your driver in detail yet so i cannot comment on your driver in particular. But we often see vendor drivers do things mainline does not allow. Custom ioctl handlers, files in /sys, write APIs in debugfs, statistic counters wrongly grouped, etc. In a vendor driver this is O.K, this is all open source, you are free to do what you want. But when it comes to mainline, you have to keep to the mainline rules. Such code will need to be removed, or reworked, breaking compatibility with your vendor driver.
So it can be advantages to have different names, it then become clear if a customer is using the vendor driver, or is using mainline.
Andrew
Simon Horman
reviewerRe: [PATCH v3 net-next 01/15] net/nebula-matrix: add minimum nbl build framework
In reply to illusion.wangOn Fri, Jan 23, 2026 at 09:17:38AM +0800, illusion.wang wrote:
...
Documentation/networking/device_drivers/ethernet/nebula-matrix/m18100.rst line 6
Quoted 12 lines
Documentation/networking/device_drivers/ethernet/nebula-matrix/m18100.rst new file +6
-0@@ -0,0 +1,47 @@ +.. SPDX-License-Identifier: GPL-2.0 + +============================================================ +Linux Base Driver for Nebula-matrix M18100-NIC family +============================================================ +
This file should be added to Documentation/networking/device_drivers/ethernet/index.rst
Flagged by make htmldocs
...
illusion.wang
maintainerPATCH v3 2/15 net/nebula-matrix: add our driver architecture
In reply to illusion.wangPatch Content:
Hardware (HW), Channel, Resource, Dispatch, Service, 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_dev only for leonis pf0), network(net_dev), common.
2. Service Layer
The Service layer includes various netops services such as packet receiving/sending, management services, etc. These are provided to the upper layer for use or registered as the operations(ops) of related devices. It describes all the service capabilities possessed by the device.
3. 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.
4. Resource Layer
Handles tasks dispatched from Dispatch Layer. These tasks fall into two categories:
4.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.
4.2 Software resource management
Operations like packet statistics collection that don't require hardware access.
5. 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.
6. Channel Layer
Handle communication between PF0 and other PF(Our PF0 has ctrl func),and provide basic interaction channels.
7. Common Layer
Provides fundamental services, including Workqueue management,debug logging, and so on
--- .../net/ethernet/nebula-matrix/nbl/Makefile | 9 +- .../nbl/nbl_channel/nbl_channel.c | 135 ++++++++++++ .../nbl/nbl_channel/nbl_channel.h | 45 ++++ .../net/ethernet/nebula-matrix/nbl/nbl_core.h | 61 +++++- .../nebula-matrix/nbl/nbl_core/nbl_dev.c | 112 ++++++++++ .../nebula-matrix/nbl/nbl_core/nbl_dev.h | 39 ++++ .../nebula-matrix/nbl/nbl_core/nbl_dispatch.c | 114 ++++++++++ .../nebula-matrix/nbl/nbl_core/nbl_dispatch.h | 43 ++++ .../nebula-matrix/nbl/nbl_core/nbl_service.c | 118 ++++++++++ .../nebula-matrix/nbl/nbl_core/nbl_service.h | 37 ++++ .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c | 177 +++++++++++++++ .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.h | 13 ++ .../nbl_hw_leonis/nbl_resource_leonis.c | 152 +++++++++++++ .../nbl_hw_leonis/nbl_resource_leonis.h | 12 + .../nebula-matrix/nbl/nbl_hw/nbl_hw_reg.h | 139 ++++++++++++ .../nebula-matrix/nbl/nbl_hw/nbl_resource.h | 55 +++++ .../nbl/nbl_include/nbl_def_channel.h | 32 +++ .../nbl/nbl_include/nbl_def_common.h | 73 ++++++ .../nbl/nbl_include/nbl_def_dev.h | 28 +++ .../nbl/nbl_include/nbl_def_dispatch.h | 34 +++ .../nbl/nbl_include/nbl_def_hw.h | 23 ++ .../nbl/nbl_include/nbl_def_resource.h | 28 +++ .../nbl/nbl_include/nbl_def_service.h | 24 ++ .../nbl/nbl_include/nbl_include.h | 13 +- .../nbl/nbl_include/nbl_product_base.h | 20 ++ .../net/ethernet/nebula-matrix/nbl/nbl_main.c | 207 ++++++++++++++++++ 26 files changed, 1740 insertions(+), 3 deletions(-) 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_core/nbl_service.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_service.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_def_service.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_product_base.h
drivers/net/ethernet/nebula-matrix/nbl/Makefile +8 -1
@@ -4,8 +4,15 @@ obj-$(CONFIG_NBL_CORE) := nbl_core.o -nbl_core-objs += nbl_main.o +nbl_core-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_service.o \ + nbl_core/nbl_dev.o \ + nbl_main.o # Provide include files ccflags-y += -I$(srctree)/drivers/net/ethernet/nebula-matrix/nbl/nbl_include/ +ccflags-y += -I$(srctree)/drivers/net/ethernet/nebula-matrix/nbl/nbl_hw ccflags-y += -I$(srctree)/drivers/net/ethernet/nebula-matrix/nbl/
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.c new file +135 -0
135 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.h new file +45 -0
45 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_core.h +60 -1
71 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.c new file +112 -0
112 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.h new file +39 -0
@@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0*/ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +* Author: +*/ + +#ifndef _NBL_DEV_H_ +#define _NBL_DEV_H_ + +#include "nbl_core.h" + +#define NBL_DEV_MGT_TO_COMMON (dev_mgt) ((dev_mgt)->common) +#define NBL_DEV_MGT_TO_DEV (dev_mgt) \ + NBL_COMMON_TO_DEV(NBL_DEV_MGT_TO_COMMON(dev_mgt)) +#define NBL_DEV_MGT_TO_COMMON_DEV (dev_mgt) ((dev_mgt)->common_dev) +#define NBL_DEV_MGT_TO_NET_DEV (dev_mgt) ((dev_mgt)->net_dev) +#define NBL_DEV_COMMON_TO_MSIX_INFO (dev_common) (&(dev_common)->msix_info) +#define NBL_DEV_MGT_TO_NETDEV_OPS (dev_mgt) ((dev_mgt)->net_dev->ops) + +#define NBL_DEV_MGT_TO_SERV_OPS_TBL (dev_mgt) ((dev_mgt)->serv_ops_tbl) +#define NBL_DEV_MGT_TO_SERV_OPS (dev_mgt) \ + (NBL_DEV_MGT_TO_SERV_OPS_TBL(dev_mgt)->ops) +#define NBL_DEV_MGT_TO_SERV_PRIV (dev_mgt) \ + (NBL_DEV_MGT_TO_SERV_OPS_TBL(dev_mgt)->priv) +#define NBL_DEV_MGT_TO_RES_PT_OPS (dev_mgt) \ + (&(NBL_DEV_MGT_TO_SERV_OPS_TBL(dev_mgt)->pt_ops)) +#define NBL_DEV_MGT_TO_CHAN_OPS_TBL (dev_mgt) ((dev_mgt)->chan_ops_tbl) +#define NBL_DEV_MGT_TO_CHAN_OPS (dev_mgt) \ + (NBL_DEV_MGT_TO_CHAN_OPS_TBL(dev_mgt)->ops) +#define NBL_DEV_MGT_TO_CHAN_PRIV (dev_mgt) \ + (NBL_DEV_MGT_TO_CHAN_OPS_TBL(dev_mgt)->priv) +struct nbl_dev_mgt { +struct nbl_common_info *common; +struct nbl_service_ops_tbl *serv_ops_tbl; +struct nbl_channel_ops_tbl *chan_ops_tbl; + +}; + +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dispatch.c new file +114 -0
114 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dispatch.h new file +43 -0
43 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_service.c new file +118 -0
118 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_service.h new file +37 -0
@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0*/ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +* Author: +*/ + +#ifndef _NBL_SERVICE_H_ +#define _NBL_SERVICE_H_ + +#include <linux/mm.h> +#include <linux/ptr_ring.h> +#include "nbl_core.h" + +#define NBL_SERV_MGT_TO_COMMON (serv_mgt) ((serv_mgt)->common) +#define NBL_SERV_MGT_TO_CHAN_OPS_TBL (serv_mgt) ((serv_mgt)->chan_ops_tbl) +#define NBL_SERV_MGT_TO_CHAN_OPS (serv_mgt) \ + (NBL_SERV_MGT_TO_CHAN_OPS_TBL(serv_mgt)->ops) +#define NBL_SERV_MGT_TO_CHAN_PRIV (serv_mgt) \ + (NBL_SERV_MGT_TO_CHAN_OPS_TBL(serv_mgt)->priv) + +enum { +NBL_PROMISC =0 , +NBL_ALLMULTI =1 , +}; + +struct nbl_serv_netdev_ops { +void *pf_netdev_ops; +}; + +struct nbl_service_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_hw/nbl_hw_leonis/nbl_hw_leonis.c new file +177 -0
177 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0*/ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +* Author: +*/ + +#ifndef _NBL_HW_LEONIS_H_ +#define _NBL_HW_LEONIS_H_ + +#include "nbl_core.h" +#include "nbl_hw_reg.h" + +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_resource_leonis.c new file +152 -0
152 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_resource_leonis.h new file +12 -0
@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0*/ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +* Author: +*/ + +#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 +139 -0
139 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.h new file +55 -0
55 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_channel.h new file +32 -0
@@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0*/ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +* Author: +*/ + +#ifndef _NBL_DEF_CHANNEL_H_ +#define _NBL_DEF_CHANNEL_H_ + +#include <linux/if_ether.h> +#include "nbl_include.h" + +#define NBL_CHAN_OPS_TBL_TO_OPS (chan_ops_tbl) ((chan_ops_tbl)->ops) +#define NBL_CHAN_OPS_TBL_TO_PRIV (chan_ops_tbl) ((chan_ops_tbl)->priv) + +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; +void *priv; +}; + +int nbl_chan_init_common (void *p,struct nbl_init_param *param); +void nbl_chan_remove_common (void *p); + +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_common.h new file +73 -0
73 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_dev.h new file +28 -0
@@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0*/ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +* Author: +*/ + +#ifndef _NBL_DEF_DEV_H_ +#define _NBL_DEF_DEV_H_ + +#include "nbl_include.h" + +#define NBL_DEV_OPS_TBL_TO_OPS (dev_ops_tbl) ((dev_ops_tbl)->ops) +#define NBL_DEV_OPS_TBL_TO_PRIV (dev_ops_tbl) ((dev_ops_tbl)->priv) + +struct nbl_dev_ops { +}; + +struct nbl_dev_ops_tbl { +struct nbl_dev_ops *ops; +void *priv; +}; + +int nbl_dev_init (void *p,struct nbl_init_param *param); +void nbl_dev_remove (void *p); +int nbl_dev_start (void *p,struct nbl_init_param *param); +void nbl_dev_stop (void *p); + +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_dispatch.h new file +34 -0
@@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0*/ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +* Author: +*/ + +#ifndef _NBL_DEF_DISPATCH_H_ +#define _NBL_DEF_DISPATCH_H_ + +#include "nbl_include.h" + +#define NBL_DISP_OPS_TBL_TO_OPS (disp_ops_tbl) ((disp_ops_tbl)->ops) +#define NBL_DISP_OPS_TBL_TO_PRIV (disp_ops_tbl) ((disp_ops_tbl)->priv) + +enum { +NBL_DISP_CTRL_LVL_NEVER =0 , +NBL_DISP_CTRL_LVL_MGT , +NBL_DISP_CTRL_LVL_NET , +NBL_DISP_CTRL_LVL_ALWAYS , +NBL_DISP_CTRL_LVL_MAX , +}; + +struct nbl_dispatch_ops { +}; + +struct nbl_dispatch_ops_tbl { +struct nbl_dispatch_ops *ops; +void *priv; +}; + +int nbl_disp_init (void *p,struct nbl_init_param *param); +void nbl_disp_remove (void *p); + +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_hw.h new file +23 -0
@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0*/ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +* Author: +*/ + +#ifndef _NBL_DEF_HW_H_ +#define _NBL_DEF_HW_H_ + +#include "nbl_include.h" + +struct nbl_hw_ops { +}; + +struct nbl_hw_ops_tbl { +struct nbl_hw_ops *ops; +void *priv; +}; + +int nbl_hw_init_leonis (void *p,struct nbl_init_param *param); +void nbl_hw_remove_leonis (void *p); + +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_resource.h new file +28 -0
@@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0*/ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +* Author: +*/ + +#ifndef _NBL_DEF_RESOURCE_H_ +#define _NBL_DEF_RESOURCE_H_ + +#include "nbl_include.h" + +struct nbl_resource_pt_ops { +netdev_tx_t (*start_xmit)(struct sk_buff *skb, +struct net_device *netdev); +int (*napi_poll)(struct napi_struct *napi,int budget); +}; + +struct nbl_resource_ops { +}; + +struct nbl_resource_ops_tbl { +struct nbl_resource_ops *ops; +void *priv; +}; + +int nbl_res_init_leonis (void *p,struct nbl_init_param *param); +void nbl_res_remove_leonis (void *p); +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_service.h new file +24 -0
@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0*/ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +* Author: +*/ + +#ifndef _NBL_DEF_SERVICE_H_ +#define _NBL_DEF_SERVICE_H_ + +#include "nbl_include.h" + +struct nbl_service_ops { +}; + +struct nbl_service_ops_tbl { +struct nbl_resource_pt_ops pt_ops; +struct nbl_service_ops *ops; +void *priv; +}; + +int nbl_serv_init (void *priv,struct nbl_init_param *param); +void nbl_serv_remove (void *priv); + +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_include.h +12 -1
@@ -8,10 +8,15 @@#define _NBL_INCLUDE_H_#include <linux/types.h> - +#include <linux/netdevice.h> /* ------ Basic definitions ------- */ #define NBL_DRIVER_NAME "nbl_core" +enum nbl_product_type { +NBL_LEONIS_TYPE , +NBL_PRODUCT_MAX , +}; +struct nbl_func_caps {u32 has_ctrl:1 ;u32 has_net:1 ;
@@ -20,4 +25,10 @@ struct nbl_func_caps { u32 rsv:28; }; +struct nbl_init_param { +struct nbl_func_caps caps; +enum nbl_product_type product_type; +bool pci_using_dac; +}; +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_product_base.h new file +20 -0
@@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0*/ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +* Author: +*/ + +#ifndef _NBL_DEF_PRODUCT_BASE_H_ +#define _NBL_DEF_PRODUCT_BASE_H_ + +#include "nbl_include.h" +struct nbl_product_base_ops { +int (*hw_init)(void *p,struct nbl_init_param *param); +void (*hw_remove)(void *p); +int (*res_init)(void *p,struct nbl_init_param *param); +void (*res_remove)(void *p); +int (*chan_init)(void *p,struct nbl_init_param *param); +void (*chan_remove)(void *p); +}; + +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c +207 -0
224 lines not on this page · raw message
Signature · 1 line
2.47.3
Re: [PATCH v3 net-next 02/15] net/nebula-matrix: add our driver architecture
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.c line 32
Quoted 1 line
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.c new file +1
-0+NBL_CHAN_MGT_TO_COMMON (&(*chan_mgt_leonis)->chan_mgt) = common;
Macros on the left hand side is pretty unusual. Why is it needed?
The cast suggests your types are messed up. You should not need casts.
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_common.h line 17
Quoted 5 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_common.h new file +5
-0+#define nbl_err (common, fmt, ...) \ +do { \ + typeof(common) _common = (common); \ + dev_err(NBL_COMMON_TO_DEV(_common), fmt, ##__VA_ARGS__);\ +} while (0)
You should probably remove these and just use dev_err() or netdev_err() directly.
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_common.h line 49
Quoted 13 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_common.h new file +13
-0+#define NBL_COMMON_TO_PDEV (common) ((common)->pdev) +#define NBL_COMMON_TO_DEV (common) ((common)->dev) +#define NBL_COMMON_TO_DMA_DEV (common) ((common)->dma_dev) +#define NBL_COMMON_TO_VSI_ID (common) ((common)->vsi_id) +#define NBL_COMMON_TO_ETH_ID (common) ((common)->eth_id) +#define NBL_COMMON_TO_ETH_MODE (common) ((common)->eth_mode) +#define NBL_COMMON_TO_DEBUG_LVL (common) ((common)->debug_lvl) + +#define NBL_COMMON_TO_OCP_CAP (common) ((common)->is_ocp) +#define NBL_COMMON_TO_PCI_USING_DAC (common) ((common)->pci_using_dac) +#define NBL_COMMON_TO_MGT_PF (common) ((common)->mgt_pf) +#define NBL_COMMON_TO_PCI_FUNC_ID (common) ((common)->function) +#define NBL_COMMON_TO_LOGIC_ETH_ID (common) ((common)->logic_eth_id)
These are all just obfuscation. Please remove them. And not just these. All of them. Such macros don't help.
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_dev.h line 26
Quoted 4 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_dev.h new file +4
-0+int nbl_dev_init (void *p,struct nbl_init_param *param); +void nbl_dev_remove (void *p); +int nbl_dev_start (void *p,struct nbl_init_param *param); +void nbl_dev_stop (void *p);
Using a void * as a parameter for something like nbl_dev_start() and nbl_dev_stop() is a red flag. You should know they type you are passing to functions like this. In general, you want the compiler to be doing type checking for you, so you need real types.
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c line 49
Quoted 7 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c +7
-0+struct nbl_adapter *nbl_core_init (struct pci_dev *pdev, +struct nbl_init_param *param) +{ +struct nbl_adapter *adapter; +struct nbl_common_info *common; +struct nbl_product_base_ops *product_base_ops; +int ret =0 ;
Reverse Christmas tree. That applies to all functions.
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c line 52
Quoted 3 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c +3
-0+ +if (!pdev) +return NULL ;
Can that happen? Don't have defensive code. If there is a real reason this could be NULL then fine, but you might want to add a comment why it can happen. But if this is not actually expected let pdev be dereferenced, get the Opps, so you can debug your driver. And i don't mean this one instance. I mean all similar tests in the driver. No defensive code, it just hides bugs.
Quoted 4 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c +4
-0+void nbl_core_remove (struct nbl_adapter *adapter) +{ +struct nbl_product_base_ops *product_base_ops; +struct device *dev;
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c line 134
Quoted 10 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c +10
-0+ + dev =NBL_ADAP_TO_DEV (adapter); + product_base_ops =NBL_ADAP_TO_RPDUCT_BASE_OPS (adapter); +nbl_dev_remove (adapter); +nbl_serv_remove (adapter); +nbl_disp_remove (adapter); + product_base_ops->res_remove (adapter); + product_base_ops->chan_remove (adapter); + product_base_ops->hw_remove (adapter); +devm_kfree (dev, adapter);
Calling devm_kfree() is unusual. Why do you do this? I suggests you don't understand what devm_ actually does. Which is pretty scary if you have such a basic thing wrong for a driver this size.
Quoted 10 lines
static int nbl_probe(struct
pci_dev*pdev,drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c +5
-0const struct pci_device_id __always_unused *id) {struct device *dev = &pdev->dev; +struct nbl_adapter *adapter =NULL ; +struct nbl_init_param param = {{0 }}; +int err; +if (pci_enable_device (pdev)) { +dev_err (&pdev->dev,"Failed to enable PCI device\n" );
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c line 176
Quoted 10 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c +10
-0+return -ENODEV ; + } + + param.pci_using_dac = true; +nbl_get_func_param (pdev, id->driver_data, ¶m); + + err =dma_set_mask_and_coherent (dev,DMA_BIT_MASK (64 )); +if (err) { +dev_err (dev,"Configure DMA 64 bit mask failed, err = %d\n" , + err);
dev_err() is usually for a fatal error. Here you just keep going, so it is not really an error. dev_dbg()?
Andrew
---
pw-bot: cr
illusion.wang
maintainerPATCH v3 3/15 net/nebula-matrix: add machine-generated headers and chip definitions
In reply to illusion.wang1. nbl_hw_leonis/base/* are machine generated headers
2. nbl_hw.h/nbl_hw_leonis.h
chip-related reg definitions
3. nbl_hw_leonis_regs.c
P4 configuration that will be invoked during chip initialization 4.nbl_def_channel.h
For compatibility, msg id value and msg structure are fixed.
--- .../net/ethernet/nebula-matrix/nbl/Makefile | 1 + .../nebula-matrix/nbl/nbl_hw/nbl_hw.h | 172 + .../nbl_hw/nbl_hw_leonis/base/nbl_datapath.h | 11 + .../nbl_hw_leonis/base/nbl_datapath_dped.h | 2152 +++++++++ .../nbl_hw_leonis/base/nbl_datapath_dstore.h | 929 ++++ .../nbl_hw_leonis/base/nbl_datapath_ucar.h | 414 ++ .../nbl/nbl_hw/nbl_hw_leonis/base/nbl_ppe.h | 10 + .../nbl_hw/nbl_hw_leonis/base/nbl_ppe_epro.h | 665 +++ .../nbl_hw/nbl_hw_leonis/base/nbl_ppe_ipro.h | 1397 ++++++ .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.h | 1129 +++++ .../nbl_hw/nbl_hw_leonis/nbl_hw_leonis_regs.c | 3903 +++++++++++++++++ .../nbl_hw/nbl_hw_leonis/nbl_hw_leonis_regs.h | 12 + .../nbl/nbl_include/nbl_def_channel.h | 338 ++ .../nbl/nbl_include/nbl_include.h | 17 + 14 files changed, 11150 insertions(+) create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/base/nbl_datapath.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/base/nbl_datapath_dped.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/base/nbl_datapath_dstore.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/base/nbl_datapath_ucar.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/base/nbl_ppe.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/base/nbl_ppe_epro.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/base/nbl_ppe_ipro.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis_regs.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis_regs.h
drivers/net/ethernet/nebula-matrix/nbl/Makefile +1 -0
@@ -7,6 +7,7 @@ obj-$(CONFIG_NBL_CORE) := nbl_core.o nbl_core-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_hw/nbl_hw_leonis/nbl_hw_leonis_regs.o \ nbl_core/nbl_dispatch.o \ nbl_core/nbl_service.o \ nbl_core/nbl_dev.o \
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw.h new file +172 -0
172 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/base/nbl_datapath.h new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0*/ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +* Author: +*/ +// Code generated by interstellar. DO NOT EDIT. +// Compatible with leonis RTL tag 0710 + +#include "nbl_datapath_ucar.h" +#include "nbl_datapath_dped.h" +#include "nbl_datapath_dstore.h"
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/base/nbl_datapath_dped.h new file +2152 -0
2,152 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/base/nbl_datapath_dstore.h new file +929 -0
658 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/base/nbl_datapath_ucar.h new file +414 -0
414 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/base/nbl_ppe.h new file +10 -0
Lines of this file are not shown. View the raw message.
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/base/nbl_ppe_epro.h new file +665 -0
665 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/base/nbl_ppe_ipro.h new file +1397 -0
1,397 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.h +1129 -0
1,129 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis_regs.c new file +3903 -0
3,903 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis_regs.h new file +12 -0
Lines of this file are not shown. View the raw message.
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_channel.h +338 -0
338 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_include.h +17 -0
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.47.3
Part of the diff is not shown here. View the raw message.
illusion.wang
maintainerPATCH v3 4/15 net/nebula-matrix: add channel layer implementation and the corresponding hw interfaces
In reply to illusion.wanga channel management layer provides structured approach to handle communication between different components and drivers. Here's a summary of its key functionalities:
1. Message Handling Framework
Message Registration/Unregistration: Functions (nbl_chan_register_msg, nbl_chan_unregister_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.
2. Channel Types and Queue Management
Mailbox Channel: For direct communication between PF0 and Other PF. Queue Initialization/Teardown: Functions (nbl_chan_init_queue, nbl_chan_teardown_queue) manage transmit (TX) and receive (RX) queues, including DMA buffer allocation/deallocation (dmam_alloc_coherent, dmam_free_coherent).
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), and DMA error checks
(check_mailbox_dma_err).
--- .../net/ethernet/nebula-matrix/nbl/Makefile | 3 +- .../nbl/nbl_channel/nbl_channel.c | 1154 +++++++++++++++++ .../nbl/nbl_channel/nbl_channel.h | 132 ++ .../nebula-matrix/nbl/nbl_common/nbl_common.c | 302 +++++ .../nebula-matrix/nbl/nbl_common/nbl_common.h | 29 + .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c | 129 ++ .../nbl/nbl_include/nbl_def_channel.h | 111 ++ .../nbl/nbl_include/nbl_def_common.h | 74 ++ .../nbl/nbl_include/nbl_def_hw.h | 31 + .../nbl/nbl_include/nbl_include.h | 15 + 10 files changed, 1979 insertions(+), 1 deletion(-) 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
@@ -4,7 +4,8 @@ obj-$(CONFIG_NBL_CORE) := nbl_core.o -nbl_core-objs += nbl_channel/nbl_channel.o \ +nbl_core-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_hw_leonis/nbl_hw_leonis_regs.o \
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.c +1154 -0
1,193 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_channel/nbl_channel.h +132 -0
141 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_common/nbl_common.c new file +302 -0
302 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_common/nbl_common.h new file +29 -0
@@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0*/ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +* Author: +*/ + +#ifndef _NBL_COMMON_H_ +#define _NBL_COMMON_H_ + +#include "nbl_def_common.h" + +/* list only need one bucket size */ +#define NBL_HASH_TBL_LIST_BUCKET_SIZE 1 + +struct nbl_hash_tbl_mgt { +struct nbl_hash_tbl_key tbl_key; +struct hlist_head *hash; +struct mutex lock;/* support multi thread */ +u16 node_num; +}; + +/* it used for y_axis no necessay */ +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 +129 -0
136 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_channel.h +111 -0
135 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_common.h +74 -0
78 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_hw.h +31 -0
@@ -10,6 +10,37 @@#include "nbl_include.h" struct nbl_hw_ops { +void (*configure_msix_map)(void *priv,u16 func_id,bool valid, +dma_addr_t dma_addr,u8 bus,u8 devid, +u8 function); +void (*configure_msix_info)(void *priv,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)(void *priv,u16 tail_ptr, +u8 txrx); +void (*config_mailbox_rxq)(void *priv,dma_addr_t dma_addr, +int size_bwid); +void (*config_mailbox_txq)(void *priv,dma_addr_t dma_addr, +int size_bwid); +void (*stop_mailbox_rxq)(void *priv); +void (*stop_mailbox_txq)(void *priv); +u16 (*get_mailbox_rx_tail_ptr)(void *priv); +bool (*check_mailbox_dma_err)(void *priv,bool tx); +u32 (*get_host_pf_mask)(void *priv); +u32 (*get_real_bus)(void *priv); +u64 (*get_pf_bar_addr)(void *priv,u16 func_id); + +void (*cfg_mailbox_qinfo)(void *priv,u16 func_id,u16 bus,u16 devid, +u16 function); +void (*enable_mailbox_irq)(void *priv,u16 func_id,bool enable_msix, +u16 global_vec_id); +void (*enable_msix_irq)(void *priv,u16 global_vec_id); +u8 __iomem *(*get_msix_irq_enable_info)(void *priv,u16 global_vec_id, +u32 *irq_data); +u32 (*get_fw_eth_num)(void *priv); +u32 (*get_fw_eth_map)(void *priv); +void (*get_board_info)(void *priv,struct nbl_board_port_info *board); +u32 (*get_quirks)(void *priv); };struct nbl_hw_ops_tbl {
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_include.h +15 -0
@@ -12,6 +12,12 @@/* ------ Basic definitions ------- */ #define NBL_DRIVER_NAME "nbl_core" +#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 ,NBL_PRODUCT_MAX ,
@@ -48,4 +54,13 @@ struct nbl_txrx_queue_param { u16 rxcsum; }; +struct nbl_vnet_queue_info_param { +u32 function_id; +u32 device_id; +u32 bus_id; +u32 msix_idx; +u32 msix_idx_valid; +u32 valid; +}; +#endif
Signature · 1 line
2.47.3
Simon Horman
reviewerRe: [v3,net-next,04/15] net/nebula-matrix: add channel layer implementation and the corresponding hw interfaces
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---net/nebula-matrix: add intr resource implementation
This patch adds MSI-X interrupt vector management for the Nebula Matrix network driver, including dynamic allocation of interrupt vectors, mapping table management, and interrupt enable/disable support.
Quoted 4 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.h +0
-0
[ ... ]
Quoted 7 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.h +2
-0@@ -10,12 +10,20 @@#include "nbl_core.h" #include "nbl_hw.h" +struct nbl_resource_mgt ; +#define NBL_RES_MGT_TO_COMMON (res_mgt) ((res_mgt)->common)
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.h line 25
Quoted 10 lines
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.h +5
-0#define NBL_RES_MGT_TO_COMMON_OPS (res_mgt) (&((res_mgt)->common_ops))#define NBL_RES_MGT_TO_DEV (res_mgt) \ NBL_COMMON_TO_DEV(NBL_RES_MGT_TO_COMMON(res_mgt))#define NBL_RES_MGT_TO_DMA_DEV (res_mgt) \ NBL_COMMON_TO_DMA_DEV(NBL_RES_MGT_TO_COMMON(res_mgt)) +#define NBL_RES_MGT_TO_INTR_MGT (res_mgt) ((res_mgt)->intr_mgt) +#define NBL_RES_MGT_TO_QUEUE_MGT (res_mgt) ((res_mgt)->queue_mgt) +#define NBL_RES_MGT_TO_TXRX_MGT (res_mgt) ((res_mgt)->txrx_mgt) +#define NBL_RES_MGT_TO_VSI_MGT (res_mgt) ((res_mgt)->vsi_mgt) +#define NBL_RES_MGT_TO_INTR_MGT (res_mgt) ((res_mgt)->intr_mgt)
^^^^^^^^^^^^^^^^^^^^^^^^
Is NBL_RES_MGT_TO_INTR_MGT intentionally defined twice here? It appears on both lines with identical definitions, which will generate a compiler warning for macro redefinition.
Quoted 1 line
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.h +1
-0+#define NBL_RES_MGT_TO_PROD_OPS (res_mgt) ((res_mgt)->product_ops)
[ ... ]
illusion.wang
maintainerPATCH v3 5/15 net/nebula-matrix: add resource layer common part implementation
In reply to illusion.wangThe 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, txrx, queue, and vsi.
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. Additionally, it offers the register_net/unregister_net interfaces.
--- .../net/ethernet/nebula-matrix/nbl/Makefile | 1 + .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c | 84 ++++ .../nbl_hw_leonis/nbl_resource_leonis.c | 376 ++++++++++++++++++ .../nbl_hw_leonis/nbl_resource_leonis.h | 1 + .../nebula-matrix/nbl/nbl_hw/nbl_resource.c | 299 ++++++++++++++ .../nebula-matrix/nbl/nbl_hw/nbl_resource.h | 101 +++++ .../nbl/nbl_include/nbl_def_common.h | 17 + .../nbl/nbl_include/nbl_def_resource.h | 7 + .../nbl/nbl_include/nbl_include.h | 44 ++ 9 files changed, 930 insertions(+) create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.c
drivers/net/ethernet/nebula-matrix/nbl/Makefile +1 -0
@@ -9,6 +9,7 @@ nbl_core-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_hw_leonis/nbl_hw_leonis_regs.o \ + nbl_hw/nbl_resource.o \ nbl_core/nbl_dispatch.o \ nbl_core/nbl_service.o \ nbl_core/nbl_dev.o \
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c +84 -0
110 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_resource_leonis.c +376 -0
402 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_resource_leonis.h +1 -0
@@ -9,4 +9,5 @@#include "nbl_resource.h" +#define NBL_MAX_PF_LEONIS 8#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.c new file +299 -0
299 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.h +101 -0
125 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_common.h +17 -0
@@ -48,6 +48,23 @@ do { \#define NBL_COMMON_TO_PCI_FUNC_ID (common) ((common)->function)#define NBL_COMMON_TO_LOGIC_ETH_ID (common) ((common)->logic_eth_id) +#define NBL_ONE_ETHERNET_PORT (1) +#define NBL_TWO_ETHERNET_PORT (2) +#define NBL_FOUR_ETHERNET_PORT (4) +#define NBL_DEFAULT_VSI_ID_GAP (1024) +#define NBL_TWO_ETHERNET_VSI_ID_GAP (512) +#define NBL_FOUR_ETHERNET_VSI_ID_GAP (256) + +#define NBL_VSI_ID_GAP (m) \ + ({ \ + typeof(m) _m = (m); \ + _m == NBL_FOUR_ETHERNET_PORT ? \ + NBL_FOUR_ETHERNET_VSI_ID_GAP : \ + (_m == NBL_TWO_ETHERNET_PORT ? \ + NBL_TWO_ETHERNET_VSI_ID_GAP : \ + NBL_DEFAULT_VSI_ID_GAP); \ + }) +struct nbl_common_info {struct pci_dev *pdev;struct device *dev;
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_resource.h +7 -0
@@ -16,6 +16,13 @@ struct nbl_resource_pt_ops { };struct nbl_resource_ops { +int (*register_net)(void *priv,u16 func_id, +struct nbl_register_net_param *register_param, +struct nbl_register_net_result *register_result); +int (*unregister_net)(void *priv,u16 func_id); +u16 (*get_vsi_id)(void *priv,u16 func_id,u16 type); +void (*get_eth_id)(void *priv,u16 vsi_id,u8 *eth_mode,u8 *eth_id, +u8 *logic_eth_id); };struct nbl_resource_ops_tbl {
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_include.h +44 -0
59 lines not on this page · raw message
Signature · 1 line
2.47.3
illusion.wang
maintainerPATCH v3 6/15 net/nebula-matrix: add intr resource implementation
In reply to illusion.wangDynamically allocate and manage MSI-X interrupt vectors, including network interrupts and other types of interrupts. Interrupt Mapping Table Management: Maintain the MSI-X mapping table (msix_map_table) to establish interrupt associations between hardware and software.
Interrupt Enabling/Disabling:
Support enabling or disabling specific interrupts through hardware operations.
Interrupt Information Query: Provide interfaces to obtain the hardware register addresses and data of interrupts.
--- .../net/ethernet/nebula-matrix/nbl/Makefile | 1 + .../net/ethernet/nebula-matrix/nbl/nbl_core.h | 4 + .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c | 95 +++++- .../nbl_hw_leonis/nbl_resource_leonis.c | 19 ++ .../nebula-matrix/nbl/nbl_hw/nbl_interrupt.c | 314 ++++++++++++++++++ .../nebula-matrix/nbl/nbl_hw/nbl_interrupt.h | 13 + .../nebula-matrix/nbl/nbl_hw/nbl_resource.h | 271 +++++++++++++++ .../nbl/nbl_include/nbl_def_resource.h | 9 + .../nbl/nbl_include/nbl_include.h | 139 +++++++- 9 files changed, 856 insertions(+), 9 deletions(-) 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
@@ -10,6 +10,7 @@ nbl_core-objs += nbl_common/nbl_common.o \ nbl_hw/nbl_hw_leonis/nbl_resource_leonis.o \ nbl_hw/nbl_hw_leonis/nbl_hw_leonis_regs.o \ nbl_hw/nbl_resource.o \ + nbl_hw/nbl_interrupt.o \ nbl_core/nbl_dispatch.o \ nbl_core/nbl_service.o \ nbl_core/nbl_dev.o \
drivers/net/ethernet/nebula-matrix/nbl/nbl_core.h +4 -0
@@ -34,6 +34,10 @@#define NBL_ADAP_TO_SERV_OPS_TBL (adapter) ((adapter)->intf.service_ops_tbl)#define NBL_ADAP_TO_DEV_OPS_TBL (adapter) ((adapter)->intf.dev_ops_tbl)#define NBL_ADAP_TO_CHAN_OPS_TBL (adapter) ((adapter)->intf.channel_ops_tbl) + +#define NBL_ADAPTER_TO_RES_PT_OPS (adapter) \ + (&(NBL_ADAP_TO_SERV_OPS_TBL(adapter)->pt_ops)) +#define NBL_CAP_TEST_BIT (val, loc) (((val) >> (loc)) & 0x1)#define NBL_CAP_IS_CTRL (val) NBL_CAP_TEST_BIT(val, NBL_CAP_HAS_CTRL_BIT)
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c +94 -1
113 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_resource_leonis.c +19 -0
@@ -173,6 +173,7 @@ static struct nbl_resource_ops res_ops = {static struct nbl_res_product_ops product_ops = { }; +static bool is_ops_inited;static int nbl_res_setup_res_mgt (struct nbl_common_info *common,struct nbl_resource_mgt_leonis **res_mgt_leonis)
@@ -220,15 +221,28 @@ static int nbl_res_setup_ops(struct device *dev,struct nbl_resource_ops_tbl **res_ops_tbl, struct nbl_resource_mgt_leonis *res_mgt_leonis) { + int ret = 0; + *res_ops_tbl =devm_kzalloc (dev,sizeof (struct nbl_resource_ops_tbl ),GFP_KERNEL );if (!*res_ops_tbl)return -ENOMEM ; +if (!is_ops_inited) { + ret =nbl_intr_setup_ops (&res_ops); +if (ret) + goto setup_fail; + is_ops_inited = true; + } + (*res_ops_tbl)->ops = &res_ops; (*res_ops_tbl)->priv = res_mgt_leonis;return 0 ; + +setup_fail: +nbl_res_remove_ops (dev, res_ops_tbl); +return -EAGAIN ; }static int nbl_res_ctrl_dev_setup_eth_info (struct nbl_resource_mgt *res_mgt)
@@ -416,6 +430,7 @@ static void nbl_res_stop(struct nbl_resource_mgt_leonis *res_mgt_leonis) {struct nbl_resource_mgt *res_mgt = &res_mgt_leonis->res_mgt; +nbl_intr_mgt_stop (res_mgt);nbl_res_ctrl_dev_remove_vsi_info (res_mgt);nbl_res_ctrl_dev_remove_eth_info (res_mgt);nbl_res_ctrl_dev_sriov_info_remove (res_mgt);
@@ -454,6 +469,10 @@ static int nbl_res_start(struct nbl_resource_mgt_leonis *res_mgt_leonis, ret =nbl_res_ring_num_info_init (res_mgt);if (ret) goto start_fail; + + ret =nbl_intr_mgt_start (res_mgt); +if (ret) + goto start_fail; }return 0 ;
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_interrupt.c new file +314 -0
314 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_interrupt.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0*/ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +* Author: +*/ + +#ifndef _NBL_INTERRUPT_H_ +#define _NBL_INTERRUPT_H_ + +#include "nbl_resource.h" + +#define NBL_MSIX_MAP_TABLE_MAX_ENTRIES (1024) +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.h +271 -0
308 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_resource.h +9 -0
@@ -16,10 +16,19 @@ struct nbl_resource_pt_ops { };struct nbl_resource_ops { +int (*configure_msix_map)(void *priv,u16 func_id,u16 num_net_msix, +u16 num_others_msix,bool net_msix_mask_en); +int (*destroy_msix_map)(void *priv,u16 func_id); +int (*enable_mailbox_irq)(void *priv,u16 func_id,u16 vector_id, +bool enable_msix); +u16 (*get_global_vector)(void *priv,u16 vsi_id,u16 local_vec_id); +u16 (*get_msix_entry_id)(void *priv,u16 vsi_id,u16 local_vec_id);int (*register_net)(void *priv,u16 func_id,struct nbl_register_net_param *register_param,struct nbl_register_net_result *register_result);int (*unregister_net)(void *priv,u16 func_id); +u8 __iomem *(*get_msix_irq_enable_info)(void *priv,u16 global_vec_id, +u32 *irq_data);u16 (*get_vsi_id)(void *priv,u16 func_id,u16 type);void (*get_eth_id)(void *priv,u16 vsi_id,u8 *eth_mode,u8 *eth_id,u8 *logic_eth_id);
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_include.h +131 -8
166 lines not on this page · raw message
Signature · 1 line
2.47.3
illusion.wang
maintainerPATCH v3 7/15 net/nebula-matrix: add queue resource implementation
In reply to illusion.wang1. Queue Resource Management
Allocation & Release:nbl_res_queue_alloc_txrx_queues: Allocates transmit/receive queues for a VSI (Virtual Station Interface). nbl_res_queue_free_txrx_queues: Releases queue resources. Initialization:nbl_res_queue_setup_queue_info: Initializes queue metadata (e.g., queue count, context).nbl_res_queue_remove_queue_info: Cleans up queue metadata.
2. Queue Mapping & Configuration
QID Mapping Table:nbl_res_queue_setup_qid_map_table_leonis: Sets up mappings from local QIDs to global QIDs. nbl_res_queue_remove_qid_map_table_leonis: Removes entries from the mapping table.
Hardware Configuration:nbl_res_queue_setup_hw_dq: Configures hardware TX/RX queues (descriptor addresses, interrupt settings). nbl_res_queue_remove_all_hw_dq: Disables and cleans up hardware queues.
3. RSS (Receive Side Scaling) Support
RSS Table Initialization:nbl_res_queue_init_epro_rss_key: Initializes RSS hash keys.nbl_res_queue_setup_rss: Allocates RSS indir table entries for a VSI.nbl_res_queue_remove_rss: Releases RSS resources.
Indirection Table:nbl_res_queue_set_rxfh_indir: Configures the RSS indirection table for traffic distribution.
4. VSI-Queue Association
VSI Registration:nbl_res_queue_register_vsi2q: Registers a VSI with the queue manager. nbl_res_queue_setup_q2vsi/nbl_res_queue_remove_q2vsi: Binds/unbinds queues to a VSI.
Queue Group Configuration:nbl_res_queue_setup_cqs: Configures queue groups (e.g., for multi-queue load balancing).nbl_res_queue_remove_cqs: Cleans up queue groups.
5. Traffic Scheduling & Shaping
Scheduling:nbl_res_queue_cfg_dsch: Maps queues to traffic classes (QoS). Hardware Initialization:nbl_res_queue_init_epro_vpt_table: Initializes virtual port tables. nbl_res_queue_init_ipro_dn_sport_tbl: Configures downstream traffic tables.
6. Initialization & Cleanup
Module Initialization:nbl_res_queue_init: Initializes the queue manager (e.g., mapping tables, RSS tables).nbl_res_queue_clear_queues: Cleans up all queue resources. Operation Registration:nbl_queue_setup_ops_leonis: Registers queue management function pointers. nbl_queue_remove_ops_leonis: Unregisters operations.
--- .../net/ethernet/nebula-matrix/nbl/Makefile | 2 + .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c | 955 ++++++++++++++ .../nbl_hw/nbl_hw_leonis/nbl_queue_leonis.c | 1129 +++++++++++++++++ .../nbl_hw/nbl_hw_leonis/nbl_queue_leonis.h | 15 + .../nbl_hw_leonis/nbl_resource_leonis.c | 13 + .../nbl_hw_leonis/nbl_resource_leonis.h | 12 + .../nebula-matrix/nbl/nbl_hw/nbl_queue.c | 60 + .../nebula-matrix/nbl/nbl_hw/nbl_queue.h | 11 + .../nebula-matrix/nbl/nbl_hw/nbl_resource.h | 4 + .../nbl/nbl_include/nbl_def_hw.h | 48 + .../nbl/nbl_include/nbl_def_resource.h | 27 + .../nbl/nbl_include/nbl_include.h | 28 + 12 files changed, 2304 insertions(+) create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_queue_leonis.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_queue_leonis.h create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_queue.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_queue.h
drivers/net/ethernet/nebula-matrix/nbl/Makefile +2 -0
@@ -7,10 +7,12 @@ obj-$(CONFIG_NBL_CORE) := nbl_core.o nbl_core-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_queue_leonis.o \ nbl_hw/nbl_hw_leonis/nbl_resource_leonis.o \ nbl_hw/nbl_hw_leonis/nbl_hw_leonis_regs.o \ nbl_hw/nbl_resource.o \ nbl_hw/nbl_interrupt.o \ + nbl_hw/nbl_queue.o \ nbl_core/nbl_dispatch.o \ nbl_core/nbl_service.o \ nbl_core/nbl_dev.o \
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c +955 -0
974 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_queue_leonis.c new file +1129 -0
1,129 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_queue_leonis.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0*/ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +* Author: +*/ + +#ifndef _NBL_QUEUE_LEONIS_H_ +#define _NBL_QUEUE_LEONIS_H_ + +#include "nbl_resource.h" + +#define NBL_QID_MAP_NOTIFY_ADDR_SHIFT (9) +#define NBL_QID_MAP_NOTIFY_ADDR_LOW_PART_LEN (23) + +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_resource_leonis.c +13 -0
@@ -171,6 +171,10 @@ static struct nbl_resource_ops res_ops = { };static struct nbl_res_product_ops product_ops = { + .queue_mgt_init = nbl_queue_mgt_init_leonis, + .setup_qid_map_table = nbl_res_queue_setup_qid_map_table_leonis, + .remove_qid_map_table = nbl_res_queue_remove_qid_map_table_leonis, + .init_qid_map_table = nbl_res_queue_init_qid_map_table, };static bool is_ops_inited;
@@ -229,6 +233,9 @@ static int nbl_res_setup_ops(struct device *dev,return -ENOMEM ;if (!is_ops_inited) { + ret =nbl_queue_setup_ops_leonis (&res_ops); +if (ret) + goto setup_fail; ret =nbl_intr_setup_ops (&res_ops);if (ret) goto setup_fail;
@@ -430,7 +437,9 @@ static void nbl_res_stop(struct nbl_resource_mgt_leonis *res_mgt_leonis) {struct nbl_resource_mgt *res_mgt = &res_mgt_leonis->res_mgt; +nbl_queue_mgt_stop (res_mgt);nbl_intr_mgt_stop (res_mgt); +nbl_res_ctrl_dev_remove_vsi_info (res_mgt);nbl_res_ctrl_dev_remove_eth_info (res_mgt);nbl_res_ctrl_dev_sriov_info_remove (res_mgt);
@@ -470,6 +479,10 @@ static int nbl_res_start(struct nbl_resource_mgt_leonis *res_mgt_leonis,if (ret) goto start_fail; + ret =nbl_queue_mgt_start (res_mgt); +if (ret) + goto start_fail; + ret =nbl_intr_mgt_start (res_mgt);if (ret) goto start_fail;
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_resource_leonis.h +12 -0
@@ -10,4 +10,16 @@#include "nbl_resource.h" #define NBL_MAX_PF_LEONIS 8 + +int nbl_queue_setup_ops_leonis (struct nbl_resource_ops *resource_ops); +void nbl_queue_remove_ops_leonis (struct nbl_resource_ops *resource_ops); + +void nbl_queue_mgt_init_leonis (struct nbl_queue_mgt *queue_mgt); +int nbl_res_queue_setup_qid_map_table_leonis (struct nbl_resource_mgt *res_mgt, +u16 func_id,u64 notify_addr); +void nbl_res_queue_remove_qid_map_table_leonis (struct nbl_resource_mgt *res_mgt, +u16 func_id); +int nbl_res_queue_init_qid_map_table (struct nbl_resource_mgt *res_mgt, +struct nbl_queue_mgt *queue_mgt, +struct nbl_hw_ops *hw_ops);#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_queue.c new file +60 -0
60 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_queue.h new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0*/ +/* +* Copyright (c) 2025 Nebula Matrix Limited. +* Author: +*/ + +#ifndef _NBL_QUEUE_H_ +#define _NBL_QUEUE_H_ + +#include "nbl_resource.h" +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.h +4 -0
@@ -422,6 +422,10 @@ u8 nbl_res_vsi_id_to_eth_id(struct nbl_resource_mgt *res_mgt, u16 vsi_id);int nbl_intr_mgt_start (struct nbl_resource_mgt *res_mgt);void nbl_intr_mgt_stop (struct nbl_resource_mgt *res_mgt);int nbl_intr_setup_ops (struct nbl_resource_ops *resource_ops); + +int nbl_queue_mgt_start (struct nbl_resource_mgt *res_mgt); +void nbl_queue_mgt_stop (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 +48 -0
54 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_resource.h +27 -0
@@ -16,6 +16,9 @@ struct nbl_resource_pt_ops { };struct nbl_resource_ops { +int (*init_chip_module)(void *priv); +void (*deinit_chip_module)(void *priv); +int (*queue_init)(void *priv);int (*configure_msix_map)(void *priv,u16 func_id,u16 num_net_msix,u16 num_others_msix,bool net_msix_mask_en);int (*destroy_msix_map)(void *priv,u16 func_id);
@@ -27,11 +30,35 @@ struct nbl_resource_ops {struct nbl_register_net_param *register_param, struct nbl_register_net_result *register_result);int (*unregister_net)(void *priv,u16 func_id); +int (*alloc_txrx_queues)(void *priv,u16 vsi_id,u16 queue_num); +void (*free_txrx_queues)(void *priv,u16 vsi_id); +int (*register_vsi2q)(void *priv,u16 vsi_index,u16 vsi_id, +u16 queue_offset,u16 queue_num); +int (*setup_q2vsi)(void *priv,u16 vsi_id); +void (*remove_q2vsi)(void *priv,u16 vsi_id); +int (*setup_rss)(void *priv,u16 vsi_id); +void (*remove_rss)(void *priv,u16 vsi_id); +int (*setup_queue)(void *priv,struct nbl_txrx_queue_param *param, +bool is_tx); +void (*remove_all_queues)(void *priv,u16 vsi_id); +int (*cfg_dsch)(void *priv,u16 vsi_id,bool vld); +int (*setup_cqs)(void *priv,u16 vsi_id,u16 real_qps, +bool rss_indir_set); +void (*remove_cqs)(void *priv,u16 vsi_id); +void (*clear_queues)(void *priv,u16 vsi_id); + +u16 (*get_global_queue_id)(void *priv,u16 vsi_id,u16 local_queue_id); +u8 __iomem *(*get_msix_irq_enable_info)(void *priv,u16 global_vec_id,u32 *irq_data);u16 (*get_vsi_id)(void *priv,u16 func_id,u16 type);void (*get_eth_id)(void *priv,u16 vsi_id,u8 *eth_mode,u8 *eth_id,u8 *logic_eth_id); +int (*set_promisc_mode)(void *priv,u16 vsi_id,u16 mode); +void (*get_rxfh_indir_size)(void *priv,u16 vsi_id, +u32 *rxfh_indir_size); +int (*set_rxfh_indir)(void *priv,u16 vsi_id,const u32 *indir, +u32 indir_size); };struct nbl_resource_ops_tbl {
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_include.h +28 -0
@@ -87,6 +87,15 @@ struct nbl_qid_map_param {u16 len; }; +struct nbl_vnet_queue_info_param { +u32 function_id; +u32 device_id; +u32 bus_id; +u32 msix_idx; +u32 msix_idx_valid; +u32 valid; +}; +struct nbl_queue_cfg_param {/* queue args*/ u64 desc;
@@ -180,6 +189,25 @@ 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) + +#define NBL_OPS_CALL_RET (func, para) \ +({ \ + typeof(func) _func = (func); \ + _func ? _func para : 0; \ +}) + +#define NBL_OPS_CALL_RET_PTR (func, para) \ +({ \ + typeof(func) _func = (func); \ + _func ? _func para : NULL; \ +}) +enum {NBL_NETIF_F_SG_BIT ,/* Scatter/gather IO. */ NBL_NETIF_F_IP_CSUM_BIT ,/* csum TCP/UDP over IPv4 */
Signature · 1 line
2.47.3
illusion.wang
maintainerPATCH v3 8/15 net/nebula-matrix: add vsi resource implementation
In reply to illusion.wangThe HW (Hardware) layer code can have a quick review since it is highly chip-specific.
Chip initialization includes the initialization of the DP module, the intf module, and the P4 registers.
The initialization of the DP module encompasses the initialization of the dped(downstream pkt edit), uped(upstream pkt edit), dsch(downstream schedule), ustore, dstore, dvn, uvn, and uqm modules.
--- .../net/ethernet/nebula-matrix/nbl/Makefile | 1 + .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c | 424 ++++++++++++++++++ .../nbl_hw_leonis/nbl_resource_leonis.c | 10 + .../nebula-matrix/nbl/nbl_hw/nbl_resource.h | 4 + .../nebula-matrix/nbl/nbl_hw/nbl_vsi.c | 120 +++++ .../nebula-matrix/nbl/nbl_hw/nbl_vsi.h | 12 + 6 files changed, 571 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
@@ -13,6 +13,7 @@ nbl_core-objs += nbl_common/nbl_common.o \ nbl_hw/nbl_resource.o \ nbl_hw/nbl_interrupt.o \ nbl_hw/nbl_queue.o \ + nbl_hw/nbl_vsi.o \ nbl_core/nbl_dispatch.o \ nbl_core/nbl_service.o \ nbl_core/nbl_dev.o \
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c +424 -0
458 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_resource_leonis.c +10 -0
@@ -237,6 +237,10 @@ static int nbl_res_setup_ops(struct device *dev,if (ret) goto setup_fail; ret =nbl_intr_setup_ops (&res_ops); +if (ret) + goto setup_fail; + + ret =nbl_vsi_setup_ops (&res_ops);if (ret) goto setup_fail; is_ops_inited = true;
@@ -440,6 +444,8 @@ static void nbl_res_stop(struct nbl_resource_mgt_leonis *res_mgt_leonis)nbl_queue_mgt_stop (res_mgt);nbl_intr_mgt_stop (res_mgt); +nbl_vsi_mgt_stop (res_mgt); +nbl_res_ctrl_dev_remove_vsi_info (res_mgt);nbl_res_ctrl_dev_remove_eth_info (res_mgt);nbl_res_ctrl_dev_sriov_info_remove (res_mgt);
@@ -483,6 +489,10 @@ static int nbl_res_start(struct nbl_resource_mgt_leonis *res_mgt_leonis,if (ret) goto start_fail; + ret =nbl_vsi_mgt_start (res_mgt); +if (ret) + goto start_fail; + ret =nbl_intr_mgt_start (res_mgt);if (ret) goto start_fail;
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.h +4 -0
@@ -426,6 +426,10 @@ int nbl_intr_setup_ops(struct nbl_resource_ops *resource_ops);int nbl_queue_mgt_start (struct nbl_resource_mgt *res_mgt);void nbl_queue_mgt_stop (struct nbl_resource_mgt *res_mgt); +int nbl_vsi_mgt_start (struct nbl_resource_mgt *res_mgt); +void nbl_vsi_mgt_stop (struct nbl_resource_mgt *res_mgt); +int nbl_vsi_setup_ops (struct nbl_resource_ops *resource_ops); +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_hw/nbl_vsi.c new file +120 -0
120 lines not on this page · raw message
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. +* Author: +*/ + +#ifndef _NBL_VSI_H_ +#define _NBL_VSI_H_ + +#include "nbl_resource.h" + +#endif
Signature · 1 line
2.47.3
illusion.wang
maintainerPATCH v3 9/15 net/nebula-matrix: add txrx resource interfaces and tx func
In reply to illusion.wangprimarily tx function and ring management
1.Ring Management for Transmit and Receive:
Alloc tx rings (nbl_alloc_tx_rings) and rx rings (nbl_alloc_rx_rings). Free tx rings (nbl_free_tx_rings) and rx rings (nbl_free_rx_rings). Start tx rings (nbl_res_txrx_start_tx_ring) and rx rings (nbl_res_txrx_start_rx_ring).
Stop tx rings (nbl_res_txrx_stop_tx_ring) and rx rings (nbl_res_txrx_stop_rx_ring).
2.Packet Handling:
Implement packet transmission (nbl_res_txrx_start_xmit), including handling TSO (TCP Segmentation Offload) and checksum offloading. Manage transmit buffers (nbl_unmap_and_free_tx_resource) and receive buffers (nbl_put_rx_frag).
Support multi-queue transmission and reception.
3.Interrupt and NAPI Management:
Provide an interface to get the NAPI structure (nbl_res_txrx_get_vector_napi).
Set interrupt information (nbl_res_txrx_set_vector_info). Trigger receive rings (nbl_res_txrx_kick_rx_ring).
--- .../net/ethernet/nebula-matrix/nbl/Makefile | 1 + .../net/ethernet/nebula-matrix/nbl/nbl_core.h | 14 + .../nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c | 22 +- .../nbl_hw_leonis/nbl_resource_leonis.c | 12 + .../nebula-matrix/nbl/nbl_hw/nbl_resource.h | 4 + .../nebula-matrix/nbl/nbl_hw/nbl_txrx.c | 1613 +++++++++++++++++ .../nebula-matrix/nbl/nbl_hw/nbl_txrx.h | 184 ++ .../nbl/nbl_include/nbl_def_hw.h | 3 + .../nbl/nbl_include/nbl_def_resource.h | 22 + .../nbl/nbl_include/nbl_include.h | 15 + 10 files changed, 1889 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_txrx.c create mode 100644 drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_txrx.h
drivers/net/ethernet/nebula-matrix/nbl/Makefile +1 -0
@@ -12,6 +12,7 @@ nbl_core-objs += nbl_common/nbl_common.o \ nbl_hw/nbl_hw_leonis/nbl_hw_leonis_regs.o \ nbl_hw/nbl_resource.o \ nbl_hw/nbl_interrupt.o \ + nbl_hw/nbl_txrx.o \ nbl_hw/nbl_queue.o \ nbl_hw/nbl_vsi.o \ nbl_core/nbl_dispatch.o \
drivers/net/ethernet/nebula-matrix/nbl/nbl_core.h +14 -0
@@ -38,6 +38,11 @@#define NBL_ADAPTER_TO_RES_PT_OPS (adapter) \ (&(NBL_ADAP_TO_SERV_OPS_TBL(adapter)->pt_ops)) +#define NBL_NETDEV_PRIV_TO_ADAPTER (priv) ((priv)->adapter) + +#define NBL_NETDEV_TO_ADAPTER (netdev) \ + (NBL_NETDEV_PRIV_TO_ADAPTER( \ + (struct nbl_netdev_priv *)netdev_priv(netdev)))#define NBL_CAP_TEST_BIT (val, loc) (((val) >> (loc)) & 0x1)#define NBL_CAP_IS_CTRL (val) NBL_CAP_TEST_BIT(val, NBL_CAP_HAS_CTRL_BIT)
@@ -81,6 +86,15 @@ struct nbl_adapter {struct nbl_init_param init_param; }; +struct nbl_netdev_priv { +struct nbl_adapter *adapter; +struct net_device *netdev; +u16 tx_queue_num; +u16 rx_queue_num; +u16 queue_size; +u16 data_vsi; +}; +struct nbl_adapter *nbl_core_init (struct pci_dev *pdev,struct nbl_init_param *param);void nbl_core_remove (struct nbl_adapter *adapter);
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c +21 -1
@@ -1581,6 +1581,23 @@ static void nbl_hw_cfg_mailbox_qinfo(void *priv, u16 func_id, u16 bus, (u8 *)&mb_qinfo_map, sizeof(mb_qinfo_map)); } +static void nbl_hw_update_tail_ptr (void *priv,struct nbl_notify_param *param) +{ +struct nbl_hw_mgt *hw_mgt = (struct nbl_hw_mgt *)priv; +u8 __iomem *notify_addr = hw_mgt->hw_addr; +u32 local_qid = param->notify_qid; +u32 tail_ptr = param->tail_ptr; + +writel ((((u32 )tail_ptr <<16 ) | (u32 )local_qid), notify_addr); +} + +static u8 __iomem *nbl_hw_get_tail_ptr (void *priv) +{ +struct nbl_hw_mgt *hw_mgt = (struct nbl_hw_mgt *)priv; + +return hw_mgt->hw_addr; +} +static void nbl_hw_set_promisc_mode (void *priv,u16 vsi_id,u16 eth_id,u16 mode) {
@@ -1668,6 +1685,7 @@ static struct nbl_hw_ops hw_ops = { .save_uvn_ctx = nbl_hw_save_uvn_ctx, .setup_queue_switch = nbl_hw_setup_queue_switch, .init_pfc = nbl_hw_init_pfc, + .configure_msix_map = nbl_hw_configure_msix_map, .configure_msix_info = nbl_hw_configure_msix_info,
@@ -1687,11 +1705,13 @@ static struct nbl_hw_ops hw_ops = { .enable_msix_irq = nbl_hw_enable_msix_irq, .get_msix_irq_enable_info = nbl_hw_get_msix_irq_enable_info, + .update_tail_ptr = nbl_hw_update_tail_ptr, + .get_tail_ptr = nbl_hw_get_tail_ptr, + .get_fw_eth_num = nbl_hw_get_fw_eth_num, .get_fw_eth_map = nbl_hw_get_fw_eth_map, .get_board_info = nbl_hw_get_board_info, .get_quirks = nbl_hw_get_quirks, - };/* Structure starts here, adding an op should not modify anything below */
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_resource_leonis.c +12 -0
@@ -236,6 +236,11 @@ static int nbl_res_setup_ops(struct device *dev, ret =nbl_queue_setup_ops_leonis (&res_ops);if (ret) goto setup_fail; + + ret =nbl_txrx_setup_ops (&res_ops); +if (ret) + goto setup_fail; + ret =nbl_intr_setup_ops (&res_ops);if (ret) goto setup_fail;
@@ -442,6 +447,7 @@ static void nbl_res_stop(struct nbl_resource_mgt_leonis *res_mgt_leonis)struct nbl_resource_mgt *res_mgt = &res_mgt_leonis->res_mgt;nbl_queue_mgt_stop (res_mgt); +nbl_txrx_mgt_stop (res_mgt);nbl_intr_mgt_stop (res_mgt);nbl_vsi_mgt_stop (res_mgt);
@@ -497,6 +503,12 @@ static int nbl_res_start(struct nbl_resource_mgt_leonis *res_mgt_leonis,if (ret) goto start_fail; } + +if (caps.has_net) { + ret =nbl_txrx_mgt_start (res_mgt); +if (ret) + goto start_fail; + }return 0 ; start_fail:
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_resource.h +4 -0
@@ -426,6 +426,10 @@ int nbl_intr_setup_ops(struct nbl_resource_ops *resource_ops);int nbl_queue_mgt_start (struct nbl_resource_mgt *res_mgt);void nbl_queue_mgt_stop (struct nbl_resource_mgt *res_mgt); +int nbl_txrx_mgt_start (struct nbl_resource_mgt *res_mgt); +void nbl_txrx_mgt_stop (struct nbl_resource_mgt *res_mgt); +int nbl_txrx_setup_ops (struct nbl_resource_ops *resource_ops); +int nbl_vsi_mgt_start (struct nbl_resource_mgt *res_mgt);void nbl_vsi_mgt_stop (struct nbl_resource_mgt *res_mgt);int nbl_vsi_setup_ops (struct nbl_resource_ops *resource_ops);
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_txrx.c new file +1613 -0
1,613 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_txrx.h new file +184 -0
184 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_hw.h +3 -0
@@ -85,6 +85,9 @@ struct nbl_hw_ops {void (*enable_msix_irq)(void *priv,u16 global_vec_id);u8 __iomem *(*get_msix_irq_enable_info)(void *priv,u16 global_vec_id,u32 *irq_data); +void (*update_tail_ptr)(void *priv,struct nbl_notify_param *param); + u8__iomem *(*get_tail_ptr)(void *priv); +u32 (*get_fw_eth_num)(void *priv);u32 (*get_fw_eth_map)(void *priv);void (*get_board_info)(void *priv,struct nbl_board_port_info *board);
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_resource.h +22 -0
@@ -18,7 +18,10 @@ struct nbl_resource_pt_ops {struct nbl_resource_ops {int (*init_chip_module)(void *priv);void (*deinit_chip_module)(void *priv); +void (*get_resource_pt_ops)(void *priv, +struct nbl_resource_pt_ops *pt_ops);int (*queue_init)(void *priv); +int (*configure_msix_map)(void *priv,u16 func_id,u16 num_net_msix,u16 num_others_msix,bool net_msix_mask_en);int (*destroy_msix_map)(void *priv,u16 func_id);
@@ -26,6 +29,21 @@ struct nbl_resource_ops { bool enable_msix);u16 (*get_global_vector)(void *priv,u16 vsi_id,u16 local_vec_id);u16 (*get_msix_entry_id)(void *priv,u16 vsi_id,u16 local_vec_id); + +int (*alloc_rings)(void *priv,struct net_device *netdev, +struct nbl_ring_param *param); +void (*remove_rings)(void *priv); +dma_addr_t (*start_tx_ring)(void *priv,u8 ring_index); +void (*stop_tx_ring)(void *priv,u8 ring_index); +dma_addr_t (*start_rx_ring)(void *priv,u8 ring_index,bool use_napi); +void (*stop_rx_ring)(void *priv,u8 ring_index); +void (*update_rx_ring)(void *priv,u16 index); +void (*kick_rx_ring)(void *priv,u16 index); +struct nbl_napi_struct *(*get_vector_napi)(void *priv,u16 index); +void (*set_vector_info)(void *priv,u8 __iomem *irq_enable_base, +u32 irq_data,u16 index,bool mask_en); +void (*register_vsi_ring)(void *priv,u16 vsi_index,u16 ring_offset, +u16 ring_num);int (*register_net)(void *priv,u16 func_id,struct nbl_register_net_param *register_param,struct nbl_register_net_result *register_result);
@@ -51,10 +69,14 @@ struct nbl_resource_ops {u8 __iomem *(*get_msix_irq_enable_info)(void *priv,u16 global_vec_id,u32 *irq_data); +u16 (*get_vsi_id)(void *priv,u16 func_id,u16 type);void (*get_eth_id)(void *priv,u16 vsi_id,u8 *eth_mode,u8 *eth_id,u8 *logic_eth_id);int (*set_promisc_mode)(void *priv,u16 vsi_id,u16 mode); +u32 (*get_tx_headroom)(void *priv); + +void (*get_net_stats)(void *priv,struct nbl_stats *queue_stats);void (*get_rxfh_indir_size)(void *priv,u16 vsi_id,u32 *rxfh_indir_size); int (*set_rxfh_indir)(void *priv, u16 vsi_id, const u32 *indir,
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_include.h +15 -0
@@ -42,6 +42,11 @@ enum { NBL_VSI_MAX, }; +enum { +NBL_TX =0 , +NBL_RX , +}; +struct nbl_func_caps {u32 has_ctrl:1 ;u32 has_net:1 ;
@@ -120,6 +125,11 @@ struct nbl_queue_cfg_param {u16 half_offload_en; }; +struct nbl_msix_info_param { +u16 msix_num; +struct msix_entry *msix_entries; +}; +struct nbl_queue_stats {u64 packets;u64 bytes;
@@ -182,6 +192,11 @@ struct nbl_stats {u64 rx_bytes; }; +struct nbl_notify_param { +u16 notify_qid; +u16 tail_ptr; +}; +enum nbl_fw_port_speed {NBL_FW_PORT_SPEED_10G ,NBL_FW_PORT_SPEED_25G ,
Signature · 1 line
2.47.3
illusion.wang
maintainerPATCH v3 10/15 net/nebula-matrix: add txrx interrupt handling logic
In reply to illusion.wangThis patch implements the TX and RX interrupt handling logic:
Transmit (TX) Handling:nbl_res_txrx_clean_tx_irq: Cleans up completed transmit descriptors, frees resources, and updates statistics.
Checks if descriptors are used (via nbl_ring_desc_used). Updates TX packet count, byte count, and descriptor count. Wakes up the TX queue if necessary (netif_wake_subqueue). Receive (RX) Handling:nbl_res_txrx_clean_rx_irq: Processes received packets, constructs sk_buff, and passes them to the upper layer.
Checks if descriptors are used.
Retrieves packet length from the descriptor and gets the RX buffer. Constructs sk_buff (nbl_construct_skb), handles checksum (nbl_rx_csum), and VLAN tags (nbl_rx_vlan_pop).
Reallocates RX buffers if necessary (nbl_alloc_rx_bufs).
--- .../nebula-matrix/nbl/nbl_hw/nbl_txrx.c | 371 ++++++++++++++++++ 1 file changed, 371 insertions(+)
drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_txrx.c +371 -0
@@ -835,6 +835,166 @@ static void nbl_res_txrx_stop_rx_ring(void *priv, u8 ring_index)nbl_debug (res_mgt->common,"Stop rx ring %d" , ring_index); } +static __always_inline bool nbl_ring_desc_used(struct nbl_ring_desc *ring_desc, +bool used_wrap_counter) +{ +bool avail; +bool used; +u16 flags; + + flags =le16_to_cpu (ring_desc->flags); + avail = !!(flags &BIT (NBL_PACKED_DESC_F_AVAIL )); + used = !!(flags &BIT (NBL_PACKED_DESC_F_USED )); + +return avail == used && used == used_wrap_counter; +} + +static int nbl_res_txrx_clean_tx_irq (struct nbl_res_tx_ring *tx_ring) +{ +struct nbl_tx_buffer *tx_buffer; +struct nbl_ring_desc *tx_desc; +unsigned int i = tx_ring->next_to_clean; +unsigned int total_tx_pkts =0 ; +unsigned int total_tx_bytes =0 ; +unsigned int total_tx_descs =0 ; +int count =64 ; + + tx_buffer =NBL_TX_BUF (tx_ring, i); + tx_desc =NBL_TX_DESC (tx_ring, i); + i -= tx_ring->desc_num; + +do { +struct nbl_ring_desc *end_desc = tx_buffer->next_to_watch; + +if (!end_desc) +break ; + +/* smp_rmb */ +smp_rmb (); + +if (!nbl_ring_desc_used (tx_desc, tx_ring->used_wrap_counter)) +break ; + + total_tx_pkts += tx_buffer->gso_segs; + total_tx_bytes += tx_buffer->bytecount; + +while (true) { + total_tx_descs++; +nbl_unmap_and_free_tx_resource (tx_ring, tx_buffer, true, + true); +if (tx_desc == end_desc) +break ; + i++; + tx_buffer++; + tx_desc++; +if (unlikely (!i)) { + i -= tx_ring->desc_num; + tx_buffer =NBL_TX_BUF (tx_ring,0 ); + tx_desc =NBL_TX_DESC (tx_ring,0 ); + tx_ring->used_wrap_counter ^=1 ; + } + } + + tx_buffer++; + tx_desc++; + i++; +if (unlikely (!i)) { + i -= tx_ring->desc_num; + tx_buffer =NBL_TX_BUF (tx_ring,0 ); + tx_desc =NBL_TX_DESC (tx_ring,0 ); + tx_ring->used_wrap_counter ^=1 ; + } + +prefetch (tx_desc); + + }while (--count); + + i += tx_ring->desc_num; + + tx_ring->next_to_clean = i; + +u64_stats_update_begin (&tx_ring->syncp); + tx_ring->stats.bytes += total_tx_bytes; + tx_ring->stats.packets += total_tx_pkts; + tx_ring->stats.descs += total_tx_descs; +u64_stats_update_end (&tx_ring->syncp); +if (nbl_txrx_within_vsi (&tx_ring->vsi_info[NBL_VSI_DATA ], + tx_ring->queue_index)) +netdev_tx_completed_queue (txring_txq (tx_ring), total_tx_pkts, + total_tx_bytes); + +#define TX_WAKE_THRESHOLD (DESC_NEEDED * 2) +if (unlikely (total_tx_pkts &&netif_carrier_ok (tx_ring->netdev) && +nbl_txrx_within_vsi (&tx_ring->vsi_info[NBL_VSI_DATA ], + tx_ring->queue_index) && + (nbl_unused_tx_desc_count (tx_ring) >=TX_WAKE_THRESHOLD ))) { +/* Make sure that anybody stopping the queue after this +* sees the new next_to_clean. +*/ +smp_mb (); + +if (__netif_subqueue_stopped (tx_ring->netdev, + tx_ring->queue_index)) { +netif_wake_subqueue (tx_ring->netdev, + tx_ring->queue_index); +dev_dbg (NBL_RING_TO_DEV (tx_ring),"wake queue %u\n" , + tx_ring->queue_index); + } + } + +return count; +} + +static void nbl_rx_csum (struct nbl_res_rx_ring *rx_ring,struct sk_buff *skb, +struct nbl_rx_extend_head *hdr) +{ + skb->ip_summed =CHECKSUM_NONE ; +skb_checksum_none_assert (skb); + +/* if user disable rx csum Offload, then stack verify the rx csum */ +if (!(rx_ring->netdev->features &NETIF_F_RXCSUM )) +return ; + +if (!hdr->checksum_status) +return ; + +if (hdr->error_code) { + rx_ring->rx_stats.rx_csum_errors++; +return ; + } + + skb->ip_summed =CHECKSUM_UNNECESSARY ; + rx_ring->rx_stats.rx_csum_packets++; +} + +static __always_inline void nbl_add_rx_frag(struct nbl_rx_buffer *rx_buffer, +struct sk_buff *skb, +unsigned int size) +{ +page_ref_inc (rx_buffer->di->page); +skb_add_rx_frag (skb,skb_shinfo (skb)->nr_frags, rx_buffer->di->page, + rx_buffer->offset, size, rx_buffer->size); +} + +static __always_inline int nbl_rx_vlan_pop(struct nbl_res_rx_ring *rx_ring, +struct sk_buff *skb) +{ +struct vlan_ethhdr *veth = (struct vlan_ethhdr *)skb->data; + +if (!rx_ring->vlan_proto) +return 0 ; + +if (rx_ring->vlan_proto !=ntohs (veth->h_vlan_proto) || + (rx_ring->vlan_tci &VLAN_VID_MASK ) != + (ntohs (veth->h_vlan_TCI) &VLAN_VID_MASK )) +return 1 ; + +memmove (skb->data +VLAN_HLEN , skb->data,2 *ETH_ALEN ); +__skb_pull (skb,VLAN_HLEN ); + +return 0 ; +} +static void nbl_txrx_register_vsi_ring (void *priv,u16 vsi_index,u16 ring_offset,u16 ring_num) {
@@ -845,6 +1005,92 @@ static void nbl_txrx_register_vsi_ring(void *priv, u16 vsi_index, txrx_mgt->vsi_info[vsi_index].ring_num = ring_num; } +/* +* Current version support merging multiple descriptor for one packet. +*/ +static struct sk_buff *nbl_construct_skb (struct nbl_res_rx_ring *rx_ring, +struct napi_struct *napi, +struct nbl_rx_buffer *rx_buf, +unsigned int size) +{ +struct sk_buff *skb; +char *p, *buf; +int tailroom, + shinfo_size =SKB_DATA_ALIGN (sizeof (struct skb_shared_info )); +unsigned int truesize = rx_buf->size; +unsigned int headlen; + + p =page_address (rx_buf->di->page) + rx_buf->offset; + buf = p -NBL_RX_PAD ; + p +=NBL_BUFFER_HDR_LEN ; + tailroom = truesize - size -NBL_RX_PAD ; + size -=NBL_BUFFER_HDR_LEN ; + +if (rx_ring->linear_skb && tailroom >= shinfo_size) { + skb =build_skb (buf, truesize); +if (unlikely (!skb)) +return NULL ; + +page_ref_inc (rx_buf->di->page); +skb_reserve (skb, p - buf); +skb_put (skb, size); + goto ok; + } + + skb =napi_alloc_skb (napi,NBL_RX_HDR_SIZE ); +if (unlikely (!skb)) +return NULL ; + + headlen = size; +if (headlen >NBL_RX_HDR_SIZE ) + headlen =eth_get_headlen (skb->dev, p,NBL_RX_HDR_SIZE ); + +memcpy (__skb_put (skb, headlen), p,ALIGN (headlen,sizeof (long ))); + size -= headlen; +if (size) { +page_ref_inc (rx_buf->di->page); +skb_add_rx_frag (skb,0 , rx_buf->di->page, + rx_buf->offset +NBL_BUFFER_HDR_LEN + headlen, + size, truesize); + } +ok: +skb_record_rx_queue (skb, rx_ring->queue_index); + +return skb; +} + +static __always_inline struct nbl_rx_buffer * +nbl_get_rx_buf (struct nbl_res_rx_ring *rx_ring) +{ +struct nbl_rx_buffer *rx_buf; + + rx_buf =NBL_RX_BUF (rx_ring, rx_ring->next_to_clean); +prefetchw (rx_buf->di->page); + +dma_sync_single_range_for_cpu (rx_ring->dma_dev, rx_buf->di->addr, + rx_buf->offset, rx_ring->buf_len, +DMA_FROM_DEVICE ); + +return rx_buf; +} + +static __always_inline void nbl_put_rx_buf(struct nbl_res_rx_ring *rx_ring, +struct nbl_rx_buffer *rx_buf) +{ +u16 ntc = rx_ring->next_to_clean +1 ; + +/* if at the end of the ring, reset ntc and flip used wrap bit */ +if (unlikely (ntc >= rx_ring->desc_num)) { + ntc =0 ; + rx_ring->used_wrap_counter ^=1 ; + } + + rx_ring->next_to_clean = ntc; +prefetch (NBL_RX_DESC (rx_ring, ntc)); + +nbl_put_rx_frag (rx_ring, rx_buf, true); +} + static __always_inline int nbl_maybe_stop_tx(struct nbl_res_tx_ring *tx_ring,unsigned int size) {
@@ -874,6 +1120,130 @@ static __always_inline int nbl_maybe_stop_tx(struct nbl_res_tx_ring *tx_ring,return 0 ; } +static int nbl_res_txrx_clean_rx_irq (struct nbl_res_rx_ring *rx_ring, +struct napi_struct *napi,int budget) +{ +struct nbl_ring_desc *rx_desc; +struct nbl_rx_buffer *rx_buf; +struct nbl_rx_extend_head *hdr; +struct sk_buff *skb =NULL ; +unsigned int total_rx_pkts =0 ; +unsigned int total_rx_bytes =0 ; +unsigned int size; +u32 rx_multicast_packets =0 ; +u32 rx_unicast_packets =0 ; +u16 desc_count =0 ; +u16 num_buffers =0 ; +u16 cleaned_count =nbl_unused_rx_desc_count (rx_ring); +bool failure =0 ; +bool drop =0 ; +u16 tmp; + +while (likely (total_rx_pkts < budget)) { + rx_desc =NBL_RX_DESC (rx_ring, rx_ring->next_to_clean); +if (!nbl_ring_desc_used (rx_desc, rx_ring->used_wrap_counter)) +break ; + +dma_rmb (); + size =le32_to_cpu (rx_desc->len); + rx_buf =nbl_get_rx_buf (rx_ring); + + desc_count++; + +if (skb) { +nbl_add_rx_frag (rx_buf, skb, size); + }else { + hdr =page_address (rx_buf->di->page) + rx_buf->offset; +net_prefetch (hdr); + skb =nbl_construct_skb (rx_ring, napi, rx_buf, size); +if (unlikely (!skb)) { + rx_ring->rx_stats.rx_alloc_buf_err_cnt++; +break ; + } + + num_buffers = (u16 )hdr->num_buffers; +nbl_rx_csum (rx_ring, skb, hdr); + drop =nbl_rx_vlan_pop (rx_ring, skb); + } + + cleaned_count++; +nbl_put_rx_buf (rx_ring, rx_buf); +if (desc_count < num_buffers) +continue ; + desc_count =0 ; + +if (unlikely (eth_skb_pad (skb))) { + skb =NULL ; + drop =0 ; +continue ; + } + +if (unlikely (drop)) { +dev_kfree_skb_any (skb); + skb =NULL ; + drop =0 ; +continue ; + } + + total_rx_bytes += skb->len; + skb->protocol =eth_type_trans (skb, rx_ring->netdev); +if (unlikely (skb->pkt_type ==PACKET_BROADCAST || + skb->pkt_type ==PACKET_MULTICAST )) + rx_multicast_packets++; +else + rx_unicast_packets++; + +napi_gro_receive (napi, skb); + skb =NULL ; + drop =0 ; + total_rx_pkts++; + } + tmp = cleaned_count & (~(NBL_MAX_BATCH_DESC -1 )); +if (tmp) + failure =nbl_alloc_rx_bufs (rx_ring, tmp); + +u64_stats_update_begin (&rx_ring->syncp); + rx_ring->stats.packets += total_rx_pkts; + rx_ring->stats.bytes += total_rx_bytes; + rx_ring->rx_stats.rx_multicast_packets += rx_multicast_packets; + rx_ring->rx_stats.rx_unicast_packets += rx_unicast_packets; +u64_stats_update_end (&rx_ring->syncp); + +return failure ? budget : total_rx_pkts; +} + +static int nbl_res_napi_poll (struct napi_struct *napi,int budget) +{ +struct nbl_napi_struct *nbl_napi = + container_of(napi, struct nbl_napi_struct, napi); +struct nbl_res_vector *vector = + container_of(nbl_napi, struct nbl_res_vector, nbl_napi); +struct nbl_res_tx_ring *tx_ring; +struct nbl_res_rx_ring *rx_ring; +int complete =1 , cleaned =0 , tx_done =1 ; + + tx_ring = vector->tx_ring; + rx_ring = vector->rx_ring; + +if (vector->started) { + tx_done =nbl_res_txrx_clean_tx_irq (tx_ring); + cleaned =nbl_res_txrx_clean_rx_irq (rx_ring, napi, budget); + } + complete = tx_done && (cleaned < budget); +if (!complete) +return budget; + +if (!napi_complete_done (napi, cleaned)) +return min_t (int, cleaned, budget -1 ); + +/* unmask irq passthrough for performace */ +if (vector->net_msix_mask_en) +writel (vector->irq_data, + (void __iomem *)vector->irq_enable_base); + +return min_t (int, cleaned, budget -1 ); +} +static unsigned int nbl_xmit_desc_count (struct sk_buff *skb) {unsigned int nr_frags =skb_shinfo (skb)->nr_frags;
@@ -1416,6 +1786,7 @@ static void nbl_res_txrx_set_vector_info(void *priv,static void nbl_res_get_pt_ops (void *priv,struct nbl_resource_pt_ops *pt_ops) { pt_ops->start_xmit = nbl_res_txrx_start_xmit; + pt_ops->napi_poll = nbl_res_napi_poll; }static u32 nbl_res_txrx_get_tx_headroom (void *priv)
Signature · 1 line
2.47.3
illusion.wang
maintainerPATCH v3 11/15 net/nebula-matrix: add Dispatch layer implementation
In reply to illusion.wangThis patch can have a quick review, function is similar
The primary issue in the Dispatch layer is how to determine the routing approach
Two routing ways:
Dispatch Layer-> Resource Layer -> HW layer
The Dispatch Layer routes tasks to Resource Layer, which may interact with the HW Layer for hardware writes.
Dispatch Layer->Channel Layer
The Dispatch Layers redirects hooks to the Channel Layer.
The primary challenge at the Dispatch layer lies in determining the routing approach, namely, how to decide which interfaces should directly invoke the Resource layer's interfaces and which should transmit requests via channels to the management PF for processing.
To address this, a ctrl_lvl (control level) mechanism is established, which comprises two parts: the control level declared by each interface and the control level configured by the upper layer. The effect is that when the upper layer configures a specific control level, all interfaces declaring this level will directly call the Resource layer's interfaces; otherwise, they will send requests via channels.
For instance, consider a regular PF that possesses network (net) capabilities but lacks control (ctrl) capabilities. It will only configure NET_LVL at the Dispatch layer. In this scenario, all interfaces declaring NET_LVL will directly invoke the Resource layer's interfaces, while those declaring CTRL_LVL will send requests via channels to the management PF. Conversely, if it is the management PF, it will configure both NET_LVL and CTRL_LVL at the Dispatch layer. Consequently, interfaces declaring CTRL_LVL will also directly call the Resource layer's interfaces without sending requests via channels. This configuration logic can be dynamic.(nbl_disp_setup_ctrl_lvl)
--- .../nebula-matrix/nbl/nbl_core/nbl_dispatch.c | 1863 +++++++++++++++++ .../nebula-matrix/nbl/nbl_core/nbl_dispatch.h | 33 + .../nbl/nbl_include/nbl_def_dispatch.h | 58 + 3 files changed, 1954 insertions(+)
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dispatch.c +1863 -0
@@ -6,6 +6,1846 @@#include <linux/etherdevice.h> #include "nbl_dispatch.h" +static int +nbl_disp_chan_register_net_req (void *priv, +struct nbl_register_net_param *register_param, +struct nbl_register_net_result *register_result) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_channel_ops *chan_ops; +struct nbl_chan_param_register_net_info param = {0 }; +struct nbl_chan_send_info chan_send; +struct nbl_common_info *common; +int ret; + + chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); + common =NBL_DISP_MGT_TO_COMMON (disp_mgt); + + param.pf_bar_start = register_param->pf_bar_start; + param.pf_bdf = register_param->pf_bdf; + +NBL_CHAN_SEND (chan_send, common->mgt_pf,NBL_CHAN_MSG_REGISTER_NET , + ¶m,sizeof (param), (void *)register_result, +sizeof (*register_result),1 ); + + ret = chan_ops->send_msg (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), + &chan_send); +return ret; +} + +static void nbl_disp_chan_register_net_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 device *dev =NBL_COMMON_TO_DEV (disp_mgt->common); +struct nbl_resource_ops *res_ops; +struct nbl_channel_ops *chan_ops; +struct nbl_chan_param_register_net_info param; +struct nbl_register_net_result result = {0 }; +struct nbl_register_net_param register_param = {0 }; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_chan_ack_info chan_ack; +int copy_len; +int err =NBL_CHAN_RESP_OK ; +int ret =0 ; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); + +memset (¶m,0 ,sizeof (struct nbl_chan_param_register_net_info )); + copy_len = data_len <sizeof (struct nbl_chan_param_register_net_info ) ? + data_len : +sizeof (struct nbl_chan_param_register_net_info ); +memcpy (¶m, data, copy_len); + + register_param.pf_bar_start = param.pf_bar_start; + register_param.pf_bdf = param.pf_bdf; + + ret =NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->register_net, p, src_id, + ®ister_param, &result); +if (ret) + err =NBL_CHAN_RESP_ERR ; + +NBL_CHAN_ACK (chan_ack, src_id,NBL_CHAN_MSG_REGISTER_NET , msg_id, err, + &result,sizeof (result)); + ret = chan_ops->send_ack (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), + &chan_ack); +if (ret) +dev_err (dev, +"channel send ack failed with ret: %d, msg_type: %d, src_id:%d\n" , + ret,NBL_CHAN_MSG_REGISTER_NET , src_id); +} + +static int nbl_disp_unregister_net (void *priv) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_resource_ops *res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); + +return NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->unregister_net, p,0 ); +} + +static int nbl_disp_chan_unregister_net_req (void *priv) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_channel_ops *chan_ops; +struct nbl_chan_send_info chan_send; +struct nbl_common_info *common; + + chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); + common =NBL_DISP_MGT_TO_COMMON (disp_mgt); + +NBL_CHAN_SEND (chan_send, common->mgt_pf,NBL_CHAN_MSG_UNREGISTER_NET , +NULL ,0 ,NULL ,0 ,1 ); + +return chan_ops->send_msg (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), + &chan_send); +} + +static void nbl_disp_chan_unregister_net_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 device *dev =NBL_COMMON_TO_DEV (disp_mgt->common); +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; +struct nbl_channel_ops *chan_ops; +struct nbl_chan_ack_info chan_ack; +int err =NBL_CHAN_RESP_OK ; +int ret =0 ; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); + + ret =NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->unregister_net, p, + src_id); +if (ret) + err =NBL_CHAN_RESP_ERR ; + +NBL_CHAN_ACK (chan_ack, src_id,NBL_CHAN_MSG_UNREGISTER_NET , msg_id, err, +NULL ,0 ); + ret = chan_ops->send_ack (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), + &chan_ack); +if (ret) +dev_err (dev, +"channel send ack failed with ret: %d, msg_type: %d, src_id:%d\n" , + ret,NBL_CHAN_MSG_UNREGISTER_NET , src_id); +} + +static int nbl_disp_chan_alloc_txrx_queues_req (void *priv,u16 vsi_id, +u16 queue_num) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_channel_ops *chan_ops; +struct nbl_chan_param_alloc_txrx_queues param = {0 }; +struct nbl_chan_param_alloc_txrx_queues result = {0 }; +struct nbl_chan_send_info chan_send; +struct nbl_common_info *common; + + chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); + common =NBL_DISP_MGT_TO_COMMON (disp_mgt); + + param.vsi_id = vsi_id; + param.queue_num = queue_num; + +NBL_CHAN_SEND (chan_send, common->mgt_pf,NBL_CHAN_MSG_ALLOC_TXRX_QUEUES , + ¶m,sizeof (param), &result,sizeof (result),1 ); +return chan_ops->send_msg (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), + &chan_send); +} + +static void nbl_disp_chan_alloc_txrx_queues_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_chan_param_alloc_txrx_queues *param; +struct nbl_chan_param_alloc_txrx_queues result = {0 }; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; +struct nbl_channel_ops *chan_ops; +struct nbl_chan_ack_info chan_ack; +int err =NBL_CHAN_RESP_OK ; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); + + param = (struct nbl_chan_param_alloc_txrx_queues *)data; + result.queue_num = param->queue_num; + + err =NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->alloc_txrx_queues, p, + param->vsi_id, param->queue_num); + +NBL_CHAN_ACK (chan_ack, src_id,NBL_CHAN_MSG_ALLOC_TXRX_QUEUES , msg_id, + err, &result,sizeof (result)); + chan_ops->send_ack (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), &chan_ack); +} + +static void nbl_disp_chan_free_txrx_queues_req (void *priv,u16 vsi_id) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_channel_ops *chan_ops; +struct nbl_chan_send_info chan_send; +struct nbl_common_info *common; + + chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); + common =NBL_DISP_MGT_TO_COMMON (disp_mgt); + +NBL_CHAN_SEND (chan_send, common->mgt_pf,NBL_CHAN_MSG_FREE_TXRX_QUEUES , + &vsi_id,sizeof (vsi_id),NULL ,0 ,1 ); + chan_ops->send_msg (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), &chan_send); +} + +static void nbl_disp_chan_free_txrx_queues_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; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; +struct nbl_channel_ops *chan_ops; +struct nbl_chan_ack_info chan_ack; +int err =NBL_CHAN_RESP_OK ; +u16 vsi_id; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); + vsi_id = *(u16 *)data; + +NBL_OPS_CALL_LOCK (disp_mgt, res_ops->free_txrx_queues, p, vsi_id); + +NBL_CHAN_ACK (chan_ack, src_id,NBL_CHAN_MSG_FREE_TXRX_QUEUES , msg_id, + err,NULL ,0 ); + chan_ops->send_ack (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), &chan_ack); +} + +static int nbl_disp_chan_register_vsi2q_req (void *priv,u16 vsi_index, +u16 vsi_id,u16 queue_offset, +u16 queue_num) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_channel_ops *chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); +struct nbl_common_info *common =NBL_DISP_MGT_TO_COMMON (disp_mgt); +struct nbl_chan_param_register_vsi2q param = {0 }; +struct nbl_chan_send_info chan_send; + + param.vsi_index = vsi_index; + param.vsi_id = vsi_id; + param.queue_offset = queue_offset; + param.queue_num = queue_num; +NBL_CHAN_SEND (chan_send, common->mgt_pf,NBL_CHAN_MSG_REGISTER_VSI2Q , + ¶m,sizeof (param),NULL ,0 ,1 ); +return chan_ops->send_msg (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), + &chan_send); +} + +static void nbl_disp_chan_register_vsi2q_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_resource_ops *res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +struct nbl_channel_ops *chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); +struct nbl_chan_param_register_vsi2q *param =NULL ; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_chan_ack_info chan_ack; +int err =NBL_CHAN_RESP_OK ; + + param = (struct nbl_chan_param_register_vsi2q *)data; + + err =NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->register_vsi2q, p, + param->vsi_index, param->vsi_id, + param->queue_offset, param->queue_num); + +NBL_CHAN_ACK (chan_ack, src_id,NBL_CHAN_MSG_REGISTER_VSI2Q , msg_id, err, +NULL ,0 ); + chan_ops->send_ack (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), &chan_ack); +} + +static int nbl_disp_chan_setup_q2vsi_req (void *priv,u16 vsi_id) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_channel_ops *chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); +struct nbl_common_info *common =NBL_DISP_MGT_TO_COMMON (disp_mgt); +struct nbl_chan_send_info chan_send; + +NBL_CHAN_SEND (chan_send, common->mgt_pf,NBL_CHAN_MSG_SETUP_Q2VSI , + &vsi_id,sizeof (vsi_id),NULL ,0 ,1 ); +return chan_ops->send_msg (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), + &chan_send); +} + +static void nbl_disp_chan_setup_q2vsi_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_resource_ops *res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +struct nbl_channel_ops *chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_chan_ack_info chan_ack; +int err =NBL_CHAN_RESP_OK ; +u16 vsi_id; + + vsi_id = *(u16 *)data; + + err =NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->setup_q2vsi, p, vsi_id); + +NBL_CHAN_ACK (chan_ack, src_id,NBL_CHAN_MSG_SETUP_Q2VSI , msg_id, err, +NULL ,0 ); + chan_ops->send_ack (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), &chan_ack); +} + +static void nbl_disp_chan_remove_q2vsi_req (void *priv,u16 vsi_id) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_channel_ops *chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); +struct nbl_common_info *common =NBL_DISP_MGT_TO_COMMON (disp_mgt); +struct nbl_chan_send_info chan_send; + +NBL_CHAN_SEND (chan_send, common->mgt_pf,NBL_CHAN_MSG_REMOVE_Q2VSI , + &vsi_id,sizeof (vsi_id),NULL ,0 ,1 ); + chan_ops->send_msg (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), &chan_send); +} + +static void nbl_disp_chan_remove_q2vsi_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_resource_ops *res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +struct nbl_channel_ops *chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_chan_ack_info chan_ack; +int err =NBL_CHAN_RESP_OK ; +u16 vsi_id; + + vsi_id = *(u16 *)data; + +NBL_OPS_CALL_LOCK (disp_mgt, res_ops->remove_q2vsi, p, vsi_id); + +NBL_CHAN_ACK (chan_ack, src_id,NBL_CHAN_MSG_REMOVE_Q2VSI , msg_id, err, +NULL ,0 ); + chan_ops->send_ack (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), &chan_ack); +} + +static int nbl_disp_chan_setup_rss_req (void *priv,u16 vsi_id) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_channel_ops *chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); +struct nbl_common_info *common =NBL_DISP_MGT_TO_COMMON (disp_mgt); +struct nbl_chan_send_info chan_send; + +NBL_CHAN_SEND (chan_send, common->mgt_pf,NBL_CHAN_MSG_SETUP_RSS , + &vsi_id,sizeof (vsi_id),NULL ,0 ,1 ); +return chan_ops->send_msg (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), + &chan_send); +} + +static void nbl_disp_chan_setup_rss_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_resource_ops *res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +struct nbl_channel_ops *chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); +struct nbl_chan_ack_info chan_ack; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +int err =NBL_CHAN_RESP_OK ; +u16 vsi_id; + + vsi_id = *(u16 *)data; + err =NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->setup_rss, p, vsi_id); + +NBL_CHAN_ACK (chan_ack, src_id,NBL_CHAN_MSG_SETUP_RSS , msg_id, err, +NULL ,0 ); + chan_ops->send_ack (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), &chan_ack); +} + +static void nbl_disp_chan_remove_rss_req (void *priv,u16 vsi_id) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_channel_ops *chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); +struct nbl_common_info *common =NBL_DISP_MGT_TO_COMMON (disp_mgt); +struct nbl_chan_send_info chan_send; + +NBL_CHAN_SEND (chan_send, common->mgt_pf,NBL_CHAN_MSG_REMOVE_RSS , + &vsi_id,sizeof (vsi_id),NULL ,0 ,1 ); + chan_ops->send_msg (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), &chan_send); +} + +static void nbl_disp_chan_remove_rss_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_resource_ops *res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +struct nbl_channel_ops *chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_chan_ack_info chan_ack; +int err =NBL_CHAN_RESP_OK ; +u16 vsi_id; + + vsi_id = *(u16 *)data; + +NBL_OPS_CALL_LOCK (disp_mgt, res_ops->remove_rss, p, vsi_id); + +NBL_CHAN_ACK (chan_ack, src_id,NBL_CHAN_MSG_REMOVE_RSS , msg_id, err, +NULL ,0 ); + chan_ops->send_ack (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), &chan_ack); +} + +static int nbl_disp_chan_setup_queue_req (void *priv, +struct nbl_txrx_queue_param *_param, +bool is_tx) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_channel_ops *chan_ops; +struct nbl_chan_param_setup_queue param; +struct nbl_chan_send_info chan_send; +struct nbl_common_info *common; + + chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); + common =NBL_DISP_MGT_TO_COMMON (disp_mgt); + +memcpy (¶m.queue_param, _param,sizeof (param.queue_param)); + param.is_tx = is_tx; + +NBL_CHAN_SEND (chan_send, common->mgt_pf,NBL_CHAN_MSG_SETUP_QUEUE , + ¶m,sizeof (param),NULL ,0 ,1 ); +return chan_ops->send_msg (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), + &chan_send); +} + +static void nbl_disp_chan_setup_queue_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; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; +struct nbl_channel_ops *chan_ops; +struct nbl_chan_param_setup_queue *param; +struct nbl_chan_ack_info chan_ack; +int err =NBL_CHAN_RESP_OK ; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); + + param = (struct nbl_chan_param_setup_queue *)data; + + err =NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->setup_queue, p, + ¶m->queue_param, param->is_tx); + +NBL_CHAN_ACK (chan_ack, src_id,NBL_CHAN_MSG_SETUP_QUEUE , msg_id, err, +NULL ,0 ); + chan_ops->send_ack (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), &chan_ack); +} + +static void nbl_disp_chan_remove_all_queues_req (void *priv,u16 vsi_id) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_channel_ops *chan_ops; +struct nbl_chan_send_info chan_send; +struct nbl_common_info *common; + + chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); + common =NBL_DISP_MGT_TO_COMMON (disp_mgt); + +NBL_CHAN_SEND (chan_send, common->mgt_pf,NBL_CHAN_MSG_REMOVE_ALL_QUEUES , + &vsi_id,sizeof (vsi_id),NULL ,0 ,1 ); + chan_ops->send_msg (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), &chan_send); +} + +static void nbl_disp_chan_remove_all_queues_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; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; +struct nbl_channel_ops *chan_ops; +struct nbl_chan_ack_info chan_ack; +int err =NBL_CHAN_RESP_OK ; +u16 vsi_id; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); + + vsi_id = *(u16 *)data; +NBL_OPS_CALL_LOCK (disp_mgt, res_ops->remove_all_queues, p, vsi_id); + +NBL_CHAN_ACK (chan_ack, src_id,NBL_CHAN_MSG_REMOVE_ALL_QUEUES , msg_id, + err,NULL ,0 ); + chan_ops->send_ack (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), &chan_ack); +} + +static int nbl_disp_chan_cfg_dsch_req (void *priv,u16 vsi_id,bool vld) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_channel_ops *chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); +struct nbl_common_info *common =NBL_DISP_MGT_TO_COMMON (disp_mgt); +struct nbl_chan_param_cfg_dsch param = {0 }; +struct nbl_chan_send_info chan_send; + + param.vsi_id = vsi_id; + param.vld = vld; + +NBL_CHAN_SEND (chan_send, common->mgt_pf,NBL_CHAN_MSG_CFG_DSCH , ¶m, +sizeof (param),NULL ,0 ,1 ); +return chan_ops->send_msg (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), + &chan_send); +} + +static void nbl_disp_chan_cfg_dsch_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; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; +struct nbl_channel_ops *chan_ops; +struct nbl_chan_param_cfg_dsch *param; +struct nbl_chan_ack_info chan_ack; +int err =NBL_CHAN_RESP_OK ; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); + + param = (struct nbl_chan_param_cfg_dsch *)data; + + err =NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->cfg_dsch, p, + param->vsi_id, param->vld); + +NBL_CHAN_ACK (chan_ack, src_id,NBL_CHAN_MSG_CFG_DSCH , msg_id, err,NULL , +0 ); + chan_ops->send_ack (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), &chan_ack); +} + +static int nbl_disp_setup_cqs (void *priv,u16 vsi_id,u16 real_qps, +bool rss_indir_set) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; +int ret; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + ret =NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->setup_cqs, p, vsi_id, + real_qps, rss_indir_set); +return ret; +} + +static int nbl_disp_chan_setup_cqs_req (void *priv,u16 vsi_id,u16 real_qps, +bool rss_indir_set) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_channel_ops *chan_ops; +struct nbl_chan_param_setup_cqs param = {0 }; +struct nbl_chan_send_info chan_send; +struct nbl_common_info *common; + + chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); + common =NBL_DISP_MGT_TO_COMMON (disp_mgt); + + param.vsi_id = vsi_id; + param.real_qps = real_qps; + param.rss_indir_set = rss_indir_set; + +NBL_CHAN_SEND (chan_send, common->mgt_pf,NBL_CHAN_MSG_SETUP_CQS , ¶m, +sizeof (param),NULL ,0 ,1 ); +return chan_ops->send_msg (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), + &chan_send); +} + +static void nbl_disp_chan_setup_cqs_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; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; +struct nbl_channel_ops *chan_ops; +struct nbl_chan_param_setup_cqs param; +struct nbl_chan_ack_info chan_ack; +int copy_len; +int err =NBL_CHAN_RESP_OK ; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); + +memset (¶m,0 ,sizeof (struct nbl_chan_param_setup_cqs )); + param.rss_indir_set = true; + copy_len = data_len <sizeof (struct nbl_chan_param_setup_cqs ) ? + data_len : +sizeof (struct nbl_chan_param_setup_cqs ); +memcpy (¶m, data, copy_len); + + err =NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->setup_cqs, p, + param.vsi_id, param.real_qps, + param.rss_indir_set); + +NBL_CHAN_ACK (chan_ack, src_id,NBL_CHAN_MSG_SETUP_CQS , msg_id, err, +NULL ,0 ); + chan_ops->send_ack (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), &chan_ack); +} + +static void nbl_disp_chan_remove_cqs_req (void *priv,u16 vsi_id) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_channel_ops *chan_ops; +struct nbl_chan_send_info chan_send; +struct nbl_common_info *common; + + chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); + common =NBL_DISP_MGT_TO_COMMON (disp_mgt); + +NBL_CHAN_SEND (chan_send, common->mgt_pf,NBL_CHAN_MSG_REMOVE_CQS , + &vsi_id,sizeof (vsi_id),NULL ,0 ,1 ); + chan_ops->send_msg (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), &chan_send); +} + +static void nbl_disp_chan_remove_cqs_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; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; +struct nbl_channel_ops *chan_ops; +struct nbl_chan_ack_info chan_ack; +int err =NBL_CHAN_RESP_OK ; +u16 vsi_id; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); + + vsi_id = *(u16 *)data; +NBL_OPS_CALL_LOCK (disp_mgt, res_ops->remove_cqs, p, vsi_id); + +NBL_CHAN_ACK (chan_ack, src_id,NBL_CHAN_MSG_REMOVE_CQS , msg_id, err, +NULL ,0 ); + chan_ops->send_ack (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), &chan_ack); +} + +static int nbl_disp_set_promisc_mode (void *priv,u16 vsi_id,u16 mode) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; +int ret =0 ; + +if (!disp_mgt) +return -EINVAL ; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + ret =NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->set_promisc_mode, p, + vsi_id, mode); +return ret; +} + +static int nbl_disp_chan_set_promisc_mode_req (void *priv,u16 vsi_id,u16 mode) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_channel_ops *chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); +struct nbl_common_info *common =NBL_DISP_MGT_TO_COMMON (disp_mgt); +struct nbl_chan_param_set_promisc_mode param = {0 }; +struct nbl_chan_send_info chan_send = {0 }; + + param.vsi_id = vsi_id; + param.mode = mode; + +NBL_CHAN_SEND (chan_send, common->mgt_pf,NBL_CHAN_MSG_SET_PROSISC_MODE , + ¶m,sizeof (param),NULL ,0 ,1 ); +return chan_ops->send_msg (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), + &chan_send); +} + +static void nbl_disp_chan_set_promisc_mode_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_resource_ops *res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +struct nbl_channel_ops *chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_chan_param_set_promisc_mode *param =NULL ; +struct nbl_chan_ack_info chan_ack; +int err =NBL_CHAN_RESP_OK ; + + param = (struct nbl_chan_param_set_promisc_mode *)data; + err =NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->set_promisc_mode, p, + param->vsi_id, param->mode); + +NBL_CHAN_ACK (chan_ack, src_id,NBL_CHAN_MSG_SET_PROSISC_MODE , msg_id, + err,NULL ,0 ); + chan_ops->send_ack (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), &chan_ack); +} + +static void nbl_disp_chan_get_rxfh_indir_size_req (void *priv,u16 vsi_id, +u32 *rxfh_indir_size) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_channel_ops *chan_ops; +struct nbl_chan_send_info chan_send = {0 }; +struct nbl_common_info *common; + + chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); + common =NBL_DISP_MGT_TO_COMMON (disp_mgt); + +NBL_CHAN_SEND (chan_send, common->mgt_pf, +NBL_CHAN_MSG_GET_RXFH_INDIR_SIZE , &vsi_id,sizeof (vsi_id), + rxfh_indir_size,sizeof (u32),1 ); + chan_ops->send_msg (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), &chan_send); +} + +static void nbl_disp_chan_get_rxfh_indir_size_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; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; +struct nbl_channel_ops *chan_ops; +struct nbl_chan_ack_info chan_ack; +u32 rxfh_indir_size =0 ; +int ret =NBL_CHAN_RESP_OK ; +u16 vsi_id; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); + + vsi_id = *(u16 *)data; +NBL_OPS_CALL (res_ops->get_rxfh_indir_size, + (p, vsi_id, &rxfh_indir_size)); +NBL_CHAN_ACK (chan_ack, src_id,NBL_CHAN_MSG_GET_RXFH_INDIR_SIZE , msg_id, + ret, &rxfh_indir_size,sizeof (u32)); + chan_ops->send_ack (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), &chan_ack); +} + +static void nbl_disp_chan_clear_queues_req (void *priv,u16 vsi_id) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_channel_ops *chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); +struct nbl_chan_send_info chan_send = {0 }; +struct nbl_common_info *common; + + common =NBL_DISP_MGT_TO_COMMON (disp_mgt); + +NBL_CHAN_SEND (chan_send, common->mgt_pf,NBL_CHAN_MSG_CLEAR_QUEUE , + &vsi_id,sizeof (vsi_id),NULL ,0 ,1 ); + chan_ops->send_msg (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), &chan_send); +} + +static void nbl_disp_chan_clear_queues_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_resource_ops *res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +struct nbl_channel_ops *chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_chan_ack_info chan_ack; +u16 *vsi_id = (u16 *)data; + +NBL_OPS_CALL_LOCK (disp_mgt, res_ops->clear_queues, p, *vsi_id); + +NBL_CHAN_ACK (chan_ack, src_id,NBL_CHAN_MSG_CLEAR_QUEUE , msg_id, +NBL_CHAN_RESP_OK ,NULL ,0 ); + chan_ops->send_ack (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), &chan_ack); +} + +static u16 nbl_disp_chan_get_vsi_id_req (void *priv,u16 func_id,u16 type) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_channel_ops *chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); +struct nbl_common_info *common =NBL_DISP_MGT_TO_COMMON (disp_mgt); +struct nbl_chan_param_get_vsi_id param = {0 }; +struct nbl_chan_param_get_vsi_id result = {0 }; +struct nbl_chan_send_info chan_send; + + param.type = type; + +NBL_CHAN_SEND (chan_send, common->mgt_pf,NBL_CHAN_MSG_GET_VSI_ID , + ¶m,sizeof (param), &result,sizeof (result),1 ); + chan_ops->send_msg (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), &chan_send); + +return result.vsi_id; +} + +static void nbl_disp_chan_get_vsi_id_resp (void *priv,u16 src_id,u16 msg_id, +void *data,u32 data_len) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_resource_ops *res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +struct nbl_channel_ops *chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); +struct device *dev =NBL_COMMON_TO_DEV (disp_mgt->common); +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_chan_param_get_vsi_id *param; +struct nbl_chan_param_get_vsi_id result; +struct nbl_chan_ack_info chan_ack; +int err =NBL_CHAN_RESP_OK ; +int ret =0 ; + + param = (struct nbl_chan_param_get_vsi_id *)data; + + result.vsi_id = +NBL_OPS_CALL_RET (res_ops->get_vsi_id, (p, src_id, param->type)); + +NBL_CHAN_ACK (chan_ack, src_id,NBL_CHAN_MSG_GET_VSI_ID , msg_id, err, + &result,sizeof (result)); + ret = chan_ops->send_ack (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), + &chan_ack); +if (ret) +dev_err (dev, +"channel send ack failed with ret: %d, msg_type: %d\n" , + ret,NBL_CHAN_MSG_GET_VSI_ID ); +} + +static void nbl_disp_chan_get_eth_id_req (void *priv,u16 vsi_id,u8 *eth_mode, +u8 *eth_id,u8 *logic_eth_id) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_channel_ops *chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); +struct nbl_chan_param_get_eth_id param = {0 }; +struct nbl_chan_param_get_eth_id result = {0 }; +struct nbl_chan_send_info chan_send; +struct nbl_common_info *common; + + common =NBL_DISP_MGT_TO_COMMON (disp_mgt); + + param.vsi_id = vsi_id; + +NBL_CHAN_SEND (chan_send, common->mgt_pf,NBL_CHAN_MSG_GET_ETH_ID , + ¶m,sizeof (param), &result,sizeof (result),1 ); + chan_ops->send_msg (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), &chan_send); + + *eth_mode = result.eth_mode; + *eth_id = result.eth_id; + *logic_eth_id = result.logic_eth_id; +} + +static void nbl_disp_chan_get_eth_id_resp (void *priv,u16 src_id,u16 msg_id, +void *data,u32 data_len) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_resource_ops *res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +struct nbl_channel_ops *chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); +struct device *dev =NBL_COMMON_TO_DEV (disp_mgt->common); +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_chan_param_get_eth_id *param; +struct nbl_chan_param_get_eth_id result = {0 }; +struct nbl_chan_ack_info chan_ack; +int err =NBL_CHAN_RESP_OK ; +int ret =0 ; + + param = (struct nbl_chan_param_get_eth_id *)data; + +NBL_OPS_CALL (res_ops->get_eth_id, + (p, param->vsi_id, &result.eth_mode, &result.eth_id, + &result.logic_eth_id)); + +NBL_CHAN_ACK (chan_ack, src_id,NBL_CHAN_MSG_GET_ETH_ID , msg_id, err, + &result,sizeof (result)); + ret = chan_ops->send_ack (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), + &chan_ack); +if (ret) +dev_err (dev, +"channel send ack failed with ret: %d, msg_type: %d\n" , + ret,NBL_CHAN_MSG_GET_ETH_ID ); +} + +static int nbl_disp_alloc_rings (void *priv,struct net_device *netdev, +struct nbl_ring_param *ring_param) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; +int ret =0 ; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + ret =NBL_OPS_CALL_RET (res_ops->alloc_rings, (p, netdev, ring_param)); +return ret; +} + +static void nbl_disp_remove_rings (void *priv) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_resource_ops *res_ops; + +if (!disp_mgt) +return ; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +NBL_OPS_CALL (res_ops->remove_rings, + (NBL_DISP_MGT_TO_RES_PRIV (disp_mgt))); +} + +static dma_addr_t nbl_disp_start_tx_ring (void *priv,u8 ring_index) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; +dma_addr_t addr =0 ; + +if (!disp_mgt) +return -EINVAL ; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + addr =NBL_OPS_CALL_RET (res_ops->start_tx_ring, (p, ring_index)); +return addr; +} + +static void nbl_disp_stop_tx_ring (void *priv,u8 ring_index) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; + +if (!disp_mgt) +return ; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +NBL_OPS_CALL (res_ops->stop_tx_ring, (p, ring_index)); +} + +static dma_addr_t nbl_disp_start_rx_ring (void *priv,u8 ring_index, +bool use_napi) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; +dma_addr_t addr =0 ; + +if (!disp_mgt) +return -EINVAL ; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + addr =NBL_OPS_CALL_RET (res_ops->start_rx_ring, + (p, ring_index, use_napi)); + +return addr; +} + +static void nbl_disp_stop_rx_ring (void *priv,u8 ring_index) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; + +if (!disp_mgt) +return ; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +NBL_OPS_CALL (res_ops->stop_rx_ring, (p, ring_index)); +} + +static void nbl_disp_kick_rx_ring (void *priv,u16 index) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +NBL_OPS_CALL (res_ops->kick_rx_ring, (p, index)); +} + +static struct nbl_napi_struct *nbl_disp_get_vector_napi (void *priv,u16 index) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +return NBL_OPS_CALL_RET_PTR (res_ops->get_vector_napi, (p, index)); +} + +static void nbl_disp_set_vector_info (void *priv,u8 __iomem *irq_enable_base, +u32 irq_data,u16 index,bool mask_en) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +NBL_OPS_CALL (res_ops->set_vector_info, + (p, irq_enable_base, irq_data, index, mask_en)); +} + +static void nbl_disp_register_vsi_ring (void *priv,u16 vsi_index, +u16 ring_offset,u16 ring_num) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_resource_ops *res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); + +NBL_OPS_CALL (res_ops->register_vsi_ring, + (p, vsi_index, ring_offset, ring_num)); +} + +static void nbl_disp_get_res_pt_ops (void *priv, +struct nbl_resource_pt_ops *pt_ops) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +NBL_OPS_CALL (res_ops->get_resource_pt_ops, (p, pt_ops)); +} + +static int +nbl_disp_register_net (void *priv,struct nbl_register_net_param *register_param, +struct nbl_register_net_result *register_result) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; +int ret =0 ; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + ret =NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->register_net, p,0 , + register_param, register_result); +return ret; +} + +static int nbl_disp_alloc_txrx_queues (void *priv,u16 vsi_id,u16 queue_num) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; +int ret =0 ; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + ret =NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->alloc_txrx_queues, p, + vsi_id, queue_num); +return ret; +} + +static void nbl_disp_free_txrx_queues (void *priv,u16 vsi_id) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +NBL_OPS_CALL_LOCK (disp_mgt, res_ops->free_txrx_queues, p, vsi_id); +} + +static int nbl_disp_register_vsi2q (void *priv,u16 vsi_index,u16 vsi_id, +u16 queue_offset,u16 queue_num) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_resource_ops *res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); + +return NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->register_vsi2q, p, + vsi_index, vsi_id, queue_offset, + queue_num); +} + +static int nbl_disp_setup_q2vsi (void *priv,u16 vsi_id) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_resource_ops *res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); + +return NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->setup_q2vsi, p, vsi_id); +} + +static void nbl_disp_remove_q2vsi (void *priv,u16 vsi_id) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_resource_ops *res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); + +NBL_OPS_CALL_LOCK (disp_mgt, res_ops->remove_q2vsi, p, vsi_id); +} + +static int nbl_disp_setup_rss (void *priv,u16 vsi_id) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_resource_ops *res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); + +return NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->setup_rss, p, vsi_id); +} + +static void nbl_disp_remove_rss (void *priv,u16 vsi_id) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_resource_ops *res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); + +NBL_OPS_CALL_LOCK (disp_mgt, res_ops->remove_rss, p, vsi_id); +} + +static int nbl_disp_setup_queue (void *priv,struct nbl_txrx_queue_param *param, +bool is_tx) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; +int ret =0 ; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + ret =NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->setup_queue, p, param, + is_tx); +return ret; +} + +static void nbl_disp_remove_all_queues (void *priv,u16 vsi_id) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +NBL_OPS_CALL_LOCK (disp_mgt, res_ops->remove_all_queues, p, vsi_id); +} + +static int nbl_disp_cfg_dsch (void *priv,u16 vsi_id,bool vld) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; +int ret =0 ; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + ret =NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->cfg_dsch, p, vsi_id, + vld); +return ret; +} + +static void nbl_disp_remove_cqs (void *priv,u16 vsi_id) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +NBL_OPS_CALL_LOCK (disp_mgt, res_ops->remove_cqs, p, vsi_id); +} + +static u8 __iomem * +nbl_disp_get_msix_irq_enable_info (void *priv,u16 global_vec_id,u32 *irq_data) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; + +if (!disp_mgt) +return NULL ; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +return NBL_OPS_CALL_RET_PTR (res_ops->get_msix_irq_enable_info, + (p, global_vec_id, irq_data)); +} + +static void nbl_disp_get_net_stats (void *priv,struct nbl_stats *net_stats) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +NBL_OPS_CALL (res_ops->get_net_stats, (p, net_stats)); +} + +static void nbl_disp_get_rxfh_indir_size (void *priv,u16 vsi_id, +u32 *rxfh_indir_size) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +NBL_OPS_CALL (res_ops->get_rxfh_indir_size, + (p, vsi_id, rxfh_indir_size)); +} + +static int nbl_disp_set_rxfh_indir (void *priv,u16 vsi_id,const u32 *indir, +u32 indir_size) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; +int ret =0 ; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + ret =NBL_OPS_CALL_RET (res_ops->set_rxfh_indir, + (p, vsi_id, indir, indir_size)); +return ret; +} + +static int nbl_disp_chan_set_rxfh_indir_req (void *priv,u16 vsi_id, +const u32 *indir,u32 indir_size) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_chan_param_set_rxfh_indir *param =NULL ; +struct nbl_chan_send_info chan_send = {0 }; +struct nbl_channel_ops *chan_ops; +struct nbl_common_info *common; +int ret =0 ; + + chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); + common =NBL_DISP_MGT_TO_COMMON (disp_mgt); + + param =kzalloc (sizeof (*param),GFP_KERNEL ); +if (!param) +return -ENOMEM ; + + param->vsi_id = vsi_id; + param->indir_size = indir_size; +memcpy (param->indir, indir, indir_size *sizeof (param->indir[0 ])); + +NBL_CHAN_SEND (chan_send,NBL_COMMON_TO_MGT_PF (common), +NBL_CHAN_MSG_SET_RXFH_INDIR , param,sizeof (*param),NULL , +0 ,1 ); + ret = chan_ops->send_msg (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), + &chan_send); +kfree (param); +return ret; +} + +static void nbl_disp_chan_set_rxfh_indir_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_resource_ops *res_ops; +struct nbl_channel_ops *chan_ops; +struct nbl_chan_param_set_rxfh_indir *param; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_chan_ack_info chan_ack; +int err =NBL_CHAN_RESP_OK ; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); + param = (struct nbl_chan_param_set_rxfh_indir *)data; + + err =NBL_OPS_CALL_RET (res_ops->set_rxfh_indir, + (p, param->vsi_id, param->indir, + param->indir_size)); +NBL_CHAN_ACK (chan_ack, src_id,NBL_CHAN_MSG_SET_RXFH_INDIR , msg_id, err, +NULL ,0 ); + chan_ops->send_ack (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), &chan_ack); +} + +static void nbl_disp_deinit_chip_module (void *priv) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_resource_ops *res_ops; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +NBL_OPS_CALL (res_ops->deinit_chip_module, + (NBL_DISP_MGT_TO_RES_PRIV (disp_mgt))); +} + +static int nbl_disp_init_chip_module (void *priv) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_resource_ops *res_ops; +int ret; + +if (!disp_mgt) +return -EINVAL ; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + ret =NBL_OPS_CALL_RET (res_ops->init_chip_module, + (NBL_DISP_MGT_TO_RES_PRIV (disp_mgt))); +return ret; +} + +static int nbl_disp_queue_init (void *priv) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_resource_ops *res_ops; +int ret; + +if (!disp_mgt) +return -EINVAL ; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + ret =NBL_OPS_CALL_RET (res_ops->queue_init, + (NBL_DISP_MGT_TO_RES_PRIV (disp_mgt))); +return ret; +} + +static int nbl_disp_configure_msix_map (void *priv,u16 num_net_msix, +u16 num_others_msix, +bool net_msix_mask_en) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; +int ret; + +if (!disp_mgt) +return -EINVAL ; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + ret =NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->configure_msix_map, p,0 , + num_net_msix, num_others_msix, + net_msix_mask_en); +return ret; +} + +static int nbl_disp_chan_configure_msix_map_req (void *priv,u16 num_net_msix, +u16 num_others_msix, +bool net_msix_mask_en) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_chan_param_cfg_msix_map param = {0 }; +struct nbl_channel_ops *chan_ops; +struct nbl_chan_send_info chan_send; +struct nbl_common_info *common; + +if (!disp_mgt) +return -EINVAL ; + + chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); + common =NBL_DISP_MGT_TO_COMMON (disp_mgt); + + param.num_net_msix = num_net_msix; + param.num_others_msix = num_others_msix; + param.msix_mask_en = net_msix_mask_en; + +NBL_CHAN_SEND (chan_send, common->mgt_pf, +NBL_CHAN_MSG_CONFIGURE_MSIX_MAP , ¶m,sizeof (param), +NULL ,0 ,1 ); +return chan_ops->send_msg (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), + &chan_send); +} + +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 device *dev =NBL_COMMON_TO_DEV (disp_mgt->common); +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; +struct nbl_channel_ops *chan_ops; +struct nbl_chan_param_cfg_msix_map *param; +struct nbl_chan_ack_info chan_ack; +int err =NBL_CHAN_RESP_OK ; +int ret; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); + param = (struct nbl_chan_param_cfg_msix_map *)data; + + ret =NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->configure_msix_map, p, + src_id, param->num_net_msix, + param->num_others_msix, + param->msix_mask_en); +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 (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), + &chan_ack); +if (ret) +dev_err (dev, +"channel send ack failed with ret: %d, msg_type: %d\n" , + ret,NBL_CHAN_MSG_CONFIGURE_MSIX_MAP ); +} + +static int nbl_disp_chan_destroy_msix_map_req (void *priv) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_channel_ops *chan_ops; +struct nbl_chan_send_info chan_send; +struct nbl_common_info *common; + +if (!disp_mgt) +return -EINVAL ; + + chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); + common =NBL_DISP_MGT_TO_COMMON (disp_mgt); + +NBL_CHAN_SEND (chan_send, common->mgt_pf,NBL_CHAN_MSG_DESTROY_MSIX_MAP , +NULL ,0 ,NULL ,0 ,1 ); +return chan_ops->send_msg (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), + &chan_send); +} + +static void nbl_disp_chan_destroy_msix_map_resp (void *priv,u16 src_id, +u16 msg_id,void *data, +u32 data_len) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct device *dev =NBL_COMMON_TO_DEV (disp_mgt->common); +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; +struct nbl_channel_ops *chan_ops; +struct nbl_chan_ack_info chan_ack; +int err =NBL_CHAN_RESP_OK ; +int ret; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); + + ret =NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->destroy_msix_map, p, + src_id); +if (ret) + err =NBL_CHAN_RESP_ERR ; + +NBL_CHAN_ACK (chan_ack, src_id,NBL_CHAN_MSG_DESTROY_MSIX_MAP , msg_id, + err,NULL ,0 ); + ret = chan_ops->send_ack (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), + &chan_ack); +if (ret) +dev_err (dev, +"channel send ack failed with ret: %d, msg_type: %d\n" , + ret,NBL_CHAN_MSG_DESTROY_MSIX_MAP ); +} + +static int nbl_disp_chan_enable_mailbox_irq_req (void *priv,u16 vector_id, +bool enable_msix) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_channel_ops *chan_ops; +struct nbl_chan_param_enable_mailbox_irq param = {0 }; +struct nbl_chan_send_info chan_send; +struct nbl_common_info *common; + +if (!disp_mgt) +return -EINVAL ; + + chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); + common =NBL_DISP_MGT_TO_COMMON (disp_mgt); + + param.vector_id = vector_id; + param.enable_msix = enable_msix; + +NBL_CHAN_SEND (chan_send, common->mgt_pf, +NBL_CHAN_MSG_MAILBOX_ENABLE_IRQ , ¶m,sizeof (param), +NULL ,0 ,1 ); +return chan_ops->send_msg (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), + &chan_send); +} + +static void nbl_disp_chan_enable_mailbox_irq_resp (void *priv,u16 src_id, +u16 msg_id,void *data, +u32 data_len) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct device *dev =NBL_COMMON_TO_DEV (disp_mgt->common); +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; +struct nbl_channel_ops *chan_ops; +struct nbl_chan_param_enable_mailbox_irq *param; +struct nbl_chan_ack_info chan_ack; +int err =NBL_CHAN_RESP_OK ; +int ret; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); + param = (struct nbl_chan_param_enable_mailbox_irq *)data; + + ret =NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->enable_mailbox_irq, p, + src_id, param->vector_id, + param->enable_msix); +if (ret) + err =NBL_CHAN_RESP_ERR ; + +NBL_CHAN_ACK (chan_ack, src_id,NBL_CHAN_MSG_MAILBOX_ENABLE_IRQ , msg_id, + err,NULL ,0 ); + ret = chan_ops->send_ack (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), + &chan_ack); +if (ret) +dev_err (dev, +"channel send ack failed with ret: %d, msg_type: %d\n" , + ret,NBL_CHAN_MSG_MAILBOX_ENABLE_IRQ ); +} + +static u16 nbl_disp_chan_get_global_vector_req (void *priv,u16 vsi_id, +u16 local_vec_id) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_channel_ops *chan_ops; +struct nbl_chan_param_get_global_vector param = {0 }; +struct nbl_chan_param_get_global_vector result = {0 }; +struct nbl_chan_send_info chan_send; +struct nbl_common_info *common; + +if (!disp_mgt) +return -EINVAL ; + + chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); + common =NBL_DISP_MGT_TO_COMMON (disp_mgt); + + param.vsi_id = vsi_id; + param.vector_id = local_vec_id; + +NBL_CHAN_SEND (chan_send, common->mgt_pf,NBL_CHAN_MSG_GET_GLOBAL_VECTOR , + ¶m,sizeof (param), &result,sizeof (result),1 ); + chan_ops->send_msg (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), &chan_send); + +return result.vector_id; +} + +static void nbl_disp_chan_get_global_vector_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 device *dev =NBL_COMMON_TO_DEV (disp_mgt->common); +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; +struct nbl_channel_ops *chan_ops; +struct nbl_chan_param_get_global_vector *param; +struct nbl_chan_param_get_global_vector result; +struct nbl_chan_ack_info chan_ack; +int err =NBL_CHAN_RESP_OK ; +int ret; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); + param = (struct nbl_chan_param_get_global_vector *)data; + + result.vector_id = +NBL_OPS_CALL_RET (res_ops->get_global_vector, + (p, param->vsi_id, param->vector_id)); + +NBL_CHAN_ACK (chan_ack, src_id,NBL_CHAN_MSG_GET_GLOBAL_VECTOR , msg_id, + err, &result,sizeof (result)); + ret = chan_ops->send_ack (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), + &chan_ack); +if (ret) +dev_err (dev, +"channel send ack failed with ret: %d, msg_type: %d\n" , + ret,NBL_CHAN_MSG_GET_GLOBAL_VECTOR ); +} + +static int nbl_disp_destroy_msix_map (void *priv) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; +int ret; + +if (!disp_mgt) +return -EINVAL ; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + ret =NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->destroy_msix_map, p,0 ); +return ret; +} + +static int nbl_disp_enable_mailbox_irq (void *priv,u16 vector_id, +bool enable_msix) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; +int ret; + +if (!disp_mgt) +return -EINVAL ; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + ret =NBL_OPS_CALL_LOCK_RET (disp_mgt, res_ops->enable_mailbox_irq, p,0 , + vector_id, enable_msix); +return ret; +} + +static u16 nbl_disp_get_global_vector (void *priv,u16 vsi_id,u16 local_vec_id) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; +u16 ret; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + ret =NBL_OPS_CALL_RET (res_ops->get_global_vector, + (p, vsi_id, local_vec_id)); +return ret; +} + +static u16 nbl_disp_get_msix_entry_id (void *priv,u16 vsi_id,u16 local_vec_id) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; +u16 ret; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); + ret =NBL_OPS_CALL_RET (res_ops->get_msix_entry_id, + (p, vsi_id, local_vec_id)); +return ret; +} + +static u16 nbl_disp_get_vsi_id (void *priv,u16 func_id,u16 type) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); +struct nbl_resource_ops *res_ops; + +if (!disp_mgt) +return -EINVAL ; + + res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +return NBL_OPS_CALL_RET (res_ops->get_vsi_id, (p, func_id, type)); +} + +static void nbl_disp_get_eth_id (void *priv,u16 vsi_id,u8 *eth_mode, +u8 *eth_id,u8 *logic_eth_id) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_resource_ops *res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); + +NBL_OPS_CALL (res_ops->get_eth_id, + (p, vsi_id, eth_mode, eth_id, logic_eth_id)); +} + +static u32 nbl_disp_get_tx_headroom (void *priv) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_resource_ops *res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +u32 ret; + + ret =NBL_OPS_CALL_RET (res_ops->get_tx_headroom, + (NBL_DISP_MGT_TO_RES_PRIV (disp_mgt))); +return ret; +} + +static void nbl_disp_clear_queues (void *priv,u16 vsi_id) +{ +struct nbl_dispatch_mgt *disp_mgt = (struct nbl_dispatch_mgt *)priv; +struct nbl_resource_ops *res_ops =NBL_DISP_MGT_TO_RES_OPS (disp_mgt); +void *p =NBL_DISP_MGT_TO_RES_PRIV (disp_mgt); + +NBL_OPS_CALL_LOCK (disp_mgt, res_ops->clear_queues, p, vsi_id); +} + +/* NBL_DISP_SET_OPS(disp_op_name, func, ctrl_lvl, msg_type, msg_req, msg_resp) +* ctrl_lvl is to define when this disp_op should go directly to res_op, +* not sending a channel msg. +* Use X Macros to reduce codes in channel_op and disp_op setup/remove +*/ +#define NBL_DISP_OPS_TBL \ +do { \ + NBL_DISP_SET_OPS(init_chip_module, nbl_disp_init_chip_module, \ + NBL_DISP_CTRL_LVL_MGT, -1, \ + NULL, NULL); \ + NBL_DISP_SET_OPS(deinit_chip_module, \ + nbl_disp_deinit_chip_module, \ + NBL_DISP_CTRL_LVL_MGT, -1, \ + NULL, NULL); \ + NBL_DISP_SET_OPS(get_resource_pt_ops, nbl_disp_get_res_pt_ops, \ + NBL_DISP_CTRL_LVL_NET, -1, \ + NULL, NULL); \ + NBL_DISP_SET_OPS(queue_init, nbl_disp_queue_init, \ + NBL_DISP_CTRL_LVL_MGT, -1, \ + NULL, NULL); \ + NBL_DISP_SET_OPS(configure_msix_map, \ + nbl_disp_configure_msix_map, \ + NBL_DISP_CTRL_LVL_MGT, \ + NBL_CHAN_MSG_CONFIGURE_MSIX_MAP, \ + nbl_disp_chan_configure_msix_map_req, \ + nbl_disp_chan_configure_msix_map_resp); \ + NBL_DISP_SET_OPS(destroy_msix_map, nbl_disp_destroy_msix_map, \ + NBL_DISP_CTRL_LVL_MGT, \ + NBL_CHAN_MSG_DESTROY_MSIX_MAP, \ + nbl_disp_chan_destroy_msix_map_req, \ + nbl_disp_chan_destroy_msix_map_resp); \ + NBL_DISP_SET_OPS(enable_mailbox_irq, \ + nbl_disp_enable_mailbox_irq, \ + NBL_DISP_CTRL_LVL_MGT, \ + NBL_CHAN_MSG_MAILBOX_ENABLE_IRQ, \ + nbl_disp_chan_enable_mailbox_irq_req, \ + nbl_disp_chan_enable_mailbox_irq_resp); \ + NBL_DISP_SET_OPS(get_global_vector, nbl_disp_get_global_vector, \ + NBL_DISP_CTRL_LVL_MGT, \ + NBL_CHAN_MSG_GET_GLOBAL_VECTOR, \ + nbl_disp_chan_get_global_vector_req, \ + nbl_disp_chan_get_global_vector_resp); \ + NBL_DISP_SET_OPS(get_msix_entry_id, nbl_disp_get_msix_entry_id, \ + NBL_DISP_CTRL_LVL_NET, -1, \ + NULL, NULL); \ + NBL_DISP_SET_OPS(alloc_rings, nbl_disp_alloc_rings, \ + NBL_DISP_CTRL_LVL_NET, -1, \ + NULL, NULL); \ + NBL_DISP_SET_OPS(remove_rings, nbl_disp_remove_rings, \ + NBL_DISP_CTRL_LVL_NET, -1, \ + NULL, NULL); \ + NBL_DISP_SET_OPS(start_tx_ring, nbl_disp_start_tx_ring, \ + NBL_DISP_CTRL_LVL_NET, -1, \ + NULL, NULL); \ + NBL_DISP_SET_OPS(stop_tx_ring, nbl_disp_stop_tx_ring, \ + NBL_DISP_CTRL_LVL_NET, -1, \ + NULL, NULL); \ + NBL_DISP_SET_OPS(start_rx_ring, nbl_disp_start_rx_ring, \ + NBL_DISP_CTRL_LVL_NET, -1, \ + NULL, NULL); \ + NBL_DISP_SET_OPS(stop_rx_ring, nbl_disp_stop_rx_ring, \ + NBL_DISP_CTRL_LVL_NET, -1, \ + NULL, NULL); \ + NBL_DISP_SET_OPS(kick_rx_ring, nbl_disp_kick_rx_ring, \ + NBL_DISP_CTRL_LVL_NET, -1, \ + NULL, NULL); \ + NBL_DISP_SET_OPS(get_vector_napi, nbl_disp_get_vector_napi, \ + NBL_DISP_CTRL_LVL_NET, -1, \ + NULL, NULL); \ + NBL_DISP_SET_OPS(set_vector_info, nbl_disp_set_vector_info, \ + NBL_DISP_CTRL_LVL_NET, -1, \ + NULL, NULL); \ + NBL_DISP_SET_OPS(register_vsi_ring, nbl_disp_register_vsi_ring, \ + NBL_DISP_CTRL_LVL_NET, -1, \ + NULL, NULL); \ + NBL_DISP_SET_OPS(register_net, nbl_disp_register_net, \ + NBL_DISP_CTRL_LVL_MGT, \ + NBL_CHAN_MSG_REGISTER_NET, \ + nbl_disp_chan_register_net_req, \ + nbl_disp_chan_register_net_resp); \ + NBL_DISP_SET_OPS(unregister_net, nbl_disp_unregister_net, \ + NBL_DISP_CTRL_LVL_MGT, \ + NBL_CHAN_MSG_UNREGISTER_NET, \ + nbl_disp_chan_unregister_net_req, \ + nbl_disp_chan_unregister_net_resp); \ + NBL_DISP_SET_OPS(alloc_txrx_queues, nbl_disp_alloc_txrx_queues, \ + NBL_DISP_CTRL_LVL_MGT, \ + NBL_CHAN_MSG_ALLOC_TXRX_QUEUES, \ + nbl_disp_chan_alloc_txrx_queues_req, \ + nbl_disp_chan_alloc_txrx_queues_resp); \ + NBL_DISP_SET_OPS(free_txrx_queues, nbl_disp_free_txrx_queues, \ + NBL_DISP_CTRL_LVL_MGT, \ + NBL_CHAN_MSG_FREE_TXRX_QUEUES, \ + nbl_disp_chan_free_txrx_queues_req, \ + nbl_disp_chan_free_txrx_queues_resp); \ + NBL_DISP_SET_OPS(register_vsi2q, nbl_disp_register_vsi2q, \ + NBL_DISP_CTRL_LVL_MGT, \ + NBL_CHAN_MSG_REGISTER_VSI2Q, \ + nbl_disp_chan_register_vsi2q_req, \ + nbl_disp_chan_register_vsi2q_resp); \ + NBL_DISP_SET_OPS(setup_q2vsi, nbl_disp_setup_q2vsi, \ + NBL_DISP_CTRL_LVL_MGT, NBL_CHAN_MSG_SETUP_Q2VSI,\ + nbl_disp_chan_setup_q2vsi_req, \ + nbl_disp_chan_setup_q2vsi_resp); \ + NBL_DISP_SET_OPS(remove_q2vsi, nbl_disp_remove_q2vsi, \ + NBL_DISP_CTRL_LVL_MGT, NBL_CHAN_MSG_REMOVE_Q2VSI,\ + nbl_disp_chan_remove_q2vsi_req, \ + nbl_disp_chan_remove_q2vsi_resp); \ + NBL_DISP_SET_OPS(setup_rss, nbl_disp_setup_rss, \ + NBL_DISP_CTRL_LVL_MGT, NBL_CHAN_MSG_SETUP_RSS, \ + nbl_disp_chan_setup_rss_req, \ + nbl_disp_chan_setup_rss_resp); \ + NBL_DISP_SET_OPS(remove_rss, nbl_disp_remove_rss, \ + NBL_DISP_CTRL_LVL_MGT, NBL_CHAN_MSG_REMOVE_RSS,\ + nbl_disp_chan_remove_rss_req, \ + nbl_disp_chan_remove_rss_resp); \ + NBL_DISP_SET_OPS(setup_queue, nbl_disp_setup_queue, \ + NBL_DISP_CTRL_LVL_MGT, NBL_CHAN_MSG_SETUP_QUEUE,\ + nbl_disp_chan_setup_queue_req, \ + nbl_disp_chan_setup_queue_resp); \ + NBL_DISP_SET_OPS(remove_all_queues, nbl_disp_remove_all_queues, \ + NBL_DISP_CTRL_LVL_MGT, \ + NBL_CHAN_MSG_REMOVE_ALL_QUEUES, \ + nbl_disp_chan_remove_all_queues_req, \ + nbl_disp_chan_remove_all_queues_resp); \ + NBL_DISP_SET_OPS(cfg_dsch, nbl_disp_cfg_dsch, \ + NBL_DISP_CTRL_LVL_MGT, NBL_CHAN_MSG_CFG_DSCH, \ + nbl_disp_chan_cfg_dsch_req, \ + nbl_disp_chan_cfg_dsch_resp); \ + NBL_DISP_SET_OPS(setup_cqs, nbl_disp_setup_cqs, \ + NBL_DISP_CTRL_LVL_MGT, NBL_CHAN_MSG_SETUP_CQS, \ + nbl_disp_chan_setup_cqs_req, \ + nbl_disp_chan_setup_cqs_resp); \ + NBL_DISP_SET_OPS(remove_cqs, nbl_disp_remove_cqs, \ + NBL_DISP_CTRL_LVL_MGT, NBL_CHAN_MSG_REMOVE_CQS,\ + nbl_disp_chan_remove_cqs_req, \ + nbl_disp_chan_remove_cqs_resp); \ + NBL_DISP_SET_OPS(get_msix_irq_enable_info, \ + nbl_disp_get_msix_irq_enable_info, \ + NBL_DISP_CTRL_LVL_NET, -1, \ + NULL, NULL); \ + NBL_DISP_SET_OPS(get_vsi_id, nbl_disp_get_vsi_id, \ + NBL_DISP_CTRL_LVL_MGT, NBL_CHAN_MSG_GET_VSI_ID,\ + nbl_disp_chan_get_vsi_id_req, \ + nbl_disp_chan_get_vsi_id_resp); \ + NBL_DISP_SET_OPS(get_eth_id, nbl_disp_get_eth_id, \ + NBL_DISP_CTRL_LVL_MGT, NBL_CHAN_MSG_GET_ETH_ID,\ + nbl_disp_chan_get_eth_id_req, \ + nbl_disp_chan_get_eth_id_resp); \ + NBL_DISP_SET_OPS(set_promisc_mode, nbl_disp_set_promisc_mode, \ + NBL_DISP_CTRL_LVL_MGT, NBL_CHAN_MSG_SET_PROSISC_MODE,\ + nbl_disp_chan_set_promisc_mode_req, \ + nbl_disp_chan_set_promisc_mode_resp); \ + NBL_DISP_SET_OPS(get_tx_headroom, nbl_disp_get_tx_headroom, \ + NBL_DISP_CTRL_LVL_NET, -1, \ + NULL, NULL); \ + NBL_DISP_SET_OPS(get_net_stats, nbl_disp_get_net_stats, \ + NBL_DISP_CTRL_LVL_NET, -1, NULL, NULL); \ + NBL_DISP_SET_OPS(get_rxfh_indir_size, nbl_disp_get_rxfh_indir_size,\ + NBL_DISP_CTRL_LVL_MGT, \ + NBL_CHAN_MSG_GET_RXFH_INDIR_SIZE,\ + nbl_disp_chan_get_rxfh_indir_size_req, \ + nbl_disp_chan_get_rxfh_indir_size_resp); \ + NBL_DISP_SET_OPS(set_rxfh_indir, nbl_disp_set_rxfh_indir, \ + NBL_DISP_CTRL_LVL_MGT, NBL_CHAN_MSG_SET_RXFH_INDIR,\ + nbl_disp_chan_set_rxfh_indir_req, \ + nbl_disp_chan_set_rxfh_indir_resp); \ + NBL_DISP_SET_OPS(clear_queues, nbl_disp_clear_queues, \ + NBL_DISP_CTRL_LVL_MGT, NBL_CHAN_MSG_CLEAR_QUEUE,\ + nbl_disp_chan_clear_queues_req, \ + nbl_disp_chan_clear_queues_resp); \ +} while (0) + +/* Structure starts here, adding an op should not modify anything below */ +static int nbl_disp_setup_msg (struct nbl_dispatch_mgt *disp_mgt) +{ +struct nbl_dispatch_ops *disp_ops =NBL_DISP_MGT_TO_DISP_OPS (disp_mgt); +struct nbl_channel_ops *chan_ops =NBL_DISP_MGT_TO_CHAN_OPS (disp_mgt); +void *p =NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt); +int ret =0 ; + +if (!chan_ops->check_queue_exist (NBL_DISP_MGT_TO_CHAN_PRIV (disp_mgt), +NBL_CHAN_TYPE_MAILBOX )) +return 0 ; + +mutex_init (&disp_mgt->ops_mutex_lock); + disp_mgt->ops_lock_required = true; + +#define NBL_DISP_SET_OPS (disp_op, func, ctrl, msg_type, msg_req, resp) \ +do { \ + typeof(msg_type) _msg_type = (msg_type); \ + typeof(ctrl) _ctrl_lvl = (ctrl); \ + (void)(disp_ops->NBL_NAME(disp_op)); \ + (void)(func); \ + (void)(msg_req); \ + (void)_ctrl_lvl; \ + if (_msg_type >= 0) \ + ret += chan_ops->register_msg(p, _msg_type, resp, disp_mgt);\ +} while (0) +NBL_DISP_OPS_TBL ; +#undef NBL_DISP_SET_OPS + +return ret; +} + +/* Ctrl lvl means that if a certain level is set, then all disp_ops that +* decleared this lvl will go directly to res_ops, rather than send a +* channel msg, and vice versa. +*/ +static int nbl_disp_setup_ctrl_lvl (struct nbl_dispatch_mgt *disp_mgt,u32 lvl) +{ +struct nbl_dispatch_ops *disp_ops; + + disp_ops =NBL_DISP_MGT_TO_DISP_OPS (disp_mgt); + +set_bit (lvl, disp_mgt->ctrl_lvl); + +#define NBL_DISP_SET_OPS (disp_op, func, ctrl, msg_type, msg_req, msg_resp) \ +do { \ + typeof(msg_type) _msg_type = (msg_type); \ + (void)(_msg_type); \ + (void)(msg_resp); \ + disp_ops->NBL_NAME(disp_op) = \ + test_bit(ctrl, disp_mgt->ctrl_lvl) ? func : msg_req; ;\ +} while (0) +NBL_DISP_OPS_TBL ; +#undef NBL_DISP_SET_OPS + +return 0 ; +} +static int nbl_disp_setup_disp_mgt (struct nbl_common_info *common,struct nbl_dispatch_mgt **disp_mgt) {
@@ -88,7 +1928,30 @@ int nbl_disp_init(void *p, struct nbl_init_param *param)NBL_DISP_MGT_TO_CHAN_OPS_TBL (*disp_mgt) = chan_ops_tbl;NBL_DISP_MGT_TO_DISP_OPS_TBL (*disp_mgt) = *disp_ops_tbl; + ret =nbl_disp_setup_msg (*disp_mgt); +if (ret) + goto setup_msg_fail; + +if (param->caps.has_ctrl) { + ret =nbl_disp_setup_ctrl_lvl (*disp_mgt,NBL_DISP_CTRL_LVL_MGT ); +if (ret) + goto setup_msg_fail; + } + +if (param->caps.has_net) { + ret =nbl_disp_setup_ctrl_lvl (*disp_mgt,NBL_DISP_CTRL_LVL_NET ); +if (ret) + goto setup_msg_fail; + } + + ret =nbl_disp_setup_ctrl_lvl (*disp_mgt,NBL_DISP_CTRL_LVL_ALWAYS ); +if (ret) + goto setup_msg_fail; +return 0 ; + +setup_msg_fail: +nbl_disp_remove_ops (dev, disp_ops_tbl); setup_ops_fail:nbl_disp_remove_disp_mgt (common, disp_mgt); setup_mgt_fail:
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dispatch.h +33 -0
@@ -29,6 +29,39 @@#define NBL_DISP_MGT_TO_DISP_PRIV (disp_mgt) \ (NBL_DISP_MGT_TO_DISP_OPS_TBL(disp_mgt)->priv) +#define NBL_OPS_CALL_LOCK (disp_mgt, func, ...) \ +do { \ + typeof(disp_mgt) _disp_mgt = (disp_mgt); \ + typeof(func) _func = (func); \ + \ + if (_disp_mgt->ops_lock_required) \ + mutex_lock(&_disp_mgt->ops_mutex_lock); \ + \ + if (_func) \ + _func(__VA_ARGS__); \ + \ + if (_disp_mgt->ops_lock_required) \ + mutex_unlock(&_disp_mgt->ops_mutex_lock); \ +} while (0) + +#define NBL_OPS_CALL_LOCK_RET (disp_mgt, func, ...) \ +({ \ + typeof(disp_mgt) _disp_mgt = (disp_mgt); \ + typeof(func) _func = (func); \ + typeof(_func(__VA_ARGS__)) _ret = 0; \ + \ + if (_disp_mgt->ops_lock_required) \ + mutex_lock(&_disp_mgt->ops_mutex_lock); \ + \ + if (_func) \ + _ret = _func(__VA_ARGS__); \ + \ + if (_disp_mgt->ops_lock_required) \ + 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;
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_dispatch.h +58 -0
64 lines not on this page · raw message
Signature · 1 line
2.47.3
illusion.wang
maintainerPATCH v3 12/15 net/nebula-matrix: add common/ctrl dev init/reinit operation
In reply to illusion.wangCommon Device Setup: nbl_dev_setup_common_dev configures mailbox queues, registers cleanup tasks, and requests IRQs.
Control Device Setup (optional): nbl_dev_setup_ctrl_dev initializes the chip and configures all channel queues.
--- .../nebula-matrix/nbl/nbl_core/nbl_dev.c | 194 +++++++++++++++++- .../nebula-matrix/nbl/nbl_core/nbl_dev.h | 92 +++++++++ .../nebula-matrix/nbl/nbl_core/nbl_service.c | 69 +++++++ .../nebula-matrix/nbl/nbl_core/nbl_service.h | 91 +++++++- .../nbl/nbl_include/nbl_def_service.h | 57 +++++ .../nbl/nbl_include/nbl_include.h | 7 + 6 files changed, 506 insertions(+), 4 deletions(-)
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.c +191 -3
@@ -11,6 +11,179 @@#include "nbl_dev.h" static struct nbl_dev_ops dev_ops; +static void nbl_dev_register_common_irq (struct nbl_dev_mgt *dev_mgt) +{ +struct nbl_dev_common *dev_common =NBL_DEV_MGT_TO_COMMON_DEV (dev_mgt); +struct nbl_msix_info *msix_info = +NBL_DEV_COMMON_TO_MSIX_INFO (dev_common); + + msix_info->serv_info[NBL_MSIX_MAILBOX_TYPE ].num =1 ; +} + +/* ---------- Channel config ---------- */ +static int nbl_dev_setup_chan_qinfo (struct nbl_dev_mgt *dev_mgt,u8 chan_type) +{ +struct nbl_channel_ops *chan_ops =NBL_DEV_MGT_TO_CHAN_OPS (dev_mgt); +struct device *dev =NBL_DEV_MGT_TO_DEV (dev_mgt); +void *priv =NBL_DEV_MGT_TO_CHAN_PRIV (dev_mgt); +int ret =0 ; + +if (!chan_ops->check_queue_exist (priv, chan_type)) +return 0 ; + + ret = chan_ops->cfg_chan_qinfo_map_table (priv, chan_type); +if (ret) +dev_err (dev,"setup chan:%d, qinfo map table failed\n" , + chan_type); + +return ret; +} + +static int nbl_dev_setup_chan_queue (struct nbl_dev_mgt *dev_mgt,u8 chan_type) +{ +struct nbl_channel_ops *chan_ops =NBL_DEV_MGT_TO_CHAN_OPS (dev_mgt); +void *priv =NBL_DEV_MGT_TO_CHAN_PRIV (dev_mgt); +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 =NBL_DEV_MGT_TO_CHAN_OPS (dev_mgt); +void *priv =NBL_DEV_MGT_TO_CHAN_PRIV (dev_mgt); +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 =NBL_DEV_MGT_TO_CHAN_OPS (dev_mgt); + +if (chan_ops->check_queue_exist (NBL_DEV_MGT_TO_CHAN_PRIV (dev_mgt), + chan_type)) + chan_ops->register_chan_task (NBL_DEV_MGT_TO_CHAN_PRIV (dev_mgt), + 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 =NBL_DEV_MGT_TO_CHAN_OPS (dev_mgt); + + chan_ops->clean_queue_subtask (NBL_DEV_MGT_TO_CHAN_PRIV (dev_mgt), +NBL_CHAN_TYPE_MAILBOX ); +} + +/* ---------- Dev init process ---------- */ +static int nbl_dev_setup_common_dev (struct nbl_adapter *adapter, +struct nbl_init_param *param) +{ +struct nbl_dev_mgt *dev_mgt = + (struct nbl_dev_mgt *)NBL_ADAP_TO_DEV_MGT (adapter); +struct nbl_dev_common *common_dev; +struct nbl_service_ops *serv_ops =NBL_DEV_MGT_TO_SERV_OPS (dev_mgt); +struct nbl_common_info *common =NBL_DEV_MGT_TO_COMMON (dev_mgt); +void *priv =NBL_DEV_MGT_TO_SERV_PRIV (dev_mgt); + + common_dev =devm_kzalloc (NBL_ADAP_TO_DEV (adapter), +sizeof (struct nbl_dev_common ),GFP_KERNEL ); +if (!common_dev) +return -ENOMEM ; + common_dev->dev_mgt = dev_mgt; + +if (nbl_dev_setup_chan_queue (dev_mgt,NBL_CHAN_TYPE_MAILBOX )) + goto setup_chan_fail; + +nbl_common_alloc_task (&common_dev->clean_mbx_task, + nbl_dev_clean_mailbox_task); + + common->vsi_id = serv_ops->get_vsi_id (priv,0 ,NBL_VSI_DATA ); + + serv_ops->get_eth_id (NBL_DEV_MGT_TO_SERV_PRIV (dev_mgt), +NBL_COMMON_TO_VSI_ID (common), + &NBL_COMMON_TO_ETH_MODE (common), + &NBL_COMMON_TO_ETH_ID (common), + &NBL_COMMON_TO_LOGIC_ETH_ID (common)); + +nbl_dev_register_chan_task (dev_mgt,NBL_CHAN_TYPE_MAILBOX , + &common_dev->clean_mbx_task); + + dev_mgt->common_dev = common_dev; +nbl_dev_register_common_irq (dev_mgt); +return 0 ; + +setup_chan_fail: +devm_kfree (NBL_ADAP_TO_DEV (adapter), common_dev); +return -EFAULT ; +} + +static void nbl_dev_remove_common_dev (struct nbl_adapter *adapter) +{ +struct nbl_dev_mgt *dev_mgt = + (struct nbl_dev_mgt *)NBL_ADAP_TO_DEV_MGT (adapter); +struct nbl_dev_common *common_dev =NBL_DEV_MGT_TO_COMMON_DEV (dev_mgt); + +if (!common_dev) +return ; + +nbl_dev_register_chan_task (dev_mgt,NBL_CHAN_TYPE_MAILBOX ,NULL ); +nbl_common_release_task (&common_dev->clean_mbx_task); +nbl_dev_remove_chan_queue (dev_mgt,NBL_CHAN_TYPE_MAILBOX ); +devm_kfree (NBL_ADAP_TO_DEV (adapter), common_dev); + dev_mgt->common_dev =NULL ; +} + +static int nbl_dev_setup_ctrl_dev (struct nbl_adapter *adapter, +struct nbl_init_param *param) +{ +struct nbl_dev_mgt *dev_mgt = + (struct nbl_dev_mgt *)NBL_ADAP_TO_DEV_MGT (adapter); +struct nbl_service_ops *serv_ops =NBL_DEV_MGT_TO_SERV_OPS (dev_mgt); +struct device *dev =NBL_ADAP_TO_DEV (adapter); +int i, ret =0 ; + + ret = serv_ops->init_chip (NBL_DEV_MGT_TO_SERV_PRIV (dev_mgt)); +if (ret) { +dev_err (dev,"ctrl dev chip_init failed\n" ); + goto chip_init_fail; + } + +for (i =0 ; i <NBL_CHAN_TYPE_MAX ; i++) { + ret =nbl_dev_setup_chan_qinfo (dev_mgt, i); +if (ret) { +dev_err (dev,"ctrl dev setup chan qinfo failed\n" ); + goto setup_chan_q_fail; + } + } + +return 0 ; + +setup_chan_q_fail: + serv_ops->destroy_chip (NBL_DEV_MGT_TO_SERV_PRIV (dev_mgt)); +chip_init_fail: +return ret; +} + +static void nbl_dev_remove_ctrl_dev (struct nbl_adapter *adapter) +{ +struct nbl_dev_mgt *dev_mgt = + (struct nbl_dev_mgt *)NBL_ADAP_TO_DEV_MGT (adapter); +struct nbl_service_ops *serv_ops =NBL_DEV_MGT_TO_SERV_OPS (dev_mgt); + + serv_ops->destroy_chip (NBL_DEV_MGT_TO_SERV_PRIV (dev_mgt)); +}static int nbl_dev_setup_dev_mgt (struct nbl_common_info *common,struct nbl_dev_mgt **dev_mgt)
@@ -74,14 +247,27 @@ int nbl_dev_init(void *p, struct nbl_init_param *param) (*dev_mgt)->serv_ops_tbl = serv_ops_tbl; (*dev_mgt)->chan_ops_tbl = chan_ops_tbl; + + ret =nbl_dev_setup_common_dev (adapter, param); +if (ret) + goto setup_common_dev_fail; + +if (common->is_ctrl) { + ret =nbl_dev_setup_ctrl_dev (adapter, param); +if (ret) + goto setup_ctrl_dev_fail; + } ret =nbl_dev_setup_ops (dev, dev_ops_tbl, adapter);if (ret) goto setup_ops_fail; -return 0 ; setup_ops_fail: - +if (common->is_ctrl) +nbl_dev_remove_ctrl_dev (adapter); +setup_ctrl_dev_fail: +nbl_dev_remove_common_dev (adapter); +setup_common_dev_fail:nbl_dev_remove_dev_mgt (common, dev_mgt); setup_mgt_fail:return ret;
@@ -98,7 +284,9 @@ void nbl_dev_remove(void *p) &NBL_ADAP_TO_DEV_OPS_TBL (adapter);nbl_dev_remove_ops (dev, dev_ops_tbl); - +if (common->is_ctrl) +nbl_dev_remove_ctrl_dev (adapter); +nbl_dev_remove_common_dev (adapter);nbl_dev_remove_dev_mgt (common, dev_mgt); }
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.h +92 -0
103 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_service.c +69 -0
94 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_service.h +90 -1
113 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_service.h +57 -0
63 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_include.h +7 -0
@@ -262,6 +262,13 @@ enum nbl_performance_mode { NBL_QUIRKS_UVN_PREFETCH_ALIGN, }; +struct nbl_vsi_param { +u16 vsi_id; +u16 queue_offset; +u16 queue_num; +u8 index; +}; +struct nbl_ring_param {u16 tx_ring_num;u16 rx_ring_num;
Signature · 1 line
2.47.3
illusion.wang
maintainerPATCH v3 13/15 net/nebula-matrix: add net dev init/reinit operation
In reply to illusion.wangnet dev init:vsi build, register vsi, register net irq
--- .../nebula-matrix/nbl/nbl_core/nbl_dev.c | 315 ++++++++++++++++++ .../nebula-matrix/nbl/nbl_core/nbl_service.c | 81 +++++ 2 files changed, 396 insertions(+)
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.c +315 -0
@@ -20,6 +20,16 @@ static void nbl_dev_register_common_irq(struct nbl_dev_mgt *dev_mgt) msix_info->serv_info[NBL_MSIX_MAILBOX_TYPE ].num =1 ; } +static void nbl_dev_register_net_irq (struct nbl_dev_mgt *dev_mgt,u16 queue_num) +{ +struct nbl_dev_common *dev_common =NBL_DEV_MGT_TO_COMMON_DEV (dev_mgt); +struct nbl_msix_info *msix_info = +NBL_DEV_COMMON_TO_MSIX_INFO (dev_common); + + msix_info->serv_info[NBL_MSIX_NET_TYPE ].num = queue_num; + msix_info->serv_info[NBL_MSIX_NET_TYPE ].hw_self_mask_en =1 ; +} +/* ---------- Channel config ---------- */ static int nbl_dev_setup_chan_qinfo (struct nbl_dev_mgt *dev_mgt,u8 chan_type) {
@@ -185,6 +195,303 @@ static void nbl_dev_remove_ctrl_dev(struct nbl_adapter *adapter) serv_ops->destroy_chip (NBL_DEV_MGT_TO_SERV_PRIV (dev_mgt)); } +static const struct net_device_ops netdev_ops_leonis_pf = { +}; + +static int nbl_dev_setup_netops_leonis (void *priv,struct net_device *netdev, +struct nbl_init_param *param) +{ +struct nbl_dev_mgt *dev_mgt = (struct nbl_dev_mgt *)priv; +struct nbl_service_ops *serv_ops =NBL_DEV_MGT_TO_SERV_OPS (dev_mgt); + + netdev->netdev_ops = &netdev_ops_leonis_pf; + serv_ops->set_netdev_ops (NBL_DEV_MGT_TO_SERV_PRIV (dev_mgt), + &netdev_ops_leonis_pf, true); +return 0 ; +} + +static int nbl_dev_register_net (struct nbl_dev_mgt *dev_mgt, +struct nbl_register_net_result *register_result) +{ +struct nbl_service_ops *serv_ops =NBL_DEV_MGT_TO_SERV_OPS (dev_mgt); +struct nbl_register_net_param register_param = {0 }; +int ret; + + ret = serv_ops->register_net (NBL_DEV_MGT_TO_SERV_PRIV (dev_mgt), + ®ister_param, register_result); + +if (!register_result->tx_queue_num || !register_result->rx_queue_num) +return -EIO ; + +return ret; +} + +static void nbl_dev_unregister_net (struct nbl_dev_mgt *dev_mgt) +{ +struct nbl_service_ops *serv_ops =NBL_DEV_MGT_TO_SERV_OPS (dev_mgt); +struct device *dev =NBL_DEV_MGT_TO_DEV (dev_mgt); +int ret; + + ret = serv_ops->unregister_net (NBL_DEV_MGT_TO_SERV_PRIV (dev_mgt)); +if (ret) +dev_err (dev,"unregister net failed\n" ); +} + +static u16 nbl_dev_vsi_alloc_queue (struct nbl_dev_net *net_dev,u16 queue_num) +{ +struct nbl_dev_vsi_controller *vsi_ctrl = &net_dev->vsi_ctrl; +u16 queue_offset =0 ; + +if (vsi_ctrl->queue_free_offset + queue_num > net_dev->kernel_queue_num) +return -ENOSPC ; + + queue_offset = vsi_ctrl->queue_free_offset; + vsi_ctrl->queue_free_offset += queue_num; + +return queue_offset; +} + +static int nbl_dev_vsi_common_setup (struct nbl_dev_mgt *dev_mgt, +struct nbl_init_param *param, +struct nbl_dev_vsi *vsi) +{ +struct nbl_service_ops *serv_ops =NBL_DEV_MGT_TO_SERV_OPS (dev_mgt); +struct nbl_dev_net *net_dev =NBL_DEV_MGT_TO_NET_DEV (dev_mgt); +struct nbl_vsi_param vsi_param = {0 }; +int ret; + + vsi->queue_offset =nbl_dev_vsi_alloc_queue (net_dev, + vsi->queue_num); + vsi_param.index = vsi->index; + vsi_param.vsi_id = vsi->vsi_id; + vsi_param.queue_offset = vsi->queue_offset; + vsi_param.queue_num = vsi->queue_num; + +/* Tell serv & res layer the mapping from vsi to queue_id */ + ret = serv_ops->register_vsi_info (NBL_DEV_MGT_TO_SERV_PRIV (dev_mgt), + &vsi_param); +return ret; +} + +static void nbl_dev_vsi_common_remove (struct nbl_dev_mgt *dev_mgt, +struct nbl_dev_vsi *vsi) +{ +} + +static int nbl_dev_vsi_data_register (struct nbl_dev_mgt *dev_mgt, +struct nbl_init_param *param, +void *vsi_data) +{ +struct nbl_common_info *common =NBL_DEV_MGT_TO_COMMON (dev_mgt); +struct nbl_dev_vsi *vsi = (struct nbl_dev_vsi *)vsi_data; +int ret; + + ret =nbl_dev_register_net (dev_mgt, &vsi->register_result); +if (ret) +return ret; + + vsi->queue_num = vsi->register_result.tx_queue_num; + vsi->queue_size = vsi->register_result.queue_size; + +nbl_debug (common,"Data vsi register, queue_num %d, queue_size %d" , + vsi->queue_num, vsi->queue_size); + +return 0 ; +} + +static int nbl_dev_vsi_data_setup (struct nbl_dev_mgt *dev_mgt, +struct nbl_init_param *param,void *vsi_data) +{ +struct nbl_dev_vsi *vsi = (struct nbl_dev_vsi *)vsi_data; + +return nbl_dev_vsi_common_setup (dev_mgt, param, vsi); +} + +static void nbl_dev_vsi_data_remove (struct nbl_dev_mgt *dev_mgt,void *vsi_data) +{ +struct nbl_dev_vsi *vsi = (struct nbl_dev_vsi *)vsi_data; + +nbl_dev_vsi_common_remove (dev_mgt, vsi); +} + +static struct nbl_dev_vsi_tbl vsi_tbl[NBL_VSI_MAX ] = { + [NBL_VSI_DATA ] = { + .vsi_ops = { + .register_vsi = nbl_dev_vsi_data_register, + .setup = nbl_dev_vsi_data_setup, + .remove = nbl_dev_vsi_data_remove, + }, + }, +}; + +static int nbl_dev_vsi_build (struct nbl_dev_mgt *dev_mgt, +struct nbl_init_param *param) +{ +struct nbl_dev_net *net_dev =NBL_DEV_MGT_TO_NET_DEV (dev_mgt); +struct nbl_service_ops *serv_ops =NBL_DEV_MGT_TO_SERV_OPS (dev_mgt); +void *priv =NBL_DEV_MGT_TO_SERV_PRIV (dev_mgt); +struct nbl_dev_vsi *vsi =NULL ; +int i; + + net_dev->vsi_ctrl.queue_num =0 ; + net_dev->vsi_ctrl.queue_free_offset =0 ; + +/* Build all vsi, and alloc vsi_id for each of them */ +for (i =0 ; i <NBL_VSI_MAX ; i++) { + vsi =devm_kzalloc (NBL_DEV_MGT_TO_DEV (dev_mgt),sizeof (*vsi), +GFP_KERNEL ); +if (!vsi) + goto malloc_vsi_fail; + + vsi->ops = &vsi_tbl[i].vsi_ops; + vsi->vsi_id = serv_ops->get_vsi_id (priv,0 , i); + vsi->index = i; + + net_dev->vsi_ctrl.vsi_list[i] = vsi; + } + +return 0 ; + +malloc_vsi_fail: +while (--i +1 ) { +devm_kfree (NBL_DEV_MGT_TO_DEV (dev_mgt), + net_dev->vsi_ctrl.vsi_list[i]); + net_dev->vsi_ctrl.vsi_list[i] =NULL ; + } + +return -ENOMEM ; +} + +static void nbl_dev_vsi_destroy (struct nbl_dev_mgt *dev_mgt) +{ +struct nbl_dev_net *net_dev =NBL_DEV_MGT_TO_NET_DEV (dev_mgt); +int i; + +for (i =0 ; i <NBL_VSI_MAX ; i++) +if (net_dev->vsi_ctrl.vsi_list[i]) { +devm_kfree (NBL_DEV_MGT_TO_DEV (dev_mgt), + net_dev->vsi_ctrl.vsi_list[i]); + net_dev->vsi_ctrl.vsi_list[i] =NULL ; + } +} + +struct nbl_dev_vsi *nbl_dev_vsi_select (struct nbl_dev_mgt *dev_mgt, +u8 vsi_index) +{ +struct nbl_dev_net *net_dev =NBL_DEV_MGT_TO_NET_DEV (dev_mgt); +struct nbl_dev_vsi *vsi =NULL ; +int i =0 ; + +for (i =0 ; i <NBL_VSI_MAX ; i++) { + vsi = net_dev->vsi_ctrl.vsi_list[i]; +if (vsi && vsi->index == vsi_index) +return vsi; + } + +return NULL ; +} + +static struct nbl_dev_net_ops netdev_ops[NBL_PRODUCT_MAX ] = { + { + .setup_netdev_ops = nbl_dev_setup_netops_leonis, + }, +}; + +static void nbl_det_setup_net_dev_ops (struct nbl_dev_mgt *dev_mgt, +struct nbl_init_param *param) +{ +NBL_DEV_MGT_TO_NETDEV_OPS (dev_mgt) = &netdev_ops[param->product_type]; +} + +static int nbl_dev_setup_net_dev (struct nbl_adapter *adapter, +struct nbl_init_param *param) +{ +struct nbl_dev_mgt *dev_mgt =NBL_ADAP_TO_DEV_MGT (adapter); +struct nbl_dev_net **net_dev = &NBL_DEV_MGT_TO_NET_DEV (dev_mgt); +struct device *dev =NBL_ADAP_TO_DEV (adapter); +struct nbl_dev_vsi *vsi; +u16 kernel_queue_num =0 ; +int i, ret; + + *net_dev =devm_kzalloc (dev,sizeof (struct nbl_dev_net ),GFP_KERNEL ); +if (!*net_dev) +return -ENOMEM ; + + ret =nbl_dev_vsi_build (dev_mgt, param); +if (ret) + goto vsi_build_fail; + +for (i =0 ; i <NBL_VSI_MAX ; i++) { + vsi = (*net_dev)->vsi_ctrl.vsi_list[i]; + +if (!vsi) +continue ; + + ret = vsi->ops->register_vsi (dev_mgt, param, vsi); +if (ret) { +dev_err (NBL_DEV_MGT_TO_DEV (dev_mgt), +"Vsi %d register failed" , vsi->index); + goto vsi_register_fail; + } + kernel_queue_num += vsi->queue_num; + } + + (*net_dev)->kernel_queue_num = kernel_queue_num; + +for (i =0 ; i <NBL_VSI_MAX ; i++) { + vsi = (*net_dev)->vsi_ctrl.vsi_list[i]; + +if (!vsi) +continue ; + ret = vsi->ops->setup (dev_mgt, param, vsi); +if (ret) { +dev_err (NBL_DEV_MGT_TO_DEV (dev_mgt), +"Vsi %d setup failed" , vsi->index); + goto vsi_setup_fail; + } + } + +nbl_dev_register_net_irq (dev_mgt, kernel_queue_num); + +nbl_det_setup_net_dev_ops (dev_mgt, param); + +return 0 ; + +vsi_setup_fail: +vsi_register_fail: +nbl_dev_vsi_destroy (dev_mgt); +vsi_build_fail: +devm_kfree (dev, *net_dev); +return ret; +} + +static void nbl_dev_remove_net_dev (struct nbl_adapter *adapter) +{ +struct device *dev =NBL_ADAP_TO_DEV (adapter); +struct nbl_dev_mgt *dev_mgt =NBL_ADAP_TO_DEV_MGT (adapter); +struct nbl_dev_net **net_dev = &NBL_DEV_MGT_TO_NET_DEV (dev_mgt); +struct nbl_dev_vsi *vsi; +int i; + +if (!*net_dev) +return ; + +for (i =0 ; i <NBL_VSI_MAX ; i++) { + vsi = (*net_dev)->vsi_ctrl.vsi_list[i]; + +if (!vsi) +continue ; + + vsi->ops->remove (dev_mgt, vsi); + } +nbl_dev_vsi_destroy (dev_mgt); + +nbl_dev_unregister_net (dev_mgt); + +devm_kfree (dev, *net_dev); + *net_dev =NULL ; +} +static int nbl_dev_setup_dev_mgt (struct nbl_common_info *common,struct nbl_dev_mgt **dev_mgt) {
@@ -257,12 +564,19 @@ int nbl_dev_init(void *p, struct nbl_init_param *param)if (ret) goto setup_ctrl_dev_fail; } + + ret =nbl_dev_setup_net_dev (adapter, param); +if (ret) + goto setup_net_dev_fail; + ret =nbl_dev_setup_ops (dev, dev_ops_tbl, adapter);if (ret) goto setup_ops_fail;return 0 ; setup_ops_fail: +nbl_dev_remove_net_dev (adapter); +setup_net_dev_fail:if (common->is_ctrl)nbl_dev_remove_ctrl_dev (adapter); setup_ctrl_dev_fail:
@@ -284,6 +598,7 @@ void nbl_dev_remove(void *p) &NBL_ADAP_TO_DEV_OPS_TBL (adapter);nbl_dev_remove_ops (dev, dev_ops_tbl); +nbl_dev_remove_net_dev (adapter);if (common->is_ctrl)nbl_dev_remove_ctrl_dev (adapter);nbl_dev_remove_common_dev (adapter);
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_service.c +81 -0
97 lines not on this page · raw message
Signature · 1 line
2.47.3
illusion.wang
maintainerPATCH v3 14/15 net/nebula-matrix: add common dev start/stop operation
In reply to illusion.wangstart common dev: config msix map table, alloc and enable msix vectors, register mailbox ISR and enable mailbox irq
--- .../nebula-matrix/nbl/nbl_core/nbl_dev.c | 306 +++++++++++++- .../nebula-matrix/nbl/nbl_core/nbl_service.c | 395 +++++++++++++++++- .../net/ethernet/nebula-matrix/nbl/nbl_main.c | 34 +- 3 files changed, 732 insertions(+), 3 deletions(-)
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.c +305 -1
@@ -11,6 +11,17 @@#include "nbl_dev.h" static struct nbl_dev_ops dev_ops; +static int nbl_dev_clean_mailbox_schedule (struct nbl_dev_mgt *dev_mgt); + +/* ---------- Interrupt config ---------- */ +static irqreturn_t nbl_dev_clean_mailbox (int __always_unused irq,void *data) +{ +struct nbl_dev_mgt *dev_mgt = (struct nbl_dev_mgt *)data; + +nbl_dev_clean_mailbox_schedule (dev_mgt); +return IRQ_HANDLED ; +} +static void nbl_dev_register_common_irq (struct nbl_dev_mgt *dev_mgt) {struct nbl_dev_common *dev_common =NBL_DEV_MGT_TO_COMMON_DEV (dev_mgt);
@@ -30,6 +41,237 @@ static void nbl_dev_register_net_irq(struct nbl_dev_mgt *dev_mgt, u16 queue_num) msix_info->serv_info[NBL_MSIX_NET_TYPE ].hw_self_mask_en =1 ; } +static int nbl_dev_request_mailbox_irq (struct nbl_dev_mgt *dev_mgt) +{ +struct nbl_dev_common *dev_common =NBL_DEV_MGT_TO_COMMON_DEV (dev_mgt); +struct nbl_msix_info *msix_info = +NBL_DEV_COMMON_TO_MSIX_INFO (dev_common); +struct nbl_common_info *common =NBL_DEV_MGT_TO_COMMON (dev_mgt); +struct device *dev =NBL_DEV_MGT_TO_DEV (dev_mgt); +u16 local_vec_id; +u32 irq_num; +int err; + +if (!msix_info->serv_info[NBL_MSIX_MAILBOX_TYPE ].num) +return 0 ; + + local_vec_id = + msix_info->serv_info[NBL_MSIX_MAILBOX_TYPE ].base_vector_id; + irq_num = msix_info->msix_entries[local_vec_id].vector; + +snprintf (dev_common->mailbox_name,sizeof (dev_common->mailbox_name), +"nbl_mailbox@pci:%s" ,pci_name (NBL_COMMON_TO_PDEV (common))); + err =devm_request_irq (dev, irq_num, nbl_dev_clean_mailbox,0 , + dev_common->mailbox_name, dev_mgt); +if (err) { +dev_err (dev,"Request mailbox irq handler failed err: %d\n" , + err); +return err; + } + +return 0 ; +} + +static void nbl_dev_free_mailbox_irq (struct nbl_dev_mgt *dev_mgt) +{ +struct nbl_dev_common *dev_common =NBL_DEV_MGT_TO_COMMON_DEV (dev_mgt); +struct nbl_msix_info *msix_info = +NBL_DEV_COMMON_TO_MSIX_INFO (dev_common); +struct device *dev =NBL_DEV_MGT_TO_DEV (dev_mgt); +u16 local_vec_id; +u32 irq_num; + +if (!msix_info->serv_info[NBL_MSIX_MAILBOX_TYPE ].num) +return ; + + local_vec_id = + msix_info->serv_info[NBL_MSIX_MAILBOX_TYPE ].base_vector_id; + irq_num = msix_info->msix_entries[local_vec_id].vector; + +devm_free_irq (dev, irq_num, dev_mgt); +} + +static int nbl_dev_enable_mailbox_irq (struct nbl_dev_mgt *dev_mgt) +{ +struct nbl_service_ops *serv_ops =NBL_DEV_MGT_TO_SERV_OPS (dev_mgt); +struct nbl_channel_ops *chan_ops =NBL_DEV_MGT_TO_CHAN_OPS (dev_mgt); +struct nbl_dev_common *dev_common =NBL_DEV_MGT_TO_COMMON_DEV (dev_mgt); +struct nbl_msix_info *msix_info = +NBL_DEV_COMMON_TO_MSIX_INFO (dev_common); +u16 local_vec_id; + +if (!msix_info->serv_info[NBL_MSIX_MAILBOX_TYPE ].num) +return 0 ; + + local_vec_id = + msix_info->serv_info[NBL_MSIX_MAILBOX_TYPE ].base_vector_id; + chan_ops->set_queue_state (NBL_DEV_MGT_TO_CHAN_PRIV (dev_mgt), +NBL_CHAN_INTERRUPT_READY , +NBL_CHAN_TYPE_MAILBOX , true); + +return serv_ops->enable_mailbox_irq (NBL_DEV_MGT_TO_SERV_PRIV (dev_mgt), + local_vec_id, true); +} + +static int nbl_dev_disable_mailbox_irq (struct nbl_dev_mgt *dev_mgt) +{ +struct nbl_service_ops *serv_ops =NBL_DEV_MGT_TO_SERV_OPS (dev_mgt); +struct nbl_channel_ops *chan_ops =NBL_DEV_MGT_TO_CHAN_OPS (dev_mgt); +struct nbl_dev_common *dev_common =NBL_DEV_MGT_TO_COMMON_DEV (dev_mgt); +struct nbl_msix_info *msix_info = +NBL_DEV_COMMON_TO_MSIX_INFO (dev_common); +u16 local_vec_id; + +if (!msix_info->serv_info[NBL_MSIX_MAILBOX_TYPE ].num) +return 0 ; + +nbl_common_flush_task (&dev_common->clean_mbx_task); + + local_vec_id = + msix_info->serv_info[NBL_MSIX_MAILBOX_TYPE ].base_vector_id; + chan_ops->set_queue_state (NBL_DEV_MGT_TO_CHAN_PRIV (dev_mgt), +NBL_CHAN_INTERRUPT_READY , +NBL_CHAN_TYPE_MAILBOX , false); + +return serv_ops->enable_mailbox_irq (NBL_DEV_MGT_TO_SERV_PRIV (dev_mgt), + local_vec_id, false); +} + +static int nbl_dev_configure_msix_map (struct nbl_dev_mgt *dev_mgt) +{ +struct nbl_service_ops *serv_ops =NBL_DEV_MGT_TO_SERV_OPS (dev_mgt); +struct nbl_dev_common *dev_common =NBL_DEV_MGT_TO_COMMON_DEV (dev_mgt); +struct nbl_msix_info *msix_info = +NBL_DEV_COMMON_TO_MSIX_INFO (dev_common); +u16 msix_not_net_num =0 ; +u16 msix_net_num = msix_info->serv_info[NBL_MSIX_NET_TYPE ].num; +bool mask_en = msix_info->serv_info[NBL_MSIX_NET_TYPE ].hw_self_mask_en; +int err =0 ; +int i; + +for (i =NBL_MSIX_NET_TYPE ; i <NBL_MSIX_TYPE_MAX ; i++) + msix_info->serv_info[i].base_vector_id = + msix_info->serv_info[i -1 ].base_vector_id + + msix_info->serv_info[i -1 ].num; + +for (i =NBL_MSIX_MAILBOX_TYPE ; i <NBL_MSIX_TYPE_MAX ; i++) { +if (i ==NBL_MSIX_NET_TYPE ) +continue ; + + msix_not_net_num += msix_info->serv_info[i].num; + } + + err = serv_ops->configure_msix_map (NBL_DEV_MGT_TO_SERV_PRIV (dev_mgt), + msix_net_num, + msix_not_net_num, + mask_en); + +return err; +} + +static int nbl_dev_destroy_msix_map (struct nbl_dev_mgt *dev_mgt) +{ +struct nbl_service_ops *serv_ops =NBL_DEV_MGT_TO_SERV_OPS (dev_mgt); + +return serv_ops->destroy_msix_map (NBL_DEV_MGT_TO_SERV_PRIV (dev_mgt)); +} + +static int nbl_dev_alloc_msix_entries (struct nbl_dev_mgt *dev_mgt, +u16 num_entries) +{ +struct nbl_dev_common *dev_common =NBL_DEV_MGT_TO_COMMON_DEV (dev_mgt); +struct nbl_msix_info *msix_info = +NBL_DEV_COMMON_TO_MSIX_INFO (dev_common); +void *priv =NBL_DEV_MGT_TO_SERV_PRIV (dev_mgt); +struct nbl_service_ops *serv_ops =NBL_DEV_MGT_TO_SERV_OPS (dev_mgt); +u16 i; + + msix_info->msix_entries = +devm_kcalloc (NBL_DEV_MGT_TO_DEV (dev_mgt), num_entries, +sizeof (msix_info->msix_entries),GFP_KERNEL ); +if (!msix_info->msix_entries) +return -ENOMEM ; + +for (i =0 ; i < num_entries; i++) + msix_info->msix_entries[i].entry = + serv_ops->get_msix_entry_id (priv, i); + +dev_info (NBL_DEV_MGT_TO_DEV (dev_mgt),"alloc msix entry: %u-%u.\n" , + msix_info->msix_entries[0 ].entry, + msix_info->msix_entries[num_entries -1 ].entry); + +return 0 ; +} + +static void nbl_dev_free_msix_entries (struct nbl_dev_mgt *dev_mgt) +{ +struct nbl_dev_common *dev_common =NBL_DEV_MGT_TO_COMMON_DEV (dev_mgt); +struct nbl_msix_info *msix_info = +NBL_DEV_COMMON_TO_MSIX_INFO (dev_common); + +devm_kfree (NBL_DEV_MGT_TO_DEV (dev_mgt), msix_info->msix_entries); + msix_info->msix_entries =NULL ; +} + +static int nbl_dev_alloc_msix_intr (struct nbl_dev_mgt *dev_mgt) +{ +struct nbl_dev_common *dev_common =NBL_DEV_MGT_TO_COMMON_DEV (dev_mgt); +struct nbl_msix_info *msix_info = +NBL_DEV_COMMON_TO_MSIX_INFO (dev_common); +struct nbl_common_info *common =NBL_DEV_MGT_TO_COMMON (dev_mgt); +int needed =0 ; +int err; +int i; + +for (i =0 ; i <NBL_MSIX_TYPE_MAX ; i++) + needed += msix_info->serv_info[i].num; + + err =nbl_dev_alloc_msix_entries (dev_mgt, (u16 )needed); +if (err) { +pr_err ("Allocate msix entries failed\n" ); +return err; + } + + err =pci_enable_msix_range (NBL_COMMON_TO_PDEV (common), + msix_info->msix_entries, needed, needed); +if (err <0 ) { +pr_err ("pci_enable_msix_range failed, err = %d.\n" , err); + goto enable_msix_failed; + } + +return needed; + +enable_msix_failed: +nbl_dev_free_msix_entries (dev_mgt); +return err; +} + +static void nbl_dev_free_msix_intr (struct nbl_dev_mgt *dev_mgt) +{ +struct nbl_common_info *common =NBL_DEV_MGT_TO_COMMON (dev_mgt); + +pci_disable_msix (NBL_COMMON_TO_PDEV (common)); +nbl_dev_free_msix_entries (dev_mgt); +} + +static int nbl_dev_init_interrupt_scheme (struct nbl_dev_mgt *dev_mgt) +{ +int err =0 ; + + err =nbl_dev_alloc_msix_intr (dev_mgt); +if (err <0 ) { +dev_err (NBL_DEV_MGT_TO_DEV (dev_mgt), +"Failed to enable MSI-X vectors\n" ); +return err; + } +return 0 ; +} + +static void nbl_dev_clear_interrupt_scheme (struct nbl_dev_mgt *dev_mgt) +{ +nbl_dev_free_msix_intr (dev_mgt); +} +/* ---------- Channel config ---------- */ static int nbl_dev_setup_chan_qinfo (struct nbl_dev_mgt *dev_mgt,u8 chan_type) {
@@ -96,6 +338,14 @@ static void nbl_dev_clean_mailbox_task(struct work_struct *work) NBL_CHAN_TYPE_MAILBOX); } +static int nbl_dev_clean_mailbox_schedule (struct nbl_dev_mgt *dev_mgt) +{ +struct nbl_dev_common *common_dev =NBL_DEV_MGT_TO_COMMON_DEV (dev_mgt); + +nbl_common_queue_work (&common_dev->clean_mbx_task, false); +return 0 ; +} +/* ---------- Dev init process ---------- */ static int nbl_dev_setup_common_dev (struct nbl_adapter *adapter,struct nbl_init_param *param)
@@ -572,6 +822,7 @@ int nbl_dev_init(void *p, struct nbl_init_param *param) ret =nbl_dev_setup_ops (dev, dev_ops_tbl, adapter);if (ret) goto setup_ops_fail; +return 0 ; setup_ops_fail:
@@ -605,11 +856,64 @@ void nbl_dev_remove(void *p)nbl_dev_remove_dev_mgt (common, dev_mgt); } -int nbl_dev_start (void *p,struct nbl_init_param *param) +/* ---------- Dev start process ---------- */ + +static int nbl_dev_start_common_dev (struct nbl_adapter *adapter, +struct nbl_init_param *param) { +struct nbl_dev_mgt *dev_mgt = + (struct nbl_dev_mgt *)NBL_ADAP_TO_DEV_MGT (adapter); +int ret; + + ret =nbl_dev_configure_msix_map (dev_mgt); +if (ret) + goto config_msix_map_err; + + ret =nbl_dev_init_interrupt_scheme (dev_mgt); +if (ret) + goto init_interrupt_scheme_err; + + ret =nbl_dev_request_mailbox_irq (dev_mgt); +if (ret) + goto mailbox_request_irq_err; + + ret =nbl_dev_enable_mailbox_irq (dev_mgt); +if (ret) + goto enable_mailbox_irq_err;return 0 ; +enable_mailbox_irq_err: +nbl_dev_free_mailbox_irq (dev_mgt); +mailbox_request_irq_err: +nbl_dev_clear_interrupt_scheme (dev_mgt); +init_interrupt_scheme_err: +nbl_dev_destroy_msix_map (dev_mgt); +config_msix_map_err: +return ret; +} + +static void nbl_dev_stop_common_dev (struct nbl_adapter *adapter) +{ +struct nbl_dev_mgt *dev_mgt = + (struct nbl_dev_mgt *)NBL_ADAP_TO_DEV_MGT (adapter); + +nbl_dev_disable_mailbox_irq (dev_mgt); +nbl_dev_free_mailbox_irq (dev_mgt); +nbl_dev_clear_interrupt_scheme (dev_mgt); +nbl_dev_destroy_msix_map (dev_mgt); +} + +int nbl_dev_start (void *p,struct nbl_init_param *param) +{ +struct nbl_adapter *adapter = (struct nbl_adapter *)p; +int ret; + + ret =nbl_dev_start_common_dev (adapter, param); +return ret; }void nbl_dev_stop (void *p) { +struct nbl_adapter *adapter = (struct nbl_adapter *)p; + +nbl_dev_stop_common_dev (adapter); }
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_service.c +394 -1
423 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c +33 -1
@@ -314,7 +314,39 @@ static struct pci_driver nbl_driver = { .remove = nbl_remove, }; -module_pci_driver (nbl_driver); +static int __init nbl_module_init (void ) +{ +int status; + + status =nbl_common_create_wq (); +if (status) { +pr_err ("Failed to create wq, err = %d\n" , status); + goto wq_create_failed; + } + status =pci_register_driver (&nbl_driver); +if (status) { +pr_err ("Failed to register PCI driver, err = %d\n" , status); + goto pci_register_driver_failed; + } +pr_info ("nbl module loaded\n" ); +return 0 ; + +pci_register_driver_failed: +nbl_common_destroy_wq (); +wq_create_failed: +return status; +} + +static void __exit nbl_module_exit(void) +{ +pci_unregister_driver (&nbl_driver); + +nbl_common_destroy_wq (); + +pr_info ("nbl module unloaded\n" ); +} +module_init (nbl_module_init); +module_exit (nbl_module_exit);MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("Nebula Matrix Network Driver" );
Signature · 1 line
2.47.3
illusion.wang
maintainerPATCH v3 15/15 net/nebula-matrix: add net dev start/stop operation
In reply to illusion.wangstart net dev:
1 alloc netdev with multi-queue support, config private data
and associatess with the adapter.
2 alloc tx/rx rings, set up network resource managements(vlan,rate
limiting)
3 build the netdev structure, map queues to msix interrupts, init
hw stats.
4 start net vsi and register net irq.
5 register netdev
--- .../net/ethernet/nebula-matrix/nbl/nbl_core.h | 26 + .../nebula-matrix/nbl/nbl_core/nbl_dev.c | 450 +++++++++++++ .../nebula-matrix/nbl/nbl_core/nbl_service.c | 595 ++++++++++++++++++ .../nebula-matrix/nbl/nbl_core/nbl_service.h | 6 + .../nbl/nbl_include/nbl_def_common.h | 1 + .../nbl/nbl_include/nbl_def_service.h | 1 - .../nbl/nbl_include/nbl_include.h | 43 ++ 7 files changed, 1121 insertions(+), 1 deletion(-)
drivers/net/ethernet/nebula-matrix/nbl/nbl_core.h +26 -0
@@ -43,6 +43,18 @@#define NBL_NETDEV_TO_ADAPTER (netdev) \ (NBL_NETDEV_PRIV_TO_ADAPTER( \ (struct nbl_netdev_priv *)netdev_priv(netdev))) + +#define NBL_NETDEV_TO_SERV_MGT (netdev) \ + (NBL_ADAP_TO_SERV_MGT(NBL_NETDEV_PRIV_TO_ADAPTER(\ + (struct nbl_netdev_priv *)netdev_priv(netdev)))) + +#define NBL_NETDEV_TO_DEV_MGT (netdev) \ + (NBL_ADAP_TO_DEV_MGT(NBL_NETDEV_TO_ADAPTER(netdev))) + +#define NBL_NETDEV_TO_COMMON (netdev) \ + (NBL_ADAP_TO_COMMON(NBL_NETDEV_PRIV_TO_ADAPTER(\ + (struct nbl_netdev_priv *)netdev_priv(netdev)))) +#define NBL_CAP_TEST_BIT (val, loc) (((val) >> (loc)) & 0x1)#define NBL_CAP_IS_CTRL (val) NBL_CAP_TEST_BIT(val, NBL_CAP_HAS_CTRL_BIT)
@@ -59,6 +71,19 @@ enum { NBL_CAP_IS_OCP_BIT, }; +enum nbl_adapter_state { +NBL_DOWN , +NBL_RESETTING , +NBL_RESET_REQUESTED , +NBL_INITING , +NBL_INIT_FAILED , +NBL_RUNNING , +NBL_TESTING , +NBL_USER , +NBL_FATAL_ERR , +NBL_STATE_NBITS +}; +struct nbl_interface {struct nbl_hw_ops_tbl *hw_ops_tbl;struct nbl_resource_ops_tbl *resource_ops_tbl;
@@ -84,6 +109,7 @@ struct nbl_adapter {struct nbl_common_info common;struct nbl_product_base_ops *product_base_ops;struct nbl_init_param init_param; +DECLARE_BITMAP (state,NBL_STATE_NBITS ); };struct nbl_netdev_priv {
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.c +450 -0
510 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_service.c +595 -0
640 lines not on this page · raw message
drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_service.h +6 -0
@@ -123,4 +123,10 @@ struct nbl_service_mgt { struct nbl_serv_net_resource_mgt *net_resource_mgt; }; +int nbl_serv_netdev_open (struct net_device *netdev); +int nbl_serv_netdev_stop (struct net_device *netdev); +int nbl_serv_vsi_open (void *priv,struct net_device *netdev,u16 vsi_index, +u16 real_qps,bool use_napi); +int nbl_serv_vsi_stop (void *priv,u16 vsi_index); +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_common.h +1 -0
@@ -161,4 +161,5 @@ int nbl_common_alloc_hash_node(void *priv, void *key, void *data, void **out_data);void *nbl_common_get_hash_node (void *priv,void *key);void nbl_common_free_hash_node (void *priv,void *key); +#endif
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_service.h +0 -1
@@ -50,7 +50,6 @@ struct nbl_service_ops {int (*setup_rss_indir)(void *priv,u16 vsi_id);int (*alloc_rings)(void *priv,struct net_device *dev,struct nbl_ring_param *param); -void (*cpu_affinity_init)(void *priv,u16 rings_num);void (*free_rings)(void *priv);int (*enable_napis)(void *priv,u16 vsi_index);void (*disable_napis)(void *priv,u16 vsi_index);
drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_include.h +43 -0
56 lines not on this page · raw message
Signature · 1 line
2.47.3
Simon Horman
reviewer...
Quoted 1 line
55 files changed, 26753 insertions(+)
Hi,
I realise this is down from the 45kLoC in v1,
but 26kLoC is still too much for a patchset.
As per Jakub's advice in his review of v1 [*], Please try to create a minimal driver in the order of ~5kLoC.
Thanks!
[*] https://lore.kernel.org/netdev/[email protected]/
...
Jakub Kicinski
maintainerQuoted 2 lines · On Tue, 27 Jan 2026 18:06:49 +0000 Simon Horman wrote:
As per Jakub's advice in his review of v1 [*], Please try to create a minimal driver in the order of ~5kLoC.
Perhaps other maintainers will disagree, but for ease of review and to avoid the huge reposts perhaps we should consider merging something like patches 1 and 3* first, as the initial series. And then you can build up the driver from there in reasonable, 5kLoC-at-a-time series?
* patch 3 currently includes things which do not seem machine generated / like register descriptors like structs added to nbl_def_channel.h and nbl_include.h
Quoted 10 lines · On Tue, 27 Jan 2026 10:53:04 -0800 Jakub Kicinski <[email protected]> wrote:
Quoted 2 lines · On Tue, 27 Jan 2026 18:06:49 +0000 Simon Horman wrote:
As per Jakub's advice in his review of v1 [*], Please try to create a minimal driver in the order of ~5kLoC.
Perhaps other maintainers will disagree, but for ease of review and to avoid the huge reposts perhaps we should consider merging something like patches 1 and 3* first, as the initial series. And then you can build up the driver from there in reasonable, 5kLoC-at-a-time series?
Quoted 4 lines
* patch 3 currently includes things which do not seem machine generated / like register descriptors like structs added to
nbl_def_channel.handnbl_include.h
Part of the size problem is that the driver has multiple layers:
resources, channels, etc and lots of code that tries to be common across OS's. This can lead to bloat. Very few drivers have done that successfully.
Illusion Wang
maintainerThank you for your feedback
patch3 primarily includes code that does not require extensive review, such as the message codes and message body structures defined in nbl_def_channel.h. These components are generally stable and used for PF/VF communication, which is why they were initially included in Patch 3. However, based on review feedback, I will extract these manually written communication protocol definitions.
Additionally, I will make another round of comprehensive code reduction to meet the submission requirements as much as possible.
------------------------------------------------------------------
发件人:Jakub Kicinski <[email protected]>
发送时间:2026年1月28日(周三) 02:53
收件人:Simon Horman<[email protected]>; Illusion Wang<[email protected]>
抄 送:Dimon<[email protected]>; Alvin<[email protected]>; Sam<[email protected]>; netdev<[email protected]>; "andrew+netdev"<[email protected]>; corbet<[email protected]>; "linux-doc"<[email protected]>; lorenzo<[email protected]>; pabeni<[email protected]>; "vadim.fedorenko"<[email protected]>; "lukas.bulwahn"<[email protected]>; hawk<[email protected]>; ast<[email protected]>; bpf<[email protected]>; sdf<[email protected]>; daniel<[email protected]>; "john.fastabend"<[email protected]>; edumazet<[email protected]>; open list<[email protected]> 主 题:Re: [PATCH v3 net-next 00/15] nbl driver for Nebulamatrix NICs
Quoted 2 lines · On Tue, 27 Jan 2026 18:06:49 +0000 Simon Horman wrote:
As per Jakub's advice in his review of v1 [*], Please try to create a minimal driver in the order of ~5kLoC.
Perhaps other maintainers will disagree, but for ease of review and to avoid the huge reposts perhaps we should consider merging something like patches 1 and 3* first, as the initial series. And then you can build up the driver from there in reasonable, 5kLoC-at-a-time series?
* patch 3 currently includes things which do not seem machine generated / like register descriptors like structs added to nbl_def_channel.h and nbl_include.h
Simon Horman
reviewerQuoted 10 lines · Jakub Kicinski
Quoted 2 lines · On Tue, 27 Jan 2026 18:06:49 +0000 Simon Horman wrote:
As per Jakub's advice in his review of v1 [*], Please try to create a minimal driver in the order of ~5kLoC.
Perhaps other maintainers will disagree, but for ease of review and to avoid the huge reposts perhaps we should consider merging something like patches 1 and 3* first, as the initial series. And then you can build up the driver from there in reasonable, 5kLoC-at-a-time series?
Quoted 3 lines
* patch 3 currently includes things which do not seem machine generated / like register descriptors like structs added to
nbl_def_channel.handnbl_include.h
Without having looked into the details: yes, I think some sort of staged approached could help here.