+ if (error) {
+ VLOG_WARN_RL(&rl, "%s: linux-sys get stats failed %d",
+ netdev_get_name(netdev_), error);
+ }
+ return error;
+
+}
+
+/* Retrieves current device stats for 'netdev-linux'. */
+static int
+netdev_linux_get_stats(const struct netdev *netdev_,
+ struct netdev_stats *stats)
+{
+ struct netdev_dev_linux *netdev_dev =
+ netdev_dev_linux_cast(netdev_get_dev(netdev_));
+ struct netdev_stats dev_stats;
+ int error;
+
+ get_stats_via_vport(netdev_, stats);
+
+ error = netdev_linux_sys_get_stats(netdev_, &dev_stats);
+
+ if (error) {
+ if (!netdev_dev->have_vport_stats) {
+ return error;
+ } else {
+ return 0;
+ }
+ }
+
+ if (!netdev_dev->have_vport_stats) {
+ /* stats not available from OVS then use ioctl stats. */
+ *stats = dev_stats;
+ } else {
+ stats->rx_errors += dev_stats.rx_errors;
+ stats->tx_errors += dev_stats.tx_errors;
+ stats->rx_dropped += dev_stats.rx_dropped;
+ stats->tx_dropped += dev_stats.tx_dropped;
+ stats->multicast += dev_stats.multicast;
+ stats->collisions += dev_stats.collisions;
+ stats->rx_length_errors += dev_stats.rx_length_errors;
+ stats->rx_over_errors += dev_stats.rx_over_errors;
+ stats->rx_crc_errors += dev_stats.rx_crc_errors;
+ stats->rx_frame_errors += dev_stats.rx_frame_errors;
+ stats->rx_fifo_errors += dev_stats.rx_fifo_errors;
+ stats->rx_missed_errors += dev_stats.rx_missed_errors;
+ stats->tx_aborted_errors += dev_stats.tx_aborted_errors;
+ stats->tx_carrier_errors += dev_stats.tx_carrier_errors;
+ stats->tx_fifo_errors += dev_stats.tx_fifo_errors;
+ stats->tx_heartbeat_errors += dev_stats.tx_heartbeat_errors;
+ stats->tx_window_errors += dev_stats.tx_window_errors;
+ }
+ return 0;
+}
+
+/* Retrieves current device stats for 'netdev-tap' netdev or
+ * netdev-internal. */
+static int
+netdev_pseudo_get_stats(const struct netdev *netdev_,
+ struct netdev_stats *stats)
+{
+ struct netdev_dev_linux *netdev_dev =
+ netdev_dev_linux_cast(netdev_get_dev(netdev_));
+ struct netdev_stats dev_stats;
+ int error;
+
+ get_stats_via_vport(netdev_, stats);
+
+ error = netdev_linux_sys_get_stats(netdev_, &dev_stats);
+ if (error) {
+ if (!netdev_dev->have_vport_stats) {
+ return error;