Skip to contentSkip to conversation

ethtool: Add NETIF_F_HW_CSUM support

PATCH In review Jon Mason 3 participants 6 messages May 23, 2005 – May 26, 2005

Subsystems (2)
lore
Share & tools
lore

Jon Mason

author
#0 lore raw

PATCH 1/1 ethtool: Add NETIF_F_HW_CSUM support

Added support to ethtool for NETIF_F_HW_CSUM.

linux/ethtool.h renamed from linux/ethtool.h.orig +1 -0
@@ -256,6 +256,7 @@ struct net_device;
 u32 ethtool_op_get_link(struct net_device *dev);
 u32 ethtool_op_get_tx_csum(struct net_device *dev);
 int ethtool_op_set_tx_csum(struct net_device *dev, u32 data);
+int ethtool_op_set_tx_hw_csum(struct net_device *dev, u32 data);
 u32 ethtool_op_get_sg(struct net_device *dev);
 int ethtool_op_set_sg(struct net_device *dev, u32 data);
 u32 ethtool_op_get_tso(struct net_device *dev);
core/ethtool.c renamed from core/ethtool.c.orig +11 -1
@@ -29,7 +29,7 @@ u32 ethtool_op_get_link(struct net_devic
 
 u32 ethtool_op_get_tx_csum(struct net_device *dev)
 {
-	return (dev->features & NETIF_F_IP_CSUM) != 0;
+	return (dev->features & (NETIF_F_IP_CSUM | NETIF_F_HW_CSUM)) != 0;
 }
 
 int ethtool_op_set_tx_csum(struct net_device *dev, u32 data)
@@ -42,6 +42,15 @@ int ethtool_op_set_tx_csum(struct net_de
 	return 0;
 }
 
+int ethtool_op_set_tx_hw_csum(struct net_device *dev, u32 data)
+{
+	if (data)
+		dev->features |= NETIF_F_HW_CSUM;
+	else
+		dev->features &= ~NETIF_F_HW_CSUM;
+
+	return 0;
+}
 u32 ethtool_op_get_sg(struct net_device *dev)
 {
 	return (dev->features & NETIF_F_SG) != 0;
@@ -817,3 +826,4 @@ EXPORT_SYMBOL(ethtool_op_get_tx_csum);
 EXPORT_SYMBOL(ethtool_op_set_sg);
 EXPORT_SYMBOL(ethtool_op_set_tso);
 EXPORT_SYMBOL(ethtool_op_set_tx_csum);
+EXPORT_SYMBOL(ethtool_op_set_tx_hw_csum);
maintainer
#1 lore raw

From: Jon Mason <[email protected]>
Subject: [PATCH linux-2.6.12-rc4-mm1] ethtool: Add NETIF_F_HW_CSUM support
Date: Mon, 23 May 2005 16:07:57 -0500

Quoted 3 lines

Added support to ethtool for NETIF_F_HW_CSUM.

You cannot blindly set these flags, you need to provide a method for the driver to override the implementation of this method so it can return and error if it cannot provide support for this feature.

author
#2 lore raw
Quoted 4 lines · David S. Miller

From: Jon Mason <[email protected]>
Subject: [PATCH linux-2.6.12-rc4-mm1] ethtool: Add NETIF_F_HW_CSUM support
Date: Mon, 23 May 2005 16:07:57 -0500

Quoted 8 lines
Quoted 3 lines

Added support to ethtool for NETIF_F_HW_CSUM.

You cannot blindly set these flags, you need to provide a method for the driver to override the implementation of this method so it can return and error if it cannot provide support for this feature.

I am only adding a generic function which gives the ability to use NETIF_F_HW_CSUM for ethtool tx offload (instead of only using NETIF_F_IP_CSUM).

If ethtool_set_tx_csum does not point to ethtool_op_set_tx_csum or ethtool_op_set_tx_hw_csum (or a local driver function) then it will return an error. Isn't this sufficient (as it is what currently happening), or am I not sufficently understanding the problem?

Thanks,
Jon

maintainer
#3 lore raw

From: Jon Mason <[email protected]>
Date: Mon, 23 May 2005 16:32:55 -0500

Quoted 4 lines

If ethtool_set_tx_csum does not point to ethtool_op_set_tx_csum or ethtool_op_set_tx_hw_csum (or a local driver function) then it will return an error. Isn't this sufficient (as it is what currently happening), or am I not sufficently understanding the problem?

Ok, that looks right.

#4 lore raw
In reply to David S. Miller
Quoted 4 lines · On Mon, 23 May 2005 14:20:09 -0700 (PDT) "David S. Miller"…

From: Jon Mason <[email protected]>
Subject: [PATCH linux-2.6.12-rc4-mm1] ethtool: Add NETIF_F_HW_CSUM support
Date: Mon, 23 May 2005 16:07:57 -0500

Quoted 8 lines
Quoted 3 lines

Added support to ethtool for NETIF_F_HW_CSUM.

You cannot blindly set these flags, you need to provide a method for the driver to override the implementation of this method so it can return and error if it cannot provide support for this feature.

This patch makes perfect sense because it allows for common code to be used by device drivers in their ethtool_ops. So this is the logical way to handle this.

In other words,

drivers/net/sungem.c could do

static struct ethtool_ops gem_ethtool_ops = {

+ .get_tx_csum = ethtool_op_get_tx_csum,
+ .set_tx_csum = ethtool_op_set_tx_hw_csum,
};

maintainer
#5 lore raw

From: Stephen Hemminger <[email protected]>
Date: Mon, 23 May 2005 14:53:21 -0700

Quoted 3 lines

This patch makes perfect sense because it allows for common code to be used by device drivers in their ethtool_ops. So this is the logical way to handle this.

You're right, of course. I've applied the patch.

Thanks.