aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2007-08-15 19:00:51 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:48:07 -0400
commit3ae7c0b2e3747b50c3a6c63ebb67469e0a6b3203 (patch)
tree0f3bacac94b8c189f7dd87f3017babca476d0a69 /net/core
parent0bcc1816188e570bde1d56a208996660f2633ae0 (diff)
[ETHTOOL]: Add ETHTOOL_[GS]FLAGS sub-ioctls
Signed-off-by: Jeff Garzik <jeff@garzik.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/ethtool.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index c5e059352d43..6f8b78bcfd84 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -109,6 +109,32 @@ int ethtool_op_set_ufo(struct net_device *dev, u32 data)
109 return 0; 109 return 0;
110} 110}
111 111
112/* the following list of flags are the same as their associated
113 * NETIF_F_xxx values in include/linux/netdevice.h
114 */
115static const u32 flags_dup_features =
116 ETH_FLAG_LRO;
117
118u32 ethtool_op_get_flags(struct net_device *dev)
119{
120 /* in the future, this function will probably contain additional
121 * handling for flags which are not so easily handled
122 * by a simple masking operation
123 */
124
125 return dev->features & flags_dup_features;
126}
127
128int ethtool_op_set_flags(struct net_device *dev, u32 data)
129{
130 if (data & ETH_FLAG_LRO)
131 dev->features |= NETIF_F_LRO;
132 else
133 dev->features &= ~NETIF_F_LRO;
134
135 return 0;
136}
137
112/* Handlers for each ethtool command */ 138/* Handlers for each ethtool command */
113 139
114static int ethtool_get_settings(struct net_device *dev, void __user *useraddr) 140static int ethtool_get_settings(struct net_device *dev, void __user *useraddr)
@@ -783,6 +809,33 @@ static int ethtool_get_perm_addr(struct net_device *dev, void __user *useraddr)
783 return 0; 809 return 0;
784} 810}
785 811
812static int ethtool_get_flags(struct net_device *dev, char __user *useraddr)
813{
814 struct ethtool_value edata = { ETHTOOL_GFLAGS };
815
816 if (!dev->ethtool_ops->get_flags)
817 return -EOPNOTSUPP;
818
819 edata.data = dev->ethtool_ops->get_flags(dev);
820
821 if (copy_to_user(useraddr, &edata, sizeof(edata)))
822 return -EFAULT;
823 return 0;
824}
825
826static int ethtool_set_flags(struct net_device *dev, char __user *useraddr)
827{
828 struct ethtool_value edata;
829
830 if (!dev->ethtool_ops->set_flags)
831 return -EOPNOTSUPP;
832
833 if (copy_from_user(&edata, useraddr, sizeof(edata)))
834 return -EFAULT;
835
836 return dev->ethtool_ops->set_flags(dev, edata.data);
837}
838
786/* The main entry point in this file. Called from net/core/dev.c */ 839/* The main entry point in this file. Called from net/core/dev.c */
787 840
788int dev_ethtool(struct ifreq *ifr) 841int dev_ethtool(struct ifreq *ifr)
@@ -935,6 +988,12 @@ int dev_ethtool(struct ifreq *ifr)
935 case ETHTOOL_SGSO: 988 case ETHTOOL_SGSO:
936 rc = ethtool_set_gso(dev, useraddr); 989 rc = ethtool_set_gso(dev, useraddr);
937 break; 990 break;
991 case ETHTOOL_GFLAGS:
992 rc = ethtool_get_flags(dev, useraddr);
993 break;
994 case ETHTOOL_SFLAGS:
995 rc = ethtool_set_flags(dev, useraddr);
996 break;
938 default: 997 default:
939 rc = -EOPNOTSUPP; 998 rc = -EOPNOTSUPP;
940 } 999 }
@@ -959,3 +1018,5 @@ EXPORT_SYMBOL(ethtool_op_set_tx_hw_csum);
959EXPORT_SYMBOL(ethtool_op_set_tx_ipv6_csum); 1018EXPORT_SYMBOL(ethtool_op_set_tx_ipv6_csum);
960EXPORT_SYMBOL(ethtool_op_set_ufo); 1019EXPORT_SYMBOL(ethtool_op_set_ufo);
961EXPORT_SYMBOL(ethtool_op_get_ufo); 1020EXPORT_SYMBOL(ethtool_op_get_ufo);
1021EXPORT_SYMBOL(ethtool_op_set_flags);
1022EXPORT_SYMBOL(ethtool_op_get_flags);