Skip to content

Commit fcbeb97

Browse files
edumazetdavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9d31a7b commit fcbeb97

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

include/linux/netdevice.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1416,6 +1416,8 @@ enum netdev_priv_flags {
14161416
* @gso_max_size: Maximum size of generic segmentation offload
14171417
* @gso_max_segs: Maximum number of segments that can be passed to the
14181418
* NIC for GSO
1419+
* @gso_min_segs: Minimum number of segments that can be passed to the
1420+
* NIC for GSO
14191421
*
14201422
* @dcbnl_ops: Data Center Bridging netlink ops
14211423
* @num_tc: Number of traffic classes in the net device
@@ -1666,7 +1668,7 @@ struct net_device {
16661668
unsigned int gso_max_size;
16671669
#define GSO_MAX_SEGS 65535
16681670
u16 gso_max_segs;
1669-
1671+
u16 gso_min_segs;
16701672
#ifdef CONFIG_DCB
16711673
const struct dcbnl_rtnl_ops *dcbnl_ops;
16721674
#endif

net/core/dev.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2567,10 +2567,12 @@ static netdev_features_t harmonize_features(struct sk_buff *skb,
25672567

25682568
netdev_features_t netif_skb_features(struct sk_buff *skb)
25692569
{
2570+
const struct net_device *dev = skb->dev;
2571+
netdev_features_t features = dev->features;
2572+
u16 gso_segs = skb_shinfo(skb)->gso_segs;
25702573
__be16 protocol = skb->protocol;
2571-
netdev_features_t features = skb->dev->features;
25722574

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)
25742576
features &= ~NETIF_F_GSO_MASK;
25752577

25762578
if (protocol == htons(ETH_P_8021Q) || protocol == htons(ETH_P_8021AD)) {
@@ -2581,7 +2583,7 @@ netdev_features_t netif_skb_features(struct sk_buff *skb)
25812583
}
25822584

25832585
features = netdev_intersect_features(features,
2584-
skb->dev->vlan_features |
2586+
dev->vlan_features |
25852587
NETIF_F_HW_VLAN_CTAG_TX |
25862588
NETIF_F_HW_VLAN_STAG_TX);
25872589

@@ -6661,6 +6663,7 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
66616663

66626664
dev->gso_max_size = GSO_MAX_SIZE;
66636665
dev->gso_max_segs = GSO_MAX_SEGS;
6666+
dev->gso_min_segs = 0;
66646667

66656668
INIT_LIST_HEAD(&dev->napi_list);
66666669
INIT_LIST_HEAD(&dev->unreg_list);

0 commit comments

Comments
 (0)