Skip to contentSkip to conversation

ethtool: device independent rx_csum and get_flags routines

PATCH Applied Sridhar Samudrala 3 participants 4 messages Jul 22, 2009 – Jul 27, 2009

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

PATCH 1/1 ethtool: device independent rx_csum and get_flags routines

[PATCH net-next-2.6] ethtool: add device independent rx_csum and get_flags routines

This helps avoid error messages with ethtool -k on devices that don't provide device specific routines.

------------------------------------------------------------------

net/core/ethtool.c +11 -2
index d9d5160..cf36ff4 100644
@@ -30,6 +30,11 @@ u32 ethtool_op_get_link(struct net_device *dev)
 	return netif_carrier_ok(dev) ? 1 : 0;
 }
 
+u32 ethtool_op_get_rx_csum(struct net_device *dev)
+{
+	return (dev->features & NETIF_F_ALL_CSUM) != 0;
+}
+
 u32 ethtool_op_get_tx_csum(struct net_device *dev)
 {
 	return (dev->features & NETIF_F_ALL_CSUM) != 0;
@@ -1004,7 +1009,9 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
 		break;
 	case ETHTOOL_GRXCSUM:
 		rc = ethtool_get_value(dev, useraddr, ethcmd,
-				       dev->ethtool_ops->get_rx_csum);
+				       (dev->ethtool_ops->get_rx_csum ?
+					dev->ethtool_ops->get_rx_csum :
+					ethtool_op_get_rx_csum));
 		break;
 	case ETHTOOL_SRXCSUM:
 		rc = ethtool_set_rx_csum(dev, useraddr);
@@ -1068,7 +1075,9 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
 		break;
 	case ETHTOOL_GFLAGS:
 		rc = ethtool_get_value(dev, useraddr, ethcmd,
-				       dev->ethtool_ops->get_flags);
+				       (dev->ethtool_ops->get_flags ?
+					dev->ethtool_ops->get_flags :
+					ethtool_op_get_flags));
 		break;
 	case ETHTOOL_SFLAGS:
 		rc = ethtool_set_value(dev, useraddr,
maintainer Applied
#1 lore raw

From: Sridhar Samudrala <[email protected]>
Date: Wed, 22 Jul 2009 16:38:22 -0700

Quoted 6 lines

[PATCH net-next-2.6] ethtool: add device independent rx_csum and get_flags routines

This helps avoid error messages with ethtool -k on devices that don't provide device specific routines.

Applied.

#2 lore raw

PATCH 1/1 net: ethtool_op_get_rx_csum() should be public and exported

Quoted 11 lines · David Miller

From: Sridhar Samudrala <[email protected]>
Date: Wed, 22 Jul 2009 16:38:22 -0700

Quoted 6 lines

[PATCH net-next-2.6] ethtool: add device independent rx_csum and get_flags routines

This helps avoid error messages with ethtool -k on devices that don't provide device specific routines.

Applied.

I wonder if ethtool_op_get_rx_csum() should be static or is meant to be used by drivers ?

I guess it should be public and exported like ethtool_op_get_tx_csum()

[PATCH] net: ethtool_op_get_rx_csum() should be public and exported

---
 include/linux/ethtool.h |    1 +
 net/core/ethtool.c      |    3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
include/linux/ethtool.h +1 -0
index 9b660bd..90c4a36 100644
@@ -368,6 +368,7 @@ struct net_device;
 
 /* Some generic methods drivers may use in their ethtool_ops */
 u32 ethtool_op_get_link(struct net_device *dev);
+u32 ethtool_op_get_rx_csum(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);
net/core/ethtool.c +2 -1
index cf36ff4..44e5711 100644
@@ -34,11 +34,13 @@ u32 ethtool_op_get_rx_csum(struct net_device *dev)
 {
 	return (dev->features & NETIF_F_ALL_CSUM) != 0;
 }
+EXPORT_SYMBOL(ethtool_op_get_rx_csum);
 
 u32 ethtool_op_get_tx_csum(struct net_device *dev)
 {
 	return (dev->features & NETIF_F_ALL_CSUM) != 0;
 }
+EXPORT_SYMBOL(ethtool_op_get_tx_csum);
 
 int ethtool_op_set_tx_csum(struct net_device *dev, u32 data)
 {
@@ -1125,7 +1127,6 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
 EXPORT_SYMBOL(ethtool_op_get_link);
 EXPORT_SYMBOL(ethtool_op_get_sg);
 EXPORT_SYMBOL(ethtool_op_get_tso);
-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);
maintainer
#3 lore raw

Re: [PATCH net-next-2.6] net: ethtool_op_get_rx_csum() should be public and exported

From: Eric Dumazet <[email protected]>
Date: Mon, 27 Jul 2009 11:18:11 +0200

Quoted 3 lines

[PATCH] net: ethtool_op_get_rx_csum() should be public and exported

Fair enough, applied, but now you are on the hook to add at least one user of this :-)