[ovs-dev] [PATCH 16/27] ofp-print: Enable display of Open Flow 1.1 & 1.2 Queue Status Reply Messages
Simon Horman
horms at verge.net.au
Tue Aug 21 04:55:48 UTC 2012
Signed-off-by: Simon Horman <horms at verge.net.au>
---
v12
* No change
v11
* No change
v10
* Make use of enum ofp_version
* Add ofp-print test
v9
* Omitted
v8
* Omitted
v7
* Omitted
v6
* No change
v5
* Initial Post
---
lib/ofp-print.c | 63 ++++++++++++++++++++++++++++++++++++++++--------------
tests/ofp-print.at | 56 +++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 102 insertions(+), 17 deletions(-)
diff --git a/lib/ofp-print.c b/lib/ofp-print.c
index 735fe42..d8328ad 100644
--- a/lib/ofp-print.c
+++ b/lib/ofp-print.c
@@ -1080,12 +1080,6 @@ static void ofp_print_port_stat(struct ds *string, const char *leader,
}
}
-static void print_port_stat(struct ds *string, const char *leader,
- const ovs_32aligned_be64 *statp, int more)
-{
- ofp_print_port_stat(string, leader, get_32aligned_be64(statp), more);
-}
-
static void
ofp_print_ofpst_port_request(struct ds *string, const struct ofp_header *oh)
{
@@ -1385,34 +1379,71 @@ static void
ofp_print_ofpst_queue_reply(struct ds *string, const struct ofp_header *oh,
int verbosity)
{
- struct ofp10_queue_stats *qs;
struct ofpbuf b;
size_t n;
+ struct ofp11_queue_stats qs;
ofpbuf_use_const(&b, oh, ntohs(oh->length));
ofpraw_pull_assert(&b);
- n = b.size / sizeof *qs;
+ /* This calculation is correct because
+ * struct ofp10_queue_stats and struct ofp11_queue_stats
+ * are the same size.
+ */
+ n = b.size / sizeof qs;
ds_put_format(string, " %zu queues\n", n);
if (verbosity < 1) {
return;
}
for (;;) {
- qs = ofpbuf_try_pull(&b, sizeof *qs);
- if (!qs) {
- return;
+ uint16_t port_no;
+
+ switch ((enum ofp_version)oh->version) {
+ case OFP11_VERSION:
+ case OFP12_VERSION: {
+ const struct ofp11_queue_stats *qs11;
+
+ qs11 = ofpbuf_try_pull(&b, sizeof *qs11);
+ if (!qs11) {
+ return;
+ }
+ if (ofputil_port_from_ofp11(qs11->port_no, &port_no)) {
+ ds_put_cstr(string, "*** parse error: invalid port ***\n");
+ return;
+ }
+ qs = *qs11;
+ break;
+ }
+
+ case OFP10_VERSION: {
+ const struct ofp10_queue_stats *qs10;
+
+ qs10 = ofpbuf_try_pull(&b, sizeof *qs10);
+ if (!qs10) {
+ return;
+ }
+ port_no = ntohs(qs10->port_no);
+ qs.queue_id = qs10->queue_id;
+ qs.tx_bytes = get_32aligned_be64(&qs10->tx_bytes);
+ qs.tx_packets = get_32aligned_be64(&qs10->tx_packets);
+ qs.tx_errors = get_32aligned_be64(&qs10->tx_errors);
+ break;
+ }
+
+ default:
+ NOT_REACHED();
}
ds_put_cstr(string, " port ");
- ofputil_format_port(ntohs(qs->port_no), string);
+ ofputil_format_port(port_no, string);
ds_put_cstr(string, " queue ");
- ofp_print_queue_name(string, ntohl(qs->queue_id));
+ ofp_print_queue_name(string, ntohl(qs.queue_id));
ds_put_cstr(string, ": ");
- print_port_stat(string, "bytes=", &qs->tx_bytes, 1);
- print_port_stat(string, "pkts=", &qs->tx_packets, 1);
- print_port_stat(string, "errors=", &qs->tx_errors, 0);
+ ofp_print_port_stat(string, "bytes=", qs.tx_bytes, 1);
+ ofp_print_port_stat(string, "pkts=", qs.tx_packets, 1);
+ ofp_print_port_stat(string, "errors=", qs.tx_errors, 0);
}
}
diff --git a/tests/ofp-print.at b/tests/ofp-print.at
index 58f4d9c..b7eb1eb 100644
--- a/tests/ofp-print.at
+++ b/tests/ofp-print.at
@@ -1003,7 +1003,7 @@ OFPST_QUEUE request (xid=0x1):port=ALL queue=ALL
])
AT_CLEANUP
-AT_SETUP([OFPST_QUEUE reply])
+AT_SETUP([OFPST_QUEUE reply - OF1.0])
AT_KEYWORDS([ofp-print OFPT_STATS_REPLY])
AT_CHECK([ovs-ofctl ofp-print "\
01 11 00 cc 00 00 00 01 00 05 00 00 00 03 00 00 \
@@ -1037,6 +1037,60 @@ OFPST_PORT_DESC request (xid=0x1):
])
AT_CLEANUP
+AT_SETUP([OFPST_QUEUE reply - OF1.1])
+AT_KEYWORDS([ofp-print OFPT_STATS_REPLY])
+AT_CHECK([ovs-ofctl ofp-print "\
+02 13 00 d0 00 00 00 01 00 05 00 00 00 00 00 00 \
+00 00 00 03 00 00 00 01 00 00 00 00 00 00 01 2e \
+00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 \
+00 00 00 03 00 00 00 02 00 00 00 00 00 00 00 00 \
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \
+00 00 00 02 00 00 00 01 00 00 00 00 00 00 08 34 \
+00 00 00 00 00 00 00 14 00 00 00 00 00 00 00 00 \
+00 00 00 02 00 00 00 02 00 00 00 00 00 00 00 00 \
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \
+00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 \
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \
+00 00 00 01 00 00 00 02 00 00 00 00 00 00 00 00 \
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \
+"], [0], [dnl
+OFPST_QUEUE reply (OF1.1) (xid=0x1): 6 queues
+ port 3 queue 1: bytes=302, pkts=1, errors=0
+ port 3 queue 2: bytes=0, pkts=0, errors=0
+ port 2 queue 1: bytes=2100, pkts=20, errors=0
+ port 2 queue 2: bytes=0, pkts=0, errors=0
+ port 1 queue 1: bytes=0, pkts=0, errors=0
+ port 1 queue 2: bytes=0, pkts=0, errors=0
+])
+AT_CLEANUP
+
+AT_SETUP([OFPST_QUEUE reply - OF1.2])
+AT_KEYWORDS([ofp-print OFPT_STATS_REPLY])
+AT_CHECK([ovs-ofctl ofp-print "\
+03 13 00 d0 00 00 00 01 00 05 00 00 00 00 00 00 \
+00 00 00 03 00 00 00 01 00 00 00 00 00 00 01 2e \
+00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 \
+00 00 00 03 00 00 00 02 00 00 00 00 00 00 00 00 \
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \
+00 00 00 02 00 00 00 01 00 00 00 00 00 00 08 34 \
+00 00 00 00 00 00 00 14 00 00 00 00 00 00 00 00 \
+00 00 00 02 00 00 00 02 00 00 00 00 00 00 00 00 \
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \
+00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 \
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \
+00 00 00 01 00 00 00 02 00 00 00 00 00 00 00 00 \
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \
+"], [0], [dnl
+OFPST_QUEUE reply (OF1.2) (xid=0x1): 6 queues
+ port 3 queue 1: bytes=302, pkts=1, errors=0
+ port 3 queue 2: bytes=0, pkts=0, errors=0
+ port 2 queue 1: bytes=2100, pkts=20, errors=0
+ port 2 queue 2: bytes=0, pkts=0, errors=0
+ port 1 queue 1: bytes=0, pkts=0, errors=0
+ port 1 queue 2: bytes=0, pkts=0, errors=0
+])
+AT_CLEANUP
+
AT_SETUP([OFPST_PORT_DESC reply - OF1.0])
AT_KEYWORDS([ofp-print OFPT_STATS_REPLY])
AT_CHECK([ovs-ofctl ofp-print "\
--
1.7.10.2.484.gcd07cc5
More information about the dev
mailing list