blob: 29a579eb3f5a129199b14204689cbd3c74bc88e7 [file] [log] [blame]
Naoki Shiotaaea88582013-11-12 17:58:34 -08001package net.onrc.onos.ofcontroller.flowprogrammer;
Naoki Shiota8ee48d52013-11-11 15:51:17 -08002
Pavlin Radoslavovab3f8862013-12-04 18:35:53 -08003import java.util.Collection;
4
Naoki Shiotac1601d32013-11-20 10:47:34 -08005import org.openflow.protocol.OFBarrierReply;
6import org.openflow.protocol.OFMessage;
7
Naoki Shiota8ee48d52013-11-11 15:51:17 -08008import net.floodlightcontroller.core.IOFSwitch;
Naoki Shiotac1601d32013-11-20 10:47:34 -08009import net.floodlightcontroller.core.internal.OFMessageFuture;
Naoki Shiota8ee48d52013-11-11 15:51:17 -080010import net.floodlightcontroller.core.module.IFloodlightService;
Brian O'Connor8c166a72013-11-14 18:41:48 -080011import net.onrc.onos.ofcontroller.util.FlowEntry;
Pavlin Radoslavovab3f8862013-12-04 18:35:53 -080012import net.onrc.onos.ofcontroller.util.Pair;
Naoki Shiota8ee48d52013-11-11 15:51:17 -080013
Naoki Shiotab485d412013-11-26 12:04:19 -080014/**
15 * FlowPusherService is a service to send message to switches in proper rate.
16 * Conceptually a queue is attached to each switch, and FlowPusherService
17 * read a message from queue and send it to switch in order.
18 * To guarantee message has been installed, FlowPusherService can add barrier
19 * message to queue and can notify when barrier message is sent to switch.
20 * @author Naoki Shiota
21 *
22 */
Naoki Shiota8ee48d52013-11-11 15:51:17 -080023public interface IFlowPusherService extends IFloodlightService {
Naoki Shiota8df97bc2014-03-13 18:42:23 -070024 public static enum MsgPriority {
25 HIGH, // High priority: e.g. flow synchronization
26 NORMAL, // Normal priority
27// LOW, // Low priority, not needed for now
28 }
29
30 public static enum QueueState {
31 READY, // Queues with all priority are at work
32 SUSPENDED, // Only prior queue is at work
33 UNKNOWN
34 }
35
Naoki Shiota8ee48d52013-11-11 15:51:17 -080036 /**
Naoki Shiotae3199732013-11-25 16:14:43 -080037 * Create a queue correspondent to the switch.
38 * @param sw Switch to which new queue is attached.
39 * @return true if new queue is successfully created.
40 */
41 boolean createQueue(IOFSwitch sw);
42
43 /**
44 * Delete a queue correspondent to the switch.
45 * Messages remains in queue will be all sent before queue is deleted.
46 * @param sw Switch of which queue is deleted.
47 * @return true if queue is successfully deleted.
48 */
49 boolean deleteQueue(IOFSwitch sw);
50
51 /**
52 * Delete a queue correspondent to the switch.
53 * By setting force flag on, queue will be deleted immediately.
54 * @param sw Switch of which queue is deleted.
Naoki Shiotab485d412013-11-26 12:04:19 -080055 * @param forceStop If this flag is set to true, queue will be deleted
56 * immediately regardless of any messages in the queue.
57 * If false, all messages will be sent to switch and queue will
58 * be deleted after that.
59 * @return true if queue is successfully deleted or flagged to be deleted.
Naoki Shiotae3199732013-11-25 16:14:43 -080060 */
Naoki Shiotab485d412013-11-26 12:04:19 -080061 boolean deleteQueue(IOFSwitch sw, boolean forceStop);
Naoki Shiotae3199732013-11-25 16:14:43 -080062
63 /**
Naoki Shiota8df97bc2014-03-13 18:42:23 -070064 * Add a message to the queue of the switch with normal priority.
Pavlin Radoslavovab3f8862013-12-04 18:35:53 -080065 *
66 * Note: Notification is NOT delivered for the pushed message.
67 *
Naoki Shiotac1601d32013-11-20 10:47:34 -080068 * @param sw Switch to which message is pushed.
69 * @param msg Message object to be added.
70 * @return true if message is successfully added to a queue.
Naoki Shiota8ee48d52013-11-11 15:51:17 -080071 */
Brian O'Connor8c166a72013-11-14 18:41:48 -080072 boolean add(IOFSwitch sw, OFMessage msg);
Naoki Shiotac1601d32013-11-20 10:47:34 -080073
74 /**
Naoki Shiota8df97bc2014-03-13 18:42:23 -070075 * Add a message to the queue of the switch with specific priority.
76 *
77 * @param sw Switch to which message is pushed.
78 * @param msg Message object to be added.
79 * @param priority Sending priority of the message.
80 * @return true if message is successfully added to a queue.
81 */
82 boolean add(IOFSwitch sw, OFMessage msg, MsgPriority priority);
83
84 /**
85 * Push a collection of Flow Entries to the corresponding switches
86 * with normal priority.
Pavlin Radoslavovab3f8862013-12-04 18:35:53 -080087 *
88 * Note: Notification is delivered for the Flow Entries that
89 * are pushed successfully.
90 *
91 * @param entries the collection of <IOFSwitch, FlowEntry> pairs
92 * to push.
93 */
94 void pushFlowEntries(Collection<Pair<IOFSwitch, FlowEntry>> entries);
95
96 /**
Naoki Shiota8df97bc2014-03-13 18:42:23 -070097 * Push a collection of Flow Entries to the corresponding switches
98 * with specific priority.
99 *
100 * Note: Notification is delivered for the Flow Entries that
101 * are pushed successfully.
102 *
103 * @param entries the collection of <IOFSwitch, FlowEntry> pairs
104 * to push.
105 * @param priority Sending priority of flow entries.
106 */
107 void pushFlowEntries(Collection<Pair<IOFSwitch, FlowEntry>> entries,
108 MsgPriority priority);
109
110 /**
Pavlin Radoslavovab3f8862013-12-04 18:35:53 -0800111 * Create a message from FlowEntry and add it to the queue of the
Naoki Shiota8df97bc2014-03-13 18:42:23 -0700112 * switch with normal priority.
Pavlin Radoslavovab3f8862013-12-04 18:35:53 -0800113 *
114 * Note: Notification is delivered for the Flow Entries that
115 * are pushed successfully.
116 *
Naoki Shiotac1601d32013-11-20 10:47:34 -0800117 * @param sw Switch to which message is pushed.
Naoki Shiotac1601d32013-11-20 10:47:34 -0800118 * @param flowEntry FlowEntry object used for creating message.
119 * @return true if message is successfully added to a queue.
120 */
Pavlin Radoslavovab3f8862013-12-04 18:35:53 -0800121 void pushFlowEntry(IOFSwitch sw, FlowEntry flowEntry);
Naoki Shiotac1601d32013-11-20 10:47:34 -0800122
123 /**
Naoki Shiota8df97bc2014-03-13 18:42:23 -0700124 * Create a message from FlowEntry and add it to the queue of the
125 * switch with specific priority.
126 *
127 * Note: Notification is delivered for the Flow Entries that
128 * are pushed successfully.
129 *
130 * @param sw Switch to which message is pushed.
131 * @param flowEntry FlowEntry object used for creating message.
132 * @return true if message is successfully added to a queue.
133 */
134 void pushFlowEntry(IOFSwitch sw, FlowEntry flowEntry,
135 MsgPriority priority);
136
137 /**
Naoki Shiotae3199732013-11-25 16:14:43 -0800138 * Set sending rate to a switch.
139 * @param sw Switch.
140 * @param rate Rate in bytes/ms.
141 */
142 public void setRate(IOFSwitch sw, long rate);
143
144 /**
Naoki Shiotac1601d32013-11-20 10:47:34 -0800145 * Add BARRIER message to queue and wait for reply.
146 * @param sw Switch to which barrier message is pushed.
147 * @return BARRIER_REPLY message sent from switch.
148 */
149 OFBarrierReply barrier(IOFSwitch sw);
150
151 /**
152 * Add BARRIER message to queue asynchronously.
153 * @param sw Switch to which barrier message is pushed.
154 * @return Future object of BARRIER_REPLY message which will be sent from switch.
155 */
156 OFMessageFuture<OFBarrierReply> barrierAsync(IOFSwitch sw);
Naoki Shiota8ee48d52013-11-11 15:51:17 -0800157
158 /**
159 * Suspend pushing message to a switch.
Naoki Shiotac1601d32013-11-20 10:47:34 -0800160 * @param sw Switch to be suspended pushing message.
Naoki Shiota8ee48d52013-11-11 15:51:17 -0800161 * @return true if success
162 */
Brian O'Connor8c166a72013-11-14 18:41:48 -0800163 boolean suspend(IOFSwitch sw);
Naoki Shiota8ee48d52013-11-11 15:51:17 -0800164
165 /**
166 * Resume pushing message to a switch.
Naoki Shiotac1601d32013-11-20 10:47:34 -0800167 * @param sw Switch to be resumed pushing message.
Naoki Shiota8ee48d52013-11-11 15:51:17 -0800168 * @return true if success
169 */
Brian O'Connor8c166a72013-11-14 18:41:48 -0800170 boolean resume(IOFSwitch sw);
Naoki Shiota8ee48d52013-11-11 15:51:17 -0800171
172 /**
Naoki Shiota8df97bc2014-03-13 18:42:23 -0700173 * Get state of queue attached to a switch.
Naoki Shiotac1601d32013-11-20 10:47:34 -0800174 * @param sw Switch to be checked.
Naoki Shiota8df97bc2014-03-13 18:42:23 -0700175 * @return State of queue.
Naoki Shiota8ee48d52013-11-11 15:51:17 -0800176 */
Naoki Shiota8df97bc2014-03-13 18:42:23 -0700177 QueueState getState(IOFSwitch sw);
Naoki Shiota8ee48d52013-11-11 15:51:17 -0800178}