[ovs-dev] [PATCH 38/41] ofp-util: Allow encoding of Open Flow 1.1 & 1.2 Queue Stats Reply Messages

Simon Horman horms at verge.net.au
Tue Aug 7 21:50:13 UTC 2012


Signed-off-by: Simon Horman <horms at verge.net.au>

---

v10
* Manual rebase
* Make use of enum ofp_version

v9
* Omitted

v8
* Omitted

v7
* Omitted

v6
* No change

v5
* Initial Post
---
 ofproto/ofproto.c | 40 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 00b9bc4..51937c2 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -2879,8 +2879,22 @@ struct queue_stats_cbdata {
 };
 
 static void
-put_queue_stats(struct queue_stats_cbdata *cbdata, uint32_t queue_id,
-                const struct netdev_queue_stats *stats)
+put_queue_stats11(struct queue_stats_cbdata *cbdata, uint32_t queue_id,
+                  const struct netdev_queue_stats *stats)
+{
+    struct ofp11_queue_stats *reply;
+
+    reply = ofpmp_append(&cbdata->replies, sizeof *reply);
+    reply->port_no = ofputil_port_to_ofp11(cbdata->ofport->pp.port_no);
+    reply->queue_id = htonl(queue_id);
+    reply->tx_bytes = htonll(stats->tx_bytes);
+    reply->tx_packets = htonll(stats->tx_packets);
+    reply->tx_errors = htonll(stats->tx_errors);
+}
+
+static void
+put_queue_stats10(struct queue_stats_cbdata *cbdata, uint32_t queue_id,
+                  const struct netdev_queue_stats *stats)
 {
     struct ofp10_queue_stats *reply;
 
@@ -2894,6 +2908,28 @@ put_queue_stats(struct queue_stats_cbdata *cbdata, uint32_t queue_id,
 }
 
 static void
+put_queue_stats(struct queue_stats_cbdata *cbdata, uint32_t queue_id,
+                const struct netdev_queue_stats *stats)
+{
+    struct ofpbuf *msg = ofpbuf_from_list(list_back(&cbdata->replies));
+    struct ofp_header *oh = msg->data;
+
+    switch ((enum ofp_version)oh->version) {
+    case OFP12_VERSION:
+    case OFP11_VERSION:
+        put_queue_stats11(cbdata, queue_id, stats);
+        break;
+
+    case OFP10_VERSION:
+        put_queue_stats10(cbdata, queue_id, stats);
+        break;
+
+    default:
+        NOT_REACHED();
+    }
+}
+
+static void
 handle_queue_stats_dump_cb(uint32_t queue_id,
                            struct netdev_queue_stats *stats,
                            void *cbdata_)
-- 
1.7.10.2.484.gcd07cc5




More information about the dev mailing list