blob: f11b0b1f83e19d485ec53db75f0cf41ceffcd1e3 [file] [log] [blame]
Jonathan Hart23701d12014-04-03 10:45:48 -07001package net.onrc.onos.core.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 net.floodlightcontroller.core.internal.OFMessageFuture;
Naoki Shiota8ee48d52013-11-11 15:51:17 -08006import net.floodlightcontroller.core.module.IFloodlightService;
Brian O'Connorc67f9fa2014-08-07 18:17:46 -07007import net.onrc.onos.core.intent.FlowEntry;
Brian O'Connoraa5a7b92014-08-29 14:45:18 -07008import net.onrc.onos.core.matchaction.MatchActionOperationEntry;
Jonathan Hart5302b6c2014-08-13 15:57:59 -07009import net.onrc.onos.core.util.Dpid;
Naoki Shiota8ee48d52013-11-11 15:51:17 -080010
Pavlin Radoslavovb05aac92014-08-26 18:26:10 -070011import org.apache.commons.lang3.tuple.Pair;
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070012import org.projectfloodlight.openflow.protocol.OFBarrierReply;
13import org.projectfloodlight.openflow.protocol.OFMessage;
Jonathan Harta99ec672014-04-03 11:30:34 -070014
Naoki Shiotab485d412013-11-26 12:04:19 -080015/**
16 * FlowPusherService is a service to send message to switches in proper rate.
17 * Conceptually a queue is attached to each switch, and FlowPusherService
18 * read a message from queue and send it to switch in order.
19 * To guarantee message has been installed, FlowPusherService can add barrier
20 * message to queue and can notify when barrier message is sent to switch.
Naoki Shiotab485d412013-11-26 12:04:19 -080021 */
Naoki Shiota8ee48d52013-11-11 15:51:17 -080022public interface IFlowPusherService extends IFloodlightService {
Ray Milkey8e5170e2014-04-02 12:09:55 -070023 public static enum MsgPriority {
Jonathan Hart5302b6c2014-08-13 15:57:59 -070024 HIGH, // High priority: e.g. flow synchronization
Ray Milkey8e5170e2014-04-02 12:09:55 -070025 NORMAL, // Normal priority
Jonathan Hart5302b6c2014-08-13 15:57:59 -070026 // LOW, // Low priority, not needed for now
Ray Milkey8e5170e2014-04-02 12:09:55 -070027 }
28
Naoki Shiota8df97bc2014-03-13 18:42:23 -070029 public static enum QueueState {
Ray Milkey8e5170e2014-04-02 12:09:55 -070030 READY, // Queues with all priority are at work
31 SUSPENDED, // Only prior queue is at work
32 UNKNOWN
33 }
Naoki Shiota8df97bc2014-03-13 18:42:23 -070034
Ray Milkey8e5170e2014-04-02 12:09:55 -070035 /**
36 * Create a queue correspondent to the switch.
37 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -070038 * @param dpid DPID of the switch to which new queue is attached.
Ray Milkey8e5170e2014-04-02 12:09:55 -070039 * @return true if new queue is successfully created.
40 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -070041 boolean createQueue(Dpid dpid);
Naoki Shiotae3199732013-11-25 16:14:43 -080042
Ray Milkey8e5170e2014-04-02 12:09:55 -070043 /**
44 * Delete a queue correspondent to the switch.
45 * Messages remains in queue will be all sent before queue is deleted.
46 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -070047 * @param dpid DPID of the switch from which the queue is deleted.
Ray Milkey8e5170e2014-04-02 12:09:55 -070048 * @return true if queue is successfully deleted.
49 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -070050 boolean deleteQueue(Dpid dpid);
Naoki Shiotac1601d32013-11-20 10:47:34 -080051
Ray Milkey8e5170e2014-04-02 12:09:55 -070052 /**
53 * Delete a queue correspondent to the switch.
54 * By setting force flag on, queue will be deleted immediately.
55 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -070056 * @param dpid DPID of the switch from which the queue is deleted.
Ray Milkey8e5170e2014-04-02 12:09:55 -070057 * @param forceStop If this flag is set to true, queue will be deleted
58 * immediately regardless of any messages in the queue.
59 * If false, all messages will be sent to switch and queue will
60 * be deleted after that.
61 * @return true if queue is successfully deleted or flagged to be deleted.
62 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -070063 boolean deleteQueue(Dpid dpid, boolean forceStop);
Pavlin Radoslavovab3f8862013-12-04 18:35:53 -080064
Ray Milkey8e5170e2014-04-02 12:09:55 -070065 /**
66 * Add a message to the queue of the switch with normal priority.
67 * <p/>
68 * Note: Notification is NOT delivered for the pushed message.
69 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -070070 * @param dpid DPID of the switch to which the message is pushed.
Ray Milkey8e5170e2014-04-02 12:09:55 -070071 * @param msg Message object to be added.
72 * @return true if message is successfully added to a queue.
73 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -070074 boolean add(Dpid dpid, OFMessage msg);
Naoki Shiotac1601d32013-11-20 10:47:34 -080075
Ray Milkey8e5170e2014-04-02 12:09:55 -070076 /**
77 * Add a message to the queue of the switch with specific priority.
78 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -070079 * @param dpid DPID of the switch to which the message is pushed.
Ray Milkey8e5170e2014-04-02 12:09:55 -070080 * @param msg Message object to be added.
81 * @param priority Sending priority of the message.
82 * @return true if message is successfully added to a queue.
83 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -070084 boolean add(Dpid dpid, OFMessage msg, MsgPriority priority);
Ray Milkey8e5170e2014-04-02 12:09:55 -070085
86 /**
87 * Push a collection of Flow Entries to the corresponding switches
88 * with normal priority.
89 * <p/>
90 * Note: Notification is delivered for the Flow Entries that
91 * are pushed successfully.
92 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -070093 * @param entries the collection of <Dpid, FlowEntry> pairs
Ray Milkey8e5170e2014-04-02 12:09:55 -070094 * to push.
95 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -070096 void pushFlowEntries(Collection<Pair<Dpid, FlowEntry>> entries);
Ray Milkey8e5170e2014-04-02 12:09:55 -070097
98 /**
99 * Push a collection of Flow Entries to the corresponding switches
100 * with specific priority.
101 * <p/>
102 * Note: Notification is delivered for the Flow Entries that
103 * are pushed successfully.
104 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700105 * @param entries the collection of <Dpid, FlowEntry> pairs
Ray Milkey8e5170e2014-04-02 12:09:55 -0700106 * to push.
107 * @param priority Sending priority of flow entries.
108 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700109 void pushFlowEntries(Collection<Pair<Dpid, FlowEntry>> entries,
Ray Milkey8e5170e2014-04-02 12:09:55 -0700110 MsgPriority priority);
111
112 /**
113 * Create a message from FlowEntry and add it to the queue of the
114 * switch with normal priority.
115 * <p/>
116 * Note: Notification is delivered for the Flow Entries that
117 * are pushed successfully.
118 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700119 * @param dpid DPID of the switch to which the message is pushed.
Ray Milkey8e5170e2014-04-02 12:09:55 -0700120 * @param flowEntry FlowEntry object used for creating message.
Ray Milkey8e5170e2014-04-02 12:09:55 -0700121 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700122 void pushFlowEntry(Dpid dpid, FlowEntry flowEntry);
Ray Milkey8e5170e2014-04-02 12:09:55 -0700123
124 /**
125 * Create a message from FlowEntry and add it to the queue of the
126 * switch with specific priority.
127 * <p/>
128 * Note: Notification is delivered for the Flow Entries that
129 * are pushed successfully.
130 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700131 * @param dpid DPID of the switch to which the message is pushed.
Ray Milkey8e5170e2014-04-02 12:09:55 -0700132 * @param flowEntry FlowEntry object used for creating message.
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700133 * @param priority Sending priority of flow entries.
Ray Milkey8e5170e2014-04-02 12:09:55 -0700134 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700135 void pushFlowEntry(Dpid dpid, FlowEntry flowEntry,
Ray Milkey8e5170e2014-04-02 12:09:55 -0700136 MsgPriority priority);
137
138 /**
Brian O'Connoraa5a7b92014-08-29 14:45:18 -0700139 * Create a message from MatchAction and add it to the queue of the switch
140 * with normal priority.
141 *
142 * @param matchActionOp MatchAction to use
143 */
144 void pushMatchAction(MatchActionOperationEntry matchActionOp);
145
146 /**
147 * Create messages for a collection of MatchActions and add them to the
148 * appropriate queue.
149 *
150 * @param matchActionOps Collection of MatchAction to use
151 */
152 void pushMatchActions(Collection<MatchActionOperationEntry> matchActionOps);
153
154 /**
Ray Milkey8e5170e2014-04-02 12:09:55 -0700155 * Set sending rate to a switch.
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700156 * <p/>
157 * TODO The rate limiter function currently does not work as we are unable
158 * to determine the size of the messages when using Loxi.
Ray Milkey8e5170e2014-04-02 12:09:55 -0700159 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700160 * @param dpid DPID of the switch to alter the sending rate of.
Ray Milkey8e5170e2014-04-02 12:09:55 -0700161 * @param rate Rate in bytes/ms.
162 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700163 public void setRate(Dpid dpid, long rate);
Ray Milkey8e5170e2014-04-02 12:09:55 -0700164
165 /**
166 * Add BARRIER message to queue and wait for reply.
167 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700168 * @param dpid DPID of the switch to which a barrier message is pushed.
Ray Milkey8e5170e2014-04-02 12:09:55 -0700169 * @return BARRIER_REPLY message sent from switch.
170 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700171 OFBarrierReply barrier(Dpid dpid);
Ray Milkey8e5170e2014-04-02 12:09:55 -0700172
173 /**
174 * Add BARRIER message to queue asynchronously.
175 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700176 * @param dpid DPID of the switch to which a barrier message is pushed.
Ray Milkey8e5170e2014-04-02 12:09:55 -0700177 * @return Future object of BARRIER_REPLY message which will be sent from switch.
178 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700179 OFMessageFuture<OFBarrierReply> barrierAsync(Dpid dpid);
Ray Milkey8e5170e2014-04-02 12:09:55 -0700180
181 /**
182 * Suspend pushing message to a switch.
183 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700184 * @param dpid DPID of the switch whose queue is to be suspended.
Ray Milkey8e5170e2014-04-02 12:09:55 -0700185 * @return true if success
186 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700187 boolean suspend(Dpid dpid);
Ray Milkey8e5170e2014-04-02 12:09:55 -0700188
189 /**
190 * Resume pushing message to a switch.
191 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700192 * @param dpid DPID of the switch whose queue is to be resumed.
Ray Milkey8e5170e2014-04-02 12:09:55 -0700193 * @return true if success
194 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700195 boolean resume(Dpid dpid);
Ray Milkey8e5170e2014-04-02 12:09:55 -0700196
197 /**
198 * Get state of queue attached to a switch.
199 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700200 * @param dpid DPID of the switch to be checked.
Ray Milkey8e5170e2014-04-02 12:09:55 -0700201 * @return State of queue.
202 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700203 QueueState getState(Dpid dpid);
Naoki Shiota8ee48d52013-11-11 15:51:17 -0800204}