Skip to content

Commit 8ceca59

Browse files
Yunsheng Lindavem330
authored andcommitted
net: hns3: fix error handling for desc filling
The content of the TX desc is automatically cleared by the HW when the HW has sent out the packet to the wire. When desc filling fails in hns3_nic_net_xmit(), it will call hns3_clear_desc() to do the error handling, which miss zeroing of the TX desc and the checking if a unmapping is needed. So add the zeroing and checking in hns3_clear_desc() to avoid the above problem. Also add DESC_TYPE_UNKNOWN to indicate the info in desc_cb is not valid, because hns3_nic_reclaim_desc() may treat the desc_cb->type of zero as packet and add to the sent pkt statistics accordingly. Fixes: 76ad4f0 ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC") Signed-off-by: Yunsheng Lin <[email protected]> Signed-off-by: Huazhong Tan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 48ae74c commit 8ceca59

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

drivers/net/ethernet/hisilicon/hns3/hnae3.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
((ring)->p = ((ring)->p - 1 + (ring)->desc_num) % (ring)->desc_num)
7878

7979
enum hns_desc_type {
80+
DESC_TYPE_UNKNOWN,
8081
DESC_TYPE_SKB,
8182
DESC_TYPE_FRAGLIST_SKB,
8283
DESC_TYPE_PAGE,

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,13 +1338,20 @@ static void hns3_clear_desc(struct hns3_enet_ring *ring, int next_to_use_orig)
13381338
unsigned int i;
13391339

13401340
for (i = 0; i < ring->desc_num; i++) {
1341+
struct hns3_desc *desc = &ring->desc[ring->next_to_use];
1342+
1343+
memset(desc, 0, sizeof(*desc));
1344+
13411345
/* check if this is where we started */
13421346
if (ring->next_to_use == next_to_use_orig)
13431347
break;
13441348

13451349
/* rollback one */
13461350
ring_ptr_move_bw(ring, next_to_use);
13471351

1352+
if (!ring->desc_cb[ring->next_to_use].dma)
1353+
continue;
1354+
13481355
/* unmap the descriptor dma address */
13491356
if (ring->desc_cb[ring->next_to_use].type == DESC_TYPE_SKB ||
13501357
ring->desc_cb[ring->next_to_use].type ==
@@ -1361,6 +1368,7 @@ static void hns3_clear_desc(struct hns3_enet_ring *ring, int next_to_use_orig)
13611368

13621369
ring->desc_cb[ring->next_to_use].length = 0;
13631370
ring->desc_cb[ring->next_to_use].dma = 0;
1371+
ring->desc_cb[ring->next_to_use].type = DESC_TYPE_UNKNOWN;
13641372
}
13651373
}
13661374

0 commit comments

Comments
 (0)