Skip to contentSkip to conversation

tg3: Fix handling of non-acceleration vlans

PATCH In review Vladislav Yasevich 5 participants 9 messages Sep 19, 2014 – Sep 30, 2014

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

v2 cover tg3: Fix handling of non-acceleration vlans

TG3 can't cope with checksum and TSO offloads when vlan headers were not accelerated. This can be demonstrated with 802.1ad vlans or by configuring a vlan on top of a bridge and turning off vlan acceleration on the bridge device.

Instead of disabling all vlan acceleration, this series works around the issue by having tg3 driver call software segmentation and checksum generation.

v2: - moved the call to software segment soonner
- Preserve the checksum flags for TSO/LSO case and turn it off if software checksum was computed.
- Add code to correctly receive full sized 802.1ad frames.

Vladislav Yasevich (2):
tg3: Work around HW/FW limitations with vlan encapsulated frames
tg3: Allow for receive of full-size 8021AD frames

 drivers/net/ethernet/broadcom/tg3.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
Signature · 1 line
1.9.3
#1 lore raw

PATCH v2 1/2 tg3: Work around HW/FW limitations with vlan encapsulated frames

TG3 appears to have an issue performing TSO and checksum offloading correctly when the frame has been vlan encapsulated (non-accelerated). In these cases, tcp checksum is not correctly updated.

This patch attempts to work around this issue. After the patch, 802.1ad vlans start working correctly over tg3 devices.

CC Prashant Sreedharan <[email protected]>
CC Michael Chan <[email protected]>

---
v2: - Moved segmentation call sooner
- Preserve checksum txd flag for LSO.

 drivers/net/ethernet/broadcom/tg3.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/net/ethernet/broadcom/tg3.c +17 -0
index cb77ae9..b78d043 100644
@@ -7924,6 +7924,13 @@ static netdev_tx_t tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
 		if (skb_cow_head(skb, 0))
 			goto drop;
 
+		/* HW/FW can not correctly segment packets that have been
+		 * vlan encapsulated.
+		 */
+		if (skb->protocol == htons(ETH_P_8021Q) ||
+		    skb->protocol == htons(ETH_P_8021AD))
+			return tg3_tso_bug(tp, tnapi, txq, skb);
+
 		iph = ip_hdr(skb);
 		tcp_opt_len = tcp_optlen(skb);
 
@@ -7979,6 +7986,16 @@ static netdev_tx_t tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
 				base_flags |= tsflags << 12;
 			}
 		}
+	} else if (skb->ip_summed == CHECKSUM_PARTIAL) {
+		/* HW/FW can not correctly checksum packets that have been
+		 * vlan encapsulated.
+		 */
+		if (skb->protocol == htons(ETH_P_8021Q) ||
+		    skb->protocol == htons(ETH_P_8021AD)) {
+			if (skb_checksum_help(skb))
+				goto drop;
+			base_flags &= ~TXD_FLAG_TCPUDP_CSUM;
+		}
 	}
 
 	if (tg3_flag(tp, USE_JUMBO_BDFLAG) &&
Signature · 1 line
1.9.3
#2 lore raw

PATCH v2 2/2 tg3: Allow for receive of full-size 8021AD frames

In reply to Vladislav Yasevich

When receiving a vlan-tagged frame that still contains a vlan header, the length of the packet will be greater then MTU+ETH_HLEN since it will account of the extra vlan header. TG3 checks this for the case for 802.1Q, but not for 802.1ad. As a result, full sized 802.1ad frames get dropped by the card.

Add a check for 802.1ad protocol when receiving full sized frames.

---
 drivers/net/ethernet/broadcom/tg3.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/tg3.c +2 -1
index 0a0938d..4f674f9 100644
@@ -6918,7 +6918,8 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget)
 		skb->protocol = eth_type_trans(skb, tp->dev);
 
 		if (len > (tp->dev->mtu + ETH_HLEN) &&
-		    skb->protocol != htons(ETH_P_8021Q)) {
+		    skb->protocol != htons(ETH_P_8021Q) &&
+		    skb->protocol != htons(ETH_P_8021AD)) {
 			dev_kfree_skb_any(skb);
 			goto drop_it_no_recycle;
 		}
Signature · 1 line
1.9.3
#3 lore raw

Re: [PATCH v2 2/2] tg3: Allow for receive of full-size 8021AD frames

Quoted 23 lines · Vladislav Yasevich

When receiving a vlan-tagged frame that still contains a vlan header, the length of the packet will be greater then MTU+ETH_HLEN since it will account of the extra vlan header. TG3 checks this for the case for 802.1Q, but not for 802.1ad. As a result, full sized 802.1ad frames get dropped by the card.

Add a check for 802.1ad protocol when receiving full sized frames.

---
 drivers/net/ethernet/broadcom/tg3.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/tg3.c +0 -0
index 0a0938d..4f674f9 100644

drivers/net/ethernet/broadcom/tg3.c static int tg3_rx(struct tg3_napi *tnapi, int budget) · line 6925

Quoted 9 lines
drivers/net/ethernet/broadcom/tg3.c +2 -1
@@ -6918,7 +6918,8 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget)
 		skb->protocol = eth_type_trans(skb, tp->dev);
 
 		if (len > (tp->dev->mtu + ETH_HLEN) &&
-		    skb->protocol != htons(ETH_P_8021Q)) {
+		    skb->protocol != htons(ETH_P_8021Q) &&
+		    skb->protocol != htons(ETH_P_8021AD)) {
 			dev_kfree_skb_any(skb);
 			goto drop_it_no_recycle;
 		}

