[ovs-dev] [PATCH 26/41] ofp-util: Add function to encode OFPT_SET_ASYNC messages.
Ben Pfaff
blp at ovn.org
Tue Jan 19 07:27:13 UTC 2016
This isn't used yet but it will be in future commits.
This also looks forward to supporting Open vSwitch extensions to OAM_*,
which will be coming up soon.
Signed-off-by: Ben Pfaff <blp at ovn.org>
---
lib/ofp-msgs.h | 3 +++
lib/ofp-util.c | 32 +++++++++++++++++++++++++++++---
lib/ofp-util.h | 9 ++++++++-
ofproto/ofproto.c | 2 +-
4 files changed, 41 insertions(+), 5 deletions(-)
diff --git a/lib/ofp-msgs.h b/lib/ofp-msgs.h
index 54018b4..4f95607 100644
--- a/lib/ofp-msgs.h
+++ b/lib/ofp-msgs.h
@@ -238,6 +238,8 @@ enum ofpraw {
OFPRAW_OFPT13_SET_ASYNC,
/* NXT 1.0+ (19): struct nx_async_config. */
OFPRAW_NXT_SET_ASYNC_CONFIG,
+ /* NXT 1.0-1.3 (27): uint8_t[8][]. */
+ OFPRAW_NXT_SET_ASYNC_CONFIG2,
/* OFPT 1.4+ (28): uint8_t[8][]. */
OFPRAW_OFPT14_SET_ASYNC,
@@ -560,6 +562,7 @@ enum ofptype {
OFPTYPE_GET_ASYNC_REPLY, /* OFPRAW_OFPT13_GET_ASYNC_REPLY.
* OFPRAW_OFPT14_GET_ASYNC_REPLY. */
OFPTYPE_SET_ASYNC_CONFIG, /* OFPRAW_NXT_SET_ASYNC_CONFIG.
+ * OFPRAW_NXT_SET_ASYNC_CONFIG2.
* OFPRAW_OFPT13_SET_ASYNC.
* OFPRAW_OFPT14_SET_ASYNC. */
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 5bb0b74..4850aa5 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -9612,7 +9612,8 @@ ofputil_decode_set_async_config(const struct ofp_header *oh, bool loose,
decode_legacy_async_masks(msg->flow_removed_mask, OAM_FLOW_REMOVED,
oh->version, ac);
} else if (raw == OFPRAW_OFPT14_SET_ASYNC ||
- raw == OFPRAW_OFPT14_GET_ASYNC_REPLY) {
+ raw == OFPRAW_OFPT14_GET_ASYNC_REPLY ||
+ raw == OFPRAW_NXT_SET_ASYNC_CONFIG2) {
*ac = *basis;
while (b.size > 0) {
struct ofpbuf property;
@@ -9694,8 +9695,8 @@ ofputil_put_async_config__(const struct ofputil_async_cfg *ac,
/* Encodes and returns a reply to the OFPT_GET_ASYNC_REQUEST in 'oh' that
* states that the asynchronous message configuration is 'ac'. */
struct ofpbuf *
-ofputil_encode_get_async_config(const struct ofp_header *oh,
- const struct ofputil_async_cfg *ac)
+ofputil_encode_get_async_reply(const struct ofp_header *oh,
+ const struct ofputil_async_cfg *ac)
{
struct ofpbuf *buf;
@@ -9711,6 +9712,31 @@ ofputil_encode_get_async_config(const struct ofp_header *oh,
return buf;
}
+/* Encodes and returns a message, in a format appropriate for OpenFlow version
+ * 'ofp_version', that sets the asynchronous message configuration to 'ac'.
+ *
+ * Specify 'oams' as a bitmap of OAM_* that indicate the asynchronous messages
+ * to configure. OF1.0 through OF1.3 can't natively configure a subset of
+ * messages, so more messages than requested may be configured. OF1.0 through
+ * OF1.3 also can't configure OVS extension OAM_* values, so if 'oam' includes
+ * any extensions then this function encodes an Open vSwitch extension message
+ * that does support configuring OVS extension OAM_*. */
+struct ofpbuf *
+ofputil_encode_set_async_config(const struct ofputil_async_cfg *ac,
+ uint32_t oams, enum ofp_version ofp_version)
+{
+ enum ofpraw raw = (ofp_version >= OFP14_VERSION ? OFPRAW_OFPT14_SET_ASYNC
+ : oams & OAM_EXTENSIONS ? OFPRAW_NXT_SET_ASYNC_CONFIG2
+ : ofp_version >= OFP13_VERSION ? OFPRAW_OFPT13_SET_ASYNC
+ : OFPRAW_NXT_SET_ASYNC_CONFIG);
+ struct ofpbuf *request = ofpraw_alloc(raw, ofp_version, 0);
+ ofputil_put_async_config__(ac, request,
+ (raw == OFPRAW_OFPT14_SET_ASYNC ||
+ raw == OFPRAW_NXT_SET_ASYNC_CONFIG2),
+ ofp_version, oams);
+ return request;
+}
+
struct ofputil_async_cfg
ofputil_async_cfg_default(enum ofp_version version)
{
diff --git a/lib/ofp-util.h b/lib/ofp-util.h
index 88c67f9..1c359b3 100644
--- a/lib/ofp-util.h
+++ b/lib/ofp-util.h
@@ -1299,12 +1299,17 @@ enum ofperr ofputil_decode_tlv_table_reply(const struct ofp_header *,
void ofputil_uninit_tlv_table(struct ovs_list *mappings);
enum ofputil_async_msg_type {
+ /* Standard asynchronous messages. */
OAM_PACKET_IN, /* OFPT_PACKET_IN or NXT_PACKET_IN. */
OAM_PORT_STATUS, /* OFPT_PORT_STATUS. */
OAM_FLOW_REMOVED, /* OFPT_FLOW_REMOVED or NXT_FLOW_REMOVED. */
OAM_ROLE_STATUS, /* OFPT_ROLE_STATUS. */
OAM_TABLE_STATUS, /* OFPT_TABLE_STATUS. */
OAM_REQUESTFORWARD, /* OFPT_REQUESTFORWARD. */
+
+ /* Extension asynchronous messages (none yet--coming soon!). */
+#define OAM_EXTENSIONS 0 /* Bitmap of all extensions. */
+
OAM_N_TYPES
};
const char *ofputil_async_msg_type_to_string(enum ofputil_async_msg_type);
@@ -1320,8 +1325,10 @@ enum ofperr ofputil_decode_set_async_config(const struct ofp_header *,
const struct ofputil_async_cfg *,
struct ofputil_async_cfg *);
-struct ofpbuf *ofputil_encode_get_async_config(
+struct ofpbuf *ofputil_encode_get_async_reply(
const struct ofp_header *, const struct ofputil_async_cfg *);
+struct ofpbuf *ofputil_encode_set_async_config(
+ const struct ofputil_async_cfg *, uint32_t oams, enum ofp_version);
struct ofputil_async_cfg ofputil_async_cfg_default(enum ofp_version);
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 957e323..cbd9c47 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -5425,7 +5425,7 @@ static enum ofperr
handle_nxt_get_async_request(struct ofconn *ofconn, const struct ofp_header *oh)
{
struct ofputil_async_cfg ac = ofconn_get_async_config(ofconn);
- ofconn_send_reply(ofconn, ofputil_encode_get_async_config(oh, &ac));
+ ofconn_send_reply(ofconn, ofputil_encode_get_async_reply(oh, &ac));
return 0;
}
--
2.1.3
More information about the dev
mailing list