Commit 339bf024756690949f536777b921f34186eaa8b4
Committed by
David S. Miller
1 parent
ff03d49f0c
Exists in
master
and in
7 other branches
[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>
Showing 2 changed files with 45 additions and 1 deletions Side-by-side Diff
include/linux/ethtool.h
... | ... | @@ -39,7 +39,8 @@ |
39 | 39 | char bus_info[ETHTOOL_BUSINFO_LEN]; /* Bus info for this IF. */ |
40 | 40 | /* For PCI devices, use pci_name(pci_dev). */ |
41 | 41 | char reserved1[32]; |
42 | - char reserved2[16]; | |
42 | + char reserved2[12]; | |
43 | + __u32 n_priv_flags; /* number of flags valid in ETHTOOL_GPFLAGS */ | |
43 | 44 | __u32 n_stats; /* number of u64's from ETHTOOL_GSTATS */ |
44 | 45 | __u32 testinfo_len; |
45 | 46 | __u32 eedump_len; /* Size of data from ETHTOOL_GEEPROM (bytes) */ |
... | ... | @@ -219,6 +220,7 @@ |
219 | 220 | enum ethtool_stringset { |
220 | 221 | ETH_SS_TEST = 0, |
221 | 222 | ETH_SS_STATS, |
223 | + ETH_SS_PRIV_FLAGS, | |
222 | 224 | }; |
223 | 225 | |
224 | 226 | /* for passing string sets for data tagging */ |
... | ... | @@ -386,6 +388,8 @@ |
386 | 388 | int (*set_ufo)(struct net_device *, u32); |
387 | 389 | u32 (*get_flags)(struct net_device *); |
388 | 390 | int (*set_flags)(struct net_device *, u32); |
391 | + u32 (*get_priv_flags)(struct net_device *); | |
392 | + int (*set_priv_flags)(struct net_device *, u32); | |
389 | 393 | int (*get_sset_count)(struct net_device *, int); |
390 | 394 | |
391 | 395 | /* the following hooks are obsolete */ |
... | ... | @@ -434,6 +438,8 @@ |
434 | 438 | #define ETHTOOL_SGSO 0x00000024 /* Set GSO enable (ethtool_value) */ |
435 | 439 | #define ETHTOOL_GFLAGS 0x00000025 /* Get flags bitmap(ethtool_value) */ |
436 | 440 | #define ETHTOOL_SFLAGS 0x00000026 /* Set flags bitmap(ethtool_value) */ |
441 | +#define ETHTOOL_GPFLAGS 0x00000027 /* Get driver-private flags bitmap */ | |
442 | +#define ETHTOOL_SPFLAGS 0x00000028 /* Set driver-private flags bitmap */ | |
437 | 443 | |
438 | 444 | /* compatibility with older code */ |
439 | 445 | #define SPARC_ETH_GSET ETHTOOL_GSET |
net/core/ethtool.c
... | ... | @@ -188,6 +188,9 @@ |
188 | 188 | rc = ops->get_sset_count(dev, ETH_SS_STATS); |
189 | 189 | if (rc >= 0) |
190 | 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 | 194 | } else { |
192 | 195 | /* code path for obsolete hooks */ |
193 | 196 | |
... | ... | @@ -881,6 +884,33 @@ |
881 | 884 | return dev->ethtool_ops->set_flags(dev, edata.data); |
882 | 885 | } |
883 | 886 | |
887 | +static 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 | + | |
901 | +static 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 | 914 | /* The main entry point in this file. Called from net/core/dev.c */ |
885 | 915 | |
886 | 916 | int dev_ethtool(struct ifreq *ifr) |
... | ... | @@ -915,6 +945,8 @@ |
915 | 945 | case ETHTOOL_GPERMADDR: |
916 | 946 | case ETHTOOL_GUFO: |
917 | 947 | case ETHTOOL_GGSO: |
948 | + case ETHTOOL_GFLAGS: | |
949 | + case ETHTOOL_GPFLAGS: | |
918 | 950 | break; |
919 | 951 | default: |
920 | 952 | if (!capable(CAP_NET_ADMIN)) |
... | ... | @@ -1038,6 +1070,12 @@ |
1038 | 1070 | break; |
1039 | 1071 | case ETHTOOL_SFLAGS: |
1040 | 1072 | rc = ethtool_set_flags(dev, useraddr); |
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); | |
1041 | 1079 | break; |
1042 | 1080 | default: |
1043 | 1081 | rc = -EOPNOTSUPP; |