[patch_v0 2/3] OF1.5-EXT-334: Extensible Flow Entry Statistics Implementation
--lib/ofp-util.c lib/ox_stat.c
Signed-off-by: Harivelam Lavanya
Co-authored-by: Satya Valli
>From f2e03a1fdcad61fd9221d6f81ff708b017a119f4 Mon Sep 17 00:00:00 2001
From: Harivelam Lavanya
Date: Wed, 19 Apr 2017 19:44:27 +0530
Subject: [PATCH 3/4] OF1.5/EXT-334-OXS Individal Flow Entry Statistics
--lib/ofp-util.c lib/ox_stat.c
---
lib/ofp-util.c | 125 ++-
lib/ox-stat.c | 310 +
2 files changed, 430 insertions(+), 5 deletions(-)
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 1f038c61e..a261d981a 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -50,9 +50,12 @@
#include "unaligned.h"
#include "util.h"
#include "uuid.h"
+#include "ox-stat.h"
VLOG_DEFINE_THIS_MODULE(ofp_util);
+extern uint8_t oxs_field_set;
+
/* Rate limit for OpenFlow message parse errors. These always indicate a bug
* in the peer and so there's not much point in showing a lot of them. */
static struct vlog_rate_limit bad_ofmsg_rl = VLOG_RATE_LIMIT_INIT(1, 5);
@@ -2313,6 +2316,39 @@ ofputil_decode_ofpst11_flow_request(struct
ofputil_flow_stats_request *fsr,
return 0;
}
+ofputil_decode_ofpst15_flow_request(struct ofputil_flow_stats_request *fsr,
+struct ofpbuf *b, bool aggregate,
+const struct tun_table *tun_table,
+const struct vl_mff_map *vl_mff_map)
+{
+ const struct ofp15_oxs_flow_stats_request *ofsr;
+ enum ofperr error,stat_error;
+ uint16_t statlen;
+
+ ofsr = ofpbuf_pull(b, sizeof *ofsr);
+ fsr->aggregate = aggregate;
+ fsr->table_id = ofsr->table_id;
+
+ error = ofputil_port_from_ofp11(ofsr->out_port, &fsr->out_port);
+ if (error) {
+ return error;
+ }
+
+ fsr->out_group = ntohl(ofsr->out_group);
+ fsr->cookie = ofsr->cookie;
+ fsr->cookie_mask = ofsr->cookie_mask;
+
+ error = ofputil_pull_ofp11_match(b, tun_table, vl_mff_map, &fsr->match,
+NULL);
+ stat_error = oxs_pull_stat(b, NULL, &statlen);
+
+ if (error || stat_error) {
+ return error;
+ }
+
+ return 0;
+}
+
static enum ofperr
ofputil_decode_nxst_flow_request(struct ofputil_flow_stats_request *fsr,
struct ofpbuf *b, bool aggregate,
@@ -2762,6 +2798,10 @@ ofputil_decode_flow_stats_request(struct
ofputil_flow_stats_request *fsr,
case OFPRAW_OFPST11_AGGREGATE_REQUEST:
return ofputil_decode_ofpst11_flow_request(fsr, &b, true, tun_table,
vl_mff_map);
+case OFPRAW_OFPST15_OXS_FLOW_REQUEST:
+oxs_field_set = 0;
+return ofputil_decode_ofpst15_flow_request(fsr, &b, false, tun_table,
+ vl_mff_map);
case OFPRAW_NXST_FLOW_REQUEST:
return ofputil_decode_nxst_flow_request(fsr, &b, false, tun_table,
@@ -2791,9 +2831,7 @@ ofputil_encode_flow_stats_request(const struct
ofputil_flow_stats_request *fsr,
case OFPUTIL_P_OF11_STD:
case OFPUTIL_P_OF12_OXM:
case OFPUTIL_P_OF13_OXM:
-case OFPUTIL_P_OF14_OXM:
-case OFPUTIL_P_OF15_OXM:
-case OFPUTIL_P_OF16_OXM: {
+case OFPUTIL_P_OF14_OXM: {
struct ofp11_flow_stats_request *ofsr;
raw = (fsr->aggregate
@@ -2811,6 +2849,25 @@ ofputil_encode_flow_stats_request(const struct
ofputil_flow_stats_request *fsr,
break;
}
+case OFPUTIL_P_OF15_OXM:
+case OFPUTIL_P_OF16_OXM: {
+struct ofp15_oxs_flow_stats_request *ofsr;
+raw = (fsr->aggregate
+ ? OFPRAW_OFPST11_AGGREGATE_REQUEST
+ : OFPRAW_OFPST15_OXS_FLOW_REQUEST);
+msg = ofpraw_alloc(raw, ofputil_protocol_to_ofp_version(protocol),
+ ofputil_match_typical_len(protocol));
+ofsr = ofpbuf_put_zeros(msg, sizeof *ofsr);
+ofsr->table_id = fsr->table_id;
+ofsr->out_port = ofputil_port_to_ofp11(fsr->out_port);
+ofsr->out_group = htonl(fsr->out_group);
+ofsr->cookie = fsr->cookie;
+ofsr->cookie_mask = fsr->cookie_mask;
+ofputil_put_ofp11_match(msg, &fsr->match, protocol);
+oxs_put_stat(msg, NULL, ofputil_protocol_to_ofp_version(protocol));
+break;
+}
+
case OFPUTIL_P_OF10_STD:
case OFPUTIL_P_OF10_STD_TID: {
struct ofp10_flow_stats_request *ofsr;
@@ -2893,7 +2950,48 @@ ofputil_decode_flow_stats_reply(struct
ofputil_flow_stats *fs,
if (!msg->size) {
return EOF;
-} else if (raw == OFPRAW_OFPST11_FLOW_REPLY
+} else if (raw == OFPRAW_OFPST15_OXS_FLOW_REPLY) {
+const struct ofp15_oxs_flow_stats_reply *ofs;
+size_t length;
+uint16_t pa