On Fri,  4 Dec 2026 16:09:44 +0800
Dimon Zhao <[email protected]> wrote:

> This series adds support for Nebulamatrix Draco adapters to the NBL PMD.
> 
> Changes in v3:
> - Fold the Leonis Tx VLAN fallback stride fix and its size check into
>   the Tx/Rx burst patch so the series applies directly to dpdk-next-net.

Still several things in AI review that need addressing.

Review: net/nbl draco support v3 (11 patches, bundle 2299)

Applied to main at ddb3b0c47 ("version: 27.03-rc0"); patch 11 applied
with the release notes excluded.  All 11 commits build with
-Dwerror=true -Denable_drivers=net/nbl, so no bisect breakage.

Descriptor layouts verified by compiling offsetof/sizeof: both arms of
union nbl_chan_tx_desc are 64 bytes and both arms of
union nbl_chan_rx_desc are 16, so the ring allocations do not change
for leonis.


Errors
------

09/11: xstats init error path double-frees, and destroys a mutex that
was never initialized

nbl_dev_hw_xstats_init() frees four pointers without clearing them:

  free_xstats:
      free(net_dev->hw_xstats_bits);
      free(net_dev->hw_xstats_total);
      free(net_dev->hw_xstats);
      rte_free(net_dev->hw_xstats_offset);
      return ret;

nbl_dev_common_start() propagates that failure out through
nbl_dev_snic_start(), so rte_eth_dev_start() fails.  nbl_dev_close()
then calls nbl_dev_release_pf() -> nbl_core_stop() -> nbl_dev_stop()
-> nbl_dev_snic_stop() unconditionally, and that frees the same four
pointers a second time:

      if (net_dev->hw_xstats_total)
              pthread_mutex_destroy(&net_dev->hw_xstats_lock);
      free(net_dev->hw_xstats_bits);
      free(net_dev->hw_xstats_total);
      free(net_dev->hw_xstats);
      rte_free(net_dev->hw_xstats_offset);

When the failure is the hw_xstats_bits calloc or get_hw_xstats_bits,
hw_xstats_total is non-NULL, so pthread_mutex_destroy() also runs on a
mutex that pthread_mutex_init() never reached.

hw_xstats_cnt is already set by then as well, so nbl_xstats_reset()
and nbl_dev_update_hw_stats() both pass their
"if (net_dev->hw_xstats_total)" test, lock the uninitialized mutex and
write into the freed arrays.

Set each pointer to NULL after freeing, in both functions, and track
whether the mutex was initialized.  While you are there,
hw_xstats_offset is the only one of the four allocated with
rte_zmalloc; it is CPU-only bookkeeping, so calloc fits and the free
path becomes uniform.

09/11: pthread mutex in rte_zmalloc memory with default attributes

  pthread_mutex_t hw_xstats_lock;

is added to struct nbl_dev_net_mgt, which comes from the DPDK heap:

  net_dev = rte_zmalloc("nbl_dev_net",
                        sizeof(struct nbl_dev_net_mgt), 0);

and is initialized process-private:

  ret = pthread_mutex_init(&net_dev->hw_xstats_lock, NULL);

That memory is mapped into secondary processes, so the mutex needs
PTHREAD_PROCESS_SHARED or it must not live there.  rte_spinlock_t is
not a drop-in substitute while the lock covers a mailbox round trip,
see the next item; narrowing the critical section first makes either
primitive correct.


Warnings
--------

08/11: changes the leonis Tx doorbell and adds a leonis Rx doorbell

Two datapath changes land on leonis, not only draco.

Tx was a bare queue id:

  rte_write32(txq->notify_qid, txq->notify);

and now carries a tail pointer and wrap flag:

  notify_val = nbl_res_txrx_notify_value(txq->notify_qid,
                                         txq->next_to_use,
                                         txq->avail_used_flags);
  rte_write32(notify_val, txq->notify);

On Rx, nbl_fill_rx_ring() gains

  rte_write32(nbl_res_txrx_notify_value(rxq->notify_qid,
                                        desc_index,
                                        rxq->avail_used_flags),
              rxq->notify);

Before this series the Rx doorbell was written once per queue at start
and never again: nbl_res_txrx_update_rx_ring() has exactly one caller,
disp_ops->update_rx_ring() in nbl_dev_txrx_start().  So leonis now
takes an extra MMIO write per NBL_RXQ_REARM_THRESH packets, and its Tx
doorbell carries a value it never carried before.

The commit offers only "A software test with mocked MMIO verified the
Leonis tail encoding and refill notifications".  A mock confirms the
value computed, not that leonis hardware accepts it.  Either confirm
on leonis hardware and say so in the commit message, or gate both
writes on product == NBL_DRACO_TYPE and leave leonis alone.

09/11: xstats lock held across a mailbox round trip

Every caller takes hw_xstats_lock and then calls
nbl_dev_sample_hw_xstats(), whose first statement is

  ret = disp_ops->get_private_stat_data(
            NBL_DEV_MGT_TO_DISP_PRIV(dev_mgt),
            common->eth_id, net_dev->hw_xstats, size);

For draco that resolves to nbl_disp_get_private_stat_data_req(), which
sends with ack set and waits in nbl_chan_send_msg(): rte_delay_us(50)
per iteration, up to NBL_CHAN_RETRY_TIMES (20000), so about a second
worst case.  nbl_dev_update_hw_stats() reaches this from the
rte_eal_alarm handler, that is, the EAL interrupt thread.

Read into a local buffer with the lock dropped and take the lock only
to fold the deltas into hw_xstats_offset and hw_xstats_total.  That
also removes the constraint noted in the second Error above.

05/11: sfid is added to the mailbox request but never populated

  u16 sfid;

in struct nbl_chan_param_get_vsi_id is the only occurrence of sfid in
the tree, and nbl_disp_chan_get_vsi_id_req() sends

  struct nbl_chan_param_get_vsi_id param = {0};

so the PF always receives zero there.  Meanwhile 04/11 captures the
function id and discards it:

  ret = hw_ops->capture_bdf(NBL_RES_MGT_TO_HW_PRIV(res_mgt),
                            &func_id, &mgt_pf);
  if (ret)
          return ret;
  common->mgt_pf = mgt_pf;

These look like two halves of one change.  If the PF reads the source
function id out of the request, keep func_id alongside mgt_pf and set
param.sfid from it.  If the field is response-only padding, call it
rsv and say so in the commit message.

10/11: draco Rx reports VLAN_STRIPPED from the descriptor alone

  if (rx_ext_hdr->draco.vlan) {
          rx_mbuf->vlan_tci = rx_ext_hdr->draco.vlan;
          rx_mbuf->ol_flags = RTE_MBUF_F_RX_VLAN |
                  RTE_MBUF_F_RX_VLAN_STRIPPED;
  }

Nothing here consults RTE_ETH_RX_OFFLOAD_VLAN_STRIP, so correctness
rests entirely on the parse-mode request having taken effect.  That
request is sent without an ACK:

  NBL_CHAN_SEND(chan_send, NBL_DISP_MGT_GET_DST_ID(disp_mgt),
                NBL_CHAN_MSG_CFG_RX_VLAN_PARSE, &param,
                sizeof(param), NULL, 0, 0);

A PF-side rejection is therefore invisible, and the driver would then
report a stripped tag on every tagged frame while the application has
strip disabled.  The leonis path a few lines below does check the
offload:

  if (rxq->product == NBL_LEONIS_TYPE &&
      (rxq->eth_dev->data->dev_conf.rxmode.offloads &
       RTE_ETH_RX_OFFLOAD_VLAN_STRIP))

Check the offload in the draco branch too, or request the ACK so a
failed parse-mode change is visible.


Info
----

03/11: DESC_R and DESC_W are unprefixed, and broader than needed

Every other macro in nbl_channel.h carries the NBL_ prefix
(NBL_CHAN_TX_DESC, NBL_CHAN_RX_DESC); these two do not.

They also put a runtime product_type branch on roughly fifteen field
accesses when only four fields move.  From the offsets I compiled: tx
buf_addr is at 10 for leonis and 8 for draco, tx buf_len at 8 and 16,
rx buf_len at 2 and 4, rx buf_id at 6 and 2.  flags, srcid, dstid,
data_len, msg_type, data, msgid and rx buf_addr sit at identical
offsets in both arms.  Suffixing only the fields that move would
leave the common ones as plain accesses.

02/11: the mailbox write flush reads the doorbell register

  rte_write32(rte_cpu_to_le_32(value),
              ((hw_mgt)->mailbox_bar_hw_addr + (reg)));
  /* Flush the posted mailbox write. */
  rte_read32(hw_mgt->mailbox_bar_hw_addr);

Offset 0 of that BAR is NBL_MAILBOX_NOTIFY_ADDR, the mailbox
doorbell.  Reading back the register just written flushes equally well
without touching the doorbell:

  rte_read32(hw_mgt->mailbox_bar_hw_addr + reg);

Replacing the leonis rte_delay_us() with a readback is otherwise a
good change.

08/11: the doorbell encoding has an unrecorded ring-size limit

nbl_res_txrx_notify_value() puts the wrap flag in bit 31 and the tail
in bits 16 to 31, so the tail has to stay inside 15 bits.  That holds
only because dev_info->{rx,tx}_desc_lim.nb_max is 32768.  Nothing ties
the two together; a static_assert or a comment at the encoder would
keep a later nb_max bump from silently corrupting the tail.

Reply via email to