blob: 7fa7560b383c9faa82456e95a1aa0a1a07e7f0de [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;
Fahad Naeem Khan1f8fb2e2014-09-25 16:39:18 -070021import java.net.SocketAddress;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080022import java.util.Collection;
23import java.util.Date;
24import java.util.List;
25import java.util.Map;
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070026import java.util.Set;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080027import java.util.concurrent.Future;
Jonathan Harta99ec672014-04-03 11:30:34 -070028
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080029import net.floodlightcontroller.core.IFloodlightProviderService.Role;
Jonathan Hartb32b24c2014-08-19 15:02:01 -070030import net.floodlightcontroller.core.web.serializers.IOFSwitchSerializer;
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070031import net.floodlightcontroller.debugcounter.IDebugCounterService;
32import net.floodlightcontroller.debugcounter.IDebugCounterService.CounterException;
33import net.floodlightcontroller.threadpool.IThreadPoolService;
34import net.floodlightcontroller.util.OrderedCollection;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080035
Jonathan Hartb32b24c2014-08-19 15:02:01 -070036import org.codehaus.jackson.map.annotate.JsonSerialize;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080037import org.jboss.netty.channel.Channel;
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070038import org.projectfloodlight.openflow.protocol.OFActionType;
39import org.projectfloodlight.openflow.protocol.OFCapabilities;
40import org.projectfloodlight.openflow.protocol.OFDescStatsReply;
Jonathan Harta213bce2014-08-11 15:44:07 -070041import org.projectfloodlight.openflow.protocol.OFFactory;
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070042import org.projectfloodlight.openflow.protocol.OFMessage;
43import org.projectfloodlight.openflow.protocol.OFPortDesc;
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070044import org.projectfloodlight.openflow.protocol.OFPortStatus;
45import org.projectfloodlight.openflow.protocol.OFStatsReply;
46import org.projectfloodlight.openflow.protocol.OFStatsRequest;
47import org.projectfloodlight.openflow.protocol.OFVersion;
48import org.projectfloodlight.openflow.types.U64;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080049
Jonathan Hartb32b24c2014-08-19 15:02:01 -070050@JsonSerialize(using = IOFSwitchSerializer.class)
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080051public interface IOFSwitch {
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070052
53 /**
54 * OF1.3 switches should support role-request messages as in the 1.3 spec.
55 * OF1.0 switches may or may not support the Nicira role request extensions.
56 * To indicate the support, this property should be set by the associated
57 * OF1.0 switch driver in the net.onrc.onos.core.drivermanager package.
58 * The property will be ignored for OF1.3 switches.
59 */
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080060 public static final String SWITCH_SUPPORTS_NX_ROLE = "supportsNxRole";
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070061
62
63 //************************
64 // Channel related
65 //************************
66
67 /**
68 * Disconnects the switch by closing the TCP connection. Results in a call
69 * to the channel handler's channelDisconnected method for cleanup
70 * @throws IOException
71 */
72 public void disconnectSwitch();
Ray Milkey269ffb92014-04-03 14:43:30 -070073
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080074 /**
75 * Writes to the OFMessage to the output stream.
76 * The message will be handed to the floodlightProvider for possible filtering
77 * and processing by message listeners
Ray Milkey269ffb92014-04-03 14:43:30 -070078 *
79 * @param m
80 * @param bc
81 * @throws IOException
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080082 */
Ray Milkey269ffb92014-04-03 14:43:30 -070083 public void write(OFMessage m, FloodlightContext bc) throws IOException;
84
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080085 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070086 * Writes the list of messages to the output stream.
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080087 * The message will be handed to the floodlightProvider for possible filtering
88 * and processing by message listeners.
Ray Milkey269ffb92014-04-03 14:43:30 -070089 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080090 * @param msglist
91 * @param bc
92 * @throws IOException
93 */
94 public void write(List<OFMessage> msglist, FloodlightContext bc) throws IOException;
Ray Milkey269ffb92014-04-03 14:43:30 -070095
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080096 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070097 * Gets the date the switch connected to this controller.
Ray Milkey269ffb92014-04-03 14:43:30 -070098 *
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070099 * @return the date
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800100 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700101 public Date getConnectedSince();
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800102
103 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700104 * Gets the next available transaction id.
105 *
106 * @return the next transaction ID
107 */
108 public int getNextTransactionId();
109
110 /**
111 * Checks if the switch is still connected.
112 * Only call while holding processMessageLock
113 *
114 * @return whether the switch is still disconnected
115 */
116 public boolean isConnected();
Fahad Naeem Khan1f8fb2e2014-09-25 16:39:18 -0700117
118 /**
119 * retun the channelSocket ip address with port number
120 * @return channelSocketAddress
121 */
122 public SocketAddress getChannelSocketAddress();
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700123
124 /**
125 * Sets whether the switch is connected.
126 * Only call while holding modifySwitchLock
127 *
128 * @param connected whether the switch is connected
129 */
130 public void setConnected(boolean connected);
131
132 /**
133 * Flushes all flows queued for this switch in the current thread.
134 * NOTE: The contract is limited to the current thread
135 */
136 public void flush();
137
138 /**
139 * Sets the Netty Channel this switch instance is associated with.
140 * <p>
141 * Called immediately after instantiation
142 *
143 * @param channel
144 */
145 public void setChannel(Channel channel);
146
147 //************************
148 // Switch features related
149 //************************
150
151 /**
152 * Gets the datapathId of the switch.
Ray Milkey269ffb92014-04-03 14:43:30 -0700153 *
Jonathan Hart99ff20a2014-06-15 16:53:00 -0700154 * @return the switch buffers
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800155 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700156 public long getId();
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800157
158 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700159 * Gets a string version of the ID for this switch.
Ray Milkey269ffb92014-04-03 14:43:30 -0700160 *
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700161 * @return string version of the ID
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800162 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700163 public String getStringId();
Ray Milkey269ffb92014-04-03 14:43:30 -0700164
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800165 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700166 * Gets the number of buffers.
Ray Milkey269ffb92014-04-03 14:43:30 -0700167 *
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700168 * @return the number of buffers
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800169 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700170 public int getNumBuffers();
171
172 public Set<OFCapabilities> getCapabilities();
173
174 public byte getNumTables();
175
176 /**
177 * Returns an OFDescStatsReply message object. Use the methods contained
178 * to retrieve switch descriptions for Manufacturer, Hw/Sw version etc.
179 */
180 public OFDescStatsReply getSwitchDescription();
181
182// /**
183// * Returns a Future object that can be used to retrieve the asynchronous
184// * OFStatisticsReply when it is available.
185// *
186// * @param request statistics request
187// * @return Future object wrapping OFStatisticsReply
188// * @throws IOException
189// */
190// public Future<OFFeaturesReply> getFeaturesReplyFromSwitch()
191// throws IOException;
192//
193// /**
194// * Deliver the featuresReply future reply
195// *
196// * @param reply the reply to deliver
197// */
198// void deliverOFFeaturesReply(OFMessage reply);
199
200 /**
201 * Cancel features reply with a specific transaction ID
202 * @param transactionId the transaction ID
203 */
204 public void cancelFeaturesReply(int transactionId);
205
206 /**
207 * Gets the OFActionType set.
208 * <p>
209 * getActions has relevance only for an OpenFlow 1.0 switch.
210 * For OF1.3, each table can support different actions
211 *
212 * @return the action set
213 */
214 public Set<OFActionType> getActions();
215
Jonathan Harta213bce2014-08-11 15:44:07 -0700216 /**
217 * Gets an OpenFlow message factory that can be used to create messages to
218 * send to this switch.
219 *
220 * @return an OFFactory for the correct OpenFlow version
221 */
222 public OFFactory getFactory();
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700223
Jonathan Harta213bce2014-08-11 15:44:07 -0700224 /**
225 * Gets the OpenFlow version (eg. OF1.0, OF1.3) for this switch.
226 *
227 * @return the OpenFlow version of the switch
228 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700229 public OFVersion getOFVersion();
230
Jonathan Harta213bce2014-08-11 15:44:07 -0700231 /**
232 * Sets the OpenFlow version (eg. OF1.0, OF1.3) for this switch.
233 */
234 public void setOFVersion(OFVersion ofv);
235
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700236
237 //************************
238 // Switch port related
239 //************************
240
241 /**
242 * the type of change that happened to an open flow port
243 */
244 public enum PortChangeType {
245 /** Either a new port has been added by the switch, or we are
246 * adding a port we just deleted (via a prior notification) due to
247 * a change in the portNumber-portName mapping.
248 */
249 ADD,
250 /** some other feature of the port has changed (eg. speed)*/
251 OTHER_UPDATE,
252 /** Either a port has been deleted by the switch, or we are deleting
253 * a port whose portNumber-portName mapping has changed. Note that in
254 * the latter case, a subsequent notification will be sent out to add a
255 * port with the new portNumber-portName mapping.
256 */
257 DELETE,
258 /** Port is up (i.e. enabled). Presumably an earlier notification had
259 * indicated that it was down. To be UP implies that the port is
260 * administratively considered UP (see ofp_port_config) AND the port
261 * link is up AND the port is no longer blocked (see ofp_port_state).
262 */
263 UP,
264 /** Port is down (i.e. disabled). Presumably an earlier notification had
265 * indicated that it was up, or the port was always up.
266 * To be DOWN implies that the port has been either
267 * administratively brought down (see ofp_port_config) OR the port
268 * link is down OR the port is blocked (see ofp_port_state).
269 */
270 DOWN,
271 }
272
273 /**
274 * Describes a change of an open flow port.
275 */
276 public static class PortChangeEvent {
277 public final OFPortDesc port;
278 public final PortChangeType type;
279 /**
280 * @param port
281 * @param type
282 */
283 public PortChangeEvent(OFPortDesc port,
284 PortChangeType type) {
285 this.port = port;
286 this.type = type;
287 }
288 /* (non-Javadoc)
289 * @see java.lang.Object#hashCode()
290 */
291 @Override
292 public int hashCode() {
293 final int prime = 31;
294 int result = 1;
295 result = prime * result + ((port == null) ? 0 : port.hashCode());
296 result = prime * result + ((type == null) ? 0 : type.hashCode());
297 return result;
298 }
299 /* (non-Javadoc)
300 * @see java.lang.Object#equals(java.lang.Object)
301 */
302 @Override
303 public boolean equals(Object obj) {
304 if (this == obj) return true;
305 if (obj == null) return false;
306 if (getClass() != obj.getClass()) return false;
307 PortChangeEvent other = (PortChangeEvent) obj;
308 if (port == null) {
309 if (other.port != null) return false;
310 } else if (!port.equals(other.port)) return false;
311 if (type != other.type) return false;
312 return true;
313 }
314 /* (non-Javadoc)
315 * @see java.lang.Object#toString()
316 */
317 @Override
318 public String toString() {
319 return "[" + type + " " + port.toString() + "]";
320 }
321 }
322
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800323
324 /**
325 * Get list of all enabled ports. This will typically be different from
326 * the list of ports in the OFFeaturesReply, since that one is a static
327 * snapshot of the ports at the time the switch connected to the controller
328 * whereas this port list also reflects the port status messages that have
329 * been received.
Ray Milkey269ffb92014-04-03 14:43:30 -0700330 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800331 * @return Unmodifiable list of ports not backed by the underlying collection
332 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700333 public Collection<OFPortDesc> getEnabledPorts();
Ray Milkey269ffb92014-04-03 14:43:30 -0700334
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800335 /**
336 * Get list of the port numbers of all enabled ports. This will typically
337 * be different from the list of ports in the OFFeaturesReply, since that
Ray Milkey269ffb92014-04-03 14:43:30 -0700338 * one is a static snapshot of the ports at the time the switch connected
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800339 * to the controller whereas this port list also reflects the port status
340 * messages that have been received.
Ray Milkey269ffb92014-04-03 14:43:30 -0700341 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800342 * @return Unmodifiable list of ports not backed by the underlying collection
343 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700344 public Collection<Integer> getEnabledPortNumbers();
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800345
346 /**
347 * Retrieve the port object by the port number. The port object
348 * is the one that reflects the port status updates that have been
349 * received, not the one from the features reply.
Ray Milkey269ffb92014-04-03 14:43:30 -0700350 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800351 * @param portNumber
352 * @return port object
353 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700354 public OFPortDesc getPort(int portNumber);
Ray Milkey269ffb92014-04-03 14:43:30 -0700355
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800356 /**
357 * Retrieve the port object by the port name. The port object
358 * is the one that reflects the port status updates that have been
359 * received, not the one from the features reply.
Ray Milkey269ffb92014-04-03 14:43:30 -0700360 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800361 * @param portName
362 * @return port object
363 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700364 public OFPortDesc getPort(String portName);
Ray Milkey269ffb92014-04-03 14:43:30 -0700365
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800366 /**
367 * Add or modify a switch port. This is called by the core controller
368 * code in response to a OFPortStatus message. It should not typically be
369 * called by other floodlight applications.
Ray Milkey269ffb92014-04-03 14:43:30 -0700370 *
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700371 * OFPPR_MODIFY and OFPPR_ADD will be treated as equivalent. The OpenFlow
372 * spec is not clear on whether portNames are portNumbers are considered
373 * authoritative identifiers. We treat portNames <-> portNumber mappings
374 * as fixed. If they change, we delete all previous conflicting ports and
375 * add all new ports.
Ray Milkey269ffb92014-04-03 14:43:30 -0700376 *
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700377 * @param ps the port status message
378 * @return the ordered Collection of changes "applied" to the old ports
379 * of the switch according to the PortStatus message. A single PortStatus
380 * message can result in multiple changes.
381 * If portName <-> portNumber mappings have
382 * changed, the iteration order ensures that delete events for old
383 * conflicting appear before before events adding new ports
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800384 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700385 public OrderedCollection<PortChangeEvent> processOFPortStatus(OFPortStatus ps);
Ray Milkey269ffb92014-04-03 14:43:30 -0700386
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800387 /**
388 * Get list of all ports. This will typically be different from
389 * the list of ports in the OFFeaturesReply, since that one is a static
390 * snapshot of the ports at the time the switch connected to the controller
391 * whereas this port list also reflects the port status messages that have
392 * been received.
Ray Milkey269ffb92014-04-03 14:43:30 -0700393 *
394 * @return Unmodifiable list of ports
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800395 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700396 public Collection<OFPortDesc> getPorts();
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800397
398 /**
399 * @param portName
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 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700403 public boolean portEnabled(int portName);
Ray Milkey269ffb92014-04-03 14:43:30 -0700404
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800405 /**
406 * @param portNumber
407 * @return Whether a port is enabled per latest port status message
408 * (not configured down nor link down nor in spanning tree blocking state)
409 */
410 public boolean portEnabled(String portName);
411
412 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700413 * Compute the changes that would be required to replace the old ports
414 * of this switch with the new ports
415 * @param ports new ports to set
416 * @return the ordered collection of changes "applied" to the old ports
417 * of the switch in order to set them to the new set.
418 * If portName <-> portNumber mappings have
419 * changed, the iteration order ensures that delete events for old
420 * conflicting appear before before events adding new ports
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800421 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700422 public OrderedCollection<PortChangeEvent>
423 comparePorts(Collection<OFPortDesc> ports);
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800424
425 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700426 * Replace the ports of this switch with the given ports.
427 * @param ports new ports to set
428 * @return the ordered collection of changes "applied" to the old ports
429 * of the switch in order to set them to the new set.
430 * If portName <-> portNumber mappings have
431 * changed, the iteration order ensures that delete events for old
432 * conflicting appear before before events adding new ports
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800433 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700434 public OrderedCollection<PortChangeEvent>
435 setPorts(Collection<OFPortDesc> ports);
436
437// XXX S The odd use of providing an API call to 'set ports' (above) would
438// logically suggest that there should be a way to delete or unset the ports.
439// Right now we forbid this. We should probably not use setPorts too.
440//
441// /**
442// * Delete a port for the switch. This is called by the core controller
443// * code in response to a OFPortStatus message. It should not typically be
444// * called by other floodlight applications.
445// *
446// * @param portNumber
447// */
448// public void deletePort(short portNumber);
449//
450// /**
451// * Delete a port for the switch. This is called by the core controller
452// * code in response to a OFPortStatus message. It should not typically be
453// * called by other floodlight applications.
454// *
455// * @param portName
456// */
457// public void deletePort(String portName);
458
459
460 //*******************************************
461 // IOFSwitch object attributes
462 //************************
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800463
464 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700465 * Gets attributes of this switch.
Ray Milkey269ffb92014-04-03 14:43:30 -0700466 *
Jonathan Hart99ff20a2014-06-15 16:53:00 -0700467 * @return attributes of the switch
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800468 */
469 public Map<Object, Object> getAttributes();
470
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700471 /**
472 * Checks if a specific switch property exists for this switch
473 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800474 * @param name name of property
475 * @return value for name
476 */
477 boolean hasAttribute(String name);
478
479 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700480 * Gets properties for switch specific behavior.
Ray Milkey269ffb92014-04-03 14:43:30 -0700481 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800482 * @param name name of property
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700483 * @return 'value' for 'name', or null if no entry for 'name' exists
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800484 */
485 Object getAttribute(String name);
486
487 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700488 * Sets properties for switch specific behavior.
Ray Milkey269ffb92014-04-03 14:43:30 -0700489 *
490 * @param name name of property
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800491 * @param value value for name
492 */
493 void setAttribute(String name, Object value);
494
495 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700496 * Removes properties for switch specific behavior.
Ray Milkey269ffb92014-04-03 14:43:30 -0700497 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800498 * @param name name of property
499 * @return current value for name or null (if not present)
500 */
501 Object removeAttribute(String name);
502
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700503 //************************
504 // Switch statistics
505 //************************
506
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800507 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700508 * Delivers the statistics future reply.
509 *
510 * @param reply the reply to deliver
511 */
512 public void deliverStatisticsReply(OFMessage reply);
513
514 /**
515 * Cancels the statistics reply with the given transaction ID.
516 *
517 * @param transactionId the transaction ID
518 */
519 public void cancelStatisticsReply(int transactionId);
520
521 /**
522 * Cancels all statistics replies.
523 */
524 public void cancelAllStatisticsReplies();
525
526 /**
527 * Gets a Future object that can be used to retrieve the asynchronous.
528 * OFStatisticsReply when it is available.
529 *
530 * @param request statistics request
531 * @return Future object wrapping OFStatisticsReply
532 * @throws IOException
533 */
534 public Future<List<OFStatsReply>> getStatistics(OFStatsRequest<?> request)
535 throws IOException;
536
537 //************************
538 // Switch other utilities
539 //************************
540
541 /**
542 * Clears all flowmods on this switch.
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800543 */
544 public void clearAllFlowMods();
545
546 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700547 * Gets the current role of this controller for this IOFSwitch.
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800548 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700549 public Role getRole();
Ray Milkey269ffb92014-04-03 14:43:30 -0700550
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800551 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700552 * Sets this controller's Role for this IOFSwitch to role.
Ray Milkey269ffb92014-04-03 14:43:30 -0700553 *
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700554 * @param role
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800555 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700556 public void setRole(Role role);
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800557
558 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700559 * Gets the next generation ID.
560 * <p>
561 * Note: relevant for role request messages in OF1.3
Ray Milkey269ffb92014-04-03 14:43:30 -0700562 *
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700563 * @return next generation ID
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800564 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700565 public U64 getNextGenerationId();
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800566
567 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700568 * Sets IFloodlightProviderService for this switch instance.
569 * <p>
570 * Called immediately after instantiation
571 *
572 * @param controller
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800573 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700574 public void setFloodlightProvider(IFloodlightProviderService controller);
575
576 /**
577 * Sets IThreadPoolService for this switch instance.
578 * <p>
579 * Called immediately after instantiation
580 *
581 * @param threadPool
582 */
583 public void setThreadPoolService(IThreadPoolService threadPool);
584
585 /**
586 * Set debug counter service for per-switch counters
587 * Called immediately after instantiation
588 * @param debugCounters
589 * @throws CounterException
590 */
591 public void setDebugCounterService(IDebugCounterService debugCounter)
592 throws CounterException;
593
594 /**
595 * Start this switch driver's sub handshake. This might be a no-op but
596 * this method must be called at least once for the switch to be become
597 * ready.
598 * This method must only be called from the I/O thread
599 * @throws IOException
600 * @throws SwitchDriverSubHandshakeAlreadyStarted if the sub-handshake has
601 * already been started
602 */
603 public void startDriverHandshake() throws IOException;
604
605 /**
606 * Check if the sub-handshake for this switch driver has been completed.
607 * This method can only be called after startDriverHandshake()
608 *
609 * This methods must only be called from the I/O thread
610 * @return true if the sub-handshake has been completed. False otherwise
611 * @throws SwitchDriverSubHandshakeNotStarted if startDriverHandshake() has
612 * not been called yet.
613 */
614 public boolean isDriverHandshakeComplete();
615
616 /**
617 * Pass the given OFMessage to the driver as part of this driver's
618 * sub-handshake. Must not be called after the handshake has been completed
619 * This methods must only be called from the I/O thread
620 * @param m The message that the driver should process
621 * @throws SwitchDriverSubHandshakeCompleted if isDriverHandshake() returns
622 * false before this method call
623 * @throws SwitchDriverSubHandshakeNotStarted if startDriverHandshake() has
624 * not been called yet.
625 */
626 public void processDriverHandshakeMessage(OFMessage m);
627
628 /**
629 * Set the flow table full flag in the switch
630 * XXX S Rethink this for multiple tables
631 */
632 public void setTableFull(boolean isFull);
633
Saurav Dasfc5e3eb2014-09-25 19:05:21 -0700634 /**
635 * Get the switch driver hanshake state
636 */
637 public String getSwitchDriverState();
638
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800639}