ovsdb: Synchronize comments and code in ovsdb_file_commit().
[sliver-openvswitch.git] / datapath / linux-2.6 / compat-2.6 / netdevice.c
1 #include <linux/if_link.h>
2 #include <linux/netdevice.h>
3
4 /* Linux 2.6.28 introduced dev_get_stats():
5  * const struct net_device_stats *dev_get_stats(struct net_device *dev);
6  *
7  * Linux 2.6.36 changed dev_get_stats() to:
8  * struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
9  *                                         struct rtnl_link_stats64 *storage);
10  */
11 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
12 struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
13                                         struct rtnl_link_stats64 *storage)
14 {
15         const struct net_device_stats *stats;
16
17 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
18         stats = dev->get_stats(dev);
19 #else  /* 2.6.28 < kernel version < 2.6.36 */
20         stats = (dev_get_stats)(dev);
21 #endif /* 2.6.28 < kernel version < 2.6.36 */
22
23         storage->rx_packets = stats->rx_packets;
24         storage->tx_packets = stats->tx_packets;
25         storage->rx_bytes = stats->rx_bytes;
26         storage->tx_bytes = stats->tx_bytes;
27         storage->rx_errors = stats->rx_errors;
28         storage->tx_errors = stats->tx_errors;
29         storage->rx_dropped = stats->rx_dropped;
30         storage->tx_dropped = stats->tx_dropped;
31         storage->multicast = stats->multicast;
32         storage->collisions = stats->collisions;
33         storage->rx_length_errors = stats->rx_length_errors;
34         storage->rx_over_errors = stats->rx_over_errors;
35         storage->rx_crc_errors = stats->rx_crc_errors;
36         storage->rx_frame_errors = stats->rx_frame_errors;
37         storage->rx_fifo_errors = stats->rx_fifo_errors;
38         storage->rx_missed_errors = stats->rx_missed_errors;
39         storage->tx_aborted_errors = stats->tx_aborted_errors;
40         storage->tx_carrier_errors = stats->tx_carrier_errors;
41         storage->tx_fifo_errors = stats->tx_fifo_errors;
42         storage->tx_heartbeat_errors = stats->tx_heartbeat_errors;
43         storage->tx_window_errors = stats->tx_window_errors;
44         storage->rx_compressed = stats->rx_compressed;
45         storage->tx_compressed = stats->tx_compressed;
46
47         return storage;
48 }
49 #endif  /* kernel version < 2.6.36 */