net: add netif_inherit_tso_max()

To make later patches smaller create a helper for inheriting
the TSO limitations of a lower device. The TSO in the name
is not an accident, subsequent patches will replace GSO
with TSO in more names.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Jakub Kicinski 2022-05-05 19:51:31 -07:00 committed by David S. Miller
parent beb21e3e8e
commit 6df6398f7c
9 changed files with 24 additions and 18 deletions

View File

@ -286,8 +286,7 @@ nfp_repr_transfer_features(struct net_device *netdev, struct net_device *lower)
if (repr->dst->u.port_info.lower_dev != lower)
return;
netif_set_gso_max_size(netdev, lower->gso_max_size);
netif_set_gso_max_segs(netdev, lower->gso_max_segs);
netif_inherit_tso_max(netdev, lower);
netdev_update_features(netdev);
}

View File

@ -139,8 +139,7 @@ static int ipvlan_init(struct net_device *dev)
dev->vlan_features = phy_dev->vlan_features & IPVLAN_FEATURES;
dev->vlan_features |= IPVLAN_ALWAYS_ON_OFLOADS;
dev->hw_enc_features |= dev->features;
netif_set_gso_max_size(dev, phy_dev->gso_max_size);
netif_set_gso_max_segs(dev, phy_dev->gso_max_segs);
netif_inherit_tso_max(dev, phy_dev);
dev->hard_header_len = phy_dev->hard_header_len;
netdev_lockdep_set_classes(dev);
@ -762,8 +761,7 @@ static int ipvlan_device_event(struct notifier_block *unused,
case NETDEV_FEAT_CHANGE:
list_for_each_entry(ipvlan, &port->ipvlans, pnode) {
netif_set_gso_max_size(ipvlan->dev, dev->gso_max_size);
netif_set_gso_max_segs(ipvlan->dev, dev->gso_max_segs);
netif_inherit_tso_max(ipvlan->dev, dev);
netdev_update_features(ipvlan->dev);
}
break;

View File

@ -904,8 +904,7 @@ static int macvlan_init(struct net_device *dev)
dev->vlan_features = lowerdev->vlan_features & MACVLAN_FEATURES;
dev->vlan_features |= ALWAYS_ON_OFFLOADS;
dev->hw_enc_features |= dev->features;
netif_set_gso_max_size(dev, lowerdev->gso_max_size);
netif_set_gso_max_segs(dev, lowerdev->gso_max_segs);
netif_inherit_tso_max(dev, lowerdev);
dev->hard_header_len = lowerdev->hard_header_len;
macvlan_set_lockdep_class(dev);
@ -1763,8 +1762,7 @@ static int macvlan_device_event(struct notifier_block *unused,
break;
case NETDEV_FEAT_CHANGE:
list_for_each_entry(vlan, &port->vlans, list) {
netif_set_gso_max_size(vlan->dev, dev->gso_max_size);
netif_set_gso_max_segs(vlan->dev, dev->gso_max_segs);
netif_inherit_tso_max(vlan->dev, dev);
netdev_update_features(vlan->dev);
}
break;

View File

@ -1758,8 +1758,7 @@ static int veth_newlink(struct net *src_net, struct net_device *dev,
if (ifmp && (dev->ifindex != 0))
peer->ifindex = ifmp->ifi_index;
netif_set_gso_max_size(peer, dev->gso_max_size);
netif_set_gso_max_segs(peer, dev->gso_max_segs);
netif_inherit_tso_max(peer, dev);
err = register_netdevice(peer);
put_net(net);

View File

@ -3683,8 +3683,7 @@ static void vxlan_config_apply(struct net_device *dev,
if (lowerdev) {
dst->remote_ifindex = conf->remote_ifindex;
netif_set_gso_max_size(dev, lowerdev->gso_max_size);
netif_set_gso_max_segs(dev, lowerdev->gso_max_segs);
netif_inherit_tso_max(dev, lowerdev);
needed_headroom = lowerdev->hard_header_len;
needed_headroom += lowerdev->needed_headroom;

View File

@ -4895,6 +4895,9 @@ static inline void netif_set_gro_max_size(struct net_device *dev,
WRITE_ONCE(dev->gro_max_size, size);
}
void netif_inherit_tso_max(struct net_device *to,
const struct net_device *from);
static inline void skb_gso_error_unwind(struct sk_buff *skb, __be16 protocol,
int pulled_hlen, u16 mac_offset,
int mac_len)

View File

@ -319,8 +319,7 @@ static void vlan_transfer_features(struct net_device *dev,
{
struct vlan_dev_priv *vlan = vlan_dev_priv(vlandev);
netif_set_gso_max_size(vlandev, dev->gso_max_size);
netif_set_gso_max_segs(vlandev, dev->gso_max_segs);
netif_inherit_tso_max(vlandev, dev);
if (vlan_hw_offload_capable(dev->features, vlan->vlan_proto))
vlandev->hard_header_len = dev->hard_header_len;

View File

@ -573,8 +573,7 @@ static int vlan_dev_init(struct net_device *dev)
NETIF_F_ALL_FCOE;
dev->features |= dev->hw_features | NETIF_F_LLTX;
netif_set_gso_max_size(dev, real_dev->gso_max_size);
netif_set_gso_max_segs(dev, real_dev->gso_max_segs);
netif_inherit_tso_max(dev, real_dev);
if (dev->features & NETIF_F_VLAN_FEATURES)
netdev_warn(real_dev, "VLAN features are set incorrectly. Q-in-Q configurations may not work correctly.\n");

View File

@ -2992,6 +2992,18 @@ int netif_set_real_num_queues(struct net_device *dev,
}
EXPORT_SYMBOL(netif_set_real_num_queues);
/**
* netif_inherit_tso_max() - copy all TSO limits from a lower device to an upper
* @to: netdev to update
* @from: netdev from which to copy the limits
*/
void netif_inherit_tso_max(struct net_device *to, const struct net_device *from)
{
netif_set_gso_max_size(to, from->gso_max_size);
netif_set_gso_max_segs(to, from->gso_max_segs);
}
EXPORT_SYMBOL(netif_inherit_tso_max);
/**
* netif_get_num_default_rss_queues - default number of RSS queues
*