On Thu, 26 Nov 2026 15:34:17 +0800
Dimon Zhao <[email protected]> wrote:

> This series adds support for Nebulamatrix Draco adapters to the NBL PMD.
> 
> Dimon Zhao (11):
>   net/nbl: prepare common interfaces for draco
>   net/nbl: add draco HW layer
>   net/nbl: add draco channel layer
>   net/nbl: add draco resource layer
>   net/nbl: add draco dispatch layer
>   net/nbl: add draco device layer
>   net/nbl: support draco queue setup and release
>   net/nbl: support draco Tx and Rx burst
>   net/nbl: support draco stats and xstats
>   net/nbl: support draco hardware VLAN offload
>   doc: update nbl driver guide for draco
> 
>  doc/guides/nics/nbl.rst                       |   8 +
>  drivers/net/nbl/meson.build                   |   2 +
>  drivers/net/nbl/nbl_core.c                    |  19 +-
>  drivers/net/nbl/nbl_core.h                    |  10 +
>  drivers/net/nbl/nbl_dev/nbl_dev.c             |  85 +++++-
>  drivers/net/nbl/nbl_dev/nbl_dev.h             |   5 +-
>  drivers/net/nbl/nbl_dispatch.c                | 170 ++++++++---
>  drivers/net/nbl/nbl_dispatch.h                |   1 +
>  drivers/net/nbl/nbl_ethdev.c                  |   9 +
>  drivers/net/nbl/nbl_hw/nbl_channel.c          | 135 ++++-----
>  drivers/net/nbl/nbl_hw/nbl_channel.h          |  91 ++++--
>  drivers/net/nbl/nbl_hw/nbl_hw.h               |   4 +
>  .../nbl_hw/nbl_hw_draco/nbl_hw_draco_snic.c   | 244 ++++++++++++++++
>  .../nbl_hw/nbl_hw_draco/nbl_hw_draco_snic.h   |  62 ++++
>  .../nbl/nbl_hw/nbl_hw_draco/nbl_res_draco.c   | 274 ++++++++++++++++++
>  .../nbl/nbl_hw/nbl_hw_draco/nbl_res_draco.h   |  10 +
>  .../nbl/nbl_hw/nbl_hw_leonis/nbl_res_leonis.c | 181 ++++++------
>  drivers/net/nbl/nbl_hw/nbl_resource.h         |  80 +++++
>  drivers/net/nbl/nbl_hw/nbl_txrx.c             |  74 ++++-
>  drivers/net/nbl/nbl_include/nbl_def_channel.h |  10 +-
>  .../net/nbl/nbl_include/nbl_def_dispatch.h    |   2 +
>  drivers/net/nbl/nbl_include/nbl_def_hw.h      |   5 +
>  .../net/nbl/nbl_include/nbl_def_resource.h    |   5 +
>  drivers/net/nbl/nbl_include/nbl_include.h     |  10 +
>  24 files changed, 1247 insertions(+), 249 deletions(-)
>  create mode 100644 drivers/net/nbl/nbl_hw/nbl_hw_draco/nbl_hw_draco_snic.c
>  create mode 100644 drivers/net/nbl/nbl_hw/nbl_hw_draco/nbl_hw_draco_snic.h
>  create mode 100644 drivers/net/nbl/nbl_hw/nbl_hw_draco/nbl_res_draco.c
>  create mode 100644 drivers/net/nbl/nbl_hw/nbl_hw_draco/nbl_res_draco.h
> 

I did first pass AI review and it saw this:
Review of [PATCH v1 00/11] net/nbl: draco support

Applied to main (ddb3b0c, 27.03-rc0) with git am, no conflicts.
Every commit builds with -Dwerror=true -Denable_drivers=net/nbl (gcc).
Review is from post-apply source. No hardware, nothing was run.

Series
------

Warning: draco PF is coexistence only, but the series tests that with
a different predicate than the rest of the driver. Patches 05/06 use

        if (!NBL_IS_COEXISTENCE(common) && !common->is_vf)

