Skip to contentSkip to conversation

mv643xx_eth: disable csum offloading if the hw limited by max size

PATCH New Saeed Bishara 7 participants 26 messages Jun 6, 2010 – Sep 1, 2010

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

PATCH 1/2 mv643xx_eth: disable csum offloading if the hw limited by max size

Some controllers (KW, Dove) limits the TX IP/layer4 checksum offloading to a max size.

---
 drivers/net/mv643xx_eth.c   |   10 ++++++++++
 include/linux/mv643xx_eth.h |    4 ++++
 2 files changed, 14 insertions(+), 0 deletions(-)
drivers/net/mv643xx_eth.c +10 -0
index e345ec8..79243dd 100644
@@ -289,6 +289,7 @@ struct mv643xx_eth_shared_private {
 	unsigned int t_clk;
 	int extended_rx_coal_limit;
 	int tx_bw_control;
+	int tx_csum_limit;
 };
 
 #define TX_BW_CONTROL_ABSENT		0
@@ -2468,6 +2469,14 @@ static int mv643xx_eth_change_mtu(struct net_device *dev, int new_mtu)
 	mv643xx_eth_recalc_skb_size(mp);
 	tx_set_rate(mp, 1000000000, 16777216);
 
+	if (mp->shared->tx_csum_limit && dev->mtu > mp->shared->tx_csum_limit) {
+		dev->features &= ~NETIF_F_IP_CSUM;
+		dev->vlan_features &= ~NETIF_F_IP_CSUM;
+	} else {
+		dev->features |= NETIF_F_IP_CSUM;
+		dev->vlan_features |= NETIF_F_IP_CSUM;
+	}
+
 	if (!netif_running(dev))
 		return 0;
 
@@ -2666,6 +2675,7 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
 	 * Detect hardware parameters.
 	 */
 	msp->t_clk = (pd != NULL && pd->t_clk != 0) ? pd->t_clk : 133000000;
+	msp->tx_csum_limit = pd->tx_csum_limit;
 	infer_hw_params(msp);
 
 	platform_set_drvdata(pdev, msp);
include/linux/mv643xx_eth.h +4 -0
index cbbbe9b..7402718 100644
@@ -19,6 +19,10 @@ struct mv643xx_eth_shared_platform_data {
 	struct mbus_dram_target_info	*dram;
 	struct platform_device	*shared_smi;
 	unsigned int		t_clk;
+	/*
+	 * Max packet size for Tx IP/Layer 4 checksum (0 -> no limit)
+	 */
+	int			tx_csum_limit;
 };
 
 #define MV643XX_ETH_PHY_ADDR_DEFAULT	0
Signature · 1 line
1.6.0.4
#1 lore raw

PATCH 2/2 set packet size limit for the mv643xx csum offloading

The mv643xx ethernet controller limits the packet size for the TX checksum offloading. this patch sets this limits for the needed devices.

---
 arch/arm/mach-dove/common.c     |    1 +
 arch/arm/mach-kirkwood/common.c |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)
