Skip to content

Commit 48ae74c

Browse files
Yunsheng Lindavem330
authored andcommitted
net: hns3: fix for not calculating TX BD send size correctly
With GRO and fraglist support, the SKB can be aggregated to a total size of 65535, and when that SKB is forwarded through a bridge, the size of the SKB may be pushed to exceed the size of 65535 when br_dev_queue_push_xmit() is called. The max send size of BD supported by the HW is 65535, when a SKB with a headlen of over 65535 is sent to the driver, the driver needs to use multi BD to send the linear data, and the send size of the last BD is calculated incorrectly by the driver who is using '&' operation, which causes a TX error. Use '%' operation to fix this problem. Fixes: 3fe13ed ("net: hns3: avoid mult + div op in critical data path") Signed-off-by: Yunsheng Lin <[email protected]> Signed-off-by: Huazhong Tan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0ec3b6a commit 48ae74c

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ static int hns3_fill_desc(struct hns3_enet_ring *ring, void *priv,
11351135
}
11361136

11371137
frag_buf_num = hns3_tx_bd_count(size);
1138-
sizeoflast = size & HNS3_TX_LAST_SIZE_M;
1138+
sizeoflast = size % HNS3_MAX_BD_SIZE;
11391139
sizeoflast = sizeoflast ? sizeoflast : HNS3_MAX_BD_SIZE;
11401140

11411141
/* When frag size is bigger than hardware limit, split this frag */

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,6 @@ enum hns3_nic_state {
165165
#define HNS3_TXD_MSS_S 0
166166
#define HNS3_TXD_MSS_M (0x3fff << HNS3_TXD_MSS_S)
167167

168-
#define HNS3_TX_LAST_SIZE_M 0xffff
169-
170168
#define HNS3_VECTOR_TX_IRQ BIT_ULL(0)
171169
#define HNS3_VECTOR_RX_IRQ BIT_ULL(1)
172170

0 commit comments

Comments
 (0)