Commit 6df6398f authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

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: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent beb21e3e
...@@ -286,8 +286,7 @@ nfp_repr_transfer_features(struct net_device *netdev, struct net_device *lower) ...@@ -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) if (repr->dst->u.port_info.lower_dev != lower)
return; return;
netif_set_gso_max_size(netdev, lower->gso_max_size); netif_inherit_tso_max(netdev, lower);
netif_set_gso_max_segs(netdev, lower->gso_max_segs);
netdev_update_features(netdev); netdev_update_features(netdev);
} }
......
...@@ -139,8 +139,7 @@ static int ipvlan_init(struct net_device *dev) ...@@ -139,8 +139,7 @@ static int ipvlan_init(struct net_device *dev)
dev->vlan_features = phy_dev->vlan_features & IPVLAN_FEATURES; dev->vlan_features = phy_dev->vlan_features & IPVLAN_FEATURES;
dev->vlan_features |= IPVLAN_ALWAYS_ON_OFLOADS; dev->vlan_features |= IPVLAN_ALWAYS_ON_OFLOADS;
dev->hw_enc_features |= dev->features; dev->hw_enc_features |= dev->features;
netif_set_gso_max_size(dev, phy_dev->gso_max_size); netif_inherit_tso_max(dev, phy_dev);
netif_set_gso_max_segs(dev, phy_dev->gso_max_segs);
dev->hard_header_len = phy_dev->hard_header_len; dev->hard_header_len = phy_dev->hard_header_len;
netdev_lockdep_set_classes(dev); netdev_lockdep_set_classes(dev);
...@@ -762,8 +761,7 @@ static int ipvlan_device_event(struct notifier_block *unused, ...@@ -762,8 +761,7 @@ static int ipvlan_device_event(struct notifier_block *unused,
case NETDEV_FEAT_CHANGE: case NETDEV_FEAT_CHANGE:
list_for_each_entry(ipvlan, &port->ipvlans, pnode) { list_for_each_entry(ipvlan, &port->ipvlans, pnode) {
netif_set_gso_max_size(ipvlan->dev, dev->gso_max_size); netif_inherit_tso_max(ipvlan->dev, dev);
netif_set_gso_max_segs(ipvlan->dev, dev->gso_max_segs);
netdev_update_features(ipvlan->dev); netdev_update_features(ipvlan->dev);
} }
break; break;
......
...@@ -904,8 +904,7 @@ static int macvlan_init(struct net_device *dev) ...@@ -904,8 +904,7 @@ static int macvlan_init(struct net_device *dev)
dev->vlan_features = lowerdev->vlan_features & MACVLAN_FEATURES; dev->vlan_features = lowerdev->vlan_features & MACVLAN_FEATURES;
dev->vlan_features |= ALWAYS_ON_OFFLOADS; dev->vlan_features |= ALWAYS_ON_OFFLOADS;
dev->hw_enc_features |= dev->features; dev->hw_enc_features |= dev->features;
netif_set_gso_max_size(dev, lowerdev->gso_max_size); netif_inherit_tso_max(dev, lowerdev);
netif_set_gso_max_segs(dev, lowerdev->gso_max_segs);
dev->hard_header_len = lowerdev->hard_header_len; dev->hard_header_len = lowerdev->hard_header_len;
macvlan_set_lockdep_class(dev); macvlan_set_lockdep_class(dev);
...@@ -1763,8 +1762,7 @@ static int macvlan_device_event(struct notifier_block *unused, ...@@ -1763,8 +1762,7 @@ static int macvlan_device_event(struct notifier_block *unused,
break; break;
case NETDEV_FEAT_CHANGE: case NETDEV_FEAT_CHANGE:
list_for_each_entry(vlan, &port->vlans, list) { list_for_each_entry(vlan, &port->vlans, list) {
netif_set_gso_max_size(vlan->dev, dev->gso_max_size); netif_inherit_tso_max(vlan->dev, dev);
netif_set_gso_max_segs(vlan->dev, dev->gso_max_segs);
netdev_update_features(vlan->dev); netdev_update_features(vlan->dev);
} }
break; break;
......
...@@ -1758,8 +1758,7 @@ static int veth_newlink(struct net *src_net, struct net_device *dev, ...@@ -1758,8 +1758,7 @@ static int veth_newlink(struct net *src_net, struct net_device *dev,
if (ifmp && (dev->ifindex != 0)) if (ifmp && (dev->ifindex != 0))
peer->ifindex = ifmp->ifi_index; peer->ifindex = ifmp->ifi_index;
netif_set_gso_max_size(peer, dev->gso_max_size); netif_inherit_tso_max(peer, dev);
netif_set_gso_max_segs(peer, dev->gso_max_segs);
err = register_netdevice(peer); err = register_netdevice(peer);
put_net(net); put_net(net);
......
...@@ -3683,8 +3683,7 @@ static void vxlan_config_apply(struct net_device *dev, ...@@ -3683,8 +3683,7 @@ static void vxlan_config_apply(struct net_device *dev,
if (lowerdev) { if (lowerdev) {
dst->remote_ifindex = conf->remote_ifindex; dst->remote_ifindex = conf->remote_ifindex;
netif_set_gso_max_size(dev, lowerdev->gso_max_size); netif_inherit_tso_max(dev, lowerdev);
netif_set_gso_max_segs(dev, lowerdev->gso_max_segs);
needed_headroom = lowerdev->hard_header_len; needed_headroom = lowerdev->hard_header_len;
needed_headroom += lowerdev->needed_headroom; needed_headroom += lowerdev->needed_headroom;
......
...@@ -4895,6 +4895,9 @@ static inline void netif_set_gro_max_size(struct net_device *dev, ...@@ -4895,6 +4895,9 @@ static inline void netif_set_gro_max_size(struct net_device *dev,
WRITE_ONCE(dev->gro_max_size, size); 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, static inline void skb_gso_error_unwind(struct sk_buff *skb, __be16 protocol,
int pulled_hlen, u16 mac_offset, int pulled_hlen, u16 mac_offset,
int mac_len) int mac_len)
......
...@@ -319,8 +319,7 @@ static void vlan_transfer_features(struct net_device *dev, ...@@ -319,8 +319,7 @@ static void vlan_transfer_features(struct net_device *dev,
{ {
struct vlan_dev_priv *vlan = vlan_dev_priv(vlandev); struct vlan_dev_priv *vlan = vlan_dev_priv(vlandev);
netif_set_gso_max_size(vlandev, dev->gso_max_size); netif_inherit_tso_max(vlandev, dev);
netif_set_gso_max_segs(vlandev, dev->gso_max_segs);
if (vlan_hw_offload_capable(dev->features, vlan->vlan_proto)) if (vlan_hw_offload_capable(dev->features, vlan->vlan_proto))
vlandev->hard_header_len = dev->hard_header_len; vlandev->hard_header_len = dev->hard_header_len;
......
...@@ -573,8 +573,7 @@ static int vlan_dev_init(struct net_device *dev) ...@@ -573,8 +573,7 @@ static int vlan_dev_init(struct net_device *dev)
NETIF_F_ALL_FCOE; NETIF_F_ALL_FCOE;
dev->features |= dev->hw_features | NETIF_F_LLTX; dev->features |= dev->hw_features | NETIF_F_LLTX;
netif_set_gso_max_size(dev, real_dev->gso_max_size); netif_inherit_tso_max(dev, real_dev);
netif_set_gso_max_segs(dev, real_dev->gso_max_segs);
if (dev->features & NETIF_F_VLAN_FEATURES) 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"); netdev_warn(real_dev, "VLAN features are set incorrectly. Q-in-Q configurations may not work correctly.\n");
......
...@@ -2992,6 +2992,18 @@ int netif_set_real_num_queues(struct net_device *dev, ...@@ -2992,6 +2992,18 @@ int netif_set_real_num_queues(struct net_device *dev,
} }
EXPORT_SYMBOL(netif_set_real_num_queues); 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 * netif_get_num_default_rss_queues - default number of RSS queues
* *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment