[PATCH net-next v2 6/6] bcm63xx_enet: improve rx loop

From: Sieng Piaw Liew
Date: Thu Dec 24 2020 - 09:27:13 EST


Use existing rx processed count to track against budget, thereby making
budget decrement operation redundant.

rx_desc_count can be calculated outside the rx loop, making the loop a
bit smaller.

Signed-off-by: Sieng Piaw Liew <liew.s.piaw@xxxxxxxxx>
---
drivers/net/ethernet/broadcom/bcm63xx_enet.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
index 8c2e97311a2c..5ff0d39be2b2 100644
--- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
@@ -339,7 +339,6 @@ static int bcm_enet_receive_queue(struct net_device *dev, int budget)
priv->rx_curr_desc++;
if (priv->rx_curr_desc == priv->rx_ring_size)
priv->rx_curr_desc = 0;
- priv->rx_desc_count--;

/* if the packet does not have start of packet _and_
* end of packet flag set, then just recycle it */
@@ -404,9 +403,10 @@ static int bcm_enet_receive_queue(struct net_device *dev, int budget)
dev->stats.rx_bytes += len;
list_add_tail(&skb->list, &rx_list);

- } while (--budget > 0);
+ } while (processed < budget);

netif_receive_skb_list(&rx_list);
+ priv->rx_desc_count -= processed;

if (processed || !priv->rx_desc_count) {
bcm_enet_refill_rx(dev, true);
--
2.17.1