diff options
author | Michał Mirosław <mirq-linux@rere.qmqm.pl> | 2011-02-15 11:59:18 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-02-17 17:16:35 -0500 |
commit | e83d360d9a7e5d71d55c13e96b19109a2ea23bf0 (patch) | |
tree | 04e4971ad73ade44eb86671851d568e494abe6e4 /net/core | |
parent | da8ac86c4a56a14bf8deea7d2f92d0a453c67f91 (diff) |
net: introduce NETIF_F_RXCSUM
Introduce NETIF_F_RXCSUM to replace device-private flags for RX checksum
offload. Integrate it with ndo_fix_features.
ethtool_op_get_rx_csum() is removed altogether as nothing in-tree uses it.
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/ethtool.c | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/net/core/ethtool.c b/net/core/ethtool.c index 65b3d50a6df2..66cdc76770ce 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c | |||
@@ -34,12 +34,6 @@ u32 ethtool_op_get_link(struct net_device *dev) | |||
34 | } | 34 | } |
35 | EXPORT_SYMBOL(ethtool_op_get_link); | 35 | EXPORT_SYMBOL(ethtool_op_get_link); |
36 | 36 | ||
37 | u32 ethtool_op_get_rx_csum(struct net_device *dev) | ||
38 | { | ||
39 | return (dev->features & NETIF_F_ALL_CSUM) != 0; | ||
40 | } | ||
41 | EXPORT_SYMBOL(ethtool_op_get_rx_csum); | ||
42 | |||
43 | u32 ethtool_op_get_tx_csum(struct net_device *dev) | 37 | u32 ethtool_op_get_tx_csum(struct net_device *dev) |
44 | { | 38 | { |
45 | return (dev->features & NETIF_F_ALL_CSUM) != 0; | 39 | return (dev->features & NETIF_F_ALL_CSUM) != 0; |
@@ -274,7 +268,7 @@ static const char netdev_features_strings[ETHTOOL_DEV_FEATURE_WORDS * 32][ETH_GS | |||
274 | /* NETIF_F_FCOE_MTU */ "fcoe-mtu", | 268 | /* NETIF_F_FCOE_MTU */ "fcoe-mtu", |
275 | /* NETIF_F_NTUPLE */ "rx-ntuple-filter", | 269 | /* NETIF_F_NTUPLE */ "rx-ntuple-filter", |
276 | /* NETIF_F_RXHASH */ "rx-hashing", | 270 | /* NETIF_F_RXHASH */ "rx-hashing", |
277 | "", | 271 | /* NETIF_F_RXCSUM */ "rx-checksum", |
278 | "", | 272 | "", |
279 | "", | 273 | "", |
280 | }; | 274 | }; |
@@ -313,6 +307,9 @@ static u32 ethtool_get_feature_mask(u32 eth_cmd) | |||
313 | case ETHTOOL_GTXCSUM: | 307 | case ETHTOOL_GTXCSUM: |
314 | case ETHTOOL_STXCSUM: | 308 | case ETHTOOL_STXCSUM: |
315 | return NETIF_F_ALL_CSUM | NETIF_F_SCTP_CSUM; | 309 | return NETIF_F_ALL_CSUM | NETIF_F_SCTP_CSUM; |
310 | case ETHTOOL_GRXCSUM: | ||
311 | case ETHTOOL_SRXCSUM: | ||
312 | return NETIF_F_RXCSUM; | ||
316 | case ETHTOOL_GSG: | 313 | case ETHTOOL_GSG: |
317 | case ETHTOOL_SSG: | 314 | case ETHTOOL_SSG: |
318 | return NETIF_F_SG; | 315 | return NETIF_F_SG; |
@@ -343,6 +340,8 @@ static void *__ethtool_get_one_feature_actor(struct net_device *dev, u32 ethcmd) | |||
343 | switch (ethcmd) { | 340 | switch (ethcmd) { |
344 | case ETHTOOL_GTXCSUM: | 341 | case ETHTOOL_GTXCSUM: |
345 | return ops->get_tx_csum; | 342 | return ops->get_tx_csum; |
343 | case ETHTOOL_GRXCSUM: | ||
344 | return ops->get_rx_csum; | ||
346 | case ETHTOOL_SSG: | 345 | case ETHTOOL_SSG: |
347 | return ops->get_sg; | 346 | return ops->get_sg; |
348 | case ETHTOOL_STSO: | 347 | case ETHTOOL_STSO: |
@@ -354,6 +353,11 @@ static void *__ethtool_get_one_feature_actor(struct net_device *dev, u32 ethcmd) | |||
354 | } | 353 | } |
355 | } | 354 | } |
356 | 355 | ||
356 | static u32 __ethtool_get_rx_csum_oldbug(struct net_device *dev) | ||
357 | { | ||
358 | return !!(dev->features & NETIF_F_ALL_CSUM); | ||
359 | } | ||
360 | |||
357 | static int ethtool_get_one_feature(struct net_device *dev, | 361 | static int ethtool_get_one_feature(struct net_device *dev, |
358 | char __user *useraddr, u32 ethcmd) | 362 | char __user *useraddr, u32 ethcmd) |
359 | { | 363 | { |
@@ -369,6 +373,10 @@ static int ethtool_get_one_feature(struct net_device *dev, | |||
369 | 373 | ||
370 | actor = __ethtool_get_one_feature_actor(dev, ethcmd); | 374 | actor = __ethtool_get_one_feature_actor(dev, ethcmd); |
371 | 375 | ||
376 | /* bug compatibility with old get_rx_csum */ | ||
377 | if (ethcmd == ETHTOOL_GRXCSUM && !actor) | ||
378 | actor = __ethtool_get_rx_csum_oldbug; | ||
379 | |||
372 | if (actor) | 380 | if (actor) |
373 | edata.data = actor(dev); | 381 | edata.data = actor(dev); |
374 | } | 382 | } |
@@ -379,6 +387,7 @@ static int ethtool_get_one_feature(struct net_device *dev, | |||
379 | } | 387 | } |
380 | 388 | ||
381 | static int __ethtool_set_tx_csum(struct net_device *dev, u32 data); | 389 | static int __ethtool_set_tx_csum(struct net_device *dev, u32 data); |
390 | static int __ethtool_set_rx_csum(struct net_device *dev, u32 data); | ||
382 | static int __ethtool_set_sg(struct net_device *dev, u32 data); | 391 | static int __ethtool_set_sg(struct net_device *dev, u32 data); |
383 | static int __ethtool_set_tso(struct net_device *dev, u32 data); | 392 | static int __ethtool_set_tso(struct net_device *dev, u32 data); |
384 | static int __ethtool_set_ufo(struct net_device *dev, u32 data); | 393 | static int __ethtool_set_ufo(struct net_device *dev, u32 data); |
@@ -416,6 +425,8 @@ static int ethtool_set_one_feature(struct net_device *dev, | |||
416 | switch (ethcmd) { | 425 | switch (ethcmd) { |
417 | case ETHTOOL_STXCSUM: | 426 | case ETHTOOL_STXCSUM: |
418 | return __ethtool_set_tx_csum(dev, edata.data); | 427 | return __ethtool_set_tx_csum(dev, edata.data); |
428 | case ETHTOOL_SRXCSUM: | ||
429 | return __ethtool_set_rx_csum(dev, edata.data); | ||
419 | case ETHTOOL_SSG: | 430 | case ETHTOOL_SSG: |
420 | return __ethtool_set_sg(dev, edata.data); | 431 | return __ethtool_set_sg(dev, edata.data); |
421 | case ETHTOOL_STSO: | 432 | case ETHTOOL_STSO: |
@@ -1404,20 +1415,15 @@ static int __ethtool_set_tx_csum(struct net_device *dev, u32 data) | |||
1404 | return dev->ethtool_ops->set_tx_csum(dev, data); | 1415 | return dev->ethtool_ops->set_tx_csum(dev, data); |
1405 | } | 1416 | } |
1406 | 1417 | ||
1407 | static int ethtool_set_rx_csum(struct net_device *dev, char __user *useraddr) | 1418 | static int __ethtool_set_rx_csum(struct net_device *dev, u32 data) |
1408 | { | 1419 | { |
1409 | struct ethtool_value edata; | ||
1410 | |||
1411 | if (!dev->ethtool_ops->set_rx_csum) | 1420 | if (!dev->ethtool_ops->set_rx_csum) |
1412 | return -EOPNOTSUPP; | 1421 | return -EOPNOTSUPP; |
1413 | 1422 | ||
1414 | if (copy_from_user(&edata, useraddr, sizeof(edata))) | 1423 | if (!data) |
1415 | return -EFAULT; | ||
1416 | |||
1417 | if (!edata.data && dev->ethtool_ops->set_sg) | ||
1418 | dev->features &= ~NETIF_F_GRO; | 1424 | dev->features &= ~NETIF_F_GRO; |
1419 | 1425 | ||
1420 | return dev->ethtool_ops->set_rx_csum(dev, edata.data); | 1426 | return dev->ethtool_ops->set_rx_csum(dev, data); |
1421 | } | 1427 | } |
1422 | 1428 | ||
1423 | static int __ethtool_set_tso(struct net_device *dev, u32 data) | 1429 | static int __ethtool_set_tso(struct net_device *dev, u32 data) |
@@ -1765,15 +1771,6 @@ int dev_ethtool(struct net *net, struct ifreq *ifr) | |||
1765 | case ETHTOOL_SPAUSEPARAM: | 1771 | case ETHTOOL_SPAUSEPARAM: |
1766 | rc = ethtool_set_pauseparam(dev, useraddr); | 1772 | rc = ethtool_set_pauseparam(dev, useraddr); |
1767 | break; | 1773 | break; |
1768 | case ETHTOOL_GRXCSUM: | ||
1769 | rc = ethtool_get_value(dev, useraddr, ethcmd, | ||
1770 | (dev->ethtool_ops->get_rx_csum ? | ||
1771 | dev->ethtool_ops->get_rx_csum : | ||
1772 | ethtool_op_get_rx_csum)); | ||
1773 | break; | ||
1774 | case ETHTOOL_SRXCSUM: | ||
1775 | rc = ethtool_set_rx_csum(dev, useraddr); | ||
1776 | break; | ||
1777 | case ETHTOOL_TEST: | 1774 | case ETHTOOL_TEST: |
1778 | rc = ethtool_self_test(dev, useraddr); | 1775 | rc = ethtool_self_test(dev, useraddr); |
1779 | break; | 1776 | break; |
@@ -1846,6 +1843,7 @@ int dev_ethtool(struct net *net, struct ifreq *ifr) | |||
1846 | rc = ethtool_set_features(dev, useraddr); | 1843 | rc = ethtool_set_features(dev, useraddr); |
1847 | break; | 1844 | break; |
1848 | case ETHTOOL_GTXCSUM: | 1845 | case ETHTOOL_GTXCSUM: |
1846 | case ETHTOOL_GRXCSUM: | ||
1849 | case ETHTOOL_GSG: | 1847 | case ETHTOOL_GSG: |
1850 | case ETHTOOL_GTSO: | 1848 | case ETHTOOL_GTSO: |
1851 | case ETHTOOL_GUFO: | 1849 | case ETHTOOL_GUFO: |
@@ -1854,6 +1852,7 @@ int dev_ethtool(struct net *net, struct ifreq *ifr) | |||
1854 | rc = ethtool_get_one_feature(dev, useraddr, ethcmd); | 1852 | rc = ethtool_get_one_feature(dev, useraddr, ethcmd); |
1855 | break; | 1853 | break; |
1856 | case ETHTOOL_STXCSUM: | 1854 | case ETHTOOL_STXCSUM: |
1855 | case ETHTOOL_SRXCSUM: | ||
1857 | case ETHTOOL_SSG: | 1856 | case ETHTOOL_SSG: |
1858 | case ETHTOOL_STSO: | 1857 | case ETHTOOL_STSO: |
1859 | case ETHTOOL_SUFO: | 1858 | case ETHTOOL_SUFO: |