Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: introduce netdevice gso_min_segs attribute

Some TSO engines might have a too heavy setup cost, that impacts
performance on hosts sending small bursts (2 MSS per packet).

This patch adds a device gso_min_segs, allowing drivers to set
a minimum segment size for TSO packets, according to the NIC
performance.

Tested on a mlx4 NIC, this allows to get a ~110% increase of
throughput when sending 2 MSS per packet.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Eric Dumazet and committed by
David S. Miller
fcbeb976 9d31a7b9

+9 -4
+3 -1
include/linux/netdevice.h
··· 1416 1416 * @gso_max_size: Maximum size of generic segmentation offload 1417 1417 * @gso_max_segs: Maximum number of segments that can be passed to the 1418 1418 * NIC for GSO 1419 + * @gso_min_segs: Minimum number of segments that can be passed to the 1420 + * NIC for GSO 1419 1421 * 1420 1422 * @dcbnl_ops: Data Center Bridging netlink ops 1421 1423 * @num_tc: Number of traffic classes in the net device ··· 1668 1666 unsigned int gso_max_size; 1669 1667 #define GSO_MAX_SEGS 65535 1670 1668 u16 gso_max_segs; 1671 - 1669 + u16 gso_min_segs; 1672 1670 #ifdef CONFIG_DCB 1673 1671 const struct dcbnl_rtnl_ops *dcbnl_ops; 1674 1672 #endif
+6 -3
net/core/dev.c
··· 2567 2567 2568 2568 netdev_features_t netif_skb_features(struct sk_buff *skb) 2569 2569 { 2570 + const struct net_device *dev = skb->dev; 2571 + netdev_features_t features = dev->features; 2572 + u16 gso_segs = skb_shinfo(skb)->gso_segs; 2570 2573 __be16 protocol = skb->protocol; 2571 - netdev_features_t features = skb->dev->features; 2572 2574 2573 - if (skb_shinfo(skb)->gso_segs > skb->dev->gso_max_segs) 2575 + if (gso_segs > dev->gso_max_segs || gso_segs < dev->gso_min_segs) 2574 2576 features &= ~NETIF_F_GSO_MASK; 2575 2577 2576 2578 if (protocol == htons(ETH_P_8021Q) || protocol == htons(ETH_P_8021AD)) { ··· 2583 2581 } 2584 2582 2585 2583 features = netdev_intersect_features(features, 2586 - skb->dev->vlan_features | 2584 + dev->vlan_features | 2587 2585 NETIF_F_HW_VLAN_CTAG_TX | 2588 2586 NETIF_F_HW_VLAN_STAG_TX); 2589 2587 ··· 6663 6661 6664 6662 dev->gso_max_size = GSO_MAX_SIZE; 6665 6663 dev->gso_max_segs = GSO_MAX_SEGS; 6664 + dev->gso_min_segs = 0; 6666 6665 6667 6666 INIT_LIST_HEAD(&dev->napi_list); 6668 6667 INIT_LIST_HEAD(&dev->unreg_list);