Added lookup count to ofp_table_stats.
authorJustin Pettit <jpettit@nicira.com>
Fri, 19 Sep 2008 02:47:27 +0000 (19:47 -0700)
committerJustin Pettit <jpettit@nicira.com>
Fri, 19 Sep 2008 02:47:27 +0000 (19:47 -0700)
12 files changed:
datapath/chain.c
datapath/datapath.c
datapath/table-hash.c
datapath/table-linear.c
datapath/table.h
include/openflow.h
lib/ofp-print.c
switch/chain.c
switch/datapath.c
switch/table-hash.c
switch/table-linear.c
switch/table.h

index 865f908..7d98056 100644 (file)
@@ -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;
index 83ef565..0ec226d 100644 (file)
@@ -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;
index 29d2059..2663bf4 100644 (file)
@@ -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;
 }
 
index 89f5c3c..c71f0bd 100644 (file)
@@ -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;
 }
 
index 3dda276..c40b4ca 100644 (file)
@@ -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
index 528efeb..632ac42 100644 (file)
@@ -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. */
index 65c7d07..de2c233 100644 (file)
@@ -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));
      }
 }
 
index c591cdb..a04aac9 100644 (file)
@@ -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;
index 032b7ec..5d4590f 100644 (file)
@@ -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;
index 0960082..d342eeb 100644 (file)
@@ -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;
 }
 
index 9a7a06c..97f458f 100644 (file)
@@ -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;
 }
 
index aacaa63..37b9141 100644 (file)
@@ -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