8021q: set hard_header_len when VLAN offload features are toggled
Subsystems (2)
RFC PATCH v2 1/1 8021q: set hard_header_len when VLAN offload features are toggled
Toggling the vlan tx|rx hw offloads needs to set the hard_header_len as well otherwise we end up using LL_RESERVED_SPACE incorrectly. This results in pskb_expand_head() being used unnecessarily.
This add a check in vlan_transfer_features to catch the ETH_FLAG_TXVLAN flag and set the header length. This requires drivers to add the ETH_FLAG_TXVLAN to vlan_features.
---
net/8021q/vlan.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
net/8021q/vlan.c +10 -0
@@ -334,6 +334,16 @@ static void vlan_transfer_features(struct net_device *dev, vlandev->features &= ~dev->vlan_features; vlandev->features |= dev->features & dev->vlan_features; vlandev->gso_max_size = dev->gso_max_size; + +/* is ETH_FLAGS_TXVLAN being toggled */ +if ((vlandev->features Ð_FLAG_TXVLAN ) ^ + (old_features Ð_FLAG_TXVLAN )) { +if (vlandev->features Ð_FLAG_TXVLAN ) + vlandev->hard_header_len -=VLAN_HLEN ; +else + vlandev->hard_header_len +=VLAN_HLEN ; + } +#if defined(CONFIG_FCOE ) || defined(CONFIG_FCOE_MODULE ) vlandev->fcoe_ddp_xid = dev->fcoe_ddp_xid;#endif
Quoted 9 lines · John Fastabend
Toggling the vlan tx|rx hw offloads needs to set the
hard_header_lenas well otherwise we end up usingLL_RESERVED_SPACEincorrectly. This results inpskb_expand_head()being used unnecessarily.This add a check in
vlan_transfer_featuresto catch theETH_FLAG_TXVLANflag and set the header length. This requires drivers to add theETH_FLAG_TXVLANtovlan_features.Signed-off-by John Fastabend <[email protected]>
I think this addresses all of the original problems. However, I don't think that we want to have drivers claim to support vlan offloading as a feature for vlan packets. That implies some type of QinQ functionality to me. In addition, if the vlan device claims to support offloading and a second vlan device is stacked on top of it, then the two will clobber skb->vlan_tci. It's probably simpler to just keep track of whether vlan offloading is currently enabled so we can find out whether it changed.
Quoted 12 lines
---
net/8021q/vlan.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)net/8021q/vlan.c +0
-0@@ -334,6 +334,16 @@ static void vlan_transfer_features(struct net_device *dev, vlandev->features &= ~dev->vlan_features; vlandev->features |= dev->features & dev->vlan_features;
net/8021q/vlan.c static void vlan_transfer_features(struct net_device *dev, · line 345
Quoted 10 lines
net/8021q/vlan.c +9
-0vlandev->gso_max_size = dev->gso_max_size; + + /* is ETH_FLAGS_TXVLAN being toggled */ + if ((vlandev->features & ETH_FLAG_TXVLAN) ^ + (old_features & ETH_FLAG_TXVLAN)) { + if (vlandev->features & ETH_FLAG_TXVLAN) + vlandev->hard_header_len -= VLAN_HLEN; + else + vlandev->hard_header_len += VLAN_HLEN; + }
The correct flag for dev->features is NETIF_F_HW_VLAN_TX. ETH_FLAGS_TXVLAN is an ethtool construct (that happens to have the same value).
Thanks.
Quoted 12 lines · Jesse Gross
Quoted 9 lines · John Fastabend
Toggling the vlan tx|rx hw offloads needs to set the
hard_header_lenas well otherwise we end up usingLL_RESERVED_SPACEincorrectly. This results inpskb_expand_head()being used unnecessarily.This add a check in
vlan_transfer_featuresto catch theETH_FLAG_TXVLANflag and set the header length. This requires drivers to add theETH_FLAG_TXVLANtovlan_features.Signed-off-by John Fastabend <[email protected]>
Quoted 9 lines
I think this addresses all of the original problems. However, I don't think that we want to have drivers claim to support vlan offloading as a feature for vlan packets. That implies some type of QinQ functionality to me. In addition, if the vlan device claims to support offloading and a second vlan device is stacked on top of it, then the two will clobber
skb->vlan_tci. It's probably simpler to just keep track of whether vlan offloading is currently enabled so we can find out whether it changed.
Agreed. Rather then trying to be clever this is probably the easiest.
net/8021q/vlan.c +6 -0
@@ -334,6 +334,12 @@ Hunk #1, a/net/8021q/vlan.c static void vlan_transfer_features(struct net_device *dev, vlandev->features &= ~dev->vlan_features; vlandev->features |= dev->features & dev->vlan_features; vlandev->gso_max_size = dev->gso_max_size; + +if (dev->features &NETIF_F_HW_VLAN_TX ) + vlandev->hard_header_len = dev->hard_header_len; +else + vlandev->hard_header_len = dev->hard_header_len +VLAN_HLEN ; +#if defined(CONFIG_FCOE ) || defined(CONFIG_FCOE_MODULE ) vlandev->fcoe_ddp_xid = dev->fcoe_ddp_xid;#endif
Quoted 32 lines
Quoted 12 lines
---
net/8021q/vlan.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)net/8021q/vlan.c +0
-0@@ -334,6 +334,16 @@ static void vlan_transfer_features(struct net_device *dev, vlandev->features &= ~dev->vlan_features; vlandev->features |= dev->features & dev->vlan_features;net/8021q/vlan.c static void vlan_transfer_features(struct net_device *dev, · line 345
Quoted 10 lines
net/8021q/vlan.c +9
-0vlandev->gso_max_size = dev->gso_max_size; + +/* is ETH_FLAGS_TXVLAN being toggled */ +if ((vlandev->features Ð_FLAG_TXVLAN ) ^ + (old_features Ð_FLAG_TXVLAN )) { +if (vlandev->features Ð_FLAG_TXVLAN ) + vlandev->hard_header_len -=VLAN_HLEN ; +else + vlandev->hard_header_len +=VLAN_HLEN ; + }The correct flag for
dev->featuresisNETIF_F_HW_VLAN_TX.ETH_FLAGS_TXVLANis an ethtool construct (that happens to have the same value).Thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 28 lines · John Fastabend
Quoted 12 lines · Jesse Gross
Quoted 9 lines · John Fastabend
Toggling the vlan tx|rx hw offloads needs to set the
hard_header_lenas well otherwise we end up usingLL_RESERVED_SPACEincorrectly. This results inpskb_expand_head()being used unnecessarily.This add a check in
vlan_transfer_featuresto catch theETH_FLAG_TXVLANflag and set the header length. This requires drivers to add theETH_FLAG_TXVLANtovlan_features.Signed-off-by John Fastabend <[email protected]>Quoted 9 lines
I think this addresses all of the original problems. However, I don't think that we want to have drivers claim to support vlan offloading as a feature for vlan packets. That implies some type of QinQ functionality to me. In addition, if the vlan device claims to support offloading and a second vlan device is stacked on top of it, then the two will clobber
skb->vlan_tci. It's probably simpler to just keep track of whether vlan offloading is currently enabled so we can find out whether it changed.Agreed. Rather then trying to be clever this is probably the easiest.
net/8021q/vlan.c Hunk #1, a/net/8021q/vlan.c static void vlan_transfer_features(struct net_device *dev, · line 342
Quoted 9 lines
net/8021q/vlan.c +6
-0@@ -334,6 +334,12 @@ Hunk #1, a/net/8021q/vlan.c static void vlan_transfer_features(struct net_device *dev, vlandev->features &= ~dev->vlan_features; vlandev->features |= dev->features & dev->vlan_features; vlandev->gso_max_size = dev->gso_max_size; + + if (dev->features & NETIF_F_HW_VLAN_TX) + vlandev->hard_header_len = dev->hard_header_len; + else + vlandev->hard_header_len = dev->hard_header_len + VLAN_HLEN; +
Great, that's even simpler than I was thinking.
I think this series is ready to go.