From: Mark Bloch <mbloch@nvidia.com>
To: Joe Damato <joe@dama.to>,
netdev@vger.kernel.org, Tariq Toukan <tariqt@nvidia.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: edumazet@google.com, horms@kernel.org,
linux-kernel@vger.kernel.org, daniel.machon@microchip.com,
linux-rdma@vger.kernel.org
Subject: Re: [PATCH net-next v3 4/5] net/mlx4: track whether a TX doorbell is pending
Date: Thu, 26 Nov 2026 05:40:56 +0200 [thread overview]
Message-ID: <a895192d-9b58-4fa0-883a-43054c9349c1@nvidia.com> (raw)
In-Reply-To: <20261125180021.1804204-5-joe@dama.to>
On 25/11/2026 20:00, Joe Damato wrote:
> When the stack sets xmit_more, mlx4_en_xmit() skips the doorbell and
> relies on a later call in the same batch to write it. Nothing records
> that a doorbell is owed, so a path that ends the batch without writing
> the doorbell leaves the WQEs posted before it unannounced to HW.
>
> Add ring->doorbell_pending, set in mlx4_en_xmit() when the doorbell is
> deferred, so such a path can flush the deferred doorbell.
>
> Place the flag in the cache line dirtied by mlx4_en_xmit(), next to
> prod. That line has no room left, so move tx_dropped, which is only
> written when an skb is dropped, to the end of the struct among the
> fields not used in the fast path.
>
> Suggested-by: Mark Bloch <mbloch@nvidia.com>
> Signed-off-by: Joe Damato <joe@dama.to>
Thanks for the patch,
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
> ---
> v3:
> - Set doorbell_pending once in mlx4_en_xmit from !send_doorbell so XDP_TX
> doesn't write it (Mark).
> - Dropped Daniel's Reviewed-by
>
> v2:
> - doorbell_pending moved to the area of the struct marked as cache line
> used and dirtied in mlx4_en_xmit. In exchange, tx_dropped is moved
> among fields not written in the fast path. It is only written for
> drops and is read for stats.
> - Update the commit message.
>
> drivers/net/ethernet/mellanox/mlx4/en_tx.c | 2 ++
> drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 3 ++-
> 2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
> index 40dc4f6a7329..8a43c86f815c 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
> @@ -193,6 +193,7 @@ int mlx4_en_activate_tx_ring(struct mlx4_en_priv *priv,
> ring->prod = 0;
> ring->cons = 0xffffffff;
> ring->last_nr_txbb = 1;
> + ring->doorbell_pending = false;
> memset(ring->tx_info, 0, ring->size * sizeof(struct mlx4_en_tx_info));
> memset(ring->buf, 0, ring->buf_size);
> ring->free_tx_desc = mlx4_en_free_tx_desc;
> @@ -1098,6 +1099,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
> send_doorbell = __netdev_tx_sent_queue(ring->tx_queue,
> tx_info->nr_bytes,
> netdev_xmit_more());
> + ring->doorbell_pending = !send_doorbell;
>
> real_size = (real_size / 16) & 0x3f;
>
> diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
> index aab97694f86b..c28d5213cccd 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
> +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
> @@ -274,7 +274,7 @@ struct mlx4_en_tx_ring {
>
> /* cache line used and dirtied in mlx4_en_xmit() */
> u32 prod ____cacheline_aligned_in_smp;
> - unsigned int tx_dropped;
> + bool doorbell_pending;
> unsigned long bytes;
> unsigned long packets;
> unsigned long tx_csum;
> @@ -311,6 +311,7 @@ struct mlx4_en_tx_ring {
> enum mlx4_qp_state sp_qp_state;
> u16 sp_stride;
> u16 sp_cqn; /* index of port CQ associated with this ring */
> + unsigned int tx_dropped;
> } ____cacheline_aligned_in_smp;
>
> struct mlx4_en_rx_desc {
next prev parent reply other threads:[~2026-11-26 3:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 18:00 [PATCH net-next v3 0/5] net/mlx4: TX helpers and deferred doorbell fix Joe Damato
2026-11-25 18:00 ` [PATCH net-next v3 1/5] net/mlx4: factor VLAN parsing into mlx4_en_prep_vlan() Joe Damato
2026-11-26 3:39 ` Mark Bloch
2026-11-25 18:00 ` [PATCH net-next v3 2/5] net/mlx4: factor csum flags into mlx4_en_csum_flags() Joe Damato
2026-11-26 3:40 ` Mark Bloch
2026-11-25 18:00 ` [PATCH net-next v3 3/5] net/mlx4: factor HW loopback DMAC into mlx4_en_set_loopback_dmac() Joe Damato
2026-11-26 3:40 ` Mark Bloch
2026-11-25 18:00 ` [PATCH net-next v3 4/5] net/mlx4: track whether a TX doorbell is pending Joe Damato
2026-11-26 3:40 ` Mark Bloch [this message]
2026-11-25 18:00 ` [PATCH net-next v3 5/5] net/mlx4: flush pending doorbell when dropping a TX skb Joe Damato
2026-11-26 3:41 ` Mark Bloch
2026-11-25 18:03 ` [PATCH net-next v3 0/5] net/mlx4: TX helpers and deferred doorbell fix netdev-bot+sinfo
2026-11-25 18:31 ` Joe Damato
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=a895192d-9b58-4fa0-883a-43054c9349c1@nvidia.com \
--to=mbloch@nvidia.com \
--cc=andrew+netdev@lunn.ch \
--cc=daniel.machon@microchip.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=joe@dama.to \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tariqt@nvidia.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