This is incremental to previous patch. It is fixed according to comments from Jesse. It removes dipf_port->stat as aggregate stats are only available at netdev layer.
Signed-off-by: Pravin B Shelar <[email protected]> --- include/openvswitch/datapath-protocol.h | 16 +++--- lib/dpif-linux.c | 11 ---- lib/dpif.c | 1 - lib/dpif.h | 1 - lib/netdev-linux.c | 96 ++++++++---------------------- lib/netdev-linux.h | 7 -- lib/netdev-vport.c | 39 +++++++++++++ utilities/ovs-dpctl.c | 47 ++++++++++------ 8 files changed, 103 insertions(+), 115 deletions(-) diff --git a/include/openvswitch/datapath-protocol.h b/include/openvswitch/datapath-protocol.h index 5d765b1..3c79c0f 100644 --- a/include/openvswitch/datapath-protocol.h +++ b/include/openvswitch/datapath-protocol.h @@ -136,14 +136,14 @@ struct ovs_dp_stats { }; struct ovs_vport_stats { - uint64_t rx_packets; /* total packets received */ - uint64_t tx_packets; /* total packets transmitted */ - uint64_t rx_bytes; /* total bytes received */ - uint64_t tx_bytes; /* total bytes transmitted */ - uint64_t rx_errors; /* bad packets received */ - uint64_t tx_errors; /* packet transmit problems */ - uint64_t rx_dropped; /* no space in linux buffers */ - uint64_t tx_dropped; /* no space available in linux */ + uint64_t rx_packets; /* total packets received */ + uint64_t tx_packets; /* total packets transmitted */ + uint64_t rx_bytes; /* total bytes received */ + uint64_t tx_bytes; /* total bytes transmitted */ + uint64_t rx_errors; /* bad packets received */ + uint64_t tx_errors; /* packet transmit problems */ + uint64_t rx_dropped; /* no space in linux buffers */ + uint64_t tx_dropped; /* no space available in linux */ }; /* Logical ports. */ diff --git a/lib/dpif-linux.c b/lib/dpif-linux.c index 3493f5a..3d081aa 100644 --- a/lib/dpif-linux.c +++ b/lib/dpif-linux.c @@ -463,12 +463,6 @@ dpif_linux_port_query__(const struct dpif *dpif, uint32_t port_no, dpif_port->name = xstrdup(reply.name); dpif_port->type = xstrdup(netdev_vport_get_netdev_type(&reply)); dpif_port->port_no = reply.port_no; - if (reply.stats) { - netdev_stats_from_ovs_vport_stats(&dpif_port->stats, - reply.stats); - } else { - memset(&dpif_port->stats, 0xff, sizeof dpif_port->stats); - } ofpbuf_delete(buf); } return error; @@ -564,11 +558,6 @@ dpif_linux_port_dump_next(const struct dpif *dpif OVS_UNUSED, void *state_, dpif_port->name = (char *) vport.name; dpif_port->type = (char *) netdev_vport_get_netdev_type(&vport); dpif_port->port_no = vport.port_no; - if (vport.stats) { - netdev_stats_from_ovs_vport_stats(&dpif_port->stats, vport.stats); - } else { - memset(&dpif_port->stats, 0xff, sizeof dpif_port->stats); - } return 0; } diff --git a/lib/dpif.c b/lib/dpif.c index 8cf7cfe..ad143c8 100644 --- a/lib/dpif.c +++ b/lib/dpif.c @@ -469,7 +469,6 @@ dpif_port_clone(struct dpif_port *dst, const struct dpif_port *src) dst->name = xstrdup(src->name); dst->type = xstrdup(src->type); dst->port_no = src->port_no; - dst->stats = src->stats; } /* Frees memory allocated to members of 'dpif_port'. diff --git a/lib/dpif.h b/lib/dpif.h index 1f35206..c01010d 100644 --- a/lib/dpif.h +++ b/lib/dpif.h @@ -72,7 +72,6 @@ struct dpif_port { char *name; /* Network device name, e.g. "eth0". */ char *type; /* Network device type, e.g. "system". */ uint32_t port_no; /* Port number within datapath. */ - struct netdev_stats stats; /* Port statistics. */ }; void dpif_port_clone(struct dpif_port *, const struct dpif_port *); void dpif_port_destroy(struct dpif_port *); diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 70f6829..ee3c5f5 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -1252,7 +1252,7 @@ swap_uint64(uint64_t *a, uint64_t *b) } static void -netdev_vport_stats(const struct netdev *netdev_, +get_stats_via_vport(const struct netdev *netdev_, struct netdev_stats *stats) { struct netdev_dev_linux *netdev_dev = @@ -1264,7 +1264,7 @@ netdev_vport_stats(const struct netdev *netdev_, error = netdev_vport_get_stats(netdev_, stats); if (error) { - VLOG_WARN_RL(&rl, "%s: ovs get stats failed %d", + VLOG_WARN_RL(&rl, "%s: obtaining netdev stats via vport failed %d", netdev_get_name(netdev_), error); } netdev_dev->have_vport_stats = !error; @@ -1312,7 +1312,7 @@ netdev_linux_get_stats(const struct netdev *netdev_, struct netdev_stats dev_stats; int error; - netdev_vport_stats(netdev_, stats); + get_stats_via_vport(netdev_, stats); error = netdev_linux_sys_get_stats(netdev_, &dev_stats); @@ -1360,7 +1360,7 @@ netdev_pseudo_get_stats(const struct netdev *netdev_, struct netdev_stats dev_stats; int error; - netdev_vport_stats(netdev_, stats); + get_stats_via_vport(netdev_, stats); error = netdev_linux_sys_get_stats(netdev_, &dev_stats); if (error) { @@ -4034,76 +4034,32 @@ tc_calc_buffer(unsigned int Bps, int mtu, uint64_t burst_bytes) return tc_bytes_to_ticks(Bps, MAX(burst_bytes, min_burst)); } -/* 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 - -#define COPY_OVS_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; - /* Copies 'src' into 'dst', performing format conversion in the process. */ -void +static 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_ovs_vport_stats(struct netdev_stats *dst, - const struct ovs_vport_stats *src) -{ - COPY_OVS_STATS - dst->multicast = 0; - dst->collisions = 0; - dst->rx_length_errors = 0; - dst->rx_over_errors = 0; - dst->rx_crc_errors = 0; - dst->rx_frame_errors = 0; - dst->rx_fifo_errors = 0; - dst->rx_missed_errors = 0; - dst->tx_aborted_errors = 0; - dst->tx_carrier_errors = 0; - dst->tx_fifo_errors = 0; - dst->tx_heartbeat_errors = 0; - dst->tx_window_errors = 0; -} - -/* Copies 'src' into 'dst', performing format conversion in the process. */ -void -netdev_stats_to_ovs_vport_stats(struct ovs_vport_stats *dst, - const struct netdev_stats *src) -{ - COPY_OVS_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; } diff --git a/lib/netdev-linux.h b/lib/netdev-linux.h index 961f5ef..c00a846 100644 --- a/lib/netdev-linux.h +++ b/lib/netdev-linux.h @@ -28,13 +28,6 @@ struct netdev; struct netdev_stats; struct rtnl_link_stats; -void netdev_stats_from_rtnl_link_stats(struct netdev_stats *dst, - const struct rtnl_link_stats *src); -void netdev_stats_from_ovs_vport_stats(struct netdev_stats *dst, - const struct ovs_vport_stats *src); -void netdev_stats_to_ovs_vport_stats(struct ovs_vport_stats *dst, - const struct netdev_stats *src); - int netdev_linux_ethtool_set_flag(struct netdev *netdev, uint32_t flag, const char *flag_name, bool enable); diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c index c60d490..c7fca55 100644 --- a/lib/netdev-vport.c +++ b/lib/netdev-vport.c @@ -375,6 +375,45 @@ netdev_vport_set_mtu(const struct netdev *netdev OVS_UNUSED, return EOPNOTSUPP; } +#define COPY_OVS_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; + +/* Copies 'src' into 'dst', performing format conversion in the process. */ +static void +netdev_stats_from_ovs_vport_stats(struct netdev_stats *dst, + const struct ovs_vport_stats *src) +{ + COPY_OVS_STATS + dst->multicast = 0; + dst->collisions = 0; + dst->rx_length_errors = 0; + dst->rx_over_errors = 0; + dst->rx_crc_errors = 0; + dst->rx_frame_errors = 0; + dst->rx_fifo_errors = 0; + dst->rx_missed_errors = 0; + dst->tx_aborted_errors = 0; + dst->tx_carrier_errors = 0; + dst->tx_fifo_errors = 0; + dst->tx_heartbeat_errors = 0; + dst->tx_window_errors = 0; +} + +/* Copies 'src' into 'dst', performing format conversion in the process. */ +static void +netdev_stats_to_ovs_vport_stats(struct ovs_vport_stats *dst, + const struct netdev_stats *src) +{ + COPY_OVS_STATS +} + int netdev_vport_get_stats(const struct netdev *netdev, struct netdev_stats *stats) { diff --git a/utilities/ovs-dpctl.c b/utilities/ovs-dpctl.c index 0e6c16f..e724e74 100644 --- a/utilities/ovs-dpctl.c +++ b/utilities/ovs-dpctl.c @@ -367,6 +367,7 @@ show_dpif(struct dpif *dpif) struct dpif_port_dump dump; struct dpif_port dpif_port; struct ovs_dp_stats stats; + struct netdev *netdev; printf("%s:\n", dpif_name(dpif)); if (!dpif_get_dp_stats(dpif, &stats)) { @@ -381,7 +382,6 @@ show_dpif(struct dpif *dpif) printf("\tport %u: %s", dpif_port.port_no, dpif_port.name); if (strcmp(dpif_port.type, "system")) { - struct netdev *netdev; int error; printf (" (%s", dpif_port.type); @@ -418,29 +418,42 @@ show_dpif(struct dpif *dpif) putchar('\n'); if (print_statistics) { - const struct netdev_stats *s = &dpif_port.stats; + struct netdev_stats s; + int error; + + error = netdev_open(dpif_port.name, dpif_port.type, &netdev); + if (error) { + printf(", open failed (%s)", strerror(error)); + continue; + } + error = netdev_get_stats(netdev, &s); + if (error) { + printf(", could not retrieve stats (%s)", strerror(error)); + continue; + } - print_stat("\t\tRX packets:", s->rx_packets); - print_stat(" errors:", s->rx_errors); - print_stat(" dropped:", s->rx_dropped); - print_stat(" overruns:", s->rx_over_errors); - print_stat(" frame:", s->rx_frame_errors); + netdev_close(netdev); + print_stat("\t\tRX packets:", s.rx_packets); + print_stat(" errors:", s.rx_errors); + print_stat(" dropped:", s.rx_dropped); + print_stat(" overruns:", s.rx_over_errors); + print_stat(" frame:", s.rx_frame_errors); printf("\n"); - print_stat("\t\tTX packets:", s->tx_packets); - print_stat(" errors:", s->tx_errors); - print_stat(" dropped:", s->tx_dropped); - print_stat(" aborted:", s->tx_aborted_errors); - print_stat(" carrier:", s->tx_carrier_errors); + print_stat("\t\tTX packets:", s.tx_packets); + print_stat(" errors:", s.tx_errors); + print_stat(" dropped:", s.tx_dropped); + print_stat(" aborted:", s.tx_aborted_errors); + print_stat(" carrier:", s.tx_carrier_errors); printf("\n"); - print_stat("\t\tcollisions:", s->collisions); + print_stat("\t\tcollisions:", s.collisions); printf("\n"); - print_stat("\t\tRX bytes:", s->rx_bytes); - print_human_size(s->rx_bytes); - print_stat(" TX bytes:", s->tx_bytes); - print_human_size(s->tx_bytes); + print_stat("\t\tRX bytes:", s.rx_bytes); + print_human_size(s.rx_bytes); + print_stat(" TX bytes:", s.tx_bytes); + print_human_size(s.tx_bytes); printf("\n"); } } -- 1.7.1 _______________________________________________ dev mailing list [email protected] http://openvswitch.org/mailman/listinfo/dev