arch/arm/mach-dove/common.c +1 -0
index 5da2cf4..473ce0b 100644
@@ -149,6 +149,7 @@ void __init dove_ehci1_init(void)
 struct mv643xx_eth_shared_platform_data dove_ge00_shared_data = {
 	.t_clk		= 0,
 	.dram		= &dove_mbus_dram_info,
+	.tx_csum_limit	= 1600,
 };
 
 static struct resource dove_ge00_shared_resources[] = {
arch/arm/mach-kirkwood/common.c +1 -0
index 4ccfdf9..c4bd8cb 100644
@@ -114,6 +114,7 @@ void __init kirkwood_ehci_init(void)
  ****************************************************************************/
 struct mv643xx_eth_shared_platform_data kirkwood_ge00_shared_data = {
 	.dram		= &kirkwood_mbus_dram_info,
+	.tx_csum_limit	= 1600,
 };
 
 static struct resource kirkwood_ge00_shared_resources[] = {
Signature · 1 line
1.6.0.4
#2 lore raw

PATCH 2/2 set packet size limit for the mv643xx csum offloading

Quoted 15 lines · Saeed Bishara

The mv643xx ethernet controller limits the packet size for the TX checksum offloading. this patch sets this limits for the needed devices.

---
 arch/arm/mach-dove/common.c     |    1 +
 arch/arm/mach-kirkwood/common.c |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)
arch/arm/mach-dove/common.c +0 -0
index 5da2cf4..473ce0b 100644

arch/arm/mach-dove/common.c void __init dove_ehci1_init(void) · line 152

Quoted 4 lines
arch/arm/mach-dove/common.c +1 -0
@@ -149,6 +149,7 @@ void __init dove_ehci1_init(void)
 struct mv643xx_eth_shared_platform_data dove_ge00_shared_data = {
 	.t_clk		= 0,
 	.dram		= &dove_mbus_dram_info,
+	.tx_csum_limit	= 1600,

Assuming that 1600 is exactly the right value (and not 1599 or 1601 etc),

Can you fill in for orion5x/dd/loki as well?

#3 lore raw

PATCH 2/2 set packet size limit for the mv643xx csum offloading

In reply to Saeed Bishara
Quoted 3 lines · Saeed Bishara

The mv643xx ethernet controller limits the packet size for the TX checksum offloading. this patch sets this limits for the needed devices.

I noticed that patch 1/2 has gone into mainline but I cannot find 2/2 in any tree. Saeed, can you add the definition for Loki that someone pointed out (9*1024) and resubmit?

Quoted 38 lines
---
 arch/arm/mach-dove/common.c     |    1 +
 arch/arm/mach-kirkwood/common.c |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)
arch/arm/mach-dove/common.c +1 -0
index 5da2cf4..473ce0b 100644
@@ -149,6 +149,7 @@ void __init dove_ehci1_init(void)
 struct mv643xx_eth_shared_platform_data dove_ge00_shared_data = {
 	.t_clk		= 0,
 	.dram		= &dove_mbus_dram_info,
+	.tx_csum_limit	= 1600,
 };
 
 static struct resource dove_ge00_shared_resources[] = {
arch/arm/mach-kirkwood/common.c +1 -0
index 4ccfdf9..c4bd8cb 100644
@@ -114,6 +114,7 @@ void __init kirkwood_ehci_init(void)
  ****************************************************************************/
 struct mv643xx_eth_shared_platform_data kirkwood_ge00_shared_data = {
 	.dram		= &kirkwood_mbus_dram_info,
+	.tx_csum_limit	= 1600,
 };
 
 static struct resource kirkwood_ge00_shared_resources[] = {
Signature · 7 lines
1.6.0.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Signature · 2 lines
Martin Michlmayr
http://www.cyrius.com/
#4 lore raw

PATCH 2/2 set packet size limit for the mv643xx csum offloading

Quoted 7 lines · Martin Michlmayr
Quoted 3 lines

The mv643xx ethernet controller limits the packet size for the TX checksum offloading. this patch sets this limits for the needed devices.

I noticed that patch 1/2 has gone into mainline but I cannot find 2/2 in any tree. Saeed, can you add the definition for Loki that someone pointed out (9*1024) and resubmit?

If you're going to supply the value explicitly for all platforms, you might as well supply it explicitly for mv78xx0 (9*1024) and orion5x (9*1024) as well.

#5 lore raw

PATCH 2/2 set packet size limit for the mv643xx csum offloading

Quoted 6 lines · Lennert Buytenhek
Quoted 4 lines · Martin Michlmayr
Quoted 3 lines

The mv643xx ethernet controller limits the packet size for the TX checksum offloading. this patch sets this limits for the needed devices.

Quoted 8 lines
Quoted 3 lines

I noticed that patch 1/2 has gone into mainline but I cannot find 2/2 in any tree. Saeed, can you add the definition for Loki that someone pointed out (9*1024) and resubmit?

If you're going to supply the value explicitly for all platforms, you might as well supply it explicitly for mv78xx0 (9*1024) and orion5x (9*1024) as well.

The default value is 9*1024, so I see there is need to supply it for mv78xx0 and Loki. agree?
saeed

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-net" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20100831/5a9974d1/attachment-0001.html>

#6 lore raw

PATCH 2/2 set packet size limit for the mv643xx csum offloading

In reply to Lennert Buytenhek
Quoted 7 lines
Quoted 3 lines

I noticed that patch 1/2 has gone into mainline but I cannot find 2/2 in any tree. ?Saeed, can you add the definition for Loki that someone pointed out (9*1024) and resubmit?

If you're going to supply the value explicitly for all platforms, you might as well supply it explicitly for mv78xx0 (9*1024) and orion5x (9*1024) as well.

The default value is 9*1024, so I see there is need to supply it for mv78xx0 and Loki. agree?
saeed

#7 lore raw

PATCH 2/2 set packet size limit for the mv643xx csum offloading

Quoted 10 lines · saeed bishara
Quoted 7 lines
Quoted 3 lines

I noticed that patch 1/2 has gone into mainline but I cannot find 2/2 in any tree. ?Saeed, can you add the definition for Loki that someone pointed out (9*1024) and resubmit?

If you're going to supply the value explicitly for all platforms, you might as well supply it explicitly for mv78xx0 (9*1024) and orion5x (9*1024) as well.

The default value is 9*1024, so I see there is need to supply it for mv78xx0 and Loki. agree?

I would supply it in any case, for clarity -- and if there are two (or more) different values out there, then neither value really has more right to be the default than the other.

#8 lore raw

PATCH 2/2 set packet size limit for the mv643xx csum offloading

Quoted 10 lines · Lennert Buytenhek
Quoted 8 lines · saeed bishara
Quoted 7 lines
Quoted 3 lines

I noticed that patch 1/2 has gone into mainline but I cannot find 2/2 in any tree. ?Saeed, can you add the definition for Loki that someone pointed out (9*1024) and resubmit?

If you're going to supply the value explicitly for all platforms, you might as well supply it explicitly for mv78xx0 (9*1024) and orion5x (9*1024) as well.

Quoted 6 lines
Quoted 2 lines

The default value is 9*1024, so I see there is need to supply it for mv78xx0 and Loki. agree?

I would supply it in any case, for clarity -- and if there are two (or more) different values out there, then neither value really has more right to be the default than the other.

ok, attached the updated version of this patch.

Quoted 1 line

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-set-packet-size-limit-for-the-mv643xx-csum-offloadin.patch
Type: application/octet-stream
Size: 4511 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20100901/c629e319/attachment-0001.obj>

#9 lore raw

PATCH 2/2 set packet size limit for the mv643xx csum offloading

Quoted 8 lines · saeed bishara
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

I noticed that patch 1/2 has gone into mainline but I cannot find 2/2 in any tree. ?Saeed, can you add the definition for Loki that someone pointed out (9*1024) and resubmit?

If you're going to supply the value explicitly for all platforms, you might as well supply it explicitly for mv78xx0 (9*1024) and orion5x (9*1024) as well.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

The default value is 9*1024, so I see there is need to supply it for mv78xx0 and Loki. agree?

I would supply it in any case, for clarity -- and if there are two (or more) different values out there, then neither value really has more right to be the default than the other.

ok, attached the updated version of this patch.

#10 lore raw

PATCH 2/2 set packet size limit for the mv643xx csum offloading

In reply to Saeed Bishara

arch/arm/mach-kirkwood/common.c void __init kirkwood_ehci_init(void) · line 120

Quoted 12 lines · Saeed Bishara
arch/arm/mach-kirkwood/common.c +1 -0
index 4ccfdf9..c4bd8cb 100644
@@ -114,6 +114,7 @@ void __init kirkwood_ehci_init(void)
  ****************************************************************************/
 struct mv643xx_eth_shared_platform_data kirkwood_ge00_shared_data = {
 	.dram		= &kirkwood_mbus_dram_info,
+	.tx_csum_limit	= 1600,
 };
 
 static struct resource kirkwood_ge00_shared_resources[] = {

Kirkwood (at least) has a second ethernet mac, please add the definition for it too.

Thanks,

Signature · 1 line
Maxime
#11 lore raw

PATCH 2/2 set packet size limit for the mv643xx csum offloading

Quoted 16 lines · Maxime Bizon

Review

Quoted 1 line · Saeed Bishara
(quoted diff) +0 -0

b/arch/arm/mach-kirkwood/common.c

arch/arm/mach-kirkwood/common.c void __init kirkwood_ehci_init(void) · line 114

Quoted 5 lines

index 4ccfdf9..c4bd8cb 100644

arch/arm/mach-kirkwood/common.c +0 -0
@@ -114,6 +114,7 @@ void __init kirkwood_ehci_init(void)
 

****************************************************************************/

Quoted 5 lines
arch/arm/mach-kirkwood/common.c +1 -0
 struct mv643xx_eth_shared_platform_data kirkwood_ge00_shared_data = {
      .dram           = &kirkwood_mbus_dram_info,
+     .tx_csum_limit  = 1600,
 };
 
Quoted 5 lines

arch/arm/mach-kirkwood/common.c void __init kirkwood_ehci_init(void) · line 120

Quoted 1 line
arch/arm/mach-kirkwood/common.c +0 -0
 static struct resource kirkwood_ge00_shared_resources[] = {

Kirkwood (at least) has a second ethernet mac, please add the definition for it too.

ok

Quoted 12 lines

Thanks,

--
Maxime

--
To unsubscribe from this list: send the line "unsubscribe linux-net" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20100831/793b6520/attachment-0001.html>

#12 lore raw

PATCH 2/2 set packet size limit for the mv643xx csum offloading

In reply to Maxime Bizon
Quoted 14 lines · Maxime Bizon
Quoted 11 lines · Saeed Bishara
arch/arm/mach-kirkwood/common.c +0 -0
index 4ccfdf9..c4bd8cb 100644
@@ -114,6 +114,7 @@ void __init kirkwood_ehci_init(void)

? ****************************************************************************/ ?struct mv643xx_eth_shared_platform_data kirkwood_ge00_shared_data = { ? ? ? .dram ? ? ? ? ? = &kirkwood_mbus_dram_info,
+ ? ? .tx_csum_limit ?= 1600,
?};

Quoted 4 lines
Quoted 1 line

?static struct resource kirkwood_ge00_shared_resources[] = {

Kirkwood (at least) has a second ethernet mac, please add the definition for it too.

ok, I'll

Quoted 12 lines

Thanks,

--
Maxime

--
To unsubscribe from this list: send the line "unsubscribe linux-net" in the body of a message to majordomo at vger.kernel.org
More majordomo info at ?http://vger.kernel.org/majordomo-info.html

#13 lore raw

PATCH 1/2 mv643xx_eth: disable csum offloading if the hw limited by max size

In reply to Saeed Bishara
Quoted 13 lines · Saeed Bishara
drivers/net/mv643xx_eth.c +1 -0
index e345ec8..79243dd 100644
@@ -289,6 +289,7 @@ struct mv643xx_eth_shared_private {
 	unsigned int t_clk;
 	int extended_rx_coal_limit;
 	int tx_bw_control;
+	int tx_csum_limit;
 };
 
 #define TX_BW_CONTROL_ABSENT		0

drivers/net/mv643xx_eth.c static int mv643xx_eth_change_mtu(struct net_device *dev, int new_mtu) · line 2478

Quoted 10 lines
drivers/net/mv643xx_eth.c +7 -0
@@ -2468,6 +2469,14 @@ static int mv643xx_eth_change_mtu(struct net_device *dev, int new_mtu)
 	mv643xx_eth_recalc_skb_size(mp);
 	tx_set_rate(mp, 1000000000, 16777216);
 
+	if (mp->shared->tx_csum_limit && dev->mtu > mp->shared->tx_csum_limit) {
+		dev->features &= ~NETIF_F_IP_CSUM;
+		dev->vlan_features &= ~NETIF_F_IP_CSUM;
+	} else {
+		dev->features |= NETIF_F_IP_CSUM;
+		dev->vlan_features |= NETIF_F_IP_CSUM;
+	}

I wonder if it would be better to still advertise NETIF_F_IP_CSUM in this case, but just call skb_checksum_help() if skb->len is > dev->mtu in txq_submit_skb(), like we do for the case where the ethernet header is of an unsupported length -- that way, we'd still have hardware checksum offload for TX packets that _do_ fit inside the hardware TX fifo, e.g. when communicating with hosts on another subnet where the default MTU is used.

include/linux/mv643xx_eth.h struct mv643xx_eth_shared_platform_data { · line 23

Quoted 10 lines
include/linux/mv643xx_eth.h +2 -0
index cbbbe9b..7402718 100644
@@ -19,6 +19,10 @@ struct mv643xx_eth_shared_platform_data {
 	struct mbus_dram_target_info	*dram;
 	struct platform_device	*shared_smi;
 	unsigned int		t_clk;
+	/*
+	 * Max packet size for Tx IP/Layer 4 checksum (0 -> no limit)

There's always a limit. :-) You might as well just fill in the right values for orion5x/kw/dd/loki while you're at it.

thanks,
Lennert

#14 lore raw

PATCH 1/2 mv643xx_eth: disable csum offloading if the hw limited by max size

Quoted 31 lines

-----Original Message-----
From: Lennert Buytenhek [mailto:buytenh at wantstofly.org]
Sent: Tuesday, June 08, 2010 8:09 PM
To: Saeed Bishara
Cc: linux-net at vger.kernel.org; linux-arm-kernel at lists.infradead.org
Subject: Re: [PATCH 1/2] mv643xx_eth: disable csum offloading if the hw limited by max size

drivers/net/mv643xx_eth.c static int

Quoted 13 lines · Saeed Bishara
drivers/net/mv643xx_eth.c +1 -0
index e345ec8..79243dd 100644
@@ -289,6 +289,7 @@ struct mv643xx_eth_shared_private {
 	unsigned int t_clk;
 	int extended_rx_coal_limit;
 	int tx_bw_control;
+	int tx_csum_limit;
 };
 
 #define TX_BW_CONTROL_ABSENT		0
@@ -2468,6 +2469,14 @@ static int 

mv643xx_eth_change_mtu(struct net_device *dev, int new_mtu)

drivers/net/mv643xx_eth.c static int mv643xx_eth_change_mtu(struct net_device *dev, int new_mtu)

Quoted 4 lines
drivers/net/mv643xx_eth.c +1 -0
 	mv643xx_eth_recalc_skb_size(mp);
 	tx_set_rate(mp, 1000000000, 16777216);
 
+	if (mp->shared->tx_csum_limit && dev->mtu > 

mp->shared->tx_csum_limit) {

Quoted 14 lines

drivers/net/mv643xx_eth.c static int mv643xx_eth_change_mtu(struct net_device *dev, int new_mtu) · line 2478

Quoted 6 lines
drivers/net/mv643xx_eth.c +6 -0
+		dev->features &= ~NETIF_F_IP_CSUM;
+		dev->vlan_features &= ~NETIF_F_IP_CSUM;
+	} else {
+		dev->features |= NETIF_F_IP_CSUM;
+		dev->vlan_features |= NETIF_F_IP_CSUM;
+	}

I wonder if it would be better to still advertise NETIF_F_IP_CSUM in this case, but just call skb_checksum_help() if skb->len is > dev->mtu in txq_submit_skb(), like we do for the case where the ethernet header is of an unsupported length -- that way, we'd still have hardware checksum offload for TX packets that _do_ fit inside the hardware TX fifo, e.g. when communicating with hosts on another subnet where the default MTU is used.

Goog idea, I'll add a check to skb->len > mp->shared->tx_csum_limit.

Quoted 4 lines

Review

Quoted 3 lines
(quoted diff) +0 -0

b/include/linux/mv643xx_eth.h

Quoted 12 lines

include/linux/mv643xx_eth.h struct mv643xx_eth_shared_platform_data { · line 23

Quoted 9 lines

index cbbbe9b..7402718 100644

include/linux/mv643xx_eth.h +2 -0
@@ -19,6 +19,10 @@ struct mv643xx_eth_shared_platform_data {
 	struct mbus_dram_target_info	*dram;
 	struct platform_device	*shared_smi;
 	unsigned int		t_clk;
+	/*
+	 * Max packet size for Tx IP/Layer 4 checksum (0 -> no limit)

There's always a limit. :-) You might as well just fill in the right values for orion5x/kw/dd/loki while you're at it.

Right, kirkwood and dove are limited to 1600, the others to 9*1024. Don't know about loki.

Quoted 5 lines

thanks,
Lennert

#15 lore raw

PATCH v2 1/2 mv643xx_eth: use sw csum for big packets

Some controllers (KW, Dove) limits the TX IP/layer4 checksum offloading to a max size.

---
 drivers/net/mv643xx_eth.c   |    7 ++++++-
 include/linux/mv643xx_eth.h |    5 +++++
 2 files changed, 11 insertions(+), 1 deletions(-)
drivers/net/mv643xx_eth.c +6 -1
index e345ec8..2d0e06b 100644
@@ -289,6 +289,7 @@ struct mv643xx_eth_shared_private {
 	unsigned int t_clk;
 	int extended_rx_coal_limit;
 	int tx_bw_control;
+	int tx_csum_limit;
 };
 
 #define TX_BW_CONTROL_ABSENT		0
@@ -782,7 +783,8 @@ static int txq_submit_skb(struct tx_queue *txq, struct sk_buff *skb)
 		       skb->protocol != htons(ETH_P_8021Q));
 
 		tag_bytes = (void *)ip_hdr(skb) - (void *)skb->data - ETH_HLEN;
-		if (unlikely(tag_bytes & ~12)) {
+		if (unlikely(tag_bytes & ~12) ||
+			skb->len > mp->shared->tx_csum_limit) {
 			if (skb_checksum_help(skb) == 0)
 				goto no_csum;
 			kfree_skb(skb);
@@ -2666,6 +2668,9 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
 	 * Detect hardware parameters.
 	 */
 	msp->t_clk = (pd != NULL && pd->t_clk != 0) ? pd->t_clk : 133000000;
+	msp->tx_csum_limit = pd->tx_csum_limit ? pd->tx_csum_limit : 9 * 1024;
+	/* add header count so we can compare against skb->len */
+	msp->tx_csum_limit += ETH_HLEN;
 	infer_hw_params(msp);
 
 	platform_set_drvdata(pdev, msp);
include/linux/mv643xx_eth.h +5 -0
index cbbbe9b..30b0c4e 100644
@@ -19,6 +19,11 @@ struct mv643xx_eth_shared_platform_data {
 	struct mbus_dram_target_info	*dram;
 	struct platform_device	*shared_smi;
 	unsigned int		t_clk;
+	/*
+	 * Max packet size for Tx IP/Layer 4 checksum, when set to 0, default
+	 * limit of 9KiB will be used.
+	 */
+	int			tx_csum_limit;
 };
 
 #define MV643XX_ETH_PHY_ADDR_DEFAULT	0
Signature · 1 line
1.6.0.4
#16 lore raw

PATCH v2 1/2 mv643xx_eth: use sw csum for big packets

Quoted 13 lines · Saeed Bishara
drivers/net/mv643xx_eth.c +1 -0
index e345ec8..2d0e06b 100644
@@ -289,6 +289,7 @@ struct mv643xx_eth_shared_private {
 	unsigned int t_clk;
 	int extended_rx_coal_limit;
 	int tx_bw_control;
+	int tx_csum_limit;
 };
 
 #define TX_BW_CONTROL_ABSENT		0

drivers/net/mv643xx_eth.c static int txq_submit_skb(struct tx_queue *txq, struct sk_buff *skb) · line 787

Quoted 6 lines
drivers/net/mv643xx_eth.c +2 -1
@@ -782,7 +783,8 @@ static int txq_submit_skb(struct tx_queue *txq, struct sk_buff *skb)
 		       skb->protocol != htons(ETH_P_8021Q));
 
 		tag_bytes = (void *)ip_hdr(skb) - (void *)skb->data - ETH_HLEN;
-		if (unlikely(tag_bytes & ~12)) {
+		if (unlikely(tag_bytes & ~12) ||
+			skb->len > mp->shared->tx_csum_limit) {

Please line up skb->len with unlikely() on the line above it.

drivers/net/mv643xx_eth.c static int mv643xx_eth_shared_probe(struct platform_device *pdev) · line 2674

Quoted 8 lines
drivers/net/mv643xx_eth.c +3 -0
@@ -2666,6 +2668,9 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
 	 * Detect hardware parameters.
 	 */
 	msp->t_clk = (pd != NULL && pd->t_clk != 0) ? pd->t_clk : 133000000;
+	msp->tx_csum_limit = pd->tx_csum_limit ? pd->tx_csum_limit : 9 * 1024;
+	/* add header count so we can compare against skb->len */
+	msp->tx_csum_limit += ETH_HLEN;
 	infer_hw_params(msp);

Is the limit 9 * 1024 + 14 for the whole packet, or 9 * 1024 for the IP part?

I.e. what happens if skb->len is 9 * 1024 + 15, but there is one VLAN tag present -- will the hardware be able to do the checksum offload or not?

#17 lore raw

PATCH v2 1/2 mv643xx_eth: use sw csum for big packets

Quoted 42 lines

-----Original Message-----
From: Lennert Buytenhek [mailto:buytenh at wantstofly.org]
Sent: Thursday, June 10, 2010 9:44 AM
To: Saeed Bishara
Cc: linux-net at vger.kernel.org; linux-arm-kernel at lists.infradead.org
Subject: Re: [PATCH 1/2 v2] mv643xx_eth: use sw csum for big packets

drivers/net/mv643xx_eth.c static int txq_submit_skb(struct

Quoted 13 lines · Saeed Bishara
drivers/net/mv643xx_eth.c +1 -0
index e345ec8..2d0e06b 100644
@@ -289,6 +289,7 @@ struct mv643xx_eth_shared_private {
 	unsigned int t_clk;
 	int extended_rx_coal_limit;
 	int tx_bw_control;
+	int tx_csum_limit;
 };
 
 #define TX_BW_CONTROL_ABSENT		0
@@ -782,7 +783,8 @@ static int txq_submit_skb(struct 

tx_queue *txq, struct sk_buff *skb)

drivers/net/mv643xx_eth.c static int txq_submit_skb(struct tx_queue *txq, struct sk_buff *skb)

Quoted 3 lines
drivers/net/mv643xx_eth.c +0 -0
 		       skb->protocol != htons(ETH_P_8021Q));
 
 		tag_bytes = (void *)ip_hdr(skb) - (void 

*)skb->data - ETH_HLEN;

drivers/net/mv643xx_eth.c static int txq_submit_skb(struct tx_queue *txq, struct sk_buff *skb) · line 787

Quoted 3 lines
drivers/net/mv643xx_eth.c +2 -1
-		if (unlikely(tag_bytes & ~12)) {
+		if (unlikely(tag_bytes & ~12) ||
+			skb->len > mp->shared->tx_csum_limit) {

Please line up skb->len with unlikely() on the line above it.

drivers/net/mv643xx_eth.c static int

Quoted 1 line
drivers/net/mv643xx_eth.c +0 -0
@@ -2666,6 +2668,9 @@ static int 

mv643xx_eth_shared_probe(struct platform_device *pdev)

drivers/net/mv643xx_eth.c static int mv643xx_eth_shared_probe(struct platform_device *pdev)

Quoted 3 lines
drivers/net/mv643xx_eth.c +0 -0
 	 * Detect hardware parameters.
 	 */
 	msp->t_clk = (pd != NULL && pd->t_clk != 0) ? pd->t_clk 

: 133000000;

Quoted 8 lines

drivers/net/mv643xx_eth.c static int · line 2671

Quoted 1 line
drivers/net/mv643xx_eth.c +1 -0
+	msp->tx_csum_limit = pd->tx_csum_limit ? 

pd->tx_csum_limit : 9 * 1024;

drivers/net/mv643xx_eth.c static int mv643xx_eth_shared_probe(struct platform_device *pdev) · line 2674

Quoted 3 lines
drivers/net/mv643xx_eth.c +2 -0
+	/* add header count so we can compare against skb->len */
+	msp->tx_csum_limit += ETH_HLEN;
 	infer_hw_params(msp);

Is the limit 9 * 1024 + 14 for the whole packet, or 9 * 1024 for the IP part?

the limit is for the IP part, but I thought that adding the header length, then comparing agains skb->len will be the same. What do you suggest?

Quoted 5 lines

I.e. what happens if skb->len is 9 * 1024 + 15, but there is one VLAN tag present -- will the hardware be able to do the checksum offload or not?

#18 lore raw

PATCH v2 1/2 mv643xx_eth: use sw csum for big packets

Quoted 33 lines · Saeed Bishara
Quoted 33 lines

drivers/net/mv643xx_eth.c static int txq_submit_skb(struct

Quoted 13 lines
drivers/net/mv643xx_eth.c +1 -0
index e345ec8..2d0e06b 100644
@@ -289,6 +289,7 @@ struct mv643xx_eth_shared_private {
 	unsigned int t_clk;
 	int extended_rx_coal_limit;
 	int tx_bw_control;
+	int tx_csum_limit;
 };
 
 #define TX_BW_CONTROL_ABSENT		0
@@ -782,7 +783,8 @@ static int txq_submit_skb(struct 

tx_queue *txq, struct sk_buff *skb)

drivers/net/mv643xx_eth.c static int txq_submit_skb(struct tx_queue *txq, struct sk_buff *skb)

Quoted 3 lines
drivers/net/mv643xx_eth.c +0 -0
 		       skb->protocol != htons(ETH_P_8021Q));
 
 		tag_bytes = (void *)ip_hdr(skb) - (void 

*)skb->data - ETH_HLEN;

drivers/net/mv643xx_eth.c static int txq_submit_skb(struct tx_queue *txq, struct sk_buff *skb) · line 787

Quoted 3 lines
drivers/net/mv643xx_eth.c +2 -1
-		if (unlikely(tag_bytes & ~12)) {
+		if (unlikely(tag_bytes & ~12) ||
+			skb->len > mp->shared->tx_csum_limit) {

Please line up skb->len with unlikely() on the line above it.

drivers/net/mv643xx_eth.c static int

Quoted 1 line
drivers/net/mv643xx_eth.c +0 -0
@@ -2666,6 +2668,9 @@ static int 

mv643xx_eth_shared_probe(struct platform_device *pdev)

drivers/net/mv643xx_eth.c static int mv643xx_eth_shared_probe(struct platform_device *pdev)

Quoted 3 lines
drivers/net/mv643xx_eth.c +0 -0
 	 * Detect hardware parameters.
 	 */
 	msp->t_clk = (pd != NULL && pd->t_clk != 0) ? pd->t_clk 

: 133000000;

drivers/net/mv643xx_eth.c static int · line 2671

Quoted 1 line
drivers/net/mv643xx_eth.c +1 -0
+	msp->tx_csum_limit = pd->tx_csum_limit ? 

pd->tx_csum_limit : 9 * 1024;

Quoted 8 lines
Quoted 6 lines

drivers/net/mv643xx_eth.c static int mv643xx_eth_shared_probe(struct platform_device *pdev) · line 2674

Quoted 3 lines
drivers/net/mv643xx_eth.c +2 -0
+	/* add header count so we can compare against skb->len */
+	msp->tx_csum_limit += ETH_HLEN;
 	infer_hw_params(msp);

Is the limit 9 * 1024 + 14 for the whole packet, or 9 * 1024 for the IP part?

the limit is for the IP part, but I thought that adding the header length, then comparing agains skb->len will be the same. What do you suggest?

Right, but for the header length you take 14, while if to include VLAN tags or DSA tags the header might actually be longer -- how does that affect the ability of the hardware to compute the checksum?

I.e. is the restriction "total packet length must be < N + 14 bytes" or is it "the IP part must be < N bytes and it doesn't matter whether there are VLAN tags or not"?

I.e.:

Quoted 3 lines
Quoted 3 lines

I.e. what happens if skb->len is 9 * 1024 + 15, but there is one VLAN tag present -- will the hardware be able to do the checksum offload or not?

#19 lore raw

PATCH v2 1/2 mv643xx_eth: use sw csum for big packets

Quoted 56 lines

-----Original Message-----
From: Lennert Buytenhek [mailto:buytenh at wantstofly.org]
Sent: Saturday, June 12, 2010 11:32 AM
To: Saeed Bishara
Cc: linux-net at vger.kernel.org; linux-arm-kernel at lists.infradead.org
Subject: Re: [PATCH 1/2 v2] mv643xx_eth: use sw csum for big packets

Quoted 30 lines · Saeed Bishara
Quoted 30 lines

drivers/net/mv643xx_eth.c static int txq_submit_skb(struct

Quoted 13 lines
drivers/net/mv643xx_eth.c +1 -0
index e345ec8..2d0e06b 100644
@@ -289,6 +289,7 @@ struct mv643xx_eth_shared_private {
 	unsigned int t_clk;
 	int extended_rx_coal_limit;
 	int tx_bw_control;
+	int tx_csum_limit;
 };
 
 #define TX_BW_CONTROL_ABSENT		0
@@ -782,7 +783,8 @@ static int txq_submit_skb(struct 

tx_queue *txq, struct sk_buff *skb)

drivers/net/mv643xx_eth.c static int txq_submit_skb(struct tx_queue *txq, struct sk_buff *skb)

Quoted 3 lines
drivers/net/mv643xx_eth.c +0 -0
 		       skb->protocol != htons(ETH_P_8021Q));
 
 		tag_bytes = (void *)ip_hdr(skb) - (void 

*)skb->data - ETH_HLEN;

drivers/net/mv643xx_eth.c static int txq_submit_skb(struct tx_queue *txq, struct sk_buff *skb) · line 787

Quoted 3 lines
drivers/net/mv643xx_eth.c +2 -1
-		if (unlikely(tag_bytes & ~12)) {
+		if (unlikely(tag_bytes & ~12) ||
+			skb->len > mp->shared->tx_csum_limit) {

Please line up skb->len with unlikely() on the line above it.

drivers/net/mv643xx_eth.c static int

Quoted 1 line
drivers/net/mv643xx_eth.c +0 -0
@@ -2666,6 +2668,9 @@ static int 

mv643xx_eth_shared_probe(struct platform_device *pdev)

Quoted 3 lines
drivers/net/mv643xx_eth.c +0 -0
 	 * Detect hardware parameters.
 	 */
 	msp->t_clk = (pd != NULL && pd->t_clk != 0) ? pd->t_clk 
Quoted 8 lines
Quoted 8 lines

: 133000000;

drivers/net/mv643xx_eth.c static int · line 2671

Quoted 1 line
drivers/net/mv643xx_eth.c +1 -0
+	msp->tx_csum_limit = pd->tx_csum_limit ? 

pd->tx_csum_limit : 9 * 1024;

drivers/net/mv643xx_eth.c static int mv643xx_eth_shared_probe(struct platform_device *pdev) · line 2674

Quoted 3 lines
drivers/net/mv643xx_eth.c +2 -0
+	/* add header count so we can compare against skb->len */
+	msp->tx_csum_limit += ETH_HLEN;
 	infer_hw_params(msp);

Is the limit 9 * 1024 + 14 for the whole packet, or 9 *

1024 for the IP

Quoted 3 lines
Quoted 1 line

part?

the limit is for the IP part, but I thought that adding the

header length, then comparing agains skb->len will be the same. What do you suggest?

Quoted 7 lines

Right, but for the header length you take 14, while if to include VLAN tags or DSA tags the header might actually be longer -- how does that affect the ability of the hardware to compute the checksum?

I.e. is the restriction "total packet length must be < N + 14 bytes" or is it "the IP part must be < N bytes and it doesn't matter whether there are VLAN tags or not"?

It's the second option: "the IP part must be < N" regardless to the L2 header. saeed

Quoted 9 lines

I.e.:

Quoted 1 line
Quoted 1 line

I.e. what happens if skb->len is 9 * 1024 + 15, but there

is one VLAN

Quoted 1 line
Quoted 1 line

tag present -- will the hardware be able to do the checksum

offload or

Quoted 1 line
Quoted 1 line

not?

#20 lore raw

PATCH v2 1/2 mv643xx_eth: use sw csum for big packets

Quoted 24 lines · Saeed Bishara
Quoted 24 lines
Quoted 5 lines
Quoted 5 lines

Review static int

Quoted 1 line
(quoted diff) +0 -0
@@ -2666,6 +2668,9 @@ static int 

mv643xx_eth_shared_probe(struct platform_device *pdev)

Quoted 3 lines
drivers/net/mv643xx_eth.c +0 -0
 	 * Detect hardware parameters.
 	 */
 	msp->t_clk = (pd != NULL && pd->t_clk != 0) ? pd->t_clk 
Quoted 8 lines
Quoted 8 lines

: 133000000;

Review static int · line 2671

Quoted 1 line
(quoted diff) +1 -0
+	msp->tx_csum_limit = pd->tx_csum_limit ? 

pd->tx_csum_limit : 9 * 1024;

drivers/net/mv643xx_eth.c static int mv643xx_eth_shared_probe(struct platform_device *pdev) · line 2674

Quoted 3 lines
drivers/net/mv643xx_eth.c +2 -0
+	/* add header count so we can compare against skb->len */
+	msp->tx_csum_limit += ETH_HLEN;
 	infer_hw_params(msp);

Is the limit 9 * 1024 + 14 for the whole packet, or 9 *

1024 for the IP

Quoted 3 lines
Quoted 1 line

part?

the limit is for the IP part, but I thought that adding the

header length, then comparing agains skb->len will be the same. What do you suggest?

Right, but for the header length you take 14, while if to include VLAN tags or DSA tags the header might actually be longer -- how does that affect the ability of the hardware to compute the checksum?

Quoted 5 lines
Quoted 3 lines

I.e. is the restriction "total packet length must be < N + 14 bytes" or is it "the IP part must be < N bytes and it doesn't matter whether there are VLAN tags or not"?

It's the second option: "the IP part must be < N" regardless to the L2 header.

Then I suppose you want to do something like:

	int hdr_len;
	int tag_bytes;

	hdr_len = (void *)ip_hdr(skb) - (void *)skb->data;
	tag_bytes = hdr_len - 4;
	if (skb->len - hdr_len > the limit || unlikely(tag_bytes & ~12)) {

(And then keep the limit as maximum number of bytes in the packet starting from the IP header part.)

#21 lore raw

PATCH v2 1/2 mv643xx_eth: use sw csum for big packets

Quoted 32 lines · Lennert Buytenhek
Quoted 24 lines · Saeed Bishara
Quoted 24 lines
Quoted 5 lines
Quoted 5 lines

Review static int

Quoted 1 line
(quoted diff) +0 -0
@@ -2666,6 +2668,9 @@ static int

mv643xx_eth_shared_probe(struct platform_device *pdev)

Quoted 3 lines

? ? ? ? ?* Detect hardware parameters.
? ? ? ? ?*/
? ? ? ? msp->t_clk = (pd != NULL && pd->t_clk != 0) ? pd->t_clk

Quoted 8 lines
Quoted 8 lines

: 133000000;

Quoted 1 line

+ ? ? ? msp->tx_csum_limit = pd->tx_csum_limit ?

pd->tx_csum_limit : 9 * 1024;

Quoted 3 lines

+ ? ? ? /* add header count so we can compare against skb->len */
+ ? ? ? msp->tx_csum_limit += ETH_HLEN;
? ? ? ? infer_hw_params(msp);

Is the limit 9 * 1024 + 14 for the whole packet, or 9 *

1024 for the IP

Quoted 3 lines
Quoted 1 line

part?

the limit is for the IP part, but I thought that adding the

header length, then comparing agains skb->len will be the same. What do you suggest?

Right, but for the header length you take 14, while if to include VLAN tags or DSA tags the header might actually be longer -- how does that affect the ability of the hardware to compute the checksum?

Quoted 5 lines
Quoted 3 lines

I.e. is the restriction "total packet length must be < N + 14 bytes" or is it "the IP part must be < N bytes and it doesn't matter whether there are VLAN tags or not"?

It's the second option: "the IP part must be < N" regardless to the L2 header.

Quoted 7 lines

Then I suppose you want to do something like:

? ? ? ?int hdr_len;
? ? ? ?int tag_bytes;

? ? ? ?hdr_len = (void *)ip_hdr(skb) - (void *)skb->data; ? ? ? ?tag_bytes = hdr_len - 4;

that should be 14 instead of 4, right?

Quoted 4 lines

? ? ? ?if (skb->len - hdr_len > the limit || unlikely(tag_bytes & ~12)) {

(And then keep the limit as maximum number of bytes in the packet starting from the IP header part.)

ok. here is the updated patch:

#22 lore raw

PATCH v2 1/2 mv643xx_eth: use sw csum for big packets

Quoted 32 lines · saeed bishara
Quoted 32 lines
Quoted 24 lines
Quoted 24 lines
Quoted 5 lines
Quoted 5 lines

Review static int

Quoted 1 line
(quoted diff) +0 -0
@@ -2666,6 +2668,9 @@ static int

mv643xx_eth_shared_probe(struct platform_device *pdev)

Quoted 3 lines

? ? ? ? ?* Detect hardware parameters.
? ? ? ? ?*/
? ? ? ? msp->t_clk = (pd != NULL && pd->t_clk != 0) ? pd->t_clk

Quoted 8 lines
Quoted 8 lines

: 133000000;

Quoted 1 line

+ ? ? ? msp->tx_csum_limit = pd->tx_csum_limit ?

pd->tx_csum_limit : 9 * 1024;

Quoted 3 lines

+ ? ? ? /* add header count so we can compare against skb->len */
+ ? ? ? msp->tx_csum_limit += ETH_HLEN;
? ? ? ? infer_hw_params(msp);

Is the limit 9 * 1024 + 14 for the whole packet, or 9 *

1024 for the IP

Quoted 3 lines
Quoted 1 line

part?

the limit is for the IP part, but I thought that adding the

header length, then comparing agains skb->len will be the same. What do you suggest?

Right, but for the header length you take 14, while if to include VLAN tags or DSA tags the header might actually be longer -- how does that affect the ability of the hardware to compute the checksum?

Quoted 5 lines
Quoted 3 lines

I.e. is the restriction "total packet length must be < N + 14 bytes" or is it "the IP part must be < N bytes and it doesn't matter whether there are VLAN tags or not"?

It's the second option: "the IP part must be < N" regardless to the L2 header.

Then I suppose you want to do something like:

Quoted 7 lines
Quoted 5 lines

? ? ? ?int hdr_len;
? ? ? ?int tag_bytes;

? ? ? ?hdr_len = (void *)ip_hdr(skb) - (void *)skb->data; ? ? ? ?tag_bytes = hdr_len - 4;

that should be 14 instead of 4, right?

Yes, sorry.

Quoted 7 lines
Quoted 4 lines

? ? ? ?if (skb->len - hdr_len > the limit || unlikely(tag_bytes & ~12)) {

(And then keep the limit as maximum number of bytes in the packet starting from the IP header part.)

ok. here is the updated patch:

Quoted 1 line

From 009530d4220dd710737d5a357629edcbc102727a Mon Sep 17 00:00:00 2001

Quoted 8 lines

From: Saeed Bishara <[email protected]>
Date: Sun, 6 Jun 2010 14:40:49 +0300
Subject: [PATCH 1/2 v3] mv643xx_eth: use sw csum for big packets

Some controllers (KW, Dove) limits the TX IP/layer4 checksum offloading to a max size.

Looks good!

maintainer
#23 lore raw

PATCH v2 1/2 mv643xx_eth: use sw csum for big packets

From: Lennert Buytenhek <[email protected]>
Date: Sun, 20 Jun 2010 13:58:59 +0200

Quoted 1 line

If the desire is to get this into one of the networking GIT trees, sending it to linux-net isn't going to accomplish that.

It needs to go to netdev at vger.kernel.org with all signoffs and ACKs.

Thanks.

#24 lore raw

PATCH 1/2 mv643xx_eth: disable csum offloading if the hw limited by max size

In reply to Saeed Bishara
Quoted 15 lines · Saeed Bishara
Quoted 14 lines

Review

Quoted 1 line
(quoted diff) +0 -0

b/include/linux/mv643xx_eth.h

include/linux/mv643xx_eth.h struct mv643xx_eth_shared_platform_data { · line 23

Quoted 9 lines

index cbbbe9b..7402718 100644

include/linux/mv643xx_eth.h +2 -0
@@ -19,6 +19,10 @@ struct mv643xx_eth_shared_platform_data {
 	struct mbus_dram_target_info	*dram;
 	struct platform_device	*shared_smi;
 	unsigned int		t_clk;
+	/*
+	 * Max packet size for Tx IP/Layer 4 checksum (0 -> no limit)

There's always a limit. :-) You might as well just fill in the right values for orion5x/kw/dd/loki while you're at it.

Quoted 1 line

Right, kirkwood and dove are limited to 1600, the others to 9*1024. Don't know about loki.

As I know Loki to be able to tx jumbo frames with hw checksum offload, it is likely 9*1024 also.

#25 lore raw

PATCH 1/2 mv643xx_eth: disable csum offloading if the hw limited by max size

Yes, Loki is 9*1024.

-----Original Message-----
From: Lennert Buytenhek [mailto:buytenh at wantstofly.org]
Sent: Wednesday, June 09, 2010 12:11 PM
To: Saeed Bishara
Cc: linux-net at vger.kernel.org; linux-arm-kernel at lists.infradead.org; Abhijeet Gole
Subject: Re: [PATCH 1/2] mv643xx_eth: disable csum offloading if the hw limited by max size

Quoted 15 lines · Saeed Bishara
Quoted 14 lines

Review

Quoted 1 line
(quoted diff) +0 -0

b/include/linux/mv643xx_eth.h

include/linux/mv643xx_eth.h struct mv643xx_eth_shared_platform_data { · line 23

Quoted 9 lines

index cbbbe9b..7402718 100644

include/linux/mv643xx_eth.h +2 -0
@@ -19,6 +19,10 @@ struct mv643xx_eth_shared_platform_data {
 	struct mbus_dram_target_info	*dram;
 	struct platform_device	*shared_smi;
 	unsigned int		t_clk;
+	/*
+	 * Max packet size for Tx IP/Layer 4 checksum (0 -> no limit)

There's always a limit. :-) You might as well just fill in the right values for orion5x/kw/dd/loki while you're at it.

Quoted 1 line

Right, kirkwood and dove are limited to 1600, the others to 9*1024. Don't know about loki.

As I know Loki to be able to tx jumbo frames with hw checksum offload, it is likely 9*1024 also.