Really I do not understand what is the value of this check.

If NIC is dumb enough to send oversized frames, what prevents these frames being VLAN ones, and this test wont avoid the crash anyway ?

#4 lore raw

Re: [PATCH v2 2/2] tg3: Allow for receive of full-size 8021AD frames

Quoted 36 lines · Eric Dumazet
Quoted 23 lines · Vladislav Yasevich

When receiving a vlan-tagged frame that still contains a vlan header, the length of the packet will be greater then MTU+ETH_HLEN since it will account of the extra vlan header. TG3 checks this for the case for 802.1Q, but not for 802.1ad. As a result, full sized 802.1ad frames get dropped by the card.

Add a check for 802.1ad protocol when receiving full sized frames.

---
 drivers/net/ethernet/broadcom/tg3.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/tg3.c +0 -0
index 0a0938d..4f674f9 100644

drivers/net/ethernet/broadcom/tg3.c static int tg3_rx(struct tg3_napi *tnapi, int budget) · line 6925

Quoted 9 lines
drivers/net/ethernet/broadcom/tg3.c +2 -1
@@ -6918,7 +6918,8 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget)
 		skb->protocol = eth_type_trans(skb, tp->dev);
 
 		if (len > (tp->dev->mtu + ETH_HLEN) &&
-		    skb->protocol != htons(ETH_P_8021Q)) {
+		    skb->protocol != htons(ETH_P_8021Q) &&
+		    skb->protocol != htons(ETH_P_8021AD)) {
 			dev_kfree_skb_any(skb);
 			goto drop_it_no_recycle;
 		}

Really I do not understand what is the value of this check.

Quoted 3 lines

If NIC is dumb enough to send oversized frames, what prevents these frames being VLAN ones, and this test wont avoid the crash anyway ?

The NIC will not receive frames of size > mtu + ETH_HLEN + VLAN_HLEN it will update the oversize_frame count and drop it. The check is to make sure the additional 4 bytes is due to a valid vlan header.

#5 lore raw

Re: [PATCH v2 2/2] tg3: Allow for receive of full-size 8021AD frames

Quoted 3 lines · Prashant Sreedharan

The NIC will not receive frames of size > mtu + ETH_HLEN + VLAN_HLEN it will update the oversize_frame count and drop it. The check is to make sure the additional 4 bytes is due to a valid vlan header.

I see, thanks for the explanation ;)

Acked-by on the v2 series
#6 lore raw
In reply to Vladislav Yasevich
Quoted 14 lines · Vladislav Yasevich

TG3 can't cope with checksum and TSO offloads when vlan headers were not accelerated. This can be demonstrated with 802.1ad vlans or by configuring a vlan on top of a bridge and turning off vlan acceleration on the bridge device.

Instead of disabling all vlan acceleration, this series works around the issue by having tg3 driver call software segmentation and checksum generation.

v2: - moved the call to software segment soonner
- Preserve the checksum flags for TSO/LSO case and turn it off if software checksum was computed.
- Add code to correctly receive full sized 802.1ad frames.

Quoted 7 lines

Vladislav Yasevich (2):
tg3: Work around HW/FW limitations with vlan encapsulated frames
tg3: Allow for receive of full-size 8021AD frames

 drivers/net/ethernet/broadcom/tg3.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
#7 lore raw

PATCH 1/1 tg3: Allow for receive of full-size 8021AD frames

In reply to Vladislav Yasevich

When receiving a vlan-tagged frame that still contains a vlan header, the length of the packet will be greater then MTU+ETH_HLEN since it will account of the extra vlan header. TG3 checks this for the case for 802.1Q, but not for 802.1ad. As a result, full sized 802.1ad frames get dropped by the card.

Add a check for 802.1ad protocol when receiving full sized frames.

---
This patch somehow got dropped. Please apply and queue for stable.

 drivers/net/ethernet/broadcom/tg3.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/tg3.c +2 -1
index 0a0938d..4f674f9 100644
@@ -6918,7 +6918,8 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget)
 		skb->protocol = eth_type_trans(skb, tp->dev);
  		if (len > (tp->dev->mtu + ETH_HLEN) &&
-		    skb->protocol != htons(ETH_P_8021Q)) {
+		    skb->protocol != htons(ETH_P_8021Q) &&
+		    skb->protocol != htons(ETH_P_8021AD)) {
 			dev_kfree_skb_any(skb);
 			goto drop_it_no_recycle;
 		}
Signature · 1 line
1.9.3
maintainer
#8 lore raw

Re: [PATCH] tg3: Allow for receive of full-size 8021AD frames

From: Vlad Yasevich <[email protected]>
Date: Tue, 30 Sep 2014 14:53:08 -0400

Quoted 1 line

This patch somehow got dropped. Please apply and queue for stable.

Because I applied your original patch:

	http://patchwork.ozlabs.org/patch/390834/

This patch here doesn't even apply to the 'net' tree because of that.

Please sort that out.

I'm marking this patch and the similar bnx2 one 'deferred'. Please resubmit everything once you've sorted things out.

Thanks.