Skip to content

Commit 399e082

Browse files
AndrewAtDaynixdavem330
authored andcommitted
driver/net/tun: Added features for USO.
Added support for USO4 and USO6. For now, to "enable" USO, it's required to set both USO4 and USO6 simultaneously. USO enables NETIF_F_GSO_UDP_L4. Signed-off-by: Andrew Melnychenko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b22bbdd commit 399e082

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

drivers/net/tap.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,10 @@ static int set_offload(struct tap_queue *q, unsigned long arg)
957957
if (arg & TUN_F_TSO6)
958958
feature_mask |= NETIF_F_TSO6;
959959
}
960+
961+
/* TODO: for now USO4 and USO6 should work simultaneously */
962+
if ((arg & (TUN_F_USO4 | TUN_F_USO6)) == (TUN_F_USO4 | TUN_F_USO6))
963+
features |= NETIF_F_GSO_UDP_L4;
960964
}
961965

962966
/* tun/tap driver inverts the usage for TSO offloads, where
@@ -967,7 +971,8 @@ static int set_offload(struct tap_queue *q, unsigned long arg)
967971
* When user space turns off TSO, we turn off GSO/LRO so that
968972
* user-space will not receive TSO frames.
969973
*/
970-
if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6))
974+
if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6) ||
975+
(feature_mask & (TUN_F_USO4 | TUN_F_USO6)) == (TUN_F_USO4 | TUN_F_USO6))
971976
features |= RX_OFFLOADS;
972977
else
973978
features &= ~RX_OFFLOADS;
@@ -1091,7 +1096,8 @@ static long tap_ioctl(struct file *file, unsigned int cmd,
10911096
case TUNSETOFFLOAD:
10921097
/* let the user check for future flags */
10931098
if (arg & ~(TUN_F_CSUM | TUN_F_TSO4 | TUN_F_TSO6 |
1094-
TUN_F_TSO_ECN | TUN_F_UFO))
1099+
TUN_F_TSO_ECN | TUN_F_UFO |
1100+
TUN_F_USO4 | TUN_F_USO6))
10951101
return -EINVAL;
10961102

10971103
rtnl_lock();

drivers/net/tun.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ struct tun_struct {
185185
struct net_device *dev;
186186
netdev_features_t set_features;
187187
#define TUN_USER_FEATURES (NETIF_F_HW_CSUM|NETIF_F_TSO_ECN|NETIF_F_TSO| \
188-
NETIF_F_TSO6)
188+
NETIF_F_TSO6 | NETIF_F_GSO_UDP_L4)
189189

190190
int align;
191191
int vnet_hdr_sz;
@@ -2878,6 +2878,12 @@ static int set_offload(struct tun_struct *tun, unsigned long arg)
28782878
}
28792879

28802880
arg &= ~TUN_F_UFO;
2881+
2882+
/* TODO: for now USO4 and USO6 should work simultaneously */
2883+
if (arg & TUN_F_USO4 && arg & TUN_F_USO6) {
2884+
features |= NETIF_F_GSO_UDP_L4;
2885+
arg &= ~(TUN_F_USO4 | TUN_F_USO6);
2886+
}
28812887
}
28822888

28832889
/* This gives the user a way to test for new features in future by

0 commit comments

Comments
 (0)