blob: 72ec404a07bb0c44a934dda38bc188a838a2c8ec [file] [log] [blame]
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08001/**
Ray Milkey269ffb92014-04-03 14:43:30 -07002 * Copyright 2011, Big Switch Networks, Inc.
3 * Originally created by David Erickson, Stanford University
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 * not use this file except in compliance with the License. You may obtain
7 * a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations
15 * under the License.
16 **/
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080017
18package net.floodlightcontroller.core;
19
20import java.io.IOException;
21import java.util.Collection;
22import java.util.Date;
23import java.util.List;
24import java.util.Map;
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070025import java.util.Set;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080026import java.util.concurrent.Future;
Jonathan Harta99ec672014-04-03 11:30:34 -070027
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080028import net.floodlightcontroller.core.IFloodlightProviderService.Role;
Jonathan Hartb32b24c2014-08-19 15:02:01 -070029import net.floodlightcontroller.core.web.serializers.IOFSwitchSerializer;
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070030import net.floodlightcontroller.debugcounter.IDebugCounterService;
31import net.floodlightcontroller.debugcounter.IDebugCounterService.CounterException;
32import net.floodlightcontroller.threadpool.IThreadPoolService;
33import net.floodlightcontroller.util.OrderedCollection;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080034
Jonathan Hartb32b24c2014-08-19 15:02:01 -070035import org.codehaus.jackson.map.annotate.JsonSerialize;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080036import org.jboss.netty.channel.Channel;
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070037import org.projectfloodlight.openflow.protocol.OFActionType;
38import org.projectfloodlight.openflow.protocol.OFCapabilities;
39import org.projectfloodlight.openflow.protocol.OFDescStatsReply;
Jonathan Harta213bce2014-08-11 15:44:07 -070040import org.projectfloodlight.openflow.protocol.OFFactory;
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070041import org.projectfloodlight.openflow.protocol.OFMessage;
42import org.projectfloodlight.openflow.protocol.OFPortDesc;
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070043import org.projectfloodlight.openflow.protocol.OFPortStatus;
44import org.projectfloodlight.openflow.protocol.OFStatsReply;
45import org.projectfloodlight.openflow.protocol.OFStatsRequest;
46import org.projectfloodlight.openflow.protocol.OFVersion;
47import org.projectfloodlight.openflow.types.U64;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080048
Jonathan Hartb32b24c2014-08-19 15:02:01 -070049@JsonSerialize(using = IOFSwitchSerializer.class)
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080050public interface IOFSwitch {
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070051
52 /**
53 * OF1.3 switches should support role-request messages as in the 1.3 spec.
54 * OF1.0 switches may or may not support the Nicira role request extensions.
55 * To indicate the support, this property should be set by the associated
56 * OF1.0 switch driver in the net.onrc.onos.core.drivermanager package.
57 * The property will be ignored for OF1.3 switches.
58 */
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080059 public static final String SWITCH_SUPPORTS_NX_ROLE = "supportsNxRole";
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070060
61
62 //************************
63 // Channel related
64 //************************
65
66 /**
67 * Disconnects the switch by closing the TCP connection. Results in a call
68 * to the channel handler's channelDisconnected method for cleanup
69 * @throws IOException
70 */
71 public void disconnectSwitch();
Ray Milkey269ffb92014-04-03 14:43:30 -070072
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080073 /**
74 * Writes to the OFMessage to the output stream.
75 * The message will be handed to the floodlightProvider for possible filtering
76 * and processing by message listeners
Ray Milkey269ffb92014-04-03 14:43:30 -070077 *
78 * @param m
79 * @param bc
80 * @throws IOException
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080081 */
Ray Milkey269ffb92014-04-03 14:43:30 -070082 public void write(OFMessage m, FloodlightContext bc) throws IOException;
83
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080084 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070085 * Writes the list of messages to the output stream.
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080086 * The message will be handed to the floodlightProvider for possible filtering
87 * and processing by message listeners.
Ray Milkey269ffb92014-04-03 14:43:30 -070088 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080089 * @param msglist
90 * @param bc
91 * @throws IOException
92 */
93 public void write(List<OFMessage> msglist, FloodlightContext bc) throws IOException;
Ray Milkey269ffb92014-04-03 14:43:30 -070094
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080095 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070096 * Gets the date the switch connected to this controller.
Ray Milkey269ffb92014-04-03 14:43:30 -070097 *
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070098 * @return the date
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080099 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700100 public Date getConnectedSince();
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800101
102 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700103 * Gets the next available transaction id.
104 *
105 * @return the next transaction ID
106 */
107 public int getNextTransactionId();
108
109 /**
110 * Checks if the switch is still connected.
111 * Only call while holding processMessageLock
112 *
113 * @return whether the switch is still disconnected
114 */
115 public boolean isConnected();
116
117 /**
118 * Sets whether the switch is connected.
119 * Only call while holding modifySwitchLock
120 *
121 * @param connected whether the switch is connected
122 */
123 public void setConnected(boolean connected);
124
125 /**
126 * Flushes all flows queued for this switch in the current thread.
127 * NOTE: The contract is limited to the current thread
128 */
129 public void flush();
130
131 /**
132 * Sets the Netty Channel this switch instance is associated with.
133 * <p>
134 * Called immediately after instantiation
135 *
136 * @param channel
137 */
138 public void setChannel(Channel channel);
139
140 //************************
141 // Switch features related
142 //************************
143
144 /**
145 * Gets the datapathId of the switch.
Ray Milkey269ffb92014-04-03 14:43:30 -0700146 *
Jonathan Hart99ff20a2014-06-15 16:53:00 -0700147 * @return the switch buffers
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800148 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700149 public long getId();
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800150
151 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700152 * Gets a string version of the ID for this switch.
Ray Milkey269ffb92014-04-03 14:43:30 -0700153 *
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700154 * @return string version of the ID
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800155 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700156 public String getStringId();
Ray Milkey269ffb92014-04-03 14:43:30 -0700157
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800158 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700159 * Gets the number of buffers.
Ray Milkey269ffb92014-04-03 14:43:30 -0700160 *
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700161 * @return the number of buffers
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800162 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700163 public int getNumBuffers();
164
165 public Set<OFCapabilities> getCapabilities();
166
167 public byte getNumTables();
168
169 /**
170 * Returns an OFDescStatsReply message object. Use the methods contained
171 * to retrieve switch descriptions for Manufacturer, Hw/Sw version etc.
172 */
173 public OFDescStatsReply getSwitchDescription();
174
175// /**
176// * Returns a Future object that can be used to retrieve the asynchronous
177// * OFStatisticsReply when it is available.
178// *
179// * @param request statistics request
180// * @return Future object wrapping OFStatisticsReply
181// * @throws IOException
182// */
183// public Future<OFFeaturesReply> getFeaturesReplyFromSwitch()
184// throws IOException;
185//
186// /**
187// * Deliver the featuresReply future reply
188// *
189// * @param reply the reply to deliver
190// */
191// void deliverOFFeaturesReply(OFMessage reply);
192
193 /**
194 * Cancel features reply with a specific transaction ID
195 * @param transactionId the transaction ID
196 */
197 public void cancelFeaturesReply(int transactionId);
198
199 /**
200 * Gets the OFActionType set.
201 * <p>
202 * getActions has relevance only for an OpenFlow 1.0 switch.
203 * For OF1.3, each table can support different actions
204 *
205 * @return the action set
206 */
207 public Set<OFActionType> getActions();
208
Jonathan Harta213bce2014-08-11 15:44:07 -0700209 /**
210 * Gets an OpenFlow message factory that can be used to create messages to
211 * send to this switch.
212 *
213 * @return an OFFactory for the correct OpenFlow version
214 */
215 public OFFactory getFactory();
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700216
Jonathan Harta213bce2014-08-11 15:44:07 -0700217 /**
218 * Gets the OpenFlow version (eg. OF1.0, OF1.3) for this switch.
219 *
220 * @return the OpenFlow version of the switch
221 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700222 public OFVersion getOFVersion();
223
Jonathan Harta213bce2014-08-11 15:44:07 -0700224 /**
225 * Sets the OpenFlow version (eg. OF1.0, OF1.3) for this switch.
226 */
227 public void setOFVersion(OFVersion ofv);
228
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700229
230 //************************
231 // Switch port related
232 //************************
233
234 /**
235 * the type of change that happened to an open flow port
236 */
237 public enum PortChangeType {
238 /** Either a new port has been added by the switch, or we are
239 * adding a port we just deleted (via a prior notification) due to
240 * a change in the portNumber-portName mapping.
241 */
242 ADD,
243 /** some other feature of the port has changed (eg. speed)*/
244 OTHER_UPDATE,
245 /** Either a port has been deleted by the switch, or we are deleting
246 * a port whose portNumber-portName mapping has changed. Note that in
247 * the latter case, a subsequent notification will be sent out to add a
248 * port with the new portNumber-portName mapping.
249 */
250 DELETE,
251 /** Port is up (i.e. enabled). Presumably an earlier notification had
252 * indicated that it was down. To be UP implies that the port is
253 * administratively considered UP (see ofp_port_config) AND the port
254 * link is up AND the port is no longer blocked (see ofp_port_state).
255 */
256 UP,
257 /** Port is down (i.e. disabled). Presumably an earlier notification had
258 * indicated that it was up, or the port was always up.
259 * To be DOWN implies that the port has been either
260 * administratively brought down (see ofp_port_config) OR the port
261 * link is down OR the port is blocked (see ofp_port_state).
262 */
263 DOWN,
264 }
265
266 /**
267 * Describes a change of an open flow port.
268 */
269 public static class PortChangeEvent {
270 public final OFPortDesc port;
271 public final PortChangeType type;
272 /**
273 * @param port
274 * @param type
275 */
276 public PortChangeEvent(OFPortDesc port,
277 PortChangeType type) {
278 this.port = port;
279 this.type = type;
280 }
281 /* (non-Javadoc)
282 * @see java.lang.Object#hashCode()
283 */
284 @Override
285 public int hashCode() {
286 final int prime = 31;
287 int result = 1;
288 result = prime * result + ((port == null) ? 0 : port.hashCode());
289 result = prime * result + ((type == null) ? 0 : type.hashCode());
290 return result;
291 }
292 /* (non-Javadoc)
293 * @see java.lang.Object#equals(java.lang.Object)
294 */
295 @Override
296 public boolean equals(Object obj) {
297 if (this == obj) return true;
298 if (obj == null) return false;
299 if (getClass() != obj.getClass()) return false;
300 PortChangeEvent other = (PortChangeEvent) obj;
301 if (port == null) {
302 if (other.port != null) return false;
303 } else if (!port.equals(other.port)) return false;
304 if (type != other.type) return false;
305 return true;
306 }
307 /* (non-Javadoc)
308 * @see java.lang.Object#toString()
309 */
310 @Override
311 public String toString() {
312 return "[" + type + " " + port.toString() + "]";
313 }
314 }
315
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800316
317 /**
318 * Get list of all enabled ports. This will typically be different from
319 * the list of ports in the OFFeaturesReply, since that one is a static
320 * snapshot of the ports at the time the switch connected to the controller
321 * whereas this port list also reflects the port status messages that have
322 * been received.
Ray Milkey269ffb92014-04-03 14:43:30 -0700323 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800324 * @return Unmodifiable list of ports not backed by the underlying collection
325 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700326 public Collection<OFPortDesc> getEnabledPorts();
Ray Milkey269ffb92014-04-03 14:43:30 -0700327
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800328 /**
329 * Get list of the port numbers of all enabled ports. This will typically
330 * be different from the list of ports in the OFFeaturesReply, since that
Ray Milkey269ffb92014-04-03 14:43:30 -0700331 * one is a static snapshot of the ports at the time the switch connected
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800332 * to the controller whereas this port list also reflects the port status
333 * messages that have been received.
Ray Milkey269ffb92014-04-03 14:43:30 -0700334 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800335 * @return Unmodifiable list of ports not backed by the underlying collection
336 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700337 public Collection<Integer> getEnabledPortNumbers();
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800338
339 /**
340 * Retrieve the port object by the port number. The port object
341 * is the one that reflects the port status updates that have been
342 * received, not the one from the features reply.
Ray Milkey269ffb92014-04-03 14:43:30 -0700343 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800344 * @param portNumber
345 * @return port object
346 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700347 public OFPortDesc getPort(int portNumber);
Ray Milkey269ffb92014-04-03 14:43:30 -0700348
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800349 /**
350 * Retrieve the port object by the port name. The port object
351 * is the one that reflects the port status updates that have been
352 * received, not the one from the features reply.
Ray Milkey269ffb92014-04-03 14:43:30 -0700353 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800354 * @param portName
355 * @return port object
356 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700357 public OFPortDesc getPort(String portName);
Ray Milkey269ffb92014-04-03 14:43:30 -0700358
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800359 /**
360 * Add or modify a switch port. This is called by the core controller
361 * code in response to a OFPortStatus message. It should not typically be
362 * called by other floodlight applications.
Ray Milkey269ffb92014-04-03 14:43:30 -0700363 *
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700364 * OFPPR_MODIFY and OFPPR_ADD will be treated as equivalent. The OpenFlow
365 * spec is not clear on whether portNames are portNumbers are considered
366 * authoritative identifiers. We treat portNames <-> portNumber mappings
367 * as fixed. If they change, we delete all previous conflicting ports and
368 * add all new ports.
Ray Milkey269ffb92014-04-03 14:43:30 -0700369 *
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700370 * @param ps the port status message
371 * @return the ordered Collection of changes "applied" to the old ports
372 * of the switch according to the PortStatus message. A single PortStatus
373 * message can result in multiple changes.
374 * If portName <-> portNumber mappings have
375 * changed, the iteration order ensures that delete events for old
376 * conflicting appear before before events adding new ports
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800377 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700378 public OrderedCollection<PortChangeEvent> processOFPortStatus(OFPortStatus ps);
Ray Milkey269ffb92014-04-03 14:43:30 -0700379
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800380 /**
381 * Get list of all ports. This will typically be different from
382 * the list of ports in the OFFeaturesReply, since that one is a static
383 * snapshot of the ports at the time the switch connected to the controller
384 * whereas this port list also reflects the port status messages that have
385 * been received.
Ray Milkey269ffb92014-04-03 14:43:30 -0700386 *
387 * @return Unmodifiable list of ports
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800388 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700389 public Collection<OFPortDesc> getPorts();
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800390
391 /**
392 * @param portName
393 * @return Whether a port is enabled per latest port status message
394 * (not configured down nor link down nor in spanning tree blocking state)
395 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700396 public boolean portEnabled(int portName);
Ray Milkey269ffb92014-04-03 14:43:30 -0700397
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800398 /**
399 * @param portNumber
400 * @return Whether a port is enabled per latest port status message
401 * (not configured down nor link down nor in spanning tree blocking state)
402 */
403 public boolean portEnabled(String portName);
404
405 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700406 * Compute the changes that would be required to replace the old ports
407 * of this switch with the new ports
408 * @param ports new ports to set
409 * @return the ordered collection of changes "applied" to the old ports
410 * of the switch in order to set them to the new set.
411 * If portName <-> portNumber mappings have
412 * changed, the iteration order ensures that delete events for old
413 * conflicting appear before before events adding new ports
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800414 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700415 public OrderedCollection<PortChangeEvent>
416 comparePorts(Collection<OFPortDesc> ports);
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800417
418 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700419 * Replace the ports of this switch with the given ports.
420 * @param ports new ports to set
421 * @return the ordered collection of changes "applied" to the old ports
422 * of the switch in order to set them to the new set.
423 * If portName <-> portNumber mappings have
424 * changed, the iteration order ensures that delete events for old
425 * conflicting appear before before events adding new ports
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800426 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700427 public OrderedCollection<PortChangeEvent>
428 setPorts(Collection<OFPortDesc> ports);
429
430// XXX S The odd use of providing an API call to 'set ports' (above) would
431// logically suggest that there should be a way to delete or unset the ports.
432// Right now we forbid this. We should probably not use setPorts too.
433//
434// /**
435// * Delete a port for the switch. This is called by the core controller
436// * code in response to a OFPortStatus message. It should not typically be
437// * called by other floodlight applications.
438// *
439// * @param portNumber
440// */
441// public void deletePort(short portNumber);
442//
443// /**
444// * Delete a port for the switch. This is called by the core controller
445// * code in response to a OFPortStatus message. It should not typically be
446// * called by other floodlight applications.
447// *
448// * @param portName
449// */
450// public void deletePort(String portName);
451
452
453 //*******************************************
454 // IOFSwitch object attributes
455 //************************
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800456
457 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700458 * Gets attributes of this switch.
Ray Milkey269ffb92014-04-03 14:43:30 -0700459 *
Jonathan Hart99ff20a2014-06-15 16:53:00 -0700460 * @return attributes of the switch
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800461 */
462 public Map<Object, Object> getAttributes();
463
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700464 /**
465 * Checks if a specific switch property exists for this switch
466 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800467 * @param name name of property
468 * @return value for name
469 */
470 boolean hasAttribute(String name);
471
472 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700473 * Gets properties for switch specific behavior.
Ray Milkey269ffb92014-04-03 14:43:30 -0700474 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800475 * @param name name of property
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700476 * @return 'value' for 'name', or null if no entry for 'name' exists
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800477 */
478 Object getAttribute(String name);
479
480 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700481 * Sets properties for switch specific behavior.
Ray Milkey269ffb92014-04-03 14:43:30 -0700482 *
483 * @param name name of property
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800484 * @param value value for name
485 */
486 void setAttribute(String name, Object value);
487
488 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700489 * Removes properties for switch specific behavior.
Ray Milkey269ffb92014-04-03 14:43:30 -0700490 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800491 * @param name name of property
492 * @return current value for name or null (if not present)
493 */
494 Object removeAttribute(String name);
495
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700496 //************************
497 // Switch statistics
498 //************************
499
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800500 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700501 * Delivers the statistics future reply.
502 *
503 * @param reply the reply to deliver
504 */
505 public void deliverStatisticsReply(OFMessage reply);
506
507 /**
508 * Cancels the statistics reply with the given transaction ID.
509 *
510 * @param transactionId the transaction ID
511 */
512 public void cancelStatisticsReply(int transactionId);
513
514 /**
515 * Cancels all statistics replies.
516 */
517 public void cancelAllStatisticsReplies();
518
519 /**
520 * Gets a Future object that can be used to retrieve the asynchronous.
521 * OFStatisticsReply when it is available.
522 *
523 * @param request statistics request
524 * @return Future object wrapping OFStatisticsReply
525 * @throws IOException
526 */
527 public Future<List<OFStatsReply>> getStatistics(OFStatsRequest<?> request)
528 throws IOException;
529
530 //************************
531 // Switch other utilities
532 //************************
533
534 /**
535 * Clears all flowmods on this switch.
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800536 */
537 public void clearAllFlowMods();
538
539 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700540 * Gets the current role of this controller for this IOFSwitch.
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800541 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700542 public Role getRole();
Ray Milkey269ffb92014-04-03 14:43:30 -0700543
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800544 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700545 * Sets this controller's Role for this IOFSwitch to role.
Ray Milkey269ffb92014-04-03 14:43:30 -0700546 *
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700547 * @param role
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800548 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700549 public void setRole(Role role);
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800550
551 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700552 * Gets the next generation ID.
553 * <p>
554 * Note: relevant for role request messages in OF1.3
Ray Milkey269ffb92014-04-03 14:43:30 -0700555 *
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700556 * @return next generation ID
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800557 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700558 public U64 getNextGenerationId();
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800559
560 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700561 * Sets IFloodlightProviderService for this switch instance.
562 * <p>
563 * Called immediately after instantiation
564 *
565 * @param controller
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800566 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700567 public void setFloodlightProvider(IFloodlightProviderService controller);
568
569 /**
570 * Sets IThreadPoolService for this switch instance.
571 * <p>
572 * Called immediately after instantiation
573 *
574 * @param threadPool
575 */
576 public void setThreadPoolService(IThreadPoolService threadPool);
577
578 /**
579 * Set debug counter service for per-switch counters
580 * Called immediately after instantiation
581 * @param debugCounters
582 * @throws CounterException
583 */
584 public void setDebugCounterService(IDebugCounterService debugCounter)
585 throws CounterException;
586
587 /**
588 * Start this switch driver's sub handshake. This might be a no-op but
589 * this method must be called at least once for the switch to be become
590 * ready.
591 * This method must only be called from the I/O thread
592 * @throws IOException
593 * @throws SwitchDriverSubHandshakeAlreadyStarted if the sub-handshake has
594 * already been started
595 */
596 public void startDriverHandshake() throws IOException;
597
598 /**
599 * Check if the sub-handshake for this switch driver has been completed.
600 * This method can only be called after startDriverHandshake()
601 *
602 * This methods must only be called from the I/O thread
603 * @return true if the sub-handshake has been completed. False otherwise
604 * @throws SwitchDriverSubHandshakeNotStarted if startDriverHandshake() has
605 * not been called yet.
606 */
607 public boolean isDriverHandshakeComplete();
608
609 /**
610 * Pass the given OFMessage to the driver as part of this driver's
611 * sub-handshake. Must not be called after the handshake has been completed
612 * This methods must only be called from the I/O thread
613 * @param m The message that the driver should process
614 * @throws SwitchDriverSubHandshakeCompleted if isDriverHandshake() returns
615 * false before this method call
616 * @throws SwitchDriverSubHandshakeNotStarted if startDriverHandshake() has
617 * not been called yet.
618 */
619 public void processDriverHandshakeMessage(OFMessage m);
620
621 /**
622 * Set the flow table full flag in the switch
623 * XXX S Rethink this for multiple tables
624 */
625 public void setTableFull(boolean isFull);
626
Saurav Dasfc5e3eb2014-09-25 19:05:21 -0700627 /**
628 * Get the switch driver hanshake state
629 */
630 public String getSwitchDriverState();
631
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800632}