Skip to content

Commit 2a7556b

Browse files
Yunsheng Lindavem330
authored andcommitted
net: hns3: implement ndo_features_check ops for hns3 driver
The function netif_skb_features() will disable the TSO feature by using dflt_features_check() if the driver does not implement ndo_features_check ops, which may cause performance degradation problem when hns3 hardware can do multiple tagged TSO. Also, the HNS3 hardware only supports checksum on the SKB with a max header len of 480 bytes, so remove the checksum and TSO related features when the header len is over 480 bytes. Signed-off-by: Yunsheng Lin <[email protected]> Signed-off-by: Huazhong Tan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 44b6b88 commit 2a7556b

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,6 +1556,37 @@ static int hns3_nic_set_features(struct net_device *netdev,
15561556
return 0;
15571557
}
15581558

1559+
static netdev_features_t hns3_features_check(struct sk_buff *skb,
1560+
struct net_device *dev,
1561+
netdev_features_t features)
1562+
{
1563+
#define HNS3_MAX_HDR_LEN 480U
1564+
#define HNS3_MAX_L4_HDR_LEN 60U
1565+
1566+
size_t len;
1567+
1568+
if (skb->ip_summed != CHECKSUM_PARTIAL)
1569+
return features;
1570+
1571+
if (skb->encapsulation)
1572+
len = skb_inner_transport_header(skb) - skb->data;
1573+
else
1574+
len = skb_transport_header(skb) - skb->data;
1575+
1576+
/* Assume L4 is 60 byte as TCP is the only protocol with a
1577+
* a flexible value, and it's max len is 60 bytes.
1578+
*/
1579+
len += HNS3_MAX_L4_HDR_LEN;
1580+
1581+
/* Hardware only supports checksum on the skb with a max header
1582+
* len of 480 bytes.
1583+
*/
1584+
if (len > HNS3_MAX_HDR_LEN)
1585+
features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
1586+
1587+
return features;
1588+
}
1589+
15591590
static void hns3_nic_get_stats64(struct net_device *netdev,
15601591
struct rtnl_link_stats64 *stats)
15611592
{
@@ -1970,6 +2001,7 @@ static const struct net_device_ops hns3_nic_netdev_ops = {
19702001
.ndo_do_ioctl = hns3_nic_do_ioctl,
19712002
.ndo_change_mtu = hns3_nic_change_mtu,
19722003
.ndo_set_features = hns3_nic_set_features,
2004+
.ndo_features_check = hns3_features_check,
19732005
.ndo_get_stats64 = hns3_nic_get_stats64,
19742006
.ndo_setup_tc = hns3_nic_setup_tc,
19752007
.ndo_set_rx_mode = hns3_nic_set_rx_mode,

0 commit comments

Comments
 (0)