From 034f125955a786ed35052da688e77d6fc2422def Mon Sep 17 00:00:00 2001 From: Justin Pettit Date: Thu, 18 Sep 2008 19:47:27 -0700 Subject: [PATCH] Added lookup count to ofp_table_stats. --- datapath/chain.c | 1 + datapath/datapath.c | 1 + datapath/table-hash.c | 2 ++ datapath/table-linear.c | 1 + datapath/table.h | 10 ++++++---- include/openflow.h | 7 ++++--- lib/ofp-print.c | 9 ++++++--- switch/chain.c | 1 + switch/datapath.c | 1 + switch/table-hash.c | 2 ++ switch/table-linear.c | 1 + switch/table.h | 10 ++++++---- 12 files changed, 32 insertions(+), 14 deletions(-) diff --git a/datapath/chain.c b/datapath/chain.c index 865f908d7..7d9805660 100644 --- a/datapath/chain.c +++ b/datapath/chain.c @@ -72,6 +72,7 @@ struct sw_flow *chain_lookup(struct sw_chain *chain, for (i = 0; i < chain->n_tables; i++) { struct sw_table *t = chain->tables[i]; struct sw_flow *flow = t->lookup(t, key); + t->n_lookup++; if (flow) { t->n_matched++; return flow; diff --git a/datapath/datapath.c b/datapath/datapath.c index 83ef56547..0ec226d9d 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -1420,6 +1420,7 @@ static int table_stats_dump(struct datapath *dp, void *state, memset(ots->pad, 0, sizeof ots->pad); ots->max_entries = htonl(stats.max_flows); ots->active_count = htonl(stats.n_flows); + ots->lookup_count = cpu_to_be64(stats.n_lookup); ots->matched_count = cpu_to_be64(stats.n_matched); } return 0; diff --git a/datapath/table-hash.c b/datapath/table-hash.c index 29d205943..2663bf4b2 100644 --- a/datapath/table-hash.c +++ b/datapath/table-hash.c @@ -220,6 +220,7 @@ static void table_hash_stats(struct sw_table *swt, stats->wildcards = 0; /* No wildcards are supported. */ stats->n_flows = th->n_flows; stats->max_flows = th->bucket_mask + 1; + stats->n_lookup = swt->n_lookup; stats->n_matched = swt->n_matched; } @@ -356,6 +357,7 @@ static void table_hash2_stats(struct sw_table *swt, stats->wildcards = 0; /* No wildcards are supported. */ stats->n_flows = substats[0].n_flows + substats[1].n_flows; stats->max_flows = substats[0].max_flows + substats[1].max_flows; + stats->n_lookup = swt->n_lookup; stats->n_matched = swt->n_matched; } diff --git a/datapath/table-linear.c b/datapath/table-linear.c index 89f5c3c4c..c71f0bdbd 100644 --- a/datapath/table-linear.c +++ b/datapath/table-linear.c @@ -178,6 +178,7 @@ static void table_linear_stats(struct sw_table *swt, stats->wildcards = OFPFW_ALL; stats->n_flows = tl->n_flows; stats->max_flows = tl->max_flows; + stats->n_lookup = swt->n_lookup; stats->n_matched = swt->n_matched; } diff --git a/datapath/table.h b/datapath/table.h index 3dda2769b..c40b4ca67 100644 --- a/datapath/table.h +++ b/datapath/table.h @@ -18,6 +18,7 @@ struct sw_table_stats { supported by the table. */ unsigned int n_flows; /* Number of active flows. */ unsigned int max_flows; /* Flow capacity. */ + unsigned long int n_lookup; /* Number of packets looked up. */ unsigned long int n_matched; /* Number of packets that have hit. */ }; @@ -35,10 +36,11 @@ struct sw_table_position { * rcu_read_lock. destroy must be fully serialized. */ struct sw_table { - /* Keep track of the number of packets that matched this table. To - * make this 100% accurate, it should be atomic. However, we're - * primarily concerned about speed. */ - unsigned long int n_matched; + /* The number of packets that have been looked up and matched, + * respecitvely. To make these 100% accurate, they should be atomic. + * However, we're primarily concerned about speed. */ + unsigned long long n_lookup; + unsigned long long n_matched; /* Searches 'table' for a flow matching 'key', which must not have any * wildcard fields. Returns the flow if successful, a null pointer diff --git a/include/openflow.h b/include/openflow.h index 528efeb89..632ac425c 100644 --- a/include/openflow.h +++ b/include/openflow.h @@ -63,7 +63,7 @@ /* The most significant bit being set in the version field indicates an * experimental OpenFlow version. */ -#define OFP_VERSION 0x91 +#define OFP_VERSION 0x92 #define OFP_MAX_TABLE_NAME_LEN 32 #define OFP_MAX_PORT_NAME_LEN 16 @@ -618,9 +618,10 @@ struct ofp_table_stats { supported by the table. */ uint32_t max_entries; /* Max number of entries supported */ uint32_t active_count; /* Number of active entries */ + uint64_t lookup_count; /* Number of packets looked up in table */ uint64_t matched_count; /* Number of packets that hit table */ }; -OFP_ASSERT(sizeof(struct ofp_table_stats) == 56); +OFP_ASSERT(sizeof(struct ofp_table_stats) == 64); /* Body of reply to OFPST_PORT request. If a counter is unsupported, set * the field to all ones. */ @@ -649,7 +650,7 @@ OFP_ASSERT(sizeof(struct ofp_port_stats) == 104); struct ofp_vendor { struct ofp_header header; /* Type OFPT_VENDOR. */ uint32_t vendor; /* Vendor ID: - * - MSB 0: low-order bytes are Ethernet OUI. + * - MSB 0: low-order bytes are IEEE OUI. * - MSB != 0: defined by OpenFlow * consortium. */ /* Vendor-defined arbitrary additional data. */ diff --git a/lib/ofp-print.c b/lib/ofp-print.c index 65c7d0721..de2c2339d 100644 --- a/lib/ofp-print.c +++ b/lib/ofp-print.c @@ -891,9 +891,12 @@ ofp_table_stats_reply(struct ds *string, const void *body, size_t len, ds_put_format(string, " %d: %-8s: ", ts->table_id, name); ds_put_format(string, "wild=0x%05"PRIx32", ", ntohl(ts->wildcards)); ds_put_format(string, "max=%6"PRIu32", ", ntohl(ts->max_entries)); - ds_put_format(string, "active=%6"PRIu32", ", ntohl(ts->active_count)); - ds_put_format(string, "matched=%6"PRIu64"\n", - ntohll(ts->matched_count)); + ds_put_format(string, "active=%"PRIu32"\n", ntohl(ts->active_count)); + ds_put_cstr(string, " "); + ds_put_format(string, "lookup=%"PRIu64", ", + ntohll(ts->lookup_count)); + ds_put_format(string, "matched=%"PRIu64"\n", + ntohll(ts->matched_count)); } } diff --git a/switch/chain.c b/switch/chain.c index c591cdbfc..a04aac905 100644 --- a/switch/chain.c +++ b/switch/chain.c @@ -87,6 +87,7 @@ chain_lookup(struct sw_chain *chain, const struct sw_flow_key *key) for (i = 0; i < chain->n_tables; i++) { struct sw_table *t = chain->tables[i]; struct sw_flow *flow = t->lookup(t, key); + t->n_lookup++; if (flow) { t->n_matched++; return flow; diff --git a/switch/datapath.c b/switch/datapath.c index 032b7ec7a..5d4590f1a 100644 --- a/switch/datapath.c +++ b/switch/datapath.c @@ -1448,6 +1448,7 @@ static int table_stats_dump(struct datapath *dp, void *state, memset(ots->pad, 0, sizeof ots->pad); ots->max_entries = htonl(stats.max_flows); ots->active_count = htonl(stats.n_flows); + ots->lookup_count = htonll(stats.n_lookup); ots->matched_count = htonll(stats.n_matched); } return 0; diff --git a/switch/table-hash.c b/switch/table-hash.c index 0960082b3..d342eeb7e 100644 --- a/switch/table-hash.c +++ b/switch/table-hash.c @@ -233,6 +233,7 @@ static void table_hash_stats(struct sw_table *swt, stats->wildcards = 0; /* No wildcards are supported. */ stats->n_flows = th->n_flows; stats->max_flows = th->bucket_mask + 1; + stats->n_lookup = swt->n_lookup; stats->n_matched = swt->n_matched; } @@ -371,6 +372,7 @@ static void table_hash2_stats(struct sw_table *swt, stats->wildcards = 0; /* No wildcards are supported. */ stats->n_flows = substats[0].n_flows + substats[1].n_flows; stats->max_flows = substats[0].max_flows + substats[1].max_flows; + stats->n_lookup = swt->n_lookup; stats->n_matched = swt->n_matched; } diff --git a/switch/table-linear.c b/switch/table-linear.c index 9a7a06cc8..97f458f18 100644 --- a/switch/table-linear.c +++ b/switch/table-linear.c @@ -204,6 +204,7 @@ static void table_linear_stats(struct sw_table *swt, stats->wildcards = OFPFW_ALL; stats->n_flows = tl->n_flows; stats->max_flows = tl->max_flows; + stats->n_lookup = swt->n_lookup; stats->n_matched = swt->n_matched; } diff --git a/switch/table.h b/switch/table.h index aacaa63fd..37b91413f 100644 --- a/switch/table.h +++ b/switch/table.h @@ -51,6 +51,7 @@ struct sw_table_stats { supported by the table. */ unsigned int n_flows; /* Number of active flows. */ unsigned int max_flows; /* Flow capacity. */ + unsigned long int n_lookup; /* Number of packets looked up. */ unsigned long int n_matched; /* Number of packets that have hit. */ }; @@ -64,10 +65,11 @@ struct sw_table_position { /* A single table of flows. */ struct sw_table { - /* Keep track of the number of packets that matched this table. To - * make this 100% accurate, it should be atomic. However, we're - * primarily concerned about speed. */ - unsigned long int n_matched; + /* The number of packets that have been looked up and matched, + * respecitvely. To make these 100% accurate, they should be atomic. + * However, we're primarily concerned about speed. */ + unsigned long long n_lookup; + unsigned long long n_matched; /* Searches 'table' for a flow matching 'key', which must not have any * wildcard fields. Returns the flow if successful, a null pointer -- 2.43.0