[PATCH iwl-next v2 04/10] ixgbevf: branch prediction and cleanup

From: Larysa Zaremba

Date: Wed Feb 25 2026 - 13:19:52 EST


Add likely/unlikely markers for better branch prediction. While touching
some functions, cleanup the code a little bit.

This patch is not supposed to make any logic changes.

Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@xxxxxxxxx>
Reviewed-by: Alexander Lobakin <aleksander.lobakin@xxxxxxxxx>
Signed-off-by: Larysa Zaremba <larysa.zaremba@xxxxxxxxx>
---
.../net/ethernet/intel/ixgbevf/ixgbevf_main.c | 29 +++++++++----------
1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
index 4f983e1365eb..f67486e5ef45 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
@@ -570,7 +570,7 @@ static void ixgbevf_alloc_rx_buffers(struct ixgbevf_ring *rx_ring,
u16 ntu = rx_ring->next_to_use;

/* nothing to do or no valid netdev defined */
- if (!cleaned_count || !rx_ring->netdev)
+ if (unlikely(!cleaned_count || !rx_ring->netdev))
return;

rx_desc = IXGBEVF_RX_DESC(rx_ring, ntu);
@@ -586,7 +586,7 @@ static void ixgbevf_alloc_rx_buffers(struct ixgbevf_ring *rx_ring,

rx_desc++;
ntu++;
- if (unlikely(ntu == rx_ring->count)) {
+ if (unlikely(ntu == fq.count)) {
rx_desc = IXGBEVF_RX_DESC(rx_ring, 0);
ntu = 0;
}
@@ -823,7 +823,7 @@ static int ixgbevf_clean_rx_irq(struct ixgbevf_q_vector *q_vector,

rx_desc = IXGBEVF_RX_DESC(rx_ring, rx_ring->next_to_clean);
size = le16_to_cpu(rx_desc->wb.upper.length);
- if (!size)
+ if (unlikely(!size))
break;

/* This memory barrier is needed to keep us from reading
@@ -855,7 +855,7 @@ static int ixgbevf_clean_rx_irq(struct ixgbevf_q_vector *q_vector,
}

/* exit if we failed to retrieve a buffer */
- if (!xdp_res && !skb) {
+ if (unlikely(!xdp_res && !skb)) {
rx_ring->rx_stats.alloc_rx_buff_failed++;
break;
}
@@ -867,21 +867,19 @@ static int ixgbevf_clean_rx_irq(struct ixgbevf_q_vector *q_vector,
continue;

/* verify the packet layout is correct */
- if (xdp_res || ixgbevf_cleanup_headers(rx_ring, rx_desc, skb)) {
+ if (xdp_res ||
+ unlikely(ixgbevf_cleanup_headers(rx_ring, rx_desc, skb))) {
skb = NULL;
continue;
}

- /* probably a little skewed due to removing CRC */
- total_rx_bytes += skb->len;
-
/* Workaround hardware that can't do proper VEPA multicast
* source pruning.
*/
- if ((skb->pkt_type == PACKET_BROADCAST ||
- skb->pkt_type == PACKET_MULTICAST) &&
- ether_addr_equal(rx_ring->netdev->dev_addr,
- eth_hdr(skb)->h_source)) {
+ if (unlikely((skb->pkt_type == PACKET_BROADCAST ||
+ skb->pkt_type == PACKET_MULTICAST) &&
+ ether_addr_equal(rx_ring->netdev->dev_addr,
+ eth_hdr(skb)->h_source))) {
dev_kfree_skb_irq(skb);
continue;
}
@@ -889,13 +887,14 @@ static int ixgbevf_clean_rx_irq(struct ixgbevf_q_vector *q_vector,
/* populate checksum, VLAN, and protocol */
ixgbevf_process_skb_fields(rx_ring, rx_desc, skb);

+ /* probably a little skewed due to removing CRC */
+ total_rx_bytes += skb->len;
+ total_rx_packets++;
+
ixgbevf_rx_skb(q_vector, skb);

/* reset skb pointer */
skb = NULL;
-
- /* update budget accounting */
- total_rx_packets++;
}

/* place incomplete frames back on ring for completion */
--
2.52.0