]> git.itanic.dy.fi Git - linux-stable/commitdiff
net: hns3: minor cleanup in hns3_clean_rx_ring
authorYunsheng Lin <linyunsheng@huawei.com>
Thu, 1 Aug 2019 03:55:39 +0000 (11:55 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 1 Aug 2019 17:32:13 +0000 (13:32 -0400)
The unused_count variable is used to indicate how many
RX BD need attaching new buffer in hns3_clean_rx_ring,
and the clean_count variable has the similar meaning.

This patch removes the clean_count variable and use
unused_count to uniformly indicate the RX BD that need
attaching new buffer.

This patch also clean up some coding style related to
variable assignment in hns3_clean_rx_ring.

Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Reviewed-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c

index 79973a016762348a685886ba7508de9e4e244703..ed05fb9f04edb6225800b6bbf82cc39455929f03 100644 (file)
@@ -2909,24 +2909,22 @@ int hns3_clean_rx_ring(struct hns3_enet_ring *ring, int budget,
                       void (*rx_fn)(struct hns3_enet_ring *, struct sk_buff *))
 {
 #define RCB_NOF_ALLOC_RX_BUFF_ONCE 16
-       int recv_pkts, recv_bds, clean_count, err;
        int unused_count = hns3_desc_unused(ring);
        struct sk_buff *skb = ring->skb;
-       int num;
+       int recv_pkts = 0;
+       int recv_bds = 0;
+       int err, num;
 
        num = readl_relaxed(ring->tqp->io_base + HNS3_RING_RX_RING_FBDNUM_REG);
        rmb(); /* Make sure num taken effect before the other data is touched */
 
-       recv_pkts = 0, recv_bds = 0, clean_count = 0;
        num -= unused_count;
        unused_count -= ring->pending_buf;
 
        while (recv_pkts < budget && recv_bds < num) {
                /* Reuse or realloc buffers */
-               if (clean_count + unused_count >= RCB_NOF_ALLOC_RX_BUFF_ONCE) {
-                       hns3_nic_alloc_rx_buffers(ring,
-                                                 clean_count + unused_count);
-                       clean_count = 0;
+               if (unused_count >= RCB_NOF_ALLOC_RX_BUFF_ONCE) {
+                       hns3_nic_alloc_rx_buffers(ring, unused_count);
                        unused_count = hns3_desc_unused(ring) -
                                        ring->pending_buf;
                }
@@ -2940,7 +2938,7 @@ int hns3_clean_rx_ring(struct hns3_enet_ring *ring, int budget,
                        goto out;
                } else if (unlikely(err)) {  /* Do jump the err */
                        recv_bds += ring->pending_buf;
-                       clean_count += ring->pending_buf;
+                       unused_count += ring->pending_buf;
                        ring->skb = NULL;
                        ring->pending_buf = 0;
                        continue;
@@ -2948,7 +2946,7 @@ int hns3_clean_rx_ring(struct hns3_enet_ring *ring, int budget,
 
                rx_fn(ring, skb);
                recv_bds += ring->pending_buf;
-               clean_count += ring->pending_buf;
+               unused_count += ring->pending_buf;
                ring->skb = NULL;
                ring->pending_buf = 0;
 
@@ -2957,8 +2955,8 @@ int hns3_clean_rx_ring(struct hns3_enet_ring *ring, int budget,
 
 out:
        /* Make all data has been write before submit */
-       if (clean_count + unused_count > 0)
-               hns3_nic_alloc_rx_buffers(ring, clean_count + unused_count);
+       if (unused_count > 0)
+               hns3_nic_alloc_rx_buffers(ring, unused_count);
 
        return recv_pkts;
 }