diff options
author | Michał Mirosław <mirq-linux@rere.qmqm.pl> | 2011-11-15 10:29:55 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-11-16 17:43:08 -0500 |
commit | 02b3a5524f6253113a46ebc283cc5ec392c34d7a (patch) | |
tree | 22780a851f9a6ee1f389e29e5357f823ad11ab8d | |
parent | bc5787c6125cc2c868eaace46c46ce6e83dcfcb6 (diff) |
net: ethtool: break association of ETH_FLAG_* with NETIF_F_*
This is the only place left where dev->features are directly
exposed to userspace.
I know checkpatch.pl complains about __ethtool_{get,set}_flags(), but
the code is easier to read this way.
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Acked-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/core/ethtool.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/net/core/ethtool.c b/net/core/ethtool.c index db8a77bb557b..a354919a32ac 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c | |||
@@ -240,32 +240,45 @@ static int ethtool_set_one_feature(struct net_device *dev, | |||
240 | return 0; | 240 | return 0; |
241 | } | 241 | } |
242 | 242 | ||
243 | /* the following list of flags are the same as their associated | 243 | #define ETH_ALL_FLAGS (ETH_FLAG_LRO | ETH_FLAG_RXVLAN | ETH_FLAG_TXVLAN | \ |
244 | * NETIF_F_xxx values in include/linux/netdevice.h | 244 | ETH_FLAG_NTUPLE | ETH_FLAG_RXHASH) |
245 | */ | 245 | #define ETH_ALL_FEATURES (NETIF_F_LRO | NETIF_F_HW_VLAN_RX | \ |
246 | static const u32 flags_dup_features = | 246 | NETIF_F_HW_VLAN_TX | NETIF_F_NTUPLE | NETIF_F_RXHASH) |
247 | (ETH_FLAG_LRO | ETH_FLAG_RXVLAN | ETH_FLAG_TXVLAN | ETH_FLAG_NTUPLE | | ||
248 | ETH_FLAG_RXHASH); | ||
249 | 247 | ||
250 | static u32 __ethtool_get_flags(struct net_device *dev) | 248 | static u32 __ethtool_get_flags(struct net_device *dev) |
251 | { | 249 | { |
252 | return dev->features & flags_dup_features; | 250 | u32 flags = 0; |
251 | |||
252 | if (dev->features & NETIF_F_LRO) flags |= ETH_FLAG_LRO; | ||
253 | if (dev->features & NETIF_F_HW_VLAN_RX) flags |= ETH_FLAG_RXVLAN; | ||
254 | if (dev->features & NETIF_F_HW_VLAN_TX) flags |= ETH_FLAG_TXVLAN; | ||
255 | if (dev->features & NETIF_F_NTUPLE) flags |= ETH_FLAG_NTUPLE; | ||
256 | if (dev->features & NETIF_F_RXHASH) flags |= ETH_FLAG_RXHASH; | ||
257 | |||
258 | return flags; | ||
253 | } | 259 | } |
254 | 260 | ||
255 | static int __ethtool_set_flags(struct net_device *dev, u32 data) | 261 | static int __ethtool_set_flags(struct net_device *dev, u32 data) |
256 | { | 262 | { |
263 | u32 features = 0; | ||
257 | u32 changed; | 264 | u32 changed; |
258 | 265 | ||
259 | if (data & ~flags_dup_features) | 266 | if (data & ~ETH_ALL_FLAGS) |
260 | return -EINVAL; | 267 | return -EINVAL; |
261 | 268 | ||
269 | if (data & ETH_FLAG_LRO) features |= NETIF_F_LRO; | ||
270 | if (data & ETH_FLAG_RXVLAN) features |= NETIF_F_HW_VLAN_RX; | ||
271 | if (data & ETH_FLAG_TXVLAN) features |= NETIF_F_HW_VLAN_TX; | ||
272 | if (data & ETH_FLAG_NTUPLE) features |= NETIF_F_NTUPLE; | ||
273 | if (data & ETH_FLAG_RXHASH) features |= NETIF_F_RXHASH; | ||
274 | |||
262 | /* allow changing only bits set in hw_features */ | 275 | /* allow changing only bits set in hw_features */ |
263 | changed = (data ^ dev->features) & flags_dup_features; | 276 | changed = (features ^ dev->features) & ETH_ALL_FEATURES; |
264 | if (changed & ~dev->hw_features) | 277 | if (changed & ~dev->hw_features) |
265 | return (changed & dev->hw_features) ? -EINVAL : -EOPNOTSUPP; | 278 | return (changed & dev->hw_features) ? -EINVAL : -EOPNOTSUPP; |
266 | 279 | ||
267 | dev->wanted_features = | 280 | dev->wanted_features = |
268 | (dev->wanted_features & ~changed) | (data & dev->hw_features); | 281 | (dev->wanted_features & ~changed) | (features & changed); |
269 | 282 | ||
270 | __netdev_update_features(dev); | 283 | __netdev_update_features(dev); |
271 | 284 | ||