[ovs-dev] [netlink v3 23/?] datapath: Drop port information from odp_stats.
Ben Pfaff
blp at nicira.com
Wed Jan 5 01:12:59 UTC 2011
As with n_flows, n_ports was used regularly by userspace to determine how
much memory to allocate when listing ports, but it is no longer needed for
that. max_ports, on the other hand, is necessary but it is also a fixed
value for the kernel datapath right now and if we expand it we can also
come up with a way to report the expanded value.
The remaining members of odp_stats are actually real statistics that I
intend to keep.
Signed-off-by: Ben Pfaff <blp at nicira.com>
---
datapath/datapath.c | 2 --
include/openvswitch/datapath-protocol.h | 5 -----
lib/dpif-linux.c | 9 +++++++++
lib/dpif-netdev.c | 9 +++++++--
lib/dpif-provider.h | 4 ++++
lib/dpif.c | 8 ++++++++
lib/dpif.h | 1 +
ofproto/ofproto.c | 4 ++--
utilities/ovs-dpctl.c | 2 --
9 files changed, 31 insertions(+), 13 deletions(-)
diff --git a/datapath/datapath.c b/datapath/datapath.c
index a045333..9ec069c 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -1192,8 +1192,6 @@ static int get_dp_stats(struct datapath *dp, struct odp_stats __user *statsp)
struct odp_stats stats;
int i;
- stats.n_ports = dp->n_ports;
- stats.max_ports = DP_MAX_PORTS;
stats.n_frags = stats.n_hit = stats.n_missed = stats.n_lost = 0;
for_each_possible_cpu(i) {
const struct dp_stats_percpu *percpu_stats;
diff --git a/include/openvswitch/datapath-protocol.h b/include/openvswitch/datapath-protocol.h
index 0e6898c..6947a13 100644
--- a/include/openvswitch/datapath-protocol.h
+++ b/include/openvswitch/datapath-protocol.h
@@ -100,11 +100,6 @@
#define ODP_GET_SFLOW_PROBABILITY _IOW('O', 20, int)
struct odp_stats {
- /* Ports. */
- uint32_t n_ports; /* Current number of ports. */
- uint32_t max_ports; /* Maximum supported number of ports. */
-
- /* Lookups. */
uint64_t n_frags; /* Number of dropped IP fragments. */
uint64_t n_hit; /* Number of flow table matches. */
uint64_t n_missed; /* Number of flow table misses. */
diff --git a/lib/dpif-linux.c b/lib/dpif-linux.c
index 1e8f90e..26a1200 100644
--- a/lib/dpif-linux.c
+++ b/lib/dpif-linux.c
@@ -359,6 +359,14 @@ dpif_linux_port_query_by_name(const struct dpif *dpif, const char *devname,
}
static int
+dpif_linux_get_max_ports(const struct dpif *dpif OVS_UNUSED)
+{
+ /* If the datapath increases its range of supported ports, then it should
+ * start reporting that. */
+ return 1024;
+}
+
+static int
dpif_linux_flow_flush(struct dpif *dpif_)
{
return do_ioctl(dpif_, ODP_FLOW_FLUSH, NULL);
@@ -672,6 +680,7 @@ const struct dpif_class dpif_linux_class = {
dpif_linux_port_del,
dpif_linux_port_query_by_number,
dpif_linux_port_query_by_name,
+ dpif_linux_get_max_ports,
dpif_linux_port_dump_start,
dpif_linux_port_dump_next,
dpif_linux_port_dump_done,
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index dd509a0..685459b 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -302,8 +302,6 @@ dpif_netdev_get_stats(const struct dpif *dpif, struct odp_stats *stats)
{
struct dp_netdev *dp = get_dp_netdev(dpif);
memset(stats, 0, sizeof *stats);
- stats->n_ports = dp->n_ports;
- stats->max_ports = MAX_PORTS;
stats->n_frags = dp->n_frags;
stats->n_hit = dp->n_hit;
stats->n_missed = dp->n_missed;
@@ -512,6 +510,12 @@ dpif_netdev_port_query_by_name(const struct dpif *dpif, const char *devname,
return error;
}
+static int
+dpif_netdev_get_max_ports(const struct dpif *dpif OVS_UNUSED)
+{
+ return MAX_PORTS;
+}
+
static void
dp_netdev_free_flow(struct dp_netdev *dp, struct dp_netdev_flow *flow)
{
@@ -1392,6 +1396,7 @@ const struct dpif_class dpif_netdev_class = {
dpif_netdev_port_del,
dpif_netdev_port_query_by_number,
dpif_netdev_port_query_by_name,
+ dpif_netdev_get_max_ports,
dpif_netdev_port_dump_start,
dpif_netdev_port_dump_next,
dpif_netdev_port_dump_done,
diff --git a/lib/dpif-provider.h b/lib/dpif-provider.h
index eca0059..f6548b3 100644
--- a/lib/dpif-provider.h
+++ b/lib/dpif-provider.h
@@ -156,6 +156,10 @@ struct dpif_class {
int (*port_query_by_name)(const struct dpif *dpif, const char *devname,
struct dpif_port *port);
+ /* Returns one greater than the largest port number accepted in flow
+ * actions. */
+ int (*get_max_ports)(const struct dpif *dpif);
+
/* Attempts to begin dumping the ports in a dpif. On success, returns 0
* and initializes '*statep' with any data needed for iteration. On
* failure, returns a positive errno value. */
diff --git a/lib/dpif.c b/lib/dpif.c
index c83f8f5..8193deb 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -552,6 +552,14 @@ dpif_port_query_by_name(const struct dpif *dpif, const char *devname,
return error;
}
+/* Returns one greater than the maximum port number accepted in flow
+ * actions. */
+int
+dpif_get_max_ports(const struct dpif *dpif)
+{
+ return dpif->dpif_class->get_max_ports(dpif);
+}
+
/* Looks up port number 'port_no' in 'dpif'. On success, returns 0 and copies
* the port's name into the 'name_size' bytes in 'name', ensuring that the
* result is null-terminated. On failure, returns a positive errno value and
diff --git a/lib/dpif.h b/lib/dpif.h
index fc70d8d..13bce2f 100644
--- a/lib/dpif.h
+++ b/lib/dpif.h
@@ -79,6 +79,7 @@ int dpif_port_query_by_name(const struct dpif *, const char *devname,
struct dpif_port *);
int dpif_port_get_name(struct dpif *, uint16_t port_no,
char *name, size_t name_size);
+int dpif_get_max_ports(const struct dpif *);
struct dpif_port_dump {
const struct dpif *dpif;
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index a3a8d32..4d068a2 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2010 Nicira Networks.
+ * Copyright (c) 2009, 2010, 2011 Nicira Networks.
* Copyright (c) 2010 Jean Tourrilhes - HP-Labs.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -476,7 +476,7 @@ ofproto_create(const char *datapath, const char *datapath_type,
p->netdev_monitor = netdev_monitor_create();
hmap_init(&p->ports);
shash_init(&p->port_by_name);
- p->max_ports = stats.max_ports;
+ p->max_ports = dpif_get_max_ports(dpif);
/* Initialize submodules. */
p->switch_status = switch_status_create(p);
diff --git a/utilities/ovs-dpctl.c b/utilities/ovs-dpctl.c
index 539962f..fab6577 100644
--- a/utilities/ovs-dpctl.c
+++ b/utilities/ovs-dpctl.c
@@ -338,8 +338,6 @@ show_dpif(struct dpif *dpif)
printf("%s:\n", dpif_name(dpif));
if (!dpif_get_dp_stats(dpif, &stats)) {
- printf("\tports: cur:%"PRIu32", max:%"PRIu32"\n",
- stats.n_ports, stats.max_ports);
printf("\tlookups: frags:%llu, hit:%llu, missed:%llu, lost:%llu\n",
(unsigned long long int) stats.n_frags,
(unsigned long long int) stats.n_hit,
--
1.7.1
More information about the dev
mailing list