blob: fca14a8935b1149d9a631739543cf83ab55dd9a0 [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;
Saurav Dasd84178f2014-09-29 17:48:54 -070030import net.floodlightcontroller.core.internal.OFBarrierReplyFuture;
Jonathan Hartb32b24c2014-08-19 15:02:01 -070031import net.floodlightcontroller.core.web.serializers.IOFSwitchSerializer;
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070032import net.floodlightcontroller.debugcounter.IDebugCounterService;
33import net.floodlightcontroller.debugcounter.IDebugCounterService.CounterException;
34import net.floodlightcontroller.threadpool.IThreadPoolService;
35import net.floodlightcontroller.util.OrderedCollection;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080036
Jonathan Hartb32b24c2014-08-19 15:02:01 -070037import org.codehaus.jackson.map.annotate.JsonSerialize;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080038import org.jboss.netty.channel.Channel;
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070039import org.projectfloodlight.openflow.protocol.OFActionType;
Saurav Dasd84178f2014-09-29 17:48:54 -070040import org.projectfloodlight.openflow.protocol.OFBarrierReply;
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070041import org.projectfloodlight.openflow.protocol.OFCapabilities;
42import org.projectfloodlight.openflow.protocol.OFDescStatsReply;
Jonathan Harta213bce2014-08-11 15:44:07 -070043import org.projectfloodlight.openflow.protocol.OFFactory;
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070044import org.projectfloodlight.openflow.protocol.OFMessage;
45import org.projectfloodlight.openflow.protocol.OFPortDesc;
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070046import org.projectfloodlight.openflow.protocol.OFPortStatus;
47import org.projectfloodlight.openflow.protocol.OFStatsReply;
48import org.projectfloodlight.openflow.protocol.OFStatsRequest;
49import org.projectfloodlight.openflow.protocol.OFVersion;
50import org.projectfloodlight.openflow.types.U64;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080051
Jonathan Hartb32b24c2014-08-19 15:02:01 -070052@JsonSerialize(using = IOFSwitchSerializer.class)
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080053public interface IOFSwitch {
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070054
55 /**
56 * OF1.3 switches should support role-request messages as in the 1.3 spec.
57 * OF1.0 switches may or may not support the Nicira role request extensions.
58 * To indicate the support, this property should be set by the associated
59 * OF1.0 switch driver in the net.onrc.onos.core.drivermanager package.
60 * The property will be ignored for OF1.3 switches.
61 */
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080062 public static final String SWITCH_SUPPORTS_NX_ROLE = "supportsNxRole";
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070063
64
65 //************************
66 // Channel related
67 //************************
68
69 /**
70 * Disconnects the switch by closing the TCP connection. Results in a call
71 * to the channel handler's channelDisconnected method for cleanup
72 * @throws IOException
73 */
74 public void disconnectSwitch();
Ray Milkey269ffb92014-04-03 14:43:30 -070075
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080076 /**
77 * Writes to the OFMessage to the output stream.
78 * The message will be handed to the floodlightProvider for possible filtering
79 * and processing by message listeners
Ray Milkey269ffb92014-04-03 14:43:30 -070080 *
81 * @param m
82 * @param bc
83 * @throws IOException
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080084 */
Ray Milkey269ffb92014-04-03 14:43:30 -070085 public void write(OFMessage m, FloodlightContext bc) throws IOException;
86
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080087 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070088 * Writes the list of messages to the output stream.
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080089 * The message will be handed to the floodlightProvider for possible filtering
90 * and processing by message listeners.
Ray Milkey269ffb92014-04-03 14:43:30 -070091 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080092 * @param msglist
93 * @param bc
94 * @throws IOException
95 */
96 public void write(List<OFMessage> msglist, FloodlightContext bc) throws IOException;
Ray Milkey269ffb92014-04-03 14:43:30 -070097
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080098 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070099 * Gets the date the switch connected to this controller.
Ray Milkey269ffb92014-04-03 14:43:30 -0700100 *
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700101 * @return the date
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800102 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700103 public Date getConnectedSince();
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800104
105 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700106 * Gets the next available transaction id.
107 *
108 * @return the next transaction ID
109 */
110 public int getNextTransactionId();
111
112 /**
113 * Checks if the switch is still connected.
114 * Only call while holding processMessageLock
115 *
116 * @return whether the switch is still disconnected
117 */
118 public boolean isConnected();
Saurav Dasd84178f2014-09-29 17:48:54 -0700119
Fahad Naeem Khan1f8fb2e2014-09-25 16:39:18 -0700120 /**
121 * retun the channelSocket ip address with port number
122 * @return channelSocketAddress
123 */
124 public SocketAddress getChannelSocketAddress();
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700125
126 /**
127 * Sets whether the switch is connected.
128 * Only call while holding modifySwitchLock
129 *
130 * @param connected whether the switch is connected
131 */
132 public void setConnected(boolean connected);
133
134 /**
135 * Flushes all flows queued for this switch in the current thread.
136 * NOTE: The contract is limited to the current thread
137 */
138 public void flush();
139
140 /**
141 * Sets the Netty Channel this switch instance is associated with.
142 * <p>
143 * Called immediately after instantiation
144 *
145 * @param channel
146 */
147 public void setChannel(Channel channel);
148
149 //************************
150 // Switch features related
151 //************************
152
153 /**
154 * Gets the datapathId of the switch.
Ray Milkey269ffb92014-04-03 14:43:30 -0700155 *
Jonathan Hart99ff20a2014-06-15 16:53:00 -0700156 * @return the switch buffers
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800157 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700158 public long getId();
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800159
160 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700161 * Gets a string version of the ID for this switch.
Ray Milkey269ffb92014-04-03 14:43:30 -0700162 *
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700163 * @return string version of the ID
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800164 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700165 public String getStringId();
Ray Milkey269ffb92014-04-03 14:43:30 -0700166
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800167 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700168 * Gets the number of buffers.
Ray Milkey269ffb92014-04-03 14:43:30 -0700169 *
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700170 * @return the number of buffers
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800171 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700172 public int getNumBuffers();
173
174 public Set<OFCapabilities> getCapabilities();
175
176 public byte getNumTables();
177
178 /**
179 * Returns an OFDescStatsReply message object. Use the methods contained
180 * to retrieve switch descriptions for Manufacturer, Hw/Sw version etc.
181 */
182 public OFDescStatsReply getSwitchDescription();
183
184// /**
185// * Returns a Future object that can be used to retrieve the asynchronous
186// * OFStatisticsReply when it is available.
187// *
188// * @param request statistics request
189// * @return Future object wrapping OFStatisticsReply
190// * @throws IOException
191// */
192// public Future<OFFeaturesReply> getFeaturesReplyFromSwitch()
193// throws IOException;
194//
195// /**
196// * Deliver the featuresReply future reply
197// *
198// * @param reply the reply to deliver
199// */
200// void deliverOFFeaturesReply(OFMessage reply);
201
202 /**
203 * Cancel features reply with a specific transaction ID
204 * @param transactionId the transaction ID
205 */
206 public void cancelFeaturesReply(int transactionId);
207
208 /**
209 * Gets the OFActionType set.
210 * <p>
211 * getActions has relevance only for an OpenFlow 1.0 switch.
212 * For OF1.3, each table can support different actions
213 *
214 * @return the action set
215 */
216 public Set<OFActionType> getActions();
217
Jonathan Harta213bce2014-08-11 15:44:07 -0700218 /**
219 * Gets an OpenFlow message factory that can be used to create messages to
220 * send to this switch.
221 *
222 * @return an OFFactory for the correct OpenFlow version
223 */
224 public OFFactory getFactory();
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700225
Jonathan Harta213bce2014-08-11 15:44:07 -0700226 /**
227 * Gets the OpenFlow version (eg. OF1.0, OF1.3) for this switch.
228 *
229 * @return the OpenFlow version of the switch
230 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700231 public OFVersion getOFVersion();
232
Jonathan Harta213bce2014-08-11 15:44:07 -0700233 /**
234 * Sets the OpenFlow version (eg. OF1.0, OF1.3) for this switch.
235 */
236 public void setOFVersion(OFVersion ofv);
237
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700238
239 //************************
240 // Switch port related
241 //************************
242
243 /**
244 * the type of change that happened to an open flow port
245 */
246 public enum PortChangeType {
247 /** Either a new port has been added by the switch, or we are
248 * adding a port we just deleted (via a prior notification) due to
249 * a change in the portNumber-portName mapping.
250 */
251 ADD,
252 /** some other feature of the port has changed (eg. speed)*/
253 OTHER_UPDATE,
254 /** Either a port has been deleted by the switch, or we are deleting
255 * a port whose portNumber-portName mapping has changed. Note that in
256 * the latter case, a subsequent notification will be sent out to add a
257 * port with the new portNumber-portName mapping.
258 */
259 DELETE,
260 /** Port is up (i.e. enabled). Presumably an earlier notification had
261 * indicated that it was down. To be UP implies that the port is
262 * administratively considered UP (see ofp_port_config) AND the port
263 * link is up AND the port is no longer blocked (see ofp_port_state).
264 */
265 UP,
266 /** Port is down (i.e. disabled). Presumably an earlier notification had
267 * indicated that it was up, or the port was always up.
268 * To be DOWN implies that the port has been either
269 * administratively brought down (see ofp_port_config) OR the port
270 * link is down OR the port is blocked (see ofp_port_state).
271 */
272 DOWN,
273 }
274
275 /**
276 * Describes a change of an open flow port.
277 */
278 public static class PortChangeEvent {
279 public final OFPortDesc port;
280 public final PortChangeType type;
281 /**
282 * @param port
283 * @param type
284 */
285 public PortChangeEvent(OFPortDesc port,
286 PortChangeType type) {
287 this.port = port;
288 this.type = type;
289 }
290 /* (non-Javadoc)
291 * @see java.lang.Object#hashCode()
292 */
293 @Override
294 public int hashCode() {
295 final int prime = 31;
296 int result = 1;
297 result = prime * result + ((port == null) ? 0 : port.hashCode());
298 result = prime * result + ((type == null) ? 0 : type.hashCode());
299 return result;
300 }
301 /* (non-Javadoc)
302 * @see java.lang.Object#equals(java.lang.Object)
303 */
304 @Override
305 public boolean equals(Object obj) {
306 if (this == obj) return true;
307 if (obj == null) return false;
308 if (getClass() != obj.getClass()) return false;
309 PortChangeEvent other = (PortChangeEvent) obj;
310 if (port == null) {
311 if (other.port != null) return false;
312 } else if (!port.equals(other.port)) return false;
313 if (type != other.type) return false;
314 return true;
315 }
316 /* (non-Javadoc)
317 * @see java.lang.Object#toString()
318 */
319 @Override
320 public String toString() {
321 return "[" + type + " " + port.toString() + "]";
322 }
323 }
324
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800325
326 /**
327 * Get list of all enabled ports. This will typically be different from
328 * the list of ports in the OFFeaturesReply, since that one is a static
329 * snapshot of the ports at the time the switch connected to the controller
330 * whereas this port list also reflects the port status messages that have
331 * been received.
Ray Milkey269ffb92014-04-03 14:43:30 -0700332 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800333 * @return Unmodifiable list of ports not backed by the underlying collection
334 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700335 public Collection<OFPortDesc> getEnabledPorts();
Ray Milkey269ffb92014-04-03 14:43:30 -0700336
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800337 /**
338 * Get list of the port numbers of all enabled ports. This will typically
339 * be different from the list of ports in the OFFeaturesReply, since that
Ray Milkey269ffb92014-04-03 14:43:30 -0700340 * one is a static snapshot of the ports at the time the switch connected
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800341 * to the controller whereas this port list also reflects the port status
342 * messages that have been received.
Ray Milkey269ffb92014-04-03 14:43:30 -0700343 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800344 * @return Unmodifiable list of ports not backed by the underlying collection
345 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700346 public Collection<Integer> getEnabledPortNumbers();
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800347
348 /**
349 * Retrieve the port object by the port number. The port object
350 * is the one that reflects the port status updates that have been
351 * received, not the one from the features reply.
Ray Milkey269ffb92014-04-03 14:43:30 -0700352 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800353 * @param portNumber
354 * @return port object
355 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700356 public OFPortDesc getPort(int portNumber);
Ray Milkey269ffb92014-04-03 14:43:30 -0700357
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800358 /**
359 * Retrieve the port object by the port name. The port object
360 * is the one that reflects the port status updates that have been
361 * received, not the one from the features reply.
Ray Milkey269ffb92014-04-03 14:43:30 -0700362 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800363 * @param portName
364 * @return port object
365 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700366 public OFPortDesc getPort(String portName);
Ray Milkey269ffb92014-04-03 14:43:30 -0700367
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800368 /**
369 * Add or modify a switch port. This is called by the core controller
370 * code in response to a OFPortStatus message. It should not typically be
371 * called by other floodlight applications.
Ray Milkey269ffb92014-04-03 14:43:30 -0700372 *
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700373 * OFPPR_MODIFY and OFPPR_ADD will be treated as equivalent. The OpenFlow
374 * spec is not clear on whether portNames are portNumbers are considered
375 * authoritative identifiers. We treat portNames <-> portNumber mappings
376 * as fixed. If they change, we delete all previous conflicting ports and
377 * add all new ports.
Ray Milkey269ffb92014-04-03 14:43:30 -0700378 *
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700379 * @param ps the port status message
380 * @return the ordered Collection of changes "applied" to the old ports
381 * of the switch according to the PortStatus message. A single PortStatus
382 * message can result in multiple changes.
383 * If portName <-> portNumber mappings have
384 * changed, the iteration order ensures that delete events for old
385 * conflicting appear before before events adding new ports
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800386 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700387 public OrderedCollection<PortChangeEvent> processOFPortStatus(OFPortStatus ps);
Ray Milkey269ffb92014-04-03 14:43:30 -0700388
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800389 /**
390 * Get list of all ports. This will typically be different from
391 * the list of ports in the OFFeaturesReply, since that one is a static
392 * snapshot of the ports at the time the switch connected to the controller
393 * whereas this port list also reflects the port status messages that have
394 * been received.
Ray Milkey269ffb92014-04-03 14:43:30 -0700395 *
396 * @return Unmodifiable list of ports
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800397 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700398 public Collection<OFPortDesc> getPorts();
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800399
400 /**
401 * @param portName
402 * @return Whether a port is enabled per latest port status message
403 * (not configured down nor link down nor in spanning tree blocking state)
404 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700405 public boolean portEnabled(int portName);
Ray Milkey269ffb92014-04-03 14:43:30 -0700406
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800407 /**
408 * @param portNumber
409 * @return Whether a port is enabled per latest port status message
410 * (not configured down nor link down nor in spanning tree blocking state)
411 */
412 public boolean portEnabled(String portName);
413
414 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700415 * Compute the changes that would be required to replace the old ports
416 * of this switch with the new ports
417 * @param ports new ports to set
418 * @return the ordered collection of changes "applied" to the old ports
419 * of the switch in order to set them to the new set.
420 * If portName <-> portNumber mappings have
421 * changed, the iteration order ensures that delete events for old
422 * conflicting appear before before events adding new ports
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800423 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700424 public OrderedCollection<PortChangeEvent>
425 comparePorts(Collection<OFPortDesc> ports);
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800426
427 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700428 * Replace the ports of this switch with the given ports.
429 * @param ports new ports to set
430 * @return the ordered collection of changes "applied" to the old ports
431 * of the switch in order to set them to the new set.
432 * If portName <-> portNumber mappings have
433 * changed, the iteration order ensures that delete events for old
434 * conflicting appear before before events adding new ports
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800435 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700436 public OrderedCollection<PortChangeEvent>
437 setPorts(Collection<OFPortDesc> ports);
438
439// XXX S The odd use of providing an API call to 'set ports' (above) would
440// logically suggest that there should be a way to delete or unset the ports.
441// Right now we forbid this. We should probably not use setPorts too.
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 portNumber
449// */
450// public void deletePort(short portNumber);
451//
452// /**
453// * Delete a port for the switch. This is called by the core controller
454// * code in response to a OFPortStatus message. It should not typically be
455// * called by other floodlight applications.
456// *
457// * @param portName
458// */
459// public void deletePort(String portName);
460
461
462 //*******************************************
463 // IOFSwitch object attributes
464 //************************
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800465
466 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700467 * Gets attributes of this switch.
Ray Milkey269ffb92014-04-03 14:43:30 -0700468 *
Jonathan Hart99ff20a2014-06-15 16:53:00 -0700469 * @return attributes of the switch
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800470 */
471 public Map<Object, Object> getAttributes();
472
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700473 /**
474 * Checks if a specific switch property exists for this switch
475 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800476 * @param name name of property
477 * @return value for name
478 */
479 boolean hasAttribute(String name);
480
481 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700482 * Gets properties for switch specific behavior.
Ray Milkey269ffb92014-04-03 14:43:30 -0700483 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800484 * @param name name of property
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700485 * @return 'value' for 'name', or null if no entry for 'name' exists
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800486 */
487 Object getAttribute(String name);
488
489 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700490 * Sets properties for switch specific behavior.
Ray Milkey269ffb92014-04-03 14:43:30 -0700491 *
492 * @param name name of property
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800493 * @param value value for name
494 */
495 void setAttribute(String name, Object value);
496
497 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700498 * Removes properties for switch specific behavior.
Ray Milkey269ffb92014-04-03 14:43:30 -0700499 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800500 * @param name name of property
501 * @return current value for name or null (if not present)
502 */
503 Object removeAttribute(String name);
504
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700505 //************************
506 // Switch statistics
507 //************************
508
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800509 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700510 * Delivers the statistics future reply.
511 *
512 * @param reply the reply to deliver
513 */
514 public void deliverStatisticsReply(OFMessage reply);
515
516 /**
517 * Cancels the statistics reply with the given transaction ID.
518 *
519 * @param transactionId the transaction ID
520 */
521 public void cancelStatisticsReply(int transactionId);
522
523 /**
524 * Cancels all statistics replies.
525 */
526 public void cancelAllStatisticsReplies();
527
528 /**
529 * Gets a Future object that can be used to retrieve the asynchronous.
530 * OFStatisticsReply when it is available.
531 *
532 * @param request statistics request
533 * @return Future object wrapping OFStatisticsReply
534 * @throws IOException
535 */
536 public Future<List<OFStatsReply>> getStatistics(OFStatsRequest<?> request)
537 throws IOException;
538
539 //************************
540 // Switch other utilities
541 //************************
542
543 /**
544 * Clears all flowmods on this switch.
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800545 */
546 public void clearAllFlowMods();
547
548 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700549 * Gets the current role of this controller for this IOFSwitch.
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800550 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700551 public Role getRole();
Ray Milkey269ffb92014-04-03 14:43:30 -0700552
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800553 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700554 * Sets this controller's Role for this IOFSwitch to role.
Ray Milkey269ffb92014-04-03 14:43:30 -0700555 *
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700556 * @param role
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800557 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700558 public void setRole(Role role);
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800559
560 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700561 * Gets the next generation ID.
562 * <p>
563 * Note: relevant for role request messages in OF1.3
Ray Milkey269ffb92014-04-03 14:43:30 -0700564 *
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700565 * @return next generation ID
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800566 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700567 public U64 getNextGenerationId();
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800568
569 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700570 * Sets IFloodlightProviderService for this switch instance.
571 * <p>
572 * Called immediately after instantiation
573 *
574 * @param controller
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800575 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700576 public void setFloodlightProvider(IFloodlightProviderService controller);
577
578 /**
579 * Sets IThreadPoolService for this switch instance.
580 * <p>
581 * Called immediately after instantiation
582 *
583 * @param threadPool
584 */
585 public void setThreadPoolService(IThreadPoolService threadPool);
586
587 /**
588 * Set debug counter service for per-switch counters
589 * Called immediately after instantiation
590 * @param debugCounters
591 * @throws CounterException
592 */
593 public void setDebugCounterService(IDebugCounterService debugCounter)
594 throws CounterException;
595
596 /**
597 * Start this switch driver's sub handshake. This might be a no-op but
598 * this method must be called at least once for the switch to be become
599 * ready.
600 * This method must only be called from the I/O thread
601 * @throws IOException
602 * @throws SwitchDriverSubHandshakeAlreadyStarted if the sub-handshake has
603 * already been started
604 */
605 public void startDriverHandshake() throws IOException;
606
607 /**
608 * Check if the sub-handshake for this switch driver has been completed.
609 * This method can only be called after startDriverHandshake()
610 *
611 * This methods must only be called from the I/O thread
612 * @return true if the sub-handshake has been completed. False otherwise
613 * @throws SwitchDriverSubHandshakeNotStarted if startDriverHandshake() has
614 * not been called yet.
615 */
616 public boolean isDriverHandshakeComplete();
617
618 /**
619 * Pass the given OFMessage to the driver as part of this driver's
620 * sub-handshake. Must not be called after the handshake has been completed
621 * This methods must only be called from the I/O thread
622 * @param m The message that the driver should process
623 * @throws SwitchDriverSubHandshakeCompleted if isDriverHandshake() returns
624 * false before this method call
625 * @throws SwitchDriverSubHandshakeNotStarted if startDriverHandshake() has
626 * not been called yet.
627 */
628 public void processDriverHandshakeMessage(OFMessage m);
629
630 /**
631 * Set the flow table full flag in the switch
632 * XXX S Rethink this for multiple tables
633 */
634 public void setTableFull(boolean isFull);
635
Saurav Dasfc5e3eb2014-09-25 19:05:21 -0700636 /**
Saurav Dasd84178f2014-09-29 17:48:54 -0700637 * Get the switch driver handshake state
Saurav Dasfc5e3eb2014-09-25 19:05:21 -0700638 */
639 public String getSwitchDriverState();
640
Saurav Dasd84178f2014-09-29 17:48:54 -0700641 /**
642 * sendBarrier sends an OF Barrier message to the switch and returns a
643 * future object to the caller. The future will automatically deregister
644 * itself after 60 secs if the corresponding barrier reply message is not
645 * received from the switch in that time.
646 * <p>
647 * The caller should use OFBarrierReplyFuture.get(timeout,timeunit) to wait
648 * for a specified time interval shorter than 60secs.
649 *
650 * @throws IOException
651 */
652 public OFBarrierReplyFuture sendBarrier() throws IOException;
653
654 /**
655 * Delivers the barrier future reply.
656 *
657 * @param reply the reply to deliver
658 */
659 public void deliverBarrierReply(OFBarrierReply reply);
660
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800661}