[firefly] [PATCH 1/3] ofproto: implement OFPT_GET_ASYNC_REQUEST

Alexandru Copot alex.mihai.c at gmail.com
Sat Sep 7 12:04:22 EEST 2013


Signed-off-by: Alexandru Copot <alex.mihai.c at gmail.com>
---
 ofproto/connmgr.c |  9 +++++++++
 ofproto/connmgr.h |  3 +++
 ofproto/ofproto.c | 29 ++++++++++++++++++++++++++++-
 3 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c
index 1e9ef5b..2f315e6 100644
--- a/ofproto/connmgr.c
+++ b/ofproto/connmgr.c
@@ -985,6 +985,15 @@ ofconn_set_async_config(struct ofconn *ofconn,
     memcpy(ofconn->slave_async_config, slave_masks, size);
 }
 
+void
+ofconn_get_async_config(struct ofconn *ofconn,
+                        uint32_t *master_masks, uint32_t *slave_masks)
+{
+    size_t size = sizeof ofconn->master_async_config;
+    memcpy(master_masks, ofconn->master_async_config, size);
+    memcpy(slave_masks, ofconn->slave_async_config, size);
+}
+
 /* Sends 'msg' on 'ofconn', accounting it as a reply.  (If there is a
  * sufficient number of OpenFlow replies in-flight on a single ofconn, then the
  * connmgr will stop accepting new OpenFlow requests on that ofconn until the
diff --git a/ofproto/connmgr.h b/ofproto/connmgr.h
index f92a523..72134b0 100644
--- a/ofproto/connmgr.h
+++ b/ofproto/connmgr.h
@@ -118,6 +118,9 @@ void ofconn_set_miss_send_len(struct ofconn *, int miss_send_len);
 void ofconn_set_async_config(struct ofconn *,
                              const uint32_t master_masks[OAM_N_TYPES],
                              const uint32_t slave_masks[OAM_N_TYPES]);
+void ofconn_get_async_config(struct ofconn *,
+                             uint32_t *master_masks,
+                             uint32_t *slave_masks);
 
 void ofconn_send_reply(const struct ofconn *, struct ofpbuf *);
 void ofconn_send_replies(const struct ofconn *, struct list *);
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index b94fd8e..36151dd 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -4122,6 +4122,31 @@ handle_nxt_set_async_config(struct ofconn *ofconn, const struct ofp_header *oh)
 }
 
 static enum ofperr
+handle_nxt_get_async_request(struct ofconn *ofconn, const struct ofp_header *oh)
+{
+    struct ofpbuf *buf;
+    uint32_t master[OAM_N_TYPES];
+    uint32_t slave[OAM_N_TYPES];
+    struct nx_async_config *msg;
+
+    ofconn_get_async_config(ofconn, master, slave);
+    buf = ofpraw_alloc_reply(OFPRAW_OFPT13_GET_ASYNC_REPLY, oh, 0);
+    msg = ofpbuf_put_zeros(buf, sizeof *msg);
+
+    msg->packet_in_mask[0] = ntohl(master[OAM_PACKET_IN]);
+    msg->port_status_mask[0] = ntohl(master[OAM_PORT_STATUS]);
+    msg->flow_removed_mask[0] = ntohl(master[OAM_FLOW_REMOVED]);
+
+    msg->packet_in_mask[1] = ntohl(slave[OAM_PACKET_IN]);
+    msg->port_status_mask[1] = ntohl(slave[OAM_PORT_STATUS]);
+    msg->flow_removed_mask[1] = ntohl(slave[OAM_FLOW_REMOVED]);
+
+    ofconn_send_reply(ofconn, buf);
+
+    return 0;
+}
+
+static enum ofperr
 handle_nxt_set_controller_id(struct ofconn *ofconn,
                              const struct ofp_header *oh)
 {
@@ -5193,6 +5218,9 @@ handle_openflow__(struct ofconn *ofconn, const struct ofpbuf *msg)
     case OFPTYPE_SET_ASYNC_CONFIG:
         return handle_nxt_set_async_config(ofconn, oh);
 
+    case OFPTYPE_GET_ASYNC_REQUEST:
+        return handle_nxt_get_async_request(ofconn, oh);
+
         /* Statistics requests. */
     case OFPTYPE_DESC_STATS_REQUEST:
         return handle_desc_stats_request(ofconn, oh);
@@ -5236,7 +5264,6 @@ handle_openflow__(struct ofconn *ofconn, const struct ofpbuf *msg)
 
         /* FIXME: Change the following once they are implemented: */
     case OFPTYPE_QUEUE_GET_CONFIG_REQUEST:
-    case OFPTYPE_GET_ASYNC_REQUEST:
     case OFPTYPE_TABLE_FEATURES_STATS_REQUEST:
         return OFPERR_OFPBRC_BAD_TYPE;
 
-- 
1.8.4



More information about the firefly mailing list