Skip to contentSkip to conversation

bridge: inherit slave devices needed_headroom

RFC PATCH In review Florian Fainelli 4 participants 6 messages Aug 20, 2013 – Aug 27, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 bridge: inherit slave devices needed_headroom

Some slave devices may have set a dev->needed_headroom value which is different than the default one, most likely in order to prepend a hardware descriptor in front of the Ethernet frame to send. Whenever a new slave is added to a bridge, ensure that we update the needed_headroom value accordingly to account for the slave needed_headroom value.

---
 net/bridge/br_if.c | 3 +++
 1 file changed, 3 insertions(+)
net/bridge/br_if.c +3 -0
index aa6c9a8..c41d5fb 100644
@@ -383,6 +383,9 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
 
 	netdev_update_features(br->dev);
 
+	if (br->dev->needed_headroom < dev->needed_headroom)
+		br->dev->needed_headroom = dev->needed_headroom;
+
 	spin_lock_bh(&br->lock);
 	changed_addr = br_stp_recalculate_bridge_id(br);
 
Signature · 1 line
1.8.1.2
maintainer
#1 lore raw

From: "Florian Fainelli" <[email protected]>
Date: Tue, 20 Aug 2013 10:21:45 +0100

Quoted 8 lines

Some slave devices may have set a dev->needed_headroom value which is different than the default one, most likely in order to prepend a hardware descriptor in front of the Ethernet frame to send. Whenever a new slave is added to a bridge, ensure that we update the needed_headroom value accordingly to account for the slave needed_headroom value.

This looks fine to me, but I'd like to see either Eric, Stephen, or Vlad review this before I apply it.

#2 lore raw
In reply to Florian Fainelli
Quoted 17 lines · On Tue, 20 Aug 2013 10:21:45 +0100 "Florian Fainelli" <[email protected]>…

Some slave devices may have set a dev->needed_headroom value which is different than the default one, most likely in order to prepend a hardware descriptor in front of the Ethernet frame to send. Whenever a new slave is added to a bridge, ensure that we update the needed_headroom value accordingly to account for the slave needed_headroom value.

---
 net/bridge/br_if.c | 3 +++
 1 file changed, 3 insertions(+)
net/bridge/br_if.c +0 -0
index aa6c9a8..c41d5fb 100644

net/bridge/br_if.c int br_add_if(struct net_bridge *br, struct net_device *dev) · line 391

Quoted 9 lines
net/bridge/br_if.c +3 -0
@@ -383,6 +383,9 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
 
 	netdev_update_features(br->dev);
 
+	if (br->dev->needed_headroom < dev->needed_headroom)
+		br->dev->needed_headroom = dev->needed_headroom;
+
 	spin_lock_bh(&br->lock);
 	changed_addr = br_stp_recalculate_bridge_id(br);
 

I am okay with this but it only helps locally generated traffic which is the minority on most bridge devices. It does nothing for the case where one port needs more headroom than the packet received on the other port. That is why a device has to always work when it receives a packet with less headroom, usually by copying.

maintainer
#3 lore raw

From: Stephen Hemminger <[email protected]>
Date: Wed, 21 Aug 2013 21:58:29 -0700

Quoted 23 lines
Quoted 20 lines · On Tue, 20 Aug 2013 10:21:45 +0100 "Florian Fainelli" <[email protected]>…

Some slave devices may have set a dev->needed_headroom value which is different than the default one, most likely in order to prepend a hardware descriptor in front of the Ethernet frame to send. Whenever a new slave is added to a bridge, ensure that we update the needed_headroom value accordingly to account for the slave needed_headroom value.

---
 net/bridge/br_if.c | 3 +++
 1 file changed, 3 insertions(+)
net/bridge/br_if.c +0 -0
index aa6c9a8..c41d5fb 100644
@@ -383,6 +383,9 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
 
 	netdev_update_features(br->dev);
 
Quoted 13 lines

net/bridge/br_if.c int br_add_if(struct net_bridge *br, struct net_device *dev) · line 391

Quoted 6 lines
net/bridge/br_if.c +3 -0
+	if (br->dev->needed_headroom < dev->needed_headroom)
+		br->dev->needed_headroom = dev->needed_headroom;
+
 	spin_lock_bh(&br->lock);
 	changed_addr = br_stp_recalculate_bridge_id(br);
 

I am okay with this but it only helps locally generated traffic which is the minority on most bridge devices. It does nothing for the case where one port needs more headroom than the packet received on the other port. That is why a device has to always work when it receives a packet with less headroom, usually by copying.

Right so this is basically an optimization.

Florian please submit this formally as a non-RFC patch so Stephen can ACK it and I can apply it, thanks.

#4 lore raw
In reply to Florian Fainelli
Quoted 17 lines · Florian Fainelli

Some slave devices may have set a dev->needed_headroom value which is different than the default one, most likely in order to prepend a hardware descriptor in front of the Ethernet frame to send. Whenever a new slave is added to a bridge, ensure that we update the needed_headroom value accordingly to account for the slave needed_headroom value.

---
 net/bridge/br_if.c | 3 +++
 1 file changed, 3 insertions(+)
net/bridge/br_if.c +0 -0
index aa6c9a8..c41d5fb 100644

net/bridge/br_if.c int br_add_if(struct net_bridge *br, struct net_device *dev) · line 388

Quoted 6 lines
net/bridge/br_if.c +3 -0
@@ -383,6 +383,9 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
 
        netdev_update_features(br->dev);
 
+       if (br->dev->needed_headroom < dev->needed_headroom)
+               br->dev->needed_headroom = dev->needed_headroom;
+

do we need to update 'br->dev->needed_headroom' in br_del_if()?

if (br->dev->needed_headroom == dev->needed_headroom)

    br->dev->needed_headroom = ....;
Quoted 11 lines
net/bridge/br_if.c +0 -1
        spin_lock_bh(&br->lock);
        changed_addr = br_stp_recalculate_bridge_id(br);
 
--

1.8.1.2

--
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

#5 lore raw

2013/8/23 Amos Kong <[email protected]>:

Quoted 21 lines · Florian Fainelli
Quoted 20 lines

Some slave devices may have set a dev->needed_headroom value which is different than the default one, most likely in order to prepend a hardware descriptor in front of the Ethernet frame to send. Whenever a new slave is added to a bridge, ensure that we update the needed_headroom value accordingly to account for the slave needed_headroom value.

---
 net/bridge/br_if.c | 3 +++
 1 file changed, 3 insertions(+)
net/bridge/br_if.c +0 -0
index aa6c9a8..c41d5fb 100644
@@ -383,6 +383,9 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
 
        netdev_update_features(br->dev);
 
Quoted 8 lines

net/bridge/br_if.c int br_add_if(struct net_bridge *br, struct net_device *dev) · line 388

Quoted 3 lines
net/bridge/br_if.c +3 -0
+       if (br->dev->needed_headroom < dev->needed_headroom)
+               br->dev->needed_headroom = dev->needed_headroom;
+

do we need to update 'br->dev->needed_headroom' in br_del_if()?

if (br->dev->needed_headroom == dev->needed_headroom)

    br->dev->needed_headroom = ....;

In theory yes, we should recompute the minimum headroom which is common to all bridge members. This is something that I want to address separately though with the NETDEV_CHANGEROOM notifier.

Signature · 1 line
Florian