lib/dpif-linux.c \
lib/dpif-linux.h \
lib/netdev-linux.c \
+ lib/netdev-linux.h \
lib/netdev-vport.c \
lib/netdev-vport.h \
lib/netlink-protocol.h \
*/
#include <config.h>
+
+#include "netdev-linux.h"
+
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
unsigned int min_burst = tc_buffer_per_jiffy(Bps) + mtu;
return tc_bytes_to_ticks(Bps, MAX(burst_bytes, min_burst));
}
-
+\f
+/* Public utility functions. */
+
+#define COPY_NETDEV_STATS \
+ dst->rx_packets = src->rx_packets; \
+ dst->tx_packets = src->tx_packets; \
+ dst->rx_bytes = src->rx_bytes; \
+ dst->tx_bytes = src->tx_bytes; \
+ dst->rx_errors = src->rx_errors; \
+ dst->tx_errors = src->tx_errors; \
+ dst->rx_dropped = src->rx_dropped; \
+ dst->tx_dropped = src->tx_dropped; \
+ dst->multicast = src->multicast; \
+ dst->collisions = src->collisions; \
+ dst->rx_length_errors = src->rx_length_errors; \
+ dst->rx_over_errors = src->rx_over_errors; \
+ dst->rx_crc_errors = src->rx_crc_errors; \
+ dst->rx_frame_errors = src->rx_frame_errors; \
+ dst->rx_fifo_errors = src->rx_fifo_errors; \
+ dst->rx_missed_errors = src->rx_missed_errors; \
+ dst->tx_aborted_errors = src->tx_aborted_errors; \
+ dst->tx_carrier_errors = src->tx_carrier_errors; \
+ dst->tx_fifo_errors = src->tx_fifo_errors; \
+ dst->tx_heartbeat_errors = src->tx_heartbeat_errors; \
+ dst->tx_window_errors = src->tx_window_errors
+
+/* Copies 'src' into 'dst', performing format conversion in the process. */
+void
+netdev_stats_from_rtnl_link_stats(struct netdev_stats *dst,
+ const struct rtnl_link_stats *src)
+{
+ COPY_NETDEV_STATS;
+}
+
+/* Copies 'src' into 'dst', performing format conversion in the process. */
+void
+netdev_stats_from_rtnl_link_stats64(struct netdev_stats *dst,
+ const struct rtnl_link_stats64 *src)
+{
+ COPY_NETDEV_STATS;
+}
+
+/* Copies 'src' into 'dst', performing format conversion in the process. */
+void
+netdev_stats_to_rtnl_link_stats64(struct rtnl_link_stats64 *dst,
+ const struct netdev_stats *src)
+{
+ COPY_NETDEV_STATS;
+}
\f
/* Utility functions. */
struct ofpbuf request;
struct ofpbuf *reply;
struct ifinfomsg *ifi;
- const struct rtnl_link_stats *rtnl_stats;
struct nlattr *attrs[ARRAY_SIZE(rtnlgrp_link_policy)];
int error;
return EPROTO;
}
- rtnl_stats = nl_attr_get(attrs[IFLA_STATS]);
- stats->rx_packets = rtnl_stats->rx_packets;
- stats->tx_packets = rtnl_stats->tx_packets;
- stats->rx_bytes = rtnl_stats->rx_bytes;
- stats->tx_bytes = rtnl_stats->tx_bytes;
- stats->rx_errors = rtnl_stats->rx_errors;
- stats->tx_errors = rtnl_stats->tx_errors;
- stats->rx_dropped = rtnl_stats->rx_dropped;
- stats->tx_dropped = rtnl_stats->tx_dropped;
- stats->multicast = rtnl_stats->multicast;
- stats->collisions = rtnl_stats->collisions;
- stats->rx_length_errors = rtnl_stats->rx_length_errors;
- stats->rx_over_errors = rtnl_stats->rx_over_errors;
- stats->rx_crc_errors = rtnl_stats->rx_crc_errors;
- stats->rx_frame_errors = rtnl_stats->rx_frame_errors;
- stats->rx_fifo_errors = rtnl_stats->rx_fifo_errors;
- stats->rx_missed_errors = rtnl_stats->rx_missed_errors;
- stats->tx_aborted_errors = rtnl_stats->tx_aborted_errors;
- stats->tx_carrier_errors = rtnl_stats->tx_carrier_errors;
- stats->tx_fifo_errors = rtnl_stats->tx_fifo_errors;
- stats->tx_heartbeat_errors = rtnl_stats->tx_heartbeat_errors;
- stats->tx_window_errors = rtnl_stats->tx_window_errors;
+ netdev_stats_from_rtnl_link_stats(stats, nl_attr_get(attrs[IFLA_STATS]));
ofpbuf_delete(reply);
--- /dev/null
+/*
+ * Copyright (c) 2011 Nicira Networks.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NETDEV_LINUX_H
+#define NETDEV_LINUX_H 1
+
+/* These functions are Linux specific, so they should be used directly only by
+ * Linux-specific code. */
+
+struct netdev_stats;
+struct rtnl_link_stats;
+struct rtnl_link_stats64;
+
+void netdev_stats_from_rtnl_link_stats(struct netdev_stats *dst,
+ const struct rtnl_link_stats *src);
+void netdev_stats_from_rtnl_link_stats64(struct netdev_stats *dst,
+ const struct rtnl_link_stats64 *src);
+void netdev_stats_to_rtnl_link_stats64(struct rtnl_link_stats64 *dst,
+ const struct netdev_stats *src);
+
+#endif /* netdev-linux.h */
#include "hash.h"
#include "hmap.h"
#include "list.h"
+#include "netdev-linux.h"
#include "netdev-provider.h"
#include "netlink.h"
#include "netlink-socket.h"
return EOPNOTSUPP;
}
- stats->rx_packets = reply.stats->rx_packets;
- stats->tx_packets = reply.stats->tx_packets;
- stats->rx_bytes = reply.stats->rx_bytes;
- stats->tx_bytes = reply.stats->tx_bytes;
- stats->rx_errors = reply.stats->rx_errors;
- stats->tx_errors = reply.stats->tx_errors;
- stats->rx_dropped = reply.stats->rx_dropped;
- stats->tx_dropped = reply.stats->tx_dropped;
- stats->multicast = reply.stats->multicast;
- stats->collisions = reply.stats->collisions;
- stats->rx_length_errors = reply.stats->rx_length_errors;
- stats->rx_over_errors = reply.stats->rx_over_errors;
- stats->rx_crc_errors = reply.stats->rx_crc_errors;
- stats->rx_frame_errors = reply.stats->rx_frame_errors;
- stats->rx_fifo_errors = reply.stats->rx_fifo_errors;
- stats->rx_missed_errors = reply.stats->rx_missed_errors;
- stats->tx_aborted_errors = reply.stats->tx_aborted_errors;
- stats->tx_carrier_errors = reply.stats->tx_carrier_errors;
- stats->tx_fifo_errors = reply.stats->tx_fifo_errors;
- stats->tx_heartbeat_errors = reply.stats->tx_heartbeat_errors;
- stats->tx_window_errors = reply.stats->tx_window_errors;
+ netdev_stats_from_rtnl_link_stats64(stats, reply.stats);
ofpbuf_delete(buf);
struct dpif_linux_vport vport;
int err;
- rtnl_stats.rx_packets = stats->rx_packets;
- rtnl_stats.tx_packets = stats->tx_packets;
- rtnl_stats.rx_bytes = stats->rx_bytes;
- rtnl_stats.tx_bytes = stats->tx_bytes;
- rtnl_stats.rx_errors = stats->rx_errors;
- rtnl_stats.tx_errors = stats->tx_errors;
- rtnl_stats.rx_dropped = stats->rx_dropped;
- rtnl_stats.tx_dropped = stats->tx_dropped;
- rtnl_stats.multicast = stats->multicast;
- rtnl_stats.collisions = stats->collisions;
- rtnl_stats.rx_length_errors = stats->rx_length_errors;
- rtnl_stats.rx_over_errors = stats->rx_over_errors;
- rtnl_stats.rx_crc_errors = stats->rx_crc_errors;
- rtnl_stats.rx_frame_errors = stats->rx_frame_errors;
- rtnl_stats.rx_fifo_errors = stats->rx_fifo_errors;
- rtnl_stats.rx_missed_errors = stats->rx_missed_errors;
- rtnl_stats.tx_aborted_errors = stats->tx_aborted_errors;
- rtnl_stats.tx_carrier_errors = stats->tx_carrier_errors;
- rtnl_stats.tx_fifo_errors = stats->tx_fifo_errors;
- rtnl_stats.tx_heartbeat_errors = stats->tx_heartbeat_errors;
- rtnl_stats.tx_window_errors = stats->tx_window_errors;
+ netdev_stats_to_rtnl_link_stats64(&rtnl_stats, stats);
dpif_linux_vport_init(&vport);
vport.cmd = ODP_VPORT_CMD_SET;