aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/ethtool.c
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2007-08-15 19:01:32 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:48:08 -0400
commit339bf024756690949f536777b921f34186eaa8b4 (patch)
treec7b18cb27dd4ce1c66bbd0260bf8dc87f50f0465 /net/core/ethtool.c
parentff03d49f0ca1959246068b315d26e009da692ff2 (diff)
[ETHTOOL]: Introduce ->{get,set}_priv_flags, ETHTOOL_[GS]PFLAGS
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.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 1edae460d616..d255209dc110 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -188,6 +188,9 @@ static int ethtool_get_drvinfo(struct net_device *dev, void __user *useraddr)
188 rc = ops->get_sset_count(dev, ETH_SS_STATS); 188 rc = ops->get_sset_count(dev, ETH_SS_STATS);
189 if (rc >= 0) 189 if (rc >= 0)
190 info.n_stats = rc; 190 info.n_stats = rc;
191 rc = ops->get_sset_count(dev, ETH_SS_PRIV_FLAGS);
192 if (rc >= 0)
193 info.n_priv_flags = rc;
191 } else { 194 } else {
192 /* code path for obsolete hooks */ 195 /* code path for obsolete hooks */
193 196
@@ -881,6 +884,33 @@ static int ethtool_set_flags(struct net_device *dev, char __user *useraddr)
881 return dev->ethtool_ops->set_flags(dev, edata.data); 884 return dev->ethtool_ops->set_flags(dev, edata.data);
882} 885}
883 886
887static int ethtool_get_priv_flags(struct net_device *dev, char __user *useraddr)
888{
889 struct ethtool_value edata = { ETHTOOL_GPFLAGS };
890
891 if (!dev->ethtool_ops->get_priv_flags)
892 return -EOPNOTSUPP;
893
894 edata.data = dev->ethtool_ops->get_priv_flags(dev);
895
896 if (copy_to_user(useraddr, &edata, sizeof(edata)))
897 return -EFAULT;
898 return 0;
899}
900
901static int ethtool_set_priv_flags(struct net_device *dev, char __user *useraddr)
902{
903 struct ethtool_value edata;
904
905 if (!dev->ethtool_ops->set_priv_flags)
906 return -EOPNOTSUPP;
907
908 if (copy_from_user(&edata, useraddr, sizeof(edata)))
909 return -EFAULT;
910
911 return dev->ethtool_ops->set_priv_flags(dev, edata.data);
912}
913
884/* The main entry point in this file. Called from net/core/dev.c */ 914/* The main entry point in this file. Called from net/core/dev.c */
885 915
886int dev_ethtool(struct ifreq *ifr) 916int dev_ethtool(struct ifreq *ifr)
@@ -915,6 +945,8 @@ int dev_ethtool(struct ifreq *ifr)
915 case ETHTOOL_GPERMADDR: 945 case ETHTOOL_GPERMADDR:
916 case ETHTOOL_GUFO: 946 case ETHTOOL_GUFO:
917 case ETHTOOL_GGSO: 947 case ETHTOOL_GGSO:
948 case ETHTOOL_GFLAGS:
949 case ETHTOOL_GPFLAGS:
918 break; 950 break;
919 default: 951 default:
920 if (!capable(CAP_NET_ADMIN)) 952 if (!capable(CAP_NET_ADMIN))
@@ -1039,6 +1071,12 @@ int dev_ethtool(struct ifreq *ifr)
1039 case ETHTOOL_SFLAGS: 1071 case ETHTOOL_SFLAGS:
1040 rc = ethtool_set_flags(dev, useraddr); 1072 rc = ethtool_set_flags(dev, useraddr);
1041 break; 1073 break;
1074 case ETHTOOL_GPFLAGS:
1075 rc = ethtool_get_priv_flags(dev, useraddr);
1076 break;
1077 case ETHTOOL_SPFLAGS:
1078 rc = ethtool_set_priv_flags(dev, useraddr);
1079 break;
1042 default: 1080 default:
1043 rc = -EOPNOTSUPP; 1081 rc = -EOPNOTSUPP;
1044 } 1082 }