Jonathan Hart | 23701d1 | 2014-04-03 10:45:48 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.flowprogrammer; |
Naoki Shiota | 8ee48d5 | 2013-11-11 15:51:17 -0800 | [diff] [blame] | 2 | |
Pavlin Radoslavov | ab3f886 | 2013-12-04 18:35:53 -0800 | [diff] [blame] | 3 | import java.util.Collection; |
| 4 | |
Naoki Shiota | c1601d3 | 2013-11-20 10:47:34 -0800 | [diff] [blame] | 5 | import net.floodlightcontroller.core.internal.OFMessageFuture; |
Naoki Shiota | 8ee48d5 | 2013-11-11 15:51:17 -0800 | [diff] [blame] | 6 | import net.floodlightcontroller.core.module.IFloodlightService; |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 7 | import net.onrc.onos.core.intent.FlowEntry; |
Brian O'Connor | aa5a7b9 | 2014-08-29 14:45:18 -0700 | [diff] [blame] | 8 | import net.onrc.onos.core.matchaction.MatchActionOperationEntry; |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 9 | import net.onrc.onos.core.util.Dpid; |
Naoki Shiota | 8ee48d5 | 2013-11-11 15:51:17 -0800 | [diff] [blame] | 10 | |
Pavlin Radoslavov | b05aac9 | 2014-08-26 18:26:10 -0700 | [diff] [blame] | 11 | import org.apache.commons.lang3.tuple.Pair; |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 12 | import org.projectfloodlight.openflow.protocol.OFBarrierReply; |
| 13 | import org.projectfloodlight.openflow.protocol.OFMessage; |
Jonathan Hart | a99ec67 | 2014-04-03 11:30:34 -0700 | [diff] [blame] | 14 | |
Naoki Shiota | b485d41 | 2013-11-26 12:04:19 -0800 | [diff] [blame] | 15 | /** |
| 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 Shiota | b485d41 | 2013-11-26 12:04:19 -0800 | [diff] [blame] | 21 | */ |
Naoki Shiota | 8ee48d5 | 2013-11-11 15:51:17 -0800 | [diff] [blame] | 22 | public interface IFlowPusherService extends IFloodlightService { |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 23 | public static enum MsgPriority { |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 24 | HIGH, // High priority: e.g. flow synchronization |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 25 | NORMAL, // Normal priority |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 26 | // LOW, // Low priority, not needed for now |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 27 | } |
| 28 | |
Naoki Shiota | 8df97bc | 2014-03-13 18:42:23 -0700 | [diff] [blame] | 29 | public static enum QueueState { |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 30 | READY, // Queues with all priority are at work |
| 31 | SUSPENDED, // Only prior queue is at work |
| 32 | UNKNOWN |
| 33 | } |
Naoki Shiota | 8df97bc | 2014-03-13 18:42:23 -0700 | [diff] [blame] | 34 | |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 35 | /** |
| 36 | * Create a queue correspondent to the switch. |
| 37 | * |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 38 | * @param dpid DPID of the switch to which new queue is attached. |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 39 | * @return true if new queue is successfully created. |
| 40 | */ |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 41 | boolean createQueue(Dpid dpid); |
Naoki Shiota | e319973 | 2013-11-25 16:14:43 -0800 | [diff] [blame] | 42 | |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 43 | /** |
| 44 | * Delete a queue correspondent to the switch. |
| 45 | * Messages remains in queue will be all sent before queue is deleted. |
| 46 | * |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 47 | * @param dpid DPID of the switch from which the queue is deleted. |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 48 | * @return true if queue is successfully deleted. |
| 49 | */ |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 50 | boolean deleteQueue(Dpid dpid); |
Naoki Shiota | c1601d3 | 2013-11-20 10:47:34 -0800 | [diff] [blame] | 51 | |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 52 | /** |
| 53 | * Delete a queue correspondent to the switch. |
| 54 | * By setting force flag on, queue will be deleted immediately. |
| 55 | * |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 56 | * @param dpid DPID of the switch from which the queue is deleted. |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 57 | * @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 Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 63 | boolean deleteQueue(Dpid dpid, boolean forceStop); |
Pavlin Radoslavov | ab3f886 | 2013-12-04 18:35:53 -0800 | [diff] [blame] | 64 | |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 65 | /** |
| 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 Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 70 | * @param dpid DPID of the switch to which the message is pushed. |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 71 | * @param msg Message object to be added. |
| 72 | * @return true if message is successfully added to a queue. |
| 73 | */ |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 74 | boolean add(Dpid dpid, OFMessage msg); |
Naoki Shiota | c1601d3 | 2013-11-20 10:47:34 -0800 | [diff] [blame] | 75 | |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 76 | /** |
| 77 | * Add a message to the queue of the switch with specific priority. |
| 78 | * |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 79 | * @param dpid DPID of the switch to which the message is pushed. |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 80 | * @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 Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 84 | boolean add(Dpid dpid, OFMessage msg, MsgPriority priority); |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 85 | |
| 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 Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 93 | * @param entries the collection of <Dpid, FlowEntry> pairs |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 94 | * to push. |
| 95 | */ |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 96 | void pushFlowEntries(Collection<Pair<Dpid, FlowEntry>> entries); |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 97 | |
| 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 Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 105 | * @param entries the collection of <Dpid, FlowEntry> pairs |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 106 | * to push. |
| 107 | * @param priority Sending priority of flow entries. |
| 108 | */ |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 109 | void pushFlowEntries(Collection<Pair<Dpid, FlowEntry>> entries, |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 110 | 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 Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 119 | * @param dpid DPID of the switch to which the message is pushed. |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 120 | * @param flowEntry FlowEntry object used for creating message. |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 121 | */ |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 122 | void pushFlowEntry(Dpid dpid, FlowEntry flowEntry); |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 123 | |
| 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 Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 131 | * @param dpid DPID of the switch to which the message is pushed. |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 132 | * @param flowEntry FlowEntry object used for creating message. |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 133 | * @param priority Sending priority of flow entries. |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 134 | */ |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 135 | void pushFlowEntry(Dpid dpid, FlowEntry flowEntry, |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 136 | MsgPriority priority); |
| 137 | |
| 138 | /** |
Brian O'Connor | aa5a7b9 | 2014-08-29 14:45:18 -0700 | [diff] [blame] | 139 | * 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 Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 155 | * Set sending rate to a switch. |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 156 | * <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 Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 159 | * |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 160 | * @param dpid DPID of the switch to alter the sending rate of. |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 161 | * @param rate Rate in bytes/ms. |
| 162 | */ |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 163 | public void setRate(Dpid dpid, long rate); |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 164 | |
| 165 | /** |
| 166 | * Add BARRIER message to queue and wait for reply. |
| 167 | * |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 168 | * @param dpid DPID of the switch to which a barrier message is pushed. |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 169 | * @return BARRIER_REPLY message sent from switch. |
| 170 | */ |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 171 | OFBarrierReply barrier(Dpid dpid); |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 172 | |
| 173 | /** |
| 174 | * Add BARRIER message to queue asynchronously. |
| 175 | * |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 176 | * @param dpid DPID of the switch to which a barrier message is pushed. |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 177 | * @return Future object of BARRIER_REPLY message which will be sent from switch. |
| 178 | */ |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 179 | OFMessageFuture<OFBarrierReply> barrierAsync(Dpid dpid); |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 180 | |
| 181 | /** |
| 182 | * Suspend pushing message to a switch. |
| 183 | * |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 184 | * @param dpid DPID of the switch whose queue is to be suspended. |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 185 | * @return true if success |
| 186 | */ |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 187 | boolean suspend(Dpid dpid); |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 188 | |
| 189 | /** |
| 190 | * Resume pushing message to a switch. |
| 191 | * |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 192 | * @param dpid DPID of the switch whose queue is to be resumed. |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 193 | * @return true if success |
| 194 | */ |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 195 | boolean resume(Dpid dpid); |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 196 | |
| 197 | /** |
| 198 | * Get state of queue attached to a switch. |
| 199 | * |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 200 | * @param dpid DPID of the switch to be checked. |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 201 | * @return State of queue. |
| 202 | */ |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame] | 203 | QueueState getState(Dpid dpid); |
Naoki Shiota | 8ee48d5 | 2013-11-11 15:51:17 -0800 | [diff] [blame] | 204 | } |