diff options
author | Jeff Garzik <jeff@garzik.org> | 2007-08-15 19:00:51 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:48:07 -0400 |
commit | 3ae7c0b2e3747b50c3a6c63ebb67469e0a6b3203 (patch) | |
tree | 0f3bacac94b8c189f7dd87f3017babca476d0a69 /net/core/ethtool.c | |
parent | 0bcc1816188e570bde1d56a208996660f2633ae0 (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/ethtool.c')
-rw-r--r-- | net/core/ethtool.c | 61 |
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 | */ | ||
115 | static const u32 flags_dup_features = | ||
116 | ETH_FLAG_LRO; | ||
117 | |||
118 | u32 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 | |||
128 | int 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 | ||
114 | static int ethtool_get_settings(struct net_device *dev, void __user *useraddr) | 140 | static 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 | ||
812 | static 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 | |||
826 | static 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 | ||
788 | int dev_ethtool(struct ifreq *ifr) | 841 | int 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); | |||
959 | EXPORT_SYMBOL(ethtool_op_set_tx_ipv6_csum); | 1018 | EXPORT_SYMBOL(ethtool_op_set_tx_ipv6_csum); |
960 | EXPORT_SYMBOL(ethtool_op_set_ufo); | 1019 | EXPORT_SYMBOL(ethtool_op_set_ufo); |
961 | EXPORT_SYMBOL(ethtool_op_get_ufo); | 1020 | EXPORT_SYMBOL(ethtool_op_get_ufo); |
1021 | EXPORT_SYMBOL(ethtool_op_set_flags); | ||
1022 | EXPORT_SYMBOL(ethtool_op_get_flags); | ||