2
0
mirror of https://github.com/openvswitch/ovs synced 2025-09-02 07:15:17 +00:00

datapath: Drop port information from odp_stats.

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@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
This commit is contained in:
Ben Pfaff
2011-01-26 09:24:59 -08:00
parent 1ba530f4b2
commit 996c1b3d7a
10 changed files with 30 additions and 24 deletions

View File

@@ -370,7 +370,6 @@ static struct vport *new_vport(const struct vport_parms *parms)
rcu_assign_pointer(dp->ports[parms->port_no], vport);
list_add_rcu(&vport->node, &dp->port_list);
dp->n_ports++;
dp_ifinfo_notify(RTM_NEWLINK, vport);
}
@@ -390,7 +389,6 @@ int dp_detach_port(struct vport *p)
dp_ifinfo_notify(RTM_DELLINK, p);
/* First drop references to device. */
p->dp->n_ports--;
list_del_rcu(&p->node);
rcu_assign_pointer(p->dp->ports[p->port_no], NULL);
@@ -1202,8 +1200,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;

View File

@@ -68,7 +68,6 @@ struct dp_stats_percpu {
* @waitqueue: Waitqueue, for waiting for new packets in @queues.
* @n_flows: Number of flows currently in flow table.
* @table: Current flow table.
* @n_ports: Number of ports currently in @ports.
* @ports: Map from port number to &struct vport. %ODPP_LOCAL port
* always exists, other ports may be %NULL.
* @port_list: List of all ports in @ports in arbitrary order.
@@ -93,7 +92,6 @@ struct datapath {
struct tbl __rcu *table;
/* Switch ports. */
unsigned int n_ports;
struct vport __rcu *ports[DP_MAX_PORTS];
struct list_head port_list;

View File

@@ -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. */

View File

@@ -365,6 +365,14 @@ dpif_linux_port_query_by_name(const struct dpif *dpif, const char *devname,
return dpif_linux_port_query__(dpif, 0, devname, dpif_port);
}
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_)
{
@@ -681,6 +689,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,

View File

@@ -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)
{
@@ -1393,6 +1397,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,

View File

@@ -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. */

View File

@@ -561,6 +561,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

View File

@@ -80,6 +80,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;

View File

@@ -429,7 +429,6 @@ ofproto_create(const char *datapath, const char *datapath_type,
const struct ofhooks *ofhooks, void *aux,
struct ofproto **ofprotop)
{
struct odp_stats stats;
struct ofproto *p;
struct dpif *dpif;
int error;
@@ -444,13 +443,6 @@ ofproto_create(const char *datapath, const char *datapath_type,
VLOG_ERR("failed to open datapath %s: %s", datapath, strerror(error));
return error;
}
error = dpif_get_dp_stats(dpif, &stats);
if (error) {
VLOG_ERR("failed to obtain stats for datapath %s: %s",
datapath, strerror(error));
dpif_close(dpif);
return error;
}
error = dpif_recv_set_mask(dpif, ODPL_MISS | ODPL_ACTION | ODPL_SFLOW);
if (error) {
VLOG_ERR("failed to listen on datapath %s: %s",
@@ -476,7 +468,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);

View File

@@ -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,