blob: 37911a8fcd5d064e586bba67f2eff95851a70487 [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 Shiota8ee48d52013-11-11 15:51:17 -08005import net.floodlightcontroller.core.IOFSwitch;
Naoki Shiotac1601d32013-11-20 10:47:34 -08006import net.floodlightcontroller.core.internal.OFMessageFuture;
Naoki Shiota8ee48d52013-11-11 15:51:17 -08007import net.floodlightcontroller.core.module.IFloodlightService;
Jonathan Hart23701d12014-04-03 10:45:48 -07008import net.onrc.onos.core.util.FlowEntry;
9import net.onrc.onos.core.util.Pair;
Naoki Shiota8ee48d52013-11-11 15:51:17 -080010
Jonathan Harta99ec672014-04-03 11:30:34 -070011import org.openflow.protocol.OFBarrierReply;
12import org.openflow.protocol.OFMessage;
13
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.
Naoki Shiotab485d412013-11-26 12:04:19 -080020 */
Naoki Shiota8ee48d52013-11-11 15:51:17 -080021public interface IFlowPusherService extends IFloodlightService {
Ray Milkey8e5170e2014-04-02 12:09:55 -070022 public static enum MsgPriority {
23 HIGH, // High priority: e.g. flow synchronization
24 NORMAL, // Normal priority
Ray Milkey269ffb92014-04-03 14:43:30 -070025// LOW, // Low priority, not needed for now
Ray Milkey8e5170e2014-04-02 12:09:55 -070026 }
27
Naoki Shiota8df97bc2014-03-13 18:42:23 -070028 public static enum QueueState {
Ray Milkey8e5170e2014-04-02 12:09:55 -070029 READY, // Queues with all priority are at work
30 SUSPENDED, // Only prior queue is at work
31 UNKNOWN
32 }
Naoki Shiota8df97bc2014-03-13 18:42:23 -070033
Ray Milkey8e5170e2014-04-02 12:09:55 -070034 /**
35 * Create a queue correspondent to the switch.
36 *
37 * @param sw Switch to which new queue is attached.
38 * @return true if new queue is successfully created.
39 */
40 boolean createQueue(IOFSwitch sw);
Naoki Shiotae3199732013-11-25 16:14:43 -080041
Ray Milkey8e5170e2014-04-02 12:09:55 -070042 /**
43 * Delete a queue correspondent to the switch.
44 * Messages remains in queue will be all sent before queue is deleted.
45 *
46 * @param sw Switch of which queue is deleted.
47 * @return true if queue is successfully deleted.
48 */
49 boolean deleteQueue(IOFSwitch sw);
Naoki Shiotac1601d32013-11-20 10:47:34 -080050
Ray Milkey8e5170e2014-04-02 12:09:55 -070051 /**
52 * Delete a queue correspondent to the switch.
53 * By setting force flag on, queue will be deleted immediately.
54 *
55 * @param sw Switch of which queue is deleted.
56 * @param forceStop If this flag is set to true, queue will be deleted
57 * immediately regardless of any messages in the queue.
58 * If false, all messages will be sent to switch and queue will
59 * be deleted after that.
60 * @return true if queue is successfully deleted or flagged to be deleted.
61 */
62 boolean deleteQueue(IOFSwitch sw, boolean forceStop);
Pavlin Radoslavovab3f8862013-12-04 18:35:53 -080063
Ray Milkey8e5170e2014-04-02 12:09:55 -070064 /**
65 * Add a message to the queue of the switch with normal priority.
66 * <p/>
67 * Note: Notification is NOT delivered for the pushed message.
68 *
69 * @param sw Switch to which message is pushed.
70 * @param msg Message object to be added.
71 * @return true if message is successfully added to a queue.
72 */
73 boolean add(IOFSwitch sw, OFMessage msg);
Naoki Shiotac1601d32013-11-20 10:47:34 -080074
Ray Milkey8e5170e2014-04-02 12:09:55 -070075 /**
76 * Add a message to the queue of the switch with specific priority.
77 *
78 * @param sw Switch to which message is pushed.
79 * @param msg Message object to be added.
80 * @param priority Sending priority of the message.
81 * @return true if message is successfully added to a queue.
82 */
83 boolean add(IOFSwitch sw, OFMessage msg, MsgPriority priority);
84
85 /**
86 * Push a collection of Flow Entries to the corresponding switches
87 * with normal priority.
88 * <p/>
89 * Note: Notification is delivered for the Flow Entries that
90 * are pushed successfully.
91 *
92 * @param entries the collection of <IOFSwitch, FlowEntry> pairs
93 * to push.
94 */
95 void pushFlowEntries(Collection<Pair<IOFSwitch, FlowEntry>> entries);
96
97 /**
98 * Push a collection of Flow Entries to the corresponding switches
99 * with specific priority.
100 * <p/>
101 * Note: Notification is delivered for the Flow Entries that
102 * are pushed successfully.
103 *
104 * @param entries the collection of <IOFSwitch, FlowEntry> pairs
105 * to push.
106 * @param priority Sending priority of flow entries.
107 */
108 void pushFlowEntries(Collection<Pair<IOFSwitch, FlowEntry>> entries,
109 MsgPriority priority);
110
111 /**
112 * Create a message from FlowEntry and add it to the queue of the
113 * switch with normal priority.
114 * <p/>
115 * Note: Notification is delivered for the Flow Entries that
116 * are pushed successfully.
117 *
118 * @param sw Switch to which message is pushed.
119 * @param flowEntry FlowEntry object used for creating message.
Ray Milkey8e5170e2014-04-02 12:09:55 -0700120 */
121 void pushFlowEntry(IOFSwitch sw, FlowEntry flowEntry);
122
123 /**
124 * Create a message from FlowEntry and add it to the queue of the
125 * switch with specific priority.
126 * <p/>
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.
Ray Milkey8e5170e2014-04-02 12:09:55 -0700132 */
133 void pushFlowEntry(IOFSwitch sw, FlowEntry flowEntry,
134 MsgPriority priority);
135
136 /**
137 * Set sending rate to a switch.
138 *
139 * @param sw Switch.
140 * @param rate Rate in bytes/ms.
141 */
142 public void setRate(IOFSwitch sw, long rate);
143
144 /**
145 * Add BARRIER message to queue and wait for reply.
146 *
147 * @param sw Switch to which barrier message is pushed.
148 * @return BARRIER_REPLY message sent from switch.
149 */
150 OFBarrierReply barrier(IOFSwitch sw);
151
152 /**
153 * Add BARRIER message to queue asynchronously.
154 *
155 * @param sw Switch to which barrier message is pushed.
156 * @return Future object of BARRIER_REPLY message which will be sent from switch.
157 */
158 OFMessageFuture<OFBarrierReply> barrierAsync(IOFSwitch sw);
159
160 /**
161 * Suspend pushing message to a switch.
162 *
163 * @param sw Switch to be suspended pushing message.
164 * @return true if success
165 */
166 boolean suspend(IOFSwitch sw);
167
168 /**
169 * Resume pushing message to a switch.
170 *
171 * @param sw Switch to be resumed pushing message.
172 * @return true if success
173 */
174 boolean resume(IOFSwitch sw);
175
176 /**
177 * Get state of queue attached to a switch.
178 *
179 * @param sw Switch to be checked.
180 * @return State of queue.
181 */
182 QueueState getState(IOFSwitch sw);
Naoki Shiota8ee48d52013-11-11 15:51:17 -0800183}