From: Ben Pfaff Date: Fri, 6 Jul 2012 06:04:12 +0000 (-0700) Subject: nicira-ext: Drop nx_aggregate_stats_reply structure. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d91cf14f5bdab1e513fc3520649e38f3617ac3b9;p=openvswitch nicira-ext: Drop nx_aggregate_stats_reply structure. It now duplicates ofp_aggregate_stats_reply except for alignment issues, so we might as well unify the code. Signed-off-by: Ben Pfaff Tested-by: Simon Horman Reviewed-by: Simon Horman --- diff --git a/include/openflow/nicira-ext.h b/include/openflow/nicira-ext.h index 1c5d3448..05f6c18a 100644 --- a/include/openflow/nicira-ext.h +++ b/include/openflow/nicira-ext.h @@ -1857,7 +1857,10 @@ struct nx_flow_stats { OFP_ASSERT(sizeof(struct nx_flow_stats) == 48); /* Nicira vendor stats request of type NXST_AGGREGATE (analogous to - * OFPST_AGGREGATE request). */ + * OFPST_AGGREGATE request). + * + * The reply format is identical to the reply format for OFPST_AGGREGATE, + * except for the header. */ struct nx_aggregate_stats_request { ovs_be16 out_port; /* Require matching entries to include this as an output port. A value of OFPP_NONE @@ -1874,16 +1877,6 @@ struct nx_aggregate_stats_request { */ }; OFP_ASSERT(sizeof(struct nx_aggregate_stats_request) == 8); - -/* Body for nicira_stats_msg reply of type NXST_AGGREGATE (analogous to - * OFPST_AGGREGATE reply). */ -struct nx_aggregate_stats_reply { - ovs_be64 packet_count; /* Number of packets, UINT64_MAX if unknown. */ - ovs_be64 byte_count; /* Number of bytes, UINT64_MAX if unknown. */ - ovs_be32 flow_count; /* Number of flows. */ - uint8_t pad[4]; /* Align to 64 bits. */ -}; -OFP_ASSERT(sizeof(struct nx_aggregate_stats_reply) == 24); /* NXT_SET_CONTROLLER_ID. * diff --git a/lib/ofp-msgs.h b/lib/ofp-msgs.h index ed73fc72..9bd5ee4e 100644 --- a/lib/ofp-msgs.h +++ b/lib/ofp-msgs.h @@ -192,7 +192,7 @@ enum ofpraw { /* OFPST 1.0 (2): struct ofp_aggregate_stats_reply. */ OFPRAW_OFPST_AGGREGATE_REPLY, - /* NXST 1.0 (1): struct nx_aggregate_stats_reply. */ + /* NXST 1.0 (1): struct ofp_aggregate_stats_reply. */ OFPRAW_NXST_AGGREGATE_REPLY, /* OFPST 1.0 (3): void. */ diff --git a/lib/ofp-util.c b/lib/ofp-util.c index 7875cbf8..c9346a50 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -1629,38 +1629,33 @@ ofputil_append_flow_stats_reply(const struct ofputil_flow_stats *fs, } /* Converts abstract ofputil_aggregate_stats 'stats' into an OFPST_AGGREGATE or - * NXST_AGGREGATE reply according to 'protocol', and returns the message. */ + * NXST_AGGREGATE reply matching 'request', and returns the message. */ struct ofpbuf * ofputil_encode_aggregate_stats_reply( const struct ofputil_aggregate_stats *stats, const struct ofp_header *request) { + struct ofp_aggregate_stats_reply *asr; + uint64_t packet_count; + uint64_t byte_count; struct ofpbuf *msg; enum ofpraw raw; ofpraw_decode(&raw, request); if (raw == OFPRAW_OFPST_AGGREGATE_REQUEST) { - struct ofp_aggregate_stats_reply *asr; - - msg = ofpraw_alloc_reply(OFPRAW_OFPST_AGGREGATE_REPLY, request, 0); - asr = ofpbuf_put_zeros(msg, sizeof *asr); - put_32aligned_be64(&asr->packet_count, - htonll(unknown_to_zero(stats->packet_count))); - put_32aligned_be64(&asr->byte_count, - htonll(unknown_to_zero(stats->byte_count))); - asr->flow_count = htonl(stats->flow_count); - } else if (raw == OFPRAW_NXST_AGGREGATE_REQUEST) { - struct nx_aggregate_stats_reply *nasr; - - msg = ofpraw_alloc_reply(OFPRAW_NXST_AGGREGATE_REPLY, request, 0); - nasr = ofpbuf_put_zeros(msg, sizeof *nasr); - nasr->packet_count = htonll(stats->packet_count); - nasr->byte_count = htonll(stats->byte_count); - nasr->flow_count = htonl(stats->flow_count); + packet_count = unknown_to_zero(stats->packet_count); + byte_count = unknown_to_zero(stats->byte_count); } else { - NOT_REACHED(); + packet_count = stats->packet_count; + byte_count = stats->byte_count; } + msg = ofpraw_alloc_stats_reply(request, 0); + asr = ofpbuf_put_zeros(msg, sizeof *asr); + put_32aligned_be64(&asr->packet_count, htonll(packet_count)); + put_32aligned_be64(&asr->byte_count, htonll(byte_count)); + asr->flow_count = htonl(stats->flow_count); + return msg; } @@ -1668,26 +1663,16 @@ enum ofperr ofputil_decode_aggregate_stats_reply(struct ofputil_aggregate_stats *stats, const struct ofp_header *reply) { + struct ofp_aggregate_stats_reply *asr; struct ofpbuf msg; - enum ofpraw raw; ofpbuf_use_const(&msg, reply, ntohs(reply->length)); - raw = ofpraw_pull_assert(&msg); - if (raw == OFPRAW_OFPST_AGGREGATE_REPLY) { - struct ofp_aggregate_stats_reply *asr = msg.l3; - - stats->packet_count = ntohll(get_32aligned_be64(&asr->packet_count)); - stats->byte_count = ntohll(get_32aligned_be64(&asr->byte_count)); - stats->flow_count = ntohl(asr->flow_count); - } else if (raw == OFPRAW_NXST_AGGREGATE_REPLY) { - struct nx_aggregate_stats_reply *nasr = msg.l3; - - stats->packet_count = ntohll(nasr->packet_count); - stats->byte_count = ntohll(nasr->byte_count); - stats->flow_count = ntohl(nasr->flow_count); - } else { - NOT_REACHED(); - } + ofpraw_pull_assert(&msg); + + asr = msg.l3; + stats->packet_count = ntohll(get_32aligned_be64(&asr->packet_count)); + stats->byte_count = ntohll(get_32aligned_be64(&asr->byte_count)); + stats->flow_count = ntohl(asr->flow_count); return 0; }