Skip to content

Commit 68752b2

Browse files
Yunsheng Lindavem330
authored andcommitted
net: hns3: schedule the polling again when allocation fails
Currently when there is a rx page allocation failure, it is possible that polling may be stopped if there is no more packet to be reveiced, which may cause queue stall problem under memory pressure. This patch makes sure polling is scheduled again when there is any rx page allocation failure, and polling will try to allocate receive buffers until it succeeds. Now the allocation retry is added, it is unnecessary to do the rx page allocation at the end of rx cleaning, so remove it. And reset the unused_count to zero after calling hns3_nic_alloc_rx_buffers() to avoid calling hns3_nic_alloc_rx_buffers() repeatedly under memory pressure. Fixes: 76ad4f0 ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC") Signed-off-by: Yunsheng Lin <[email protected]> Signed-off-by: Guangbin Huang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9f9f0f1 commit 68752b2

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3_enet.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3486,7 +3486,8 @@ static int hns3_desc_unused(struct hns3_enet_ring *ring)
34863486
return ((ntc >= ntu) ? 0 : ring->desc_num) + ntc - ntu;
34873487
}
34883488

3489-
static void hns3_nic_alloc_rx_buffers(struct hns3_enet_ring *ring,
3489+
/* Return true if there is any allocation failure */
3490+
static bool hns3_nic_alloc_rx_buffers(struct hns3_enet_ring *ring,
34903491
int cleand_count)
34913492
{
34923493
struct hns3_desc_cb *desc_cb;
@@ -3511,7 +3512,10 @@ static void hns3_nic_alloc_rx_buffers(struct hns3_enet_ring *ring,
35113512
hns3_rl_err(ring_to_netdev(ring),
35123513
"alloc rx buffer failed: %d\n",
35133514
ret);
3514-
break;
3515+
3516+
writel(i, ring->tqp->io_base +
3517+
HNS3_RING_RX_RING_HEAD_REG);
3518+
return true;
35153519
}
35163520
hns3_replace_buffer(ring, ring->next_to_use, &res_cbs);
35173521

@@ -3524,6 +3528,7 @@ static void hns3_nic_alloc_rx_buffers(struct hns3_enet_ring *ring,
35243528
}
35253529

35263530
writel(i, ring->tqp->io_base + HNS3_RING_RX_RING_HEAD_REG);
3531+
return false;
35273532
}
35283533

35293534
static bool hns3_can_reuse_page(struct hns3_desc_cb *cb)
@@ -4175,6 +4180,7 @@ int hns3_clean_rx_ring(struct hns3_enet_ring *ring, int budget,
41754180
{
41764181
#define RCB_NOF_ALLOC_RX_BUFF_ONCE 16
41774182
int unused_count = hns3_desc_unused(ring);
4183+
bool failure = false;
41784184
int recv_pkts = 0;
41794185
int err;
41804186

@@ -4183,9 +4189,9 @@ int hns3_clean_rx_ring(struct hns3_enet_ring *ring, int budget,
41834189
while (recv_pkts < budget) {
41844190
/* Reuse or realloc buffers */
41854191
if (unused_count >= RCB_NOF_ALLOC_RX_BUFF_ONCE) {
4186-
hns3_nic_alloc_rx_buffers(ring, unused_count);
4187-
unused_count = hns3_desc_unused(ring) -
4188-
ring->pending_buf;
4192+
failure = failure ||
4193+
hns3_nic_alloc_rx_buffers(ring, unused_count);
4194+
unused_count = 0;
41894195
}
41904196

41914197
/* Poll one pkt */
@@ -4204,11 +4210,7 @@ int hns3_clean_rx_ring(struct hns3_enet_ring *ring, int budget,
42044210
}
42054211

42064212
out:
4207-
/* Make all data has been write before submit */
4208-
if (unused_count > 0)
4209-
hns3_nic_alloc_rx_buffers(ring, unused_count);
4210-
4211-
return recv_pkts;
4213+
return failure ? budget : recv_pkts;
42124214
}
42134215

42144216
static void hns3_update_rx_int_coalesce(struct hns3_enet_tqp_vector *tqp_vector)

0 commit comments

Comments
 (0)