Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 1 | package net.floodlightcontroller.flowcache; |
| 2 | |
| 3 | import org.openflow.protocol.OFMatchWithSwDpid; |
| 4 | |
| 5 | import net.floodlightcontroller.core.FloodlightContext; |
| 6 | import net.floodlightcontroller.core.FloodlightContextStore; |
| 7 | import net.floodlightcontroller.core.IOFSwitch; |
| 8 | import net.floodlightcontroller.devicemanager.SwitchPort; |
| 9 | import net.floodlightcontroller.core.module.IFloodlightService; |
| 10 | |
| 11 | /** |
| 12 | * The Interface IFlowCache. |
| 13 | * <p> |
| 14 | * public interface APIs to Big Switch Flow-Cache Service. Flow-Cache maintains |
| 15 | * the network-level flows that are currently deployed in the underlying |
| 16 | * network. The flow cache can be queried using various filters by using the |
| 17 | * corresponding APIs. |
| 18 | * |
| 19 | * @author subrata |
| 20 | * |
| 21 | */ |
| 22 | public interface IFlowCacheService extends IFloodlightService { |
| 23 | |
| 24 | public static final String FLOWCACHE_APP_NAME = |
| 25 | "net.floodlightcontroller.flowcache.appName"; |
| 26 | public static final String FLOWCACHE_APP_INSTANCE_NAME = |
| 27 | "net.floodlightcontroller.flowcache.appInstanceName"; |
| 28 | |
| 29 | /** |
| 30 | * The flow cache query event type indicating the event that triggered the |
| 31 | * query. The callerOpaqueObj can be keyed based on this event type |
| 32 | */ |
| 33 | public static enum FCQueryEvType { |
| 34 | /** The GET query. Flows need not be reconciled for this query type */ |
| 35 | GET, |
| 36 | /** A new App was added. */ |
| 37 | APP_ADDED, |
| 38 | /** An App was deleted. */ |
| 39 | APP_DELETED, |
| 40 | /** Interface rule of an app was modified */ |
| 41 | APP_INTERFACE_RULE_CHANGED, |
| 42 | /** Some App configuration was changed */ |
| 43 | APP_CONFIG_CHANGED, |
| 44 | /** An ACL was added */ |
| 45 | ACL_ADDED, |
| 46 | /** An ACL was deleted */ |
| 47 | ACL_DELETED, |
| 48 | /** An ACL rule was added */ |
| 49 | ACL_RULE_ADDED, |
| 50 | /** An ACL rule was deleted */ |
| 51 | ACL_RULE_DELETED, |
| 52 | /** ACL configuration was changed */ |
| 53 | ACL_CONFIG_CHANGED, |
| 54 | /** device had moved to a different port in the network */ |
| 55 | DEVICE_MOVED, |
| 56 | /** device's property had changed, such as tag assignment */ |
| 57 | DEVICE_PROPERTY_CHANGED, |
| 58 | /** Link down */ |
| 59 | LINK_DOWN, |
| 60 | /** Periodic scan of switch flow table */ |
| 61 | PERIODIC_SCAN, |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * A FloodlightContextStore object that can be used to interact with the |
| 66 | * FloodlightContext information about flowCache. |
| 67 | */ |
| 68 | public static final FloodlightContextStore<String> fcStore = |
| 69 | new FloodlightContextStore<String>(); |
| 70 | |
| 71 | /** |
| 72 | * Submit a flow cache query with query parameters specified in FCQueryObj |
| 73 | * object. The query object can be created using one of the newFCQueryObj |
| 74 | * helper functions in IFlowCache interface. |
| 75 | * <p> |
| 76 | * The queried flows are returned via the flowQueryRespHandler() callback |
| 77 | * that the caller must implement. The caller can match the query with |
| 78 | * the response using unique callerOpaqueData which remains unchanged |
| 79 | * in the request and response callback. |
| 80 | * |
| 81 | * @see com.bigswitch.floodlight.flowcache#flowQueryRespHandler |
| 82 | * @param query the flow cache query object as input |
| 83 | * |
| 84 | */ |
| 85 | public void submitFlowCacheQuery(FCQueryObj query); |
| 86 | |
| 87 | /** |
| 88 | * Deactivates all flows in the flow cache for which the source switch |
| 89 | * matches the given switchDpid. Note that the flows are NOT deleted |
| 90 | * from the cache. |
| 91 | * |
| 92 | * @param switchDpid Data-path identifier of the source switch |
| 93 | */ |
| 94 | public void deactivateFlowCacheBySwitch(long switchDpid); |
| 95 | |
| 96 | /** |
| 97 | * Deletes all flows in the flow cache for which the source switch |
| 98 | * matches the given switchDpid. |
| 99 | * |
| 100 | * @param switchDpid Data-path identifier of the source switch |
| 101 | */ |
| 102 | public void deleteFlowCacheBySwitch(long switchDpid); |
| 103 | |
| 104 | /** |
| 105 | * Add a flow to the flow-cache - called when a flow-mod is about to be |
| 106 | * written to a set of switches. If it returns false then it should not |
| 107 | * be written to the switches. If it returns true then the cookie returned |
| 108 | * should be used for the flow mod sent to the switches. |
| 109 | * |
| 110 | * @param appInstName Application instance name |
| 111 | * @param ofm openflow match object |
| 112 | * @param cookie openflow-mod cookie |
| 113 | * @param swPort SwitchPort object |
| 114 | * @param priority openflow match priority |
| 115 | * @param action action taken on the matched packets (PERMIT or DENY) |
| 116 | * @return true: flow should be written to the switch(es) |
| 117 | * false: flow should not be written to the switch(es). false is |
| 118 | * returned, for example, when the flow was recently |
| 119 | * written to the flow-cache and hence it is dampened to |
| 120 | * avoid frequent writes of the same flow to the switches |
| 121 | * This case can typically arise for the flows written at the |
| 122 | * internal ports as they are heavily wild-carded. |
| 123 | */ |
| 124 | public boolean addFlow(String appInstName, OFMatchWithSwDpid ofm, |
| 125 | Long cookie, long srcSwDpid, |
| 126 | short inPort, short priority, byte action); |
| 127 | |
| 128 | /** |
| 129 | * Add a flow to the flow-cache - called when a flow-mod is about to be |
| 130 | * written to a set of switches. If it returns false then it should not |
| 131 | * be written to the switches. If it returns true then the cookie returned |
| 132 | * should be used for the flow mod sent to the switches. |
| 133 | * |
| 134 | * @param cntx the cntx |
| 135 | * @param ofm the ofm |
| 136 | * @param cookie the cookie |
| 137 | * @param swPort the sw port |
| 138 | * @param priority the priority |
| 139 | * @param action the action |
| 140 | * @return true: flow should be written to the switch(es) |
| 141 | * false: flow should not be written to the switch(es). false is |
| 142 | * returned, for example, when the flow was recently |
| 143 | * written to the flow-cache and hence it is dampened to |
| 144 | * avoid frequent writes of the same flow to the switches |
| 145 | * This case can typically arise for the flows written at the |
| 146 | * internal ports as they are heavily wild-carded. |
| 147 | */ |
| 148 | public boolean addFlow(FloodlightContext cntx, OFMatchWithSwDpid ofm, |
| 149 | Long cookie, SwitchPort swPort, |
| 150 | short priority, byte action); |
| 151 | |
| 152 | /** |
| 153 | * Move the specified flow from its current application instance to a |
| 154 | * different application instance. This API can be used when a flow moves |
| 155 | * to a different application instance when the application instance |
| 156 | * configuration changes or when a device moves to a different part in |
| 157 | * the network that belongs to a different application instance. |
| 158 | * <p> |
| 159 | * Note that, if the flow was not found in the current application |
| 160 | * instance then the flow is not moved to the new application instance. |
| 161 | * |
| 162 | * @param ofMRc the object containing the flow match and new application |
| 163 | * instance name. |
| 164 | * @return true is the flow was found in the flow cache in the current |
| 165 | * application instance; false if the flow was not found in the flow-cache |
| 166 | * in the current application instance. |
| 167 | */ |
| 168 | public boolean moveFlowToDifferentApplInstName(OFMatchReconcile ofMRc); |
| 169 | |
| 170 | /** |
| 171 | * Delete all flow from the specified switch |
| 172 | * @param sw |
| 173 | */ |
| 174 | public void deleteAllFlowsAtASourceSwitch(IOFSwitch sw); |
| 175 | |
| 176 | /** |
| 177 | * Post a request to update flowcache from a switch. |
| 178 | * This is an asynchronous operation. |
| 179 | * It queries the switch for stats and updates the flowcache asynchronously |
| 180 | * with the response. |
| 181 | * @param swDpid |
| 182 | * @param delay_ms |
| 183 | */ |
| 184 | public void querySwitchFlowTable(long swDpid); |
| 185 | } |