which is devfd != -1. nbl_chan_setup_ops(), nbl_dev_common_start() and
nbl_pci_unmap_device() use NBL_IS_NOT_COEXISTENCE(), which is
nl_socket_route < 0 || ifindex < 0. nbl_pci_map_device() does not fail
when NBL_DEV_USER_GET_IFINDEX or the netlink socket fails, so devfd can
be valid while NBL_IS_NOT_COEXISTENCE() is true. In that state a draco
PF passes the check in nbl_dev_snic_init(), gets nbl_chan_ops (native
mailbox), and nbl_userdev.c has set mem_resource[2].addr = 0, so
nbl_hw_config_mailbox_txq() writes through a NULL mailbox_bar_hw_addr.
Use the same macro as the channel layer:

        if (adapter->caps.product_type == NBL_DRACO_TYPE &&
            NBL_IS_NOT_COEXISTENCE(common) && !common->is_vf) {

Warning: nbl_hw_draco_snic.c is nbl_hw_leonis_snic.c with capture_bdf
added and one delay replaced by a readback; nbl_res_draco.c differs from
nbl_res_leonis.c only in the stats table and nbl_res_start(). That is
about 400 lines of copy. Share the code and keep only the differences
per product (ops table, stats table, mbx write, bdf capture).

Warning: no release note. New device family in an existing driver
belongs in release_27_03.rst.

Info: 01/11 adds the draco IDs to pci_id_nbl_map, but the port is not
usable until 08/11. Move the ID table entries to 08/11 and most of the
"return -ENOTSUP until the next layer exists" churn in 01-07 goes away.

Patch 03/11: add draco channel layer
------------------------------------

Warning: product_type is stored inside one arm of the union it is
supposed to describe:

        union nbl_chan_info {
                struct { ... enum nbl_product_type product_type; } mailbox;
                struct { ... } userdev;
        };

and nbl_chan_recv_msg() reads chan_info->mailbox.product_type on the
userdev path too (nbl_chan_userdev_eventfd_handler). It only works
because the field lands at offset 280 and the userdev arm is 80 bytes.
Draco PF always runs the userdev arm. Put it in struct nbl_channel_mgt.

Warning: DESC_R()/DESC_W() silently use a local named chan_info, and
nbl_chan_recv_msg() grows a variable only to feed the macro. Pass the
type explicitly, for example

        static inline bool nbl_chan_is_draco(const struct nbl_channel_mgt *m)
        #define DESC_R(mgt, desc, field) ...

or, since only buf_len/buf_addr (Tx) and buf_len/buf_id (Rx) move
between the two layouts (checked with offsetof, the rest is at the same
offset), keep one struct and add small accessors for those fields.

Patch 05/11: add draco dispatch layer
Patch 06/11: add draco device layer
-----------------------------------

Warning: 06/11 rewrites a line 05/11 just added (devfd == -1 becomes
!NBL_IS_COEXISTENCE). Fold that into 05/11.

Info: the NBL_DISP_CTRL_LVL_MGT branch in nbl_disp_draco_init() cannot
be used. nbl_dev_snic_init() rejects the only case that selects it, and
draco has no resource ops behind the MGT level calls. Set NET
unconditionally and drop the branch.

Patch 07/11: support draco queue setup and release
--------------------------------------------------

Info (pre-existing, not introduced here, but the patch rewrites the
lines): the fallback Tx header slots overlap for leonis.

        u = RTE_PTR_ADD(tx_region, (size_t)desc_index * txq->exthdr_len);

Leonis stride is 12 bytes, but the VLAN fallback writes
12 + 14 + 4 = 30 bytes at u. A single segment packet that cannot be
pushed uses two descriptors, so the next such packet starts 24 bytes
later and overwrites the ether_type and VLAN header of the previous one
before the kick. The memzone is already nb_desc * NBL_TX_HEADER_LEN, so

        u = RTE_PTR_ADD(tx_region, (size_t)desc_index * NBL_TX_HEADER_LEN);
        ...
        head_desc->addr = net_hdr_mem +
                          (size_t)desc_index * NBL_TX_HEADER_LEN;

fixes it for both products. Separate patch with Fixes: and Cc: stable.

Patch 08/11: support draco Tx and Rx burst
------------------------------------------

Info: this changes leonis as well. nbl_res_txrx_update_rx_ring() used
to OR the wrap flag into bit 0 of next_to_use and now puts it in bit 15,
and nbl_fill_rx_ring() adds an MMIO write per refill on leonis. The
first looks like a bug fix; say so in the commit message and state that
leonis was retested.

Patch 09/11: support draco stats and xstats
-------------------------------------------

Warning: masking the delta fixes the bogus huge value after a wrap, but
the reported xstat is still only 32 (or 48) bits wide:

        return (current - baseline) & ((UINT64_C(1) << bits) - 1);

eth_rx_prioN_packets goes back to 0 after 2^32 packets since the last
reset, which is a couple of minutes at 25G. xstats are 64 bit and
monotonic. Accumulate instead:

        delta = (cur - net_dev->hw_xstats_prev[i]) & mask;
        net_dev->hw_xstats_total[i] += delta;
        net_dev->hw_xstats_prev[i] = cur;
        xstats[count].value = net_dev->hw_xstats_total[i];

with xstats_reset clearing total[]. That still needs a read at least
once per wrap period; if the kernel PF can return widened counters that
is the better fix.

Warning: hw_xstats_bits is control path only bookkeeping, no need for
hugepage memory. Use calloc()/free() as hw_xstats already does:

        net_dev->hw_xstats_bits = rte_zmalloc("nbl_xstats_bits", priv_cnt, 0);

Patch 10/11: support draco hardware VLAN offload
------------------------------------------------

Error: the strip setting from dev_configure is never sent to hardware.
nbl_vlan_offload_set() is only reachable as the ethdev callback
(nbl_ethdev.c .vlan_offload_set); nothing in nbl_dev_configure() or
nbl_dev_port_start() calls it, and ethdev does not call it on
configure/start. An application that sets RTE_ETH_RX_OFFLOAD_VLAN_STRIP
in rxmode.offloads gets whatever parse mode the kernel PF left behind,
and one that leaves it off may still get tags stripped. Apply the
configured state at start:

        /* nbl_dev_port_start() */
        ret = nbl_vlan_offload_set(eth_dev, RTE_ETH_VLAN_STRIP_MASK);
        if (ret) {
                NBL_LOG(ERR, "vlan strip config failed %d", ret);
                goto ...;
        }

Warning: stripped priority-tagged frames lose the tag.

        if (rx_ext_hdr->draco.vlan & 0xFFF) {

VID 0 with a non-zero PCP is a valid 802.1Q tag. Hardware strips it,
the test fails, and the mbuf is delivered untagged with no
RTE_MBUF_F_RX_VLAN. If the Rx header has a "tag stripped" bit use it;
otherwise test the full 16 bits.

Warning: rx_hash_en no longer means what its name says. 07/11 adds it
as "selects the Rx header length ... RSS hash reporting is not enabled",
and this patch turns it on for every draco queue in a VLAN patch:

        param.rx_hash_en = adapter->caps.product_type == NBL_DRACO_TYPE;

without a word in the commit message. After this patch the
"if (!param->rx_hash_en) exthdr_len -= sizeof(u32)" branch is dead. If
the 16 byte header follows from half_offload_en, drop rx_hash_en and
the 12 byte case from the series and set half_offload_en where the
datapath is enabled (08/11), so the Rx header length does not change
between bisect points.

Info: nbl_disp_cfg_rx_vlan_parse() and the cfg_rx_vlan_parse resource
op have no implementation and no caller that can reach them (see the
MGT level note under 05/11). Drop them until something implements it.

Info (pre-existing, nbl_res_leonis.c, not touched by this series):
nbl_res_setup_ops() does rte_free(*res_ops_tbl) on memory that came from
calloc(). The draco copy has this fixed; leonis still needs it.

Reply via email to