* [PATCH net-next 1/5] net/mlx4: factor VLAN parsing into mlx4_en_prep_vlan()
2026-11-10 23:12 [PATCH net-next 0/5] mlx4: cleanup and doorbell fix Joe Damato
@ 2026-11-10 23:12 ` Joe Damato
2026-11-11 23:13 ` sashiko-bot
2026-11-12 13:40 ` Daniel Machon
2026-11-10 23:12 ` [PATCH net-next 2/5] net/mlx4: factor csum flags into mlx4_en_csum_flags() Joe Damato
` (4 subsequent siblings)
5 siblings, 2 replies; 19+ messages in thread
From: Joe Damato @ 2026-11-10 23:12 UTC (permalink / raw)
To: netdev, Tariq Toukan, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: edumazet, horms, linux-kernel, Joe Damato, linux-rdma
Extract the code which converts an skb VLAN tag into WQE fields into a
small helper. This helper will be used by a follow-up series implementing
software USO, to avoid code duplication.
Signed-off-by: Joe Damato <joe@dama.to>
---
drivers/net/ethernet/mellanox/mlx4/en_tx.c | 33 ++++++++++++++--------
1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index c5d564e5a581..00210dbae1c3 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -861,6 +861,26 @@ static bool mlx4_en_build_dma_wqe(struct mlx4_en_priv *priv,
return false;
}
+static bool mlx4_en_prep_vlan(const struct sk_buff *skb,
+ union mlx4_wqe_qpn_vlan *qpn_vlan)
+{
+ u16 vlan_proto;
+
+ if (!skb_vlan_tag_present(skb))
+ return false;
+
+ qpn_vlan->vlan_tag = cpu_to_be16(skb_vlan_tag_get(skb));
+ vlan_proto = be16_to_cpu(skb->vlan_proto);
+ if (vlan_proto == ETH_P_8021AD)
+ qpn_vlan->ins_vlan = MLX4_WQE_CTRL_INS_SVLAN;
+ else if (vlan_proto == ETH_P_8021Q)
+ qpn_vlan->ins_vlan = MLX4_WQE_CTRL_INS_CVLAN;
+ else
+ qpn_vlan->ins_vlan = 0;
+
+ return true;
+}
+
netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct skb_shared_info *shinfo = skb_shinfo(skb);
@@ -902,19 +922,8 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
nr_txbb = desc_size >> LOG_TXBB_SIZE;
bf_ok = ring->bf_enabled;
- if (skb_vlan_tag_present(skb)) {
- u16 vlan_proto;
-
- qpn_vlan.vlan_tag = cpu_to_be16(skb_vlan_tag_get(skb));
- vlan_proto = be16_to_cpu(skb->vlan_proto);
- if (vlan_proto == ETH_P_8021AD)
- qpn_vlan.ins_vlan = MLX4_WQE_CTRL_INS_SVLAN;
- else if (vlan_proto == ETH_P_8021Q)
- qpn_vlan.ins_vlan = MLX4_WQE_CTRL_INS_CVLAN;
- else
- qpn_vlan.ins_vlan = 0;
+ if (mlx4_en_prep_vlan(skb, &qpn_vlan))
bf_ok = false;
- }
netdev_txq_bql_enqueue_prefetchw(ring->tx_queue);
--
2.53.0-Meta
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH net-next 1/5] net/mlx4: factor VLAN parsing into mlx4_en_prep_vlan()
2026-11-10 23:12 ` [PATCH net-next 1/5] net/mlx4: factor VLAN parsing into mlx4_en_prep_vlan() Joe Damato
@ 2026-11-11 23:13 ` sashiko-bot
2026-11-12 13:40 ` Daniel Machon
1 sibling, 0 replies; 19+ messages in thread
From: sashiko-bot @ 2026-11-11 23:13 UTC (permalink / raw)
To: Joe Damato; +Cc: linux-rdma
> Extract the code which converts an skb VLAN tag into WQE fields into a
> small helper. This helper will be used by a follow-up series implementing
> software USO, to avoid code duplication.
>
> Signed-off-by: Joe Damato <joe@dama.to>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261110231304.1859217-1-joe@dama.to?part=1
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH net-next 1/5] net/mlx4: factor VLAN parsing into mlx4_en_prep_vlan()
2026-11-10 23:12 ` [PATCH net-next 1/5] net/mlx4: factor VLAN parsing into mlx4_en_prep_vlan() Joe Damato
2026-11-11 23:13 ` sashiko-bot
@ 2026-11-12 13:40 ` Daniel Machon
1 sibling, 0 replies; 19+ messages in thread
From: Daniel Machon @ 2026-11-12 13:40 UTC (permalink / raw)
To: Joe Damato
Cc: netdev, Tariq Toukan, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, edumazet, horms, linux-kernel,
linux-rdma
> Extract the code which converts an skb VLAN tag into WQE fields into a
> small helper. This helper will be used by a follow-up series implementing
> software USO, to avoid code duplication.
Reviewed-by: Daniel Machon <daniel.machon@microchip.com>
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH net-next 2/5] net/mlx4: factor csum flags into mlx4_en_csum_flags()
2026-11-10 23:12 [PATCH net-next 0/5] mlx4: cleanup and doorbell fix Joe Damato
2026-11-10 23:12 ` [PATCH net-next 1/5] net/mlx4: factor VLAN parsing into mlx4_en_prep_vlan() Joe Damato
@ 2026-11-10 23:12 ` Joe Damato
2026-11-11 23:13 ` sashiko-bot
2026-11-12 13:41 ` Daniel Machon
2026-11-10 23:12 ` [PATCH net-next 3/5] net/mlx4: factor HW loopback DMAC into mlx4_en_set_loopback_dmac() Joe Damato
` (3 subsequent siblings)
5 siblings, 2 replies; 19+ messages in thread
From: Joe Damato @ 2026-11-10 23:12 UTC (permalink / raw)
To: netdev, Tariq Toukan, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: edumazet, horms, linux-kernel, Joe Damato, linux-rdma
Extract the code which converts skb csum fields to WQE fields into a
helper. This helper will be used by a follow-up series implementing
software USO, to reduce code duplication.
Signed-off-by: Joe Damato <joe@dama.to>
---
drivers/net/ethernet/mellanox/mlx4/en_tx.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index 00210dbae1c3..f6059b533eac 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -861,6 +861,16 @@ static bool mlx4_en_build_dma_wqe(struct mlx4_en_priv *priv,
return false;
}
+static __be32 mlx4_en_csum_flags(const struct sk_buff *skb)
+{
+ if (unlikely(skb->ip_summed != CHECKSUM_PARTIAL))
+ return 0;
+ if (skb->encapsulation)
+ return cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM);
+
+ return cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM | MLX4_WQE_CTRL_TCP_UDP_CSUM);
+}
+
static bool mlx4_en_prep_vlan(const struct sk_buff *skb,
union mlx4_wqe_qpn_vlan *qpn_vlan)
{
@@ -891,12 +901,12 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
struct mlx4_wqe_data_seg *data;
struct mlx4_en_tx_info *tx_info;
u32 __maybe_unused ring_cons;
+ __be32 op_own, csum_flags;
int tx_ind;
int nr_txbb;
int desc_size;
int real_size;
u32 index, bf_index;
- __be32 op_own;
int lso_header_size;
void *fragptr = NULL;
bool bounce = false;
@@ -991,12 +1001,10 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
/* Prepare ctrl segment apart opcode+ownership, which depends on
* whether LSO is used */
tx_desc->ctrl.srcrb_flags = priv->ctrl_flags;
- if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) {
- if (!skb->encapsulation)
- tx_desc->ctrl.srcrb_flags |= cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM |
- MLX4_WQE_CTRL_TCP_UDP_CSUM);
- else
- tx_desc->ctrl.srcrb_flags |= cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM);
+
+ csum_flags = mlx4_en_csum_flags(skb);
+ if (csum_flags) {
+ tx_desc->ctrl.srcrb_flags |= csum_flags;
ring->tx_csum++;
}
--
2.53.0-Meta
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH net-next 2/5] net/mlx4: factor csum flags into mlx4_en_csum_flags()
2026-11-10 23:12 ` [PATCH net-next 2/5] net/mlx4: factor csum flags into mlx4_en_csum_flags() Joe Damato
@ 2026-11-11 23:13 ` sashiko-bot
2026-11-12 13:41 ` Daniel Machon
1 sibling, 0 replies; 19+ messages in thread
From: sashiko-bot @ 2026-11-11 23:13 UTC (permalink / raw)
To: Joe Damato; +Cc: linux-rdma
> Extract the code which converts skb csum fields to WQE fields into a
> helper. This helper will be used by a follow-up series implementing
> software USO, to reduce code duplication.
>
> Signed-off-by: Joe Damato <joe@dama.to>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261110231304.1859217-1-joe@dama.to?part=2
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH net-next 2/5] net/mlx4: factor csum flags into mlx4_en_csum_flags()
2026-11-10 23:12 ` [PATCH net-next 2/5] net/mlx4: factor csum flags into mlx4_en_csum_flags() Joe Damato
2026-11-11 23:13 ` sashiko-bot
@ 2026-11-12 13:41 ` Daniel Machon
1 sibling, 0 replies; 19+ messages in thread
From: Daniel Machon @ 2026-11-12 13:41 UTC (permalink / raw)
To: Joe Damato
Cc: netdev, Tariq Toukan, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, edumazet, horms, linux-kernel,
linux-rdma
> Extract the code which converts skb csum fields to WQE fields into a
> helper. This helper will be used by a follow-up series implementing
> software USO, to reduce code duplication.
>
> Signed-off-by: Joe Damato <joe@dama.to>
Reviewed-by: Daniel Machon <daniel.machon@microchip.com>
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH net-next 3/5] net/mlx4: factor HW loopback DMAC into mlx4_en_set_loopback_dmac()
2026-11-10 23:12 [PATCH net-next 0/5] mlx4: cleanup and doorbell fix Joe Damato
2026-11-10 23:12 ` [PATCH net-next 1/5] net/mlx4: factor VLAN parsing into mlx4_en_prep_vlan() Joe Damato
2026-11-10 23:12 ` [PATCH net-next 2/5] net/mlx4: factor csum flags into mlx4_en_csum_flags() Joe Damato
@ 2026-11-10 23:12 ` Joe Damato
2026-11-11 23:13 ` sashiko-bot
2026-11-12 13:41 ` Daniel Machon
2026-11-10 23:12 ` [PATCH net-next 4/5] net/mlx4: track whether a TX doorbell is pending Joe Damato
` (2 subsequent siblings)
5 siblings, 2 replies; 19+ messages in thread
From: Joe Damato @ 2026-11-10 23:12 UTC (permalink / raw)
To: netdev, Tariq Toukan, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: edumazet, horms, linux-kernel, Joe Damato, linux-rdma
Extract the code which copies the destination MAC into the WQE for
eSwitch loopback into a helper. This helper will be used by a follow-up
series implementing software USO, so USO packets between functions on
the same port are looped back too.
Signed-off-by: Joe Damato <joe@dama.to>
---
drivers/net/ethernet/mellanox/mlx4/en_tx.c | 28 ++++++++++++++--------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index f6059b533eac..97f27e005810 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -871,6 +871,23 @@ static __be32 mlx4_en_csum_flags(const struct sk_buff *skb)
return cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM | MLX4_WQE_CTRL_TCP_UDP_CSUM);
}
+static void mlx4_en_set_loopback_dmac(const struct mlx4_en_priv *priv,
+ struct mlx4_en_tx_desc *tx_desc,
+ const struct sk_buff *skb)
+{
+ struct ethhdr *ethh;
+
+ if (!(priv->flags & MLX4_EN_FLAG_ENABLE_HW_LOOPBACK))
+ return;
+
+ /* Copy dst mac address to wqe. This allows loopback in eSwitch,
+ * so that VFs and PF can communicate with each other
+ */
+ ethh = (struct ethhdr *)skb->data;
+ tx_desc->ctrl.srcrb_flags16[0] = get_unaligned((__be16 *)ethh->h_dest);
+ tx_desc->ctrl.imm = get_unaligned((__be32 *)(ethh->h_dest + 2));
+}
+
static bool mlx4_en_prep_vlan(const struct sk_buff *skb,
union mlx4_wqe_qpn_vlan *qpn_vlan)
{
@@ -1008,16 +1025,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
ring->tx_csum++;
}
- if (priv->flags & MLX4_EN_FLAG_ENABLE_HW_LOOPBACK) {
- struct ethhdr *ethh;
-
- /* Copy dst mac address to wqe. This allows loopback in eSwitch,
- * so that VFs and PF can communicate with each other
- */
- ethh = (struct ethhdr *)skb->data;
- tx_desc->ctrl.srcrb_flags16[0] = get_unaligned((__be16 *)ethh->h_dest);
- tx_desc->ctrl.imm = get_unaligned((__be32 *)(ethh->h_dest + 2));
- }
+ mlx4_en_set_loopback_dmac(priv, tx_desc, skb);
/* Handle LSO (TSO) packets */
if (lso_header_size) {
--
2.53.0-Meta
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH net-next 3/5] net/mlx4: factor HW loopback DMAC into mlx4_en_set_loopback_dmac()
2026-11-10 23:12 ` [PATCH net-next 3/5] net/mlx4: factor HW loopback DMAC into mlx4_en_set_loopback_dmac() Joe Damato
@ 2026-11-11 23:13 ` sashiko-bot
2026-11-12 13:41 ` Daniel Machon
1 sibling, 0 replies; 19+ messages in thread
From: sashiko-bot @ 2026-11-11 23:13 UTC (permalink / raw)
To: Joe Damato; +Cc: linux-rdma
> Extract the code which copies the destination MAC into the WQE for
> eSwitch loopback into a helper. This helper will be used by a follow-up
> series implementing software USO, so USO packets between functions on
> the same port are looped back too.
>
> Signed-off-by: Joe Damato <joe@dama.to>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261110231304.1859217-1-joe@dama.to?part=3
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH net-next 3/5] net/mlx4: factor HW loopback DMAC into mlx4_en_set_loopback_dmac()
2026-11-10 23:12 ` [PATCH net-next 3/5] net/mlx4: factor HW loopback DMAC into mlx4_en_set_loopback_dmac() Joe Damato
2026-11-11 23:13 ` sashiko-bot
@ 2026-11-12 13:41 ` Daniel Machon
1 sibling, 0 replies; 19+ messages in thread
From: Daniel Machon @ 2026-11-12 13:41 UTC (permalink / raw)
To: Joe Damato
Cc: netdev, Tariq Toukan, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, edumazet, horms, linux-kernel,
linux-rdma
> Extract the code which copies the destination MAC into the WQE for
> eSwitch loopback into a helper. This helper will be used by a follow-up
> series implementing software USO, so USO packets between functions on
> the same port are looped back too.
>
> Signed-off-by: Joe Damato <joe@dama.to>
Reviewed-by: Daniel Machon <daniel.machon@microchip.com>
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH net-next 4/5] net/mlx4: track whether a TX doorbell is pending
2026-11-10 23:12 [PATCH net-next 0/5] mlx4: cleanup and doorbell fix Joe Damato
` (2 preceding siblings ...)
2026-11-10 23:12 ` [PATCH net-next 3/5] net/mlx4: factor HW loopback DMAC into mlx4_en_set_loopback_dmac() Joe Damato
@ 2026-11-10 23:12 ` Joe Damato
2026-11-11 23:13 ` sashiko-bot
2026-11-12 13:41 ` Daniel Machon
2026-11-10 23:12 ` [PATCH net-next 5/5] net/mlx4: flush pending doorbell when dropping a TX skb Joe Damato
2026-11-10 23:17 ` [PATCH net-next 0/5] mlx4: cleanup and doorbell fix netdev-bot+sinfo
5 siblings, 2 replies; 19+ messages in thread
From: Joe Damato @ 2026-11-10 23:12 UTC (permalink / raw)
To: netdev, Tariq Toukan, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: edumazet, horms, linux-kernel, Joe Damato, linux-rdma
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 when the doorbell is deferred and
cleared whenever a doorbell or a BlueFlame write is issued, so such a
path can flush the deferred doorbell.
Signed-off-by: Joe Damato <joe@dama.to>
---
drivers/net/ethernet/mellanox/mlx4/en_tx.c | 9 +++++++--
drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 1 +
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index 97f27e005810..123071a47bed 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -194,6 +194,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;
@@ -757,6 +758,7 @@ void mlx4_en_xmit_doorbell(struct mlx4_en_tx_ring *ring)
iowrite32be(
#endif
(__force u32)ring->doorbell_qpn, ring->doorbell_address);
+ ring->doorbell_pending = false;
}
static void mlx4_en_tx_write_desc(struct mlx4_en_tx_ring *ring,
@@ -784,16 +786,19 @@ static void mlx4_en_tx_write_desc(struct mlx4_en_tx_ring *ring,
wmb();
ring->bf.offset ^= ring->bf.buf_size;
+ ring->doorbell_pending = false;
} else {
/* Ensure new descriptor hits memory
* before setting ownership of this descriptor to HW
*/
dma_wmb();
tx_desc->ctrl.owner_opcode = op_own;
- if (send_doorbell)
+ if (send_doorbell) {
mlx4_en_xmit_doorbell(ring);
- else
+ } else {
ring->xmit_more++;
+ ring->doorbell_pending = true;
+ }
}
}
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
index aab97694f86b..601c09020f38 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
@@ -281,6 +281,7 @@ struct mlx4_en_tx_ring {
unsigned long tso_packets;
unsigned long xmit_more;
struct mlx4_bf bf;
+ bool doorbell_pending;
/* Following part should be mostly read */
void __iomem *doorbell_address;
--
2.53.0-Meta
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH net-next 4/5] net/mlx4: track whether a TX doorbell is pending
2026-11-10 23:12 ` [PATCH net-next 4/5] net/mlx4: track whether a TX doorbell is pending Joe Damato
@ 2026-11-11 23:13 ` sashiko-bot
2026-11-12 13:41 ` Daniel Machon
1 sibling, 0 replies; 19+ messages in thread
From: sashiko-bot @ 2026-11-11 23:13 UTC (permalink / raw)
To: Joe Damato; +Cc: linux-rdma
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] net/mlx4: doorbell_pending placed in read-mostly cacheline of
mlx4_en_tx_ring
--
commit c4a2c0626cb72780e7edec3e4335fdf04dad4de9
Author: Joe Damato <joe@dama.to>
net/mlx4: track whether a TX doorbell is pending
This commit adds a doorbell_pending flag to struct mlx4_en_tx_ring to track
when a TX doorbell write has been deferred due to xmit_more.
> diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
> index aab97694f86b3..601c09020f380 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
> +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
> @@ -281,6 +281,7 @@ struct mlx4_en_tx_ring {
> unsigned long tso_packets;
> unsigned long xmit_more;
> struct mlx4_bf bf;
> + bool doorbell_pending;
>
> /* Following part should be mostly read */
> void __iomem *doorbell_address;
[Severity: Low]
Does placing doorbell_pending after struct mlx4_bf put a per-packet written
field into the read-mostly cacheline of struct mlx4_en_tx_ring?
On 64-bit SMP builds, the TX producer cacheline starting at prod (offset
0x40) is filled through bf.uar, while the read-only bf.reg pointer starts
the next cacheline at offset 0x80 alongside doorbell_address, size_mask,
buf, and tx_info, as arranged by commit e3f42f845390 ("mlx4: reorganize
struct mlx4_en_tx_ring").
Because mlx4_en_tx_write_desc() and mlx4_en_xmit_doorbell() write
doorbell_pending on every packet, placing it at offset 0x88 dirties that
read-mostly cacheline on every TX packet, causing false sharing with TX
completion polling in mlx4_en_process_tx_cq(). The 7 bytes of alignment
padding before doorbell_address also push bf_enabled and hwtstamp_tx_type
into a third cacheline.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261110231304.1859217-1-joe@dama.to?part=4
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH net-next 4/5] net/mlx4: track whether a TX doorbell is pending
2026-11-10 23:12 ` [PATCH net-next 4/5] net/mlx4: track whether a TX doorbell is pending Joe Damato
2026-11-11 23:13 ` sashiko-bot
@ 2026-11-12 13:41 ` Daniel Machon
1 sibling, 0 replies; 19+ messages in thread
From: Daniel Machon @ 2026-11-12 13:41 UTC (permalink / raw)
To: Joe Damato
Cc: netdev, Tariq Toukan, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, edumazet, horms, linux-kernel,
linux-rdma
> 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 when the doorbell is deferred and
> cleared whenever a doorbell or a BlueFlame write is issued, so such a
> path can flush the deferred doorbell.
>
> Signed-off-by: Joe Damato <joe@dama.to>
Reviewed-by: Daniel Machon <daniel.machon@microchip.com>
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH net-next 5/5] net/mlx4: flush pending doorbell when dropping a TX skb
2026-11-10 23:12 [PATCH net-next 0/5] mlx4: cleanup and doorbell fix Joe Damato
` (3 preceding siblings ...)
2026-11-10 23:12 ` [PATCH net-next 4/5] net/mlx4: track whether a TX doorbell is pending Joe Damato
@ 2026-11-10 23:12 ` Joe Damato
2026-11-11 23:13 ` sashiko-bot
2026-11-12 13:43 ` Daniel Machon
2026-11-10 23:17 ` [PATCH net-next 0/5] mlx4: cleanup and doorbell fix netdev-bot+sinfo
5 siblings, 2 replies; 19+ messages in thread
From: Joe Damato @ 2026-11-10 23:12 UTC (permalink / raw)
To: netdev, Tariq Toukan, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: edumazet, horms, linux-kernel, Joe Damato, linux-rdma
If mlx4_en_xmit drops an skb (for example because DMA mapping fails) and
that skb happens to be the last one in the batch, the doorbell for the
WQEs posted earlier in the batch isn't written.
The queue stays awake, though, so those WQEs are eventually announced to
the HW after the next TX, but that depends on traffic and could induce
latency.
Avoid all of that by writing the pending doorbell in the drop path.
Signed-off-by: Joe Damato <joe@dama.to>
---
drivers/net/ethernet/mellanox/mlx4/en_tx.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index 123071a47bed..3166837711be 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -1135,6 +1135,9 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
tx_drop_count:
ring->tx_dropped++;
+ /* an earlier skb in this batch may have deferred the doorbell */
+ if (ring->doorbell_pending)
+ mlx4_en_xmit_doorbell(ring);
tx_drop:
dev_kfree_skb_any(skb);
return NETDEV_TX_OK;
--
2.53.0-Meta
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH net-next 5/5] net/mlx4: flush pending doorbell when dropping a TX skb
2026-11-10 23:12 ` [PATCH net-next 5/5] net/mlx4: flush pending doorbell when dropping a TX skb Joe Damato
@ 2026-11-11 23:13 ` sashiko-bot
2026-11-12 13:43 ` Daniel Machon
1 sibling, 0 replies; 19+ messages in thread
From: sashiko-bot @ 2026-11-11 23:13 UTC (permalink / raw)
To: Joe Damato; +Cc: linux-rdma
> If mlx4_en_xmit drops an skb (for example because DMA mapping fails) and
> that skb happens to be the last one in the batch, the doorbell for the
> WQEs posted earlier in the batch isn't written.
>
> The queue stays awake, though, so those WQEs are eventually announced to
> the HW after the next TX, but that depends on traffic and could induce
> latency.
>
> Avoid all of that by writing the pending doorbell in the drop path.
>
> Signed-off-by: Joe Damato <joe@dama.to>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261110231304.1859217-1-joe@dama.to?part=5
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH net-next 5/5] net/mlx4: flush pending doorbell when dropping a TX skb
2026-11-10 23:12 ` [PATCH net-next 5/5] net/mlx4: flush pending doorbell when dropping a TX skb Joe Damato
2026-11-11 23:13 ` sashiko-bot
@ 2026-11-12 13:43 ` Daniel Machon
2026-11-12 14:49 ` Paolo Abeni
1 sibling, 1 reply; 19+ messages in thread
From: Daniel Machon @ 2026-11-12 13:43 UTC (permalink / raw)
To: Joe Damato
Cc: netdev, Tariq Toukan, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, edumazet, horms, linux-kernel,
linux-rdma
> If mlx4_en_xmit drops an skb (for example because DMA mapping fails) and
> that skb happens to be the last one in the batch, the doorbell for the
> WQEs posted earlier in the batch isn't written.
>
> The queue stays awake, though, so those WQEs are eventually announced to
> the HW after the next TX, but that depends on traffic and could induce
> latency.
>
> Avoid all of that by writing the pending doorbell in the drop path.
>
> Signed-off-by: Joe Damato <joe@dama.to>
> ---
> drivers/net/ethernet/mellanox/mlx4/en_tx.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
> index 123071a47bed..3166837711be 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
> @@ -1135,6 +1135,9 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
>
> tx_drop_count:
> ring->tx_dropped++;
> + /* an earlier skb in this batch may have deferred the doorbell */
> + if (ring->doorbell_pending)
I think checking !netdev_xmit_more() here would let you ditch the new ring
state, but it seems bnxt does it the same way, so fine by me.
> + mlx4_en_xmit_doorbell(ring);
> tx_drop:
> dev_kfree_skb_any(skb);
> return NETDEV_TX_OK;
> --
> 2.53.0-Meta
>
Reviewed-by: Daniel Machon <daniel.machon@microchip.com>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH net-next 5/5] net/mlx4: flush pending doorbell when dropping a TX skb
2026-11-12 13:43 ` Daniel Machon
@ 2026-11-12 14:49 ` Paolo Abeni
0 siblings, 0 replies; 19+ messages in thread
From: Paolo Abeni @ 2026-11-12 14:49 UTC (permalink / raw)
To: Daniel Machon, Joe Damato
Cc: netdev, Tariq Toukan, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, edumazet, horms, linux-kernel, linux-rdma
On 11/12/26 14:43, Daniel Machon wrote:
>> diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
>> index 123071a47bed..3166837711be 100644
>> --- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
>> +++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
>> @@ -1135,6 +1135,9 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
>>
>> tx_drop_count:
>> ring->tx_dropped++;
>> + /* an earlier skb in this batch may have deferred the doorbell */
>> + if (ring->doorbell_pending)
>
> I think checking !netdev_xmit_more() here would let you ditch the new ring
> state, but it seems bnxt does it the same way, so fine by me.
I don't think checking `!netdev_xmit_more()` would work, as
`__netdev_tx_sent_queue()` adds more logic to it.
Still I think that the cacheline alignment comment by sashiko
on patch 4 is relevant:
https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261110231304.1859217-1-joe@dama.to
I think a better binary layout for `struct mlx4_en_tx_ring` is needed.
Thanks,
Paolo
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH net-next 0/5] mlx4: cleanup and doorbell fix
2026-11-10 23:12 [PATCH net-next 0/5] mlx4: cleanup and doorbell fix Joe Damato
` (4 preceding siblings ...)
2026-11-10 23:12 ` [PATCH net-next 5/5] net/mlx4: flush pending doorbell when dropping a TX skb Joe Damato
@ 2026-11-10 23:17 ` netdev-bot+sinfo
2026-11-10 23:21 ` Joe Damato
5 siblings, 1 reply; 19+ messages in thread
From: netdev-bot+sinfo @ 2026-11-10 23:17 UTC (permalink / raw)
To: Joe Damato
Cc: netdev, andrew+netdev, davem, edumazet, kuba, pabeni, horms,
linux-kernel, Eric Dumazet, linux-rdma, Tariq Toukan
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- What hardware the change was tested on. For driver fixes please
mention the device (and if relevant firmware version) used for
testing, or say that the change was not tested on real hardware.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account. If the series needs another revision for
other reasons, please include the information in the commit messages
then.
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH net-next 0/5] mlx4: cleanup and doorbell fix
2026-11-10 23:17 ` [PATCH net-next 0/5] mlx4: cleanup and doorbell fix netdev-bot+sinfo
@ 2026-11-10 23:21 ` Joe Damato
0 siblings, 0 replies; 19+ messages in thread
From: Joe Damato @ 2026-11-10 23:21 UTC (permalink / raw)
To: netdev-bot+sinfo
Cc: netdev, andrew+netdev, davem, edumazet, kuba, pabeni, horms,
linux-kernel, Eric Dumazet, linux-rdma, Tariq Toukan
On Tue, Nov 10, 2026 at 11:17:20PM +0000, netdev-bot+sinfo@kernel.org wrote:
> Hi!
>
> This is an automated message. This series looks like a fix, but its
> commit messages seem to be missing some information:
>
> - What hardware the change was tested on. For driver fixes please
> mention the device (and if relevant firmware version) used for
> testing, or say that the change was not tested on real hardware.
>
> Please do not repost the series just to address the above. Instead,
> reply to this email with the missing information, so that reviewers
> can take it into account. If the series needs another revision for
> other reasons, please include the information in the commit messages
> then.
>
> The evaluation is done by an LLM so it may be wrong, if you think
> that is the case please reply and explain.
I ran this code as part of a larger series that also includes SW USO support
on an mlx4 machine.
The only fix in this series is the deferred doorbell flush (patch 5), but I
need the other code (patches 1-4) for SW USO support I plan to submit next if
this series is applied.
Since patch 5 fixes an issue I've never actually seen, I am sending this
series to net-next without a fixes tag.
^ permalink raw reply [flat|nested] 19+ messages in thread