From: netdev-bot+sashiko@kernel.org
To: tariqt@nvidia.com
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, netdev@vger.kernel.org, pabeni@redhat.com,
willemb@google.com, cjubran@nvidia.com, gal@nvidia.com,
linux-kernel@vger.kernel.org, shshitrit@nvidia.com
Subject: Re: [PATCH net-next V4 2/5] net/mlx5: nodnic: Implement data path
Date: Fri, 04 Dec 2026 21:45:47 +0000 [thread overview]
Message-ID: <179642074710.3146.821124371315133765@kernel.org> (raw)
In-Reply-To: <20261203205721.4090361-3-tariqt@nvidia.com>
Thank you for your contribution! Sashiko AI review found 14 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 7 · Low: 7
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] This patch is the first to call mlx5_nodnic_enable_port(), so
its fixed RX filter setup now takes effect.
- [Medium] Error CQEs are never recovered.
- [Medium] mlx5_nodnic_handle_recv_cqe() takes `byte_count =
be32_to_cpu(cqe->byte_cnt)` straight from the device CQE and passes it…
- [Medium] On close, mlx5_nodnic_deactivate_queues() calls
mlx5_nodnic_quiesce_port(), which goes through…
- [Medium] net/mlx5: unratelimited log and unbudgeted loop in
mlx5_nodnic_napi_poll()
- [Medium] net/mlx5: nodnic advertises NETIF_F_HW_CSUM without generic
checksum offload
- [Medium] net/mlx5: nodnic: full-page RX buffers bloat ring and truesize
on 64K pages
- [Low] The commit message talks only about the TX/RX/NAPI data path, but
the patch also changes device-level control-path behaviour.
- [Low] mlx5_nodnic_xmit() never calls skb_tx_timestamp().
- [Low] In netpoll mode, poll_one_napi() calls napi->poll(napi, 0)
(net/core/netpoll.c).
- [Low] mlx5_nodnic_activate_queues() calls napi_enable_locked(), then
mlx5_nodnic_arm_cq(cq) from process context, then napi_schedule().
- [Low] mlx5_nodnic_tx_build_wqe_ds() assumes every skb is linear.
- [Low] net/mlx5: nodnic: duplicate dma_wmb() on TX path in
mlx5_nodnic_xmit()
- [Low] net/mlx5: nodnic: missing linux/types.h include in rx.h
--
net/mlx5: nodnic: Implement data path
This commit adds the TX and RX data paths for the mlx5_nodnic driver. It
covers WQE posting, BlueFlame doorbells, page pool backed RX and a NAPI
poll loop over a CQ shared by TX and RX. It also wires up ndo_start_xmit
and ndo_features_check and enables TX/RX checksum offload.
> diff --git a/drivers/net/ethernet/mellanox/mlx5/nodnic/en.c b/drivers/net/ethernet/mellanox/mlx5/nodnic/en.c
> new file mode 100644
> index 0000000000000..6cbdfaf7cc01d
> --- /dev/null
> +++ b/drivers/net/ethernet/mellanox/mlx5/nodnic/en.c
> @@ -0,0 +1,290 @@
[ ... ]
> +static void mlx5_nodnic_handle_err_cqe(struct mlx5_nodnic_cq *cq,
> + struct mlx5_cqe64 *cqe64,
> + int napi_budget)
> +{
[ ... ]
> + if (opcode == OPCODE_CQ_SEND_ERR) {
> + struct mlx5_nodnic_sq *sq = &priv->sq;
> + u16 sq_pi = mlx5_nodnic_sq_get_pi(sq, wqe_counter);
> +
> + mlx5_nodnic_complete_send_wqe(sq, &sq->wqe_info[sq_pi],
> + napi_budget);
> + } else {
> + struct mlx5_nodnic_rq *rq = &priv->rq;
> + u16 ci = wqe_counter & (rq->ring.num_entries - 1);
> +
> + mlx5_nodnic_release_rx_wqe(rq, ci);
> + }
> +}
[Severity: Medium]
Is there a recovery path for error CQEs? This releases only the single WQE
named by wqe_counter. Nothing marks the queue as errored, schedules
recovery work, or resets the SQ, RQ or port.
The syndrome table above decodes WR_FLUSH_ERR, LOCAL_QP_OP_ERR and
LOCAL_PROT_ERR. In the mlx5 CQE format these mean the queue has moved to
an error state and later WQEs get flushed.
On RX, mlx5_nodnic_napi_poll() reposts the freed slots unconditionally:
if (!mlx5_nodnic_rq_post_wqes(priv))
return budget;
If the device flushes those WQEs, each flush CQE counts as RX work. The
poll returns budget, so NAPI keeps cycling and printing rate-limited
errors. If the device doesn't flush them, RX stays dead.
On TX, every later packet would complete as a flush error and be freed,
and BQL would credit it as sent. The later "Add TX/RX statistics" commit
also counts these completions as transmitted packets in
mlx5_nodnic_sq_stats_inc().
There is no .ndo_tx_timeout either, so netdev_watchdog_up() returns early
and a stalled SQ is never detected. The carrier stays up while traffic is
dead until the interface is cycled. The later "Add health monitoring"
commit only polls firmware health, so it doesn't change this.
[ ... ]
> +int mlx5_nodnic_napi_poll(struct napi_struct *napi, int budget)
> +{
[ ... ]
> + while (true) {
> + cqe = mlx5_nodnic_cq_get_cqe(cq);
> + if (!cqe)
> + break;
> +
> + /* RX and TX share the CQ. With budget == 0 (netpoll) only TX
> + * completions may be processed, leave RX CQEs in place.
> + */
> + if (unlikely(!budget) && mlx5_nodnic_cqe_is_rx(cqe))
> + break;
[Severity: Medium]
The default case in mlx5_nodnic_handle_cqe() logs every unexpected
opcode with a plain netdev_err(). mlx5_nodnic_napi_poll() also doesn't
count MLX5_NODNIC_CQE_IGNORED against the RX budget or against
MLX5_NODNIC_TX_CQ_POLL_BUDGET.
Suppose buggy firmware or a faulty device fills the CQ with unexpected
opcodes. One poll can then walk all cq->num_entries entries in softirq
context and print an error for each, which can stall a slow console.
If the device keeps producing such CQEs with a matching owner bit, the
loop never exits at all. The netpoll budget == 0 check doesn't stop it
either, since mlx5_nodnic_cqe_is_rx() only matches the RECV and
RECV_ERR opcodes.
mlx5_nodnic_handle_err_cqe() in the same file already wraps its output
in net_ratelimit(). Should this message be rate limited as well? And
should ignored CQEs count toward some per-poll limit, so the loop is
always bounded?
[Severity: Low]
TX and RX share one in-order CQ. Doesn't breaking at the first RX CQE
here block every TX completion queued behind it?
Netpoll reaches this through poll_one_napi()->napi->poll(napi, 0). In
that case cc_pending_pkts stays 0 and mlx5_nodnic_sq_publish_cc() frees
no SQ slots.
Suppose NAPI can't run, for example netconsole during a panic or oops,
while RX traffic keeps arriving. Each netpoll retry would hit the same RX
CQE. Once the TX ring fills, the queue stays stopped and netconsole
output is dropped.
[ ... ]
> diff --git a/drivers/net/ethernet/mellanox/mlx5/nodnic/en_cfg.c b/drivers/net/ethernet/mellanox/mlx5/nodnic/en_cfg.c
> index 738722671090b..b6adec5fc50d7 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/nodnic/en_cfg.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/nodnic/en_cfg.c
[ ... ]
> @@ -580,6 +650,156 @@ void mlx5_nodnic_refresh_carrier(struct mlx5_nodnic_priv *priv)
> mutex_unlock(&priv->state_lock);
> }
>
[ ... ]
> +/* If the port can't be disabled, stop the device from mastering the bus,
> + * so it can't DMA into the buffers that are about to be freed.
> + * Bus mastering is restored on the next open.
> + */
> +static void mlx5_nodnic_quiesce_port(struct mlx5_nodnic_core_dev *dev)
> +{
> + int err;
> +
> + err = mlx5_nodnic_vsc_context_acquire(dev->vsc_ctx);
> + if (!err) {
> + err = mlx5_nodnic_disable_port(dev);
> + mlx5_nodnic_vsc_context_release(dev->vsc_ctx);
> + }
> +
> + if (err)
> + pci_clear_master(dev->pdev);
> +}
[Severity: Low]
This isn't a bug, but the commit message only describes the TX/RX/NAPI
data path. The patch also changes control-path behaviour:
- It adds the first callers of mlx5_nodnic_enable_port() and
mlx5_nodnic_disable_port(). ndo_open now enables network, DMA and
MSI-X on the port, and ndo_stop disables them.
- It changes mlx5_nodnic_disable_port() from void to int.
- It adds this pci_clear_master() fallback, which relies on
mlx5_nodnic_enable_port() to restore bus mastering.
- It requests a new data MSI-X IRQ in mlx5_nodnic_open_cq().
- It adds a new open error-unwind path.
Could the commit message mention these changes?
> +static int mlx5_nodnic_activate_queues(struct mlx5_nodnic_core_dev *dev)
> +{
[ ... ]
> + mlx5_nodnic_activate_sq(dev);
> +
> + napi_enable_locked(&cq->napi);
> + mlx5_nodnic_arm_cq(cq);
> + napi_schedule(&cq->napi);
[Severity: Low]
Can this mlx5_nodnic_arm_cq() call race with one from NAPI context on
another CPU?
After napi_enable_locked() the NAPI instance is live again and keeps its
persistent napi_config ID. A busy-polling socket holding the old
sk_napi_id can therefore run busy_poll_stop()->napi->poll(), and
mlx5_nodnic_napi_poll() calls mlx5_nodnic_arm_cq() after
napi_complete_done().
Neither path synchronizes with the other. Both read cq->cc and
cq->arm_sn, both write cq->dbr.db[1], and both issue mlx5_write64() to
the CQ doorbell. On 32-bit, mlx5_write64() is two __raw_writel() calls,
and include/linux/mlx5/doorbell.h says callers must serialize it.
The napi_schedule() that follows already arms the CQ when the poll
completes. Is the direct arm here needed?
[ ... ]
> +static void mlx5_nodnic_deactivate_queues(struct mlx5_nodnic_core_dev *dev)
> +{
> + napi_disable_locked(&dev->priv->cq.napi);
> + mlx5_nodnic_deactivate_sq(&dev->priv->sq);
> + mlx5_nodnic_quiesce_port(dev);
> + mlx5_nodnic_deactivate_rq(dev);
> +}
[Severity: Medium]
Is the device guaranteed to have stopped DMA before
mlx5_nodnic_deactivate_rq() returns every posted RX page to the page
pool?
mlx5_nodnic_disable_port() writes dma_en=0 and network_en=0 through the
VSC gateway. That write only waits for the gateway flag to clear.
Nothing reads back a DMA-idle or port-inactive status, and
pci_clear_master() is only used when the VSC access itself fails.
After that, mlx5_nodnic_rq_free_pages() puts the pages back and
page_pool_destroy() runs. Later, mlx5_nodnic_sq_free_pending() unmaps and
frees the in-flight TX skbs.
Firmware may guarantee that acknowledging dma_en=0 means all outstanding
DMA has drained. If it doesn't, could a frame written during close land
in a page already returned to the page allocator? Could TX DMA read
freed skb data?
[ ... ]
> @@ -764,6 +995,8 @@ int mlx5_nodnic_close(struct net_device *netdev)
> static const struct net_device_ops mlx5_nodnic_netdev_ops = {
> .ndo_open = mlx5_nodnic_open,
> .ndo_stop = mlx5_nodnic_close,
> + .ndo_start_xmit = mlx5_nodnic_xmit,
> + .ndo_features_check = mlx5_nodnic_check_features,
> };
[Severity: Medium]
This patch is the first to call mlx5_nodnic_enable_port(), which only
enables receive filter 0:
MLX5_SET(nodnic_port_network, &val, network_en, 1);
MLX5_SET(nodnic_port_network, &val, receive_filter_en, BIT(0));
The patch never sets promisc_en or promisc_multicast_en and never
programs the mac_filters table. There is also no .ndo_set_rx_mode, so
changes to the multicast list and to IFF_PROMISC or IFF_ALLMULTI never
reach the hardware.
If the receive filter drops frames that match no entry, will this
interface still receive IPv6 solicited-node multicast for neighbour
discovery, router advertisements, joined IGMP/MLD groups, or mDNS?
Promiscuous mode would also be silently ignored, which affects tcpdump,
bridge and macvlan setups. No later patch in the series appears to add
rx-mode handling.
[ ... ]
> diff --git a/drivers/net/ethernet/mellanox/mlx5/nodnic/rx.c b/drivers/net/ethernet/mellanox/mlx5/nodnic/rx.c
> new file mode 100644
> index 0000000000000..7736a1f24ea5b
> --- /dev/null
> +++ b/drivers/net/ethernet/mellanox/mlx5/nodnic/rx.c
> @@ -0,0 +1,169 @@
[ ... ]
> +void mlx5_nodnic_handle_recv_cqe(struct mlx5_nodnic_cq *cq,
> + struct mlx5_cqe64 *cqe)
> +{
> + struct mlx5_nodnic_priv *priv = container_of(cq,
> + struct mlx5_nodnic_priv,
> + cq);
> + u32 byte_count = be32_to_cpu(cqe->byte_cnt);
[ ... ]
> + page_pool_dma_sync_for_cpu(rq->page_pool, page, 0, byte_count);
> +
> + skb = napi_build_skb(page_address(page), PAGE_SIZE);
> + if (unlikely(!skb))
> + goto err_recycle;
> +
> + skb_mark_for_recycle(skb);
> + rq->pages[ci] = NULL;
> +
> + skb_reserve(skb, MLX5_NODNIC_SKB_HEADROOM_BYTES);
> + skb_put(skb, byte_count);
> + skb->protocol = eth_type_trans(skb, priv->netdev);
[Severity: Medium]
Each RX WQE gets its own order-0 page, and napi_build_skb() is passed
PAGE_SIZE as the frag size. Frames are at most MLX5_NODNIC_HW_MTU
(1522) bytes.
On 4K pages that is about a 2x overhead. 64K page kernels are common on
the ARM64 hosts this BlueField device is paired with. There, a
1024-entry ring pins 64 MiB of DMA mapped memory, and every packet is
charged roughly 64K of skb->truesize.
That truesize hurts the stack:
- In tcp_measure_rcv_mss() the scaling_ratio drops to about 5/256,
which clamps the initial window to a couple of MSS.
- A few GRO-coalesced segments push the socket past sk_rcvbuf and into
tcp_prune_queue() and tcp_collapse().
- A UDP socket with the default rmem starts dropping after about three
queued packets.
Could the RX buffers instead be carved from a page with
page_pool_dev_alloc_frag() or page_pool_dev_alloc()? Each fragment
would be sized for the MTU plus headroom and skb_shared_info, and that
size passed to napi_build_skb(). The page pool offset and max_len for
PP_FLAG_DMA_SYNC_DEV would need adjusting to match.
[Severity: Medium]
byte_count comes straight from the device CQE. It is used for the DMA
sync and for skb_put() without being checked against the posted buffer
size (MLX5_NODNIC_HW_MTU) or the skb tailroom.
If a corrupted CQE or a misbehaving device reports a larger value, could
skb_put() hit skb_over_panic()?
A value below ETH_HLEN has a different problem: eth_type_trans() would
parse stale recycled page pool memory as the Ethernet header.
Would it be appropriate to recycle the page and drop the frame when a
check like this fails?
if (unlikely(byte_count < ETH_HLEN || byte_count > MLX5_NODNIC_HW_MTU))
[ ... ]
> diff --git a/drivers/net/ethernet/mellanox/mlx5/nodnic/tx.c b/drivers/net/ethernet/mellanox/mlx5/nodnic/tx.c
> new file mode 100644
> index 0000000000000..c0dba88b49e01
> --- /dev/null
> +++ b/drivers/net/ethernet/mellanox/mlx5/nodnic/tx.c
> @@ -0,0 +1,252 @@
[ ... ]
> +static int
> +mlx5_nodnic_tx_build_wqe_ds(struct mlx5_nodnic_sq *sq, struct sk_buff *skb,
> + struct mlx5_nodnic_wqe_data_seg *dseg)
> +{
> + dma_addr_t dma_addr = 0;
> +
> + dseg->byte_count = cpu_to_be32(skb->len & 0x7FFFFFFF);
> + dseg->lkey = cpu_to_be32(sq->ring.lkey);
> + dma_addr = dma_map_single(sq->device, skb->data, skb->len,
> + DMA_TO_DEVICE);
[Severity: Low]
This assumes the skb is linear. The driver doesn't advertise NETIF_F_SG,
so validate_xmit_skb() linearizes skbs on the normal dev_queue_xmit()
path.
pktgen is an exception. It accepts frags without checking device
features and transmits through netdev_start_xmit() directly.
For such an skb, skb->len is headlen + data_len. Would this mapping then
run past the linear head into skb_shared_info and adjacent slab memory,
and send those kernel bytes on the wire?
Would a skb_is_nonlinear() check (linearize or drop), or mapping only
skb_headlen(), be safer here?
[ ... ]
> +netdev_tx_t mlx5_nodnic_xmit(struct sk_buff *skb, struct net_device *netdev)
> +{
[ ... ]
> + WRITE_ONCE(sq->pc, sq->pc + 1);
> +
> + netdev_tx_sent_queue(sq->txq, skb->len);
> +
> + mlx5_nodnic_tx_notify_hw(priv, dev->uar_base, sq->pc, &wqe->ctrl);
[Severity: Low]
Should skb_tx_timestamp() be called here, before the doorbell is rung?
Without it, software TX timestamps requested through SO_TIMESTAMPING
(SOF_TIMESTAMPING_TX_SOFTWARE) are never generated for this interface.
No later patch in the series appears to add it.
[ ... ]
> @@ -0,0 +1,252 @@
> +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
> +// Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
> +
> +#include <linux/dma-mapping.h>
> +#include <linux/errno.h>
> +#include <linux/kernel.h>
> +#include <linux/mlx5/doorbell.h>
> +#include <linux/net.h>
> +#include <linux/netdevice.h>
> +#include <linux/skbuff.h>
> +#include <linux/types.h>
> +#include <net/netdev_queues.h>
> +
> +#include "en.h"
> +#include "nodnic.h"
> +#include "tx.h"
> +
> +#define MLX5_NODNIC_OPCODE_SEND 0x0a
> +#define MLX5_NODNIC_DS_COUNT 3
> +#define MLX5_NODNIC_CE_ALWAYS 0x2
> +#define MLX5_NODNIC_SQ_STOP_ROOM 1
> +
> +static void mlx5_nodnic_tx_build_wqe_eseg(struct sk_buff *skb,
[Severity: Medium]
NETIF_F_HW_CSUM tells the stack the device can compute a generic ones'
complement checksum. The checksum starts at skb->csum_start and is
stored at skb->csum_start + skb->csum_offset.
mlx5_nodnic_tx_build_wqe_eseg() ignores both fields. It only sets the
L3/L4 checksum flags, which ask the hardware to parse the headers and
fill in the IPv4 and TCP/UDP checksums itself.
With NETIF_F_HW_CSUM set, skb_csum_hwoffload_help() returns early and
can_checksum_protocol() accepts any ethertype. The software fallback
therefore never runs for packets the hardware can't handle, and they
would go out with a wrong checksum. Examples:
- GRE with checksum. gre_build_header() points csum_start at the GRE
header, and iptunnel_handle_offloads() clears skb->encapsulation for
non-offloaded inner packets.
- IPv6 packets with extension headers.
- Arbitrary CHECKSUM_PARTIAL frames injected through PACKET_VNET_HDR
or tun.
mlx5_nodnic_check_features() doesn't catch these, because it only looks
at skb->encapsulation. Since hw_enc_features is 0,
__netif_skb_features() already strips checksum offload for
encapsulated skbs before it is called, so that check adds nothing.
Would NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM be a better match for what
the hardware does? The mlx5e representor and mlx5i netdevs use those.
Otherwise, mlx5_nodnic_check_features() would need to drop checksum
offload for anything that isn't plain TCP/UDP over IPv4/IPv6.
> + struct mlx5_nodnic_wqe_eth_seg *eseg)
> +{
> + u8 flags = 0;
> +
> + if (likely(skb->ip_summed == CHECKSUM_PARTIAL))
> + flags |= MLX5_NODNIC_ETH_WQE_L3_CSUM |
> + MLX5_NODNIC_ETH_WQE_L4_CSUM;
> +
> + eseg->cs_flags_mss = cpu_to_be32((u32)flags << 24);
> + eseg->inline_hdr_sz = 0;
> +}
> +
> +static void
> +mlx5_nodnic_tx_build_wqe_ctrl(struct mlx5_nodnic_sq *sq,
> + struct mlx5_nodnic_wqe_ctrl_seg *ctrl)
> +{
> + ctrl->opmod_idx_opcode = cpu_to_be32((sq->pc << 8) |
> + MLX5_NODNIC_OPCODE_SEND);
> + ctrl->qpn_ds = cpu_to_be32((sq->ring.qn << 8) | MLX5_NODNIC_DS_COUNT);
> + ctrl->fm_ce_se = cpu_to_be32(MLX5_NODNIC_CE_ALWAYS << 2);
> + ctrl->general_id = 0;
> +}
> +
> +static void mlx5_nodnic_tx_fill_wqe_info(struct mlx5_nodnic_sq *sq,
> + struct sk_buff *skb,
> + dma_addr_t dma_addr)
> +{
> + u16 pi = mlx5_nodnic_sq_get_pi(sq, sq->pc);
> +
> + sq->wqe_info[pi].skb = skb;
> + sq->wqe_info[pi].num_bytes = skb->len;
> + sq->wqe_info[pi].dma = dma_addr;
> +}
> +
> +static int
> +mlx5_nodnic_tx_build_wqe_ds(struct mlx5_nodnic_sq *sq, struct sk_buff *skb,
> + struct mlx5_nodnic_wqe_data_seg *dseg)
> +{
> + dma_addr_t dma_addr = 0;
> +
> + dseg->byte_count = cpu_to_be32(skb->len & 0x7FFFFFFF);
> + dseg->lkey = cpu_to_be32(sq->ring.lkey);
> + dma_addr = dma_map_single(sq->device, skb->data, skb->len,
> + DMA_TO_DEVICE);
> + if (unlikely(dma_mapping_error(sq->device, dma_addr)))
> + return -ENOMEM;
> +
> + dseg->addr = cpu_to_be64(dma_addr);
> +
> + mlx5_nodnic_tx_fill_wqe_info(sq, skb, dma_addr);
> +
> + return 0;
> +}
> +
> +static __always_inline int
> +mlx5_nodnic_tx_write_wqe(struct mlx5_nodnic_sq *sq, struct sk_buff *skb,
> + struct mlx5_nodnic_tx_wqe *wqe)
> +{
> + int err;
> +
> + memset(wqe, 0, MLX5_NODNIC_SQ_WQEBB_B);
> + mlx5_nodnic_tx_build_wqe_ctrl(sq, &wqe->ctrl);
> + mlx5_nodnic_tx_build_wqe_eseg(skb, &wqe->eth);
> + err = mlx5_nodnic_tx_build_wqe_ds(sq, skb, &wqe->data);
> + if (err)
> + return err;
> +
> + /* Ensure WQE stores are visible to the device before ringing the db */
> + dma_wmb();
> +
> + return 0;
> +}
> +
> +/* pc is written by xmit and cc by NAPI, see the barriers in
> + * netif_txq_maybe_stop() and netif_txq_completed_wake().
> + */
> +static u16 mlx5_nodnic_sq_room(struct mlx5_nodnic_sq *sq)
> +{
> + return sq->ring.num_entries -
> + (u16)(READ_ONCE(sq->pc) - READ_ONCE(sq->cc));
> +}
> +
> +static int mlx5_nodnic_tx_get_next_sq_offset(struct mlx5_nodnic_sq *sq)
> +{
> + u16 pi;
> +
> + pi = mlx5_nodnic_sq_get_pi(sq, sq->pc);
> + return pi * MLX5_NODNIC_SQ_WQEBB_B;
> +}
> +
> +static void mlx5_nodnic_tx_notify_hw(struct mlx5_nodnic_priv *priv,
> + void __iomem *uar_base, u16 pc,
> + struct mlx5_nodnic_wqe_ctrl_seg *ctrl)
> +{
> + /* ensure wqe is visible to device before updating doorbell record */
> + dma_wmb();
> +
> + priv->dbr.db[MLX5_NODNIC_SND_DBR] = cpu_to_be32(pc);
> +
> + /* ensure doorbell record is visible to device before ringing the
> + * doorbell
> + */
> + wmb();
> +
> + mlx5_write64((__be32 *)ctrl, uar_base + MLX5_BF_OFFSET);
> +}
> +
> +netdev_tx_t mlx5_nodnic_xmit(struct sk_buff *skb, struct net_device *netdev)
> +{
> + struct mlx5_nodnic_priv *priv = netdev_priv(netdev);
> + struct mlx5_nodnic_core_dev *dev = priv->core_dev;
> + struct mlx5_nodnic_sq *sq = &priv->sq;
> + struct mlx5_nodnic_tx_wqe *wqe;
> + u16 next_offset;
> + int err;
> +
> + /* netif_txq_completed_wake can falsely wake while the ring is full, so
> + * check for room before touching the next descriptor.
> + */
> + if (unlikely(!netif_txq_maybe_stop(sq->txq, mlx5_nodnic_sq_room(sq),
> + MLX5_NODNIC_SQ_STOP_ROOM,
> + MLX5_NODNIC_SQ_STOP_ROOM)))
> + return NETDEV_TX_BUSY;
> +
> + next_offset = mlx5_nodnic_tx_get_next_sq_offset(sq);
> +
> + wqe = (struct mlx5_nodnic_tx_wqe *)((u8 *)sq->ring.wq + next_offset);
> +
> + err = mlx5_nodnic_tx_write_wqe(sq, skb, wqe);
> + if (err) {
> + dev_kfree_skb_any(skb);
> +
> + return NETDEV_TX_OK;
> + }
> +
> + WRITE_ONCE(sq->pc, sq->pc + 1);
> +
> + netdev_tx_sent_queue(sq->txq, skb->len);
> +
> + mlx5_nodnic_tx_notify_hw(priv, dev->uar_base, sq->pc, &wqe->ctrl);
> +
> + netif_txq_maybe_stop(sq->txq, mlx5_nodnic_sq_room(sq),
> + MLX5_NODNIC_SQ_STOP_ROOM,
> + MLX5_NODNIC_SQ_STOP_ROOM);
> +
> + return NETDEV_TX_OK;
> +}
> +
> +u16 mlx5_nodnic_sq_get_pi(struct mlx5_nodnic_sq *sq, u16 pc)
> +{
> + return pc & (sq->ring.num_entries - 1);
> +}
> +
> +void mlx5_nodnic_handle_send_cqe(struct mlx5_nodnic_cq *cq,
> + struct mlx5_cqe64 *cqe, int napi_budget)
> +{
> + struct mlx5_nodnic_priv *priv = container_of(cq,
> + struct mlx5_nodnic_priv,
> + cq);
> + struct mlx5_nodnic_sq *sq = &priv->sq;
> + struct mlx5_nodnic_tx_wqe_info *wi;
> + u16 pi;
> +
> + pi = mlx5_nodnic_sq_get_pi(sq, be16_to_cpu(cqe->wqe_counter));
> + wi = &sq->wqe_info[pi];
> +
> + mlx5_nodnic_complete_send_wqe(sq, wi, napi_budget);
> +}
> +
> +void mlx5_nodnic_complete_send_wqe(struct mlx5_nodnic_sq *sq,
> + struct mlx5_nodnic_tx_wqe_info *wi,
> + int napi_budget)
> +{
> + u32 num_bytes = wi->num_bytes;
> +
> + dma_unmap_single(sq->device, wi->dma, num_bytes, DMA_TO_DEVICE);
> + napi_consume_skb(wi->skb, napi_budget);
> +
> + /* The slot is handed back to xmit by mlx5_nodnic_sq_publish_cc(),
> + * after the CQ consumer index has reached the device.
> + */
> + sq->cc_pending_pkts++;
> + sq->cc_pending_bytes += num_bytes;
> +}
> +
> +void mlx5_nodnic_sq_publish_cc(struct mlx5_nodnic_sq *sq)
> +{
> + if (!sq->cc_pending_pkts)
> + return;
> +
> + WRITE_ONCE(sq->cc, sq->cc + sq->cc_pending_pkts);
> +
> + netif_txq_completed_wake(sq->txq, sq->cc_pending_pkts,
> + sq->cc_pending_bytes,
> + mlx5_nodnic_sq_room(sq),
> + MLX5_NODNIC_SQ_STOP_ROOM);
> +
> + sq->cc_pending_pkts = 0;
> + sq->cc_pending_bytes = 0;
> +}
> +
> +void mlx5_nodnic_sq_free_pending(struct mlx5_nodnic_sq *sq)
> +{
> + struct mlx5_nodnic_tx_wqe_info *wi;
> + unsigned int completed_bytes = 0;
> + unsigned int completed_pkts = 0;
> + u16 sqcc = sq->cc;
> + u16 ci;
> +
> + while (sqcc != sq->pc) {
> + ci = mlx5_nodnic_sq_get_pi(sq, sqcc);
> + wi = &sq->wqe_info[ci];
> +
> + dma_unmap_single(sq->device, wi->dma,
> + wi->num_bytes, DMA_TO_DEVICE);
> +
> + completed_pkts++;
> + completed_bytes += wi->num_bytes;
> +
> + dev_kfree_skb_any(wi->skb);
> +
> + sqcc++;
> + }
> +
> + if (completed_pkts)
> + netdev_tx_completed_queue(sq->txq, completed_pkts,
> + completed_bytes);
> + sq->cc = sqcc;
> +}
[Severity: Low]
mlx5_nodnic_tx_write_wqe() ends with a dma_wmb(). Its only caller,
mlx5_nodnic_xmit(), then calls mlx5_nodnic_tx_notify_hw(), which
starts with a second dma_wmb() for the same WQE-before-doorbell-record
ordering. In between, xmit only does the WRITE_ONCE() of sq->pc and
netdev_tx_sent_queue(), and neither of those touches the WQE.
So every transmitted packet pays for two identical barriers. Could the
one at the end of mlx5_nodnic_tx_write_wqe() be dropped? That would
keep the one right before the priv->dbr.db[MLX5_NODNIC_SND_DBR] store.
[ ... ]
> diff --git a/drivers/net/ethernet/mellanox/mlx5/nodnic/rx.h b/drivers/net/ethernet/mellanox/mlx5/nodnic/rx.h
> --- /dev/null
> +++ b/drivers/net/ethernet/mellanox/mlx5/nodnic/rx.h
> @@ -0,0 +1,25 @@
> +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
> +// Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
> +
> +#ifndef __MLX5_NODNIC_RX_H__
> +#define __MLX5_NODNIC_RX_H__
> +
> +struct mlx5_nodnic_priv;
> +struct mlx5_nodnic_cq;
> +struct mlx5_nodnic_rq;
> +struct mlx5_cqe64;
> +
> +struct mlx5_nodnic_rx_wqe {
> + __be32 byte_count;
> + __be32 lkey;
> + __be64 addr;
> +};
> +
> +int mlx5_nodnic_rq_alloc_pages(struct mlx5_nodnic_rq *rq);
> +void mlx5_nodnic_rq_free_pages(struct mlx5_nodnic_rq *rq);
> +bool mlx5_nodnic_rq_post_wqes(struct mlx5_nodnic_priv *priv);
> +void mlx5_nodnic_handle_recv_cqe(struct mlx5_nodnic_cq *cq,
> + struct mlx5_cqe64 *cqe);
> +void mlx5_nodnic_release_rx_wqe(struct mlx5_nodnic_rq *rq, u16 ci);
> +
> +#endif /* __MLX5_NODNIC_RX_H__ */
[Severity: Low]
This isn't a bug, but rx.h uses __be32, __be64, u16 and bool without
including any header. It only builds because en.c, en_cfg.c and rx.c
pull in linux/types.h, directly or through en.h, before rx.h.
tx.h, added in the same patch, includes linux/types.h. Could rx.h do
the same so it is self-contained?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203205721.4090361-1-tariqt%40nvidia.com
next prev parent reply other threads:[~2026-12-04 21:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 20:57 [PATCH net-next V4 0/5] net/mlx5: Introduce mlx5_nodnic, a driver for DRAM-less NVIDIA Mellanox NIC functions Tariq Toukan
2026-12-03 20:57 ` [PATCH net-next V4 1/5] net/mlx5: nodnic: Introduce the mlx5_nodnic driver Tariq Toukan
2026-12-04 21:45 ` netdev-bot+sashiko
2026-12-03 20:57 ` [PATCH net-next V4 2/5] net/mlx5: nodnic: Implement data path Tariq Toukan
2026-12-04 21:45 ` netdev-bot+sashiko [this message]
2026-12-03 20:57 ` [PATCH net-next V4 3/5] net/mlx5: nodnic: Add TX/RX statistics Tariq Toukan
2026-12-04 21:45 ` netdev-bot+sashiko
2026-12-03 20:57 ` [PATCH net-next V4 4/5] net/mlx5: nodnic: Add ethtool driver info Tariq Toukan
2026-12-03 20:57 ` [PATCH net-next V4 5/5] net/mlx5: nodnic: Add health monitoring Tariq Toukan
2026-12-04 21:45 ` netdev-bot+sashiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179642074710.3146.821124371315133765@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=cjubran@nvidia.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=gal@nvidia.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shshitrit@nvidia.com \
--cc=tariqt@nvidia.com \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox