alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onosproject.net.flowobjective; |
| 17 | |
Thomas Vachuska | a9d491e | 2015-05-20 11:17:21 -0700 | [diff] [blame] | 18 | import com.google.common.annotations.Beta; |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 19 | import org.onosproject.core.ApplicationId; |
Saurav Das | 8a0732e | 2015-11-20 15:27:53 -0800 | [diff] [blame] | 20 | import org.onosproject.net.flow.TrafficSelector; |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 21 | import org.onosproject.net.flow.TrafficTreatment; |
| 22 | |
| 23 | import java.util.Collection; |
| 24 | |
| 25 | /** |
| 26 | * Represents a nexthop which will be translated by a driver |
| 27 | * into the appropriate group or actions needed to implement |
alshabib | 9d9e3a3 | 2015-06-25 18:33:50 -0700 | [diff] [blame] | 28 | * the egress function. |
| 29 | * |
Sho SHIMIZU | fee286d | 2015-07-01 10:19:10 -0700 | [diff] [blame] | 30 | * A next objective is made up of a collection of traffic treatments |
alshabib | 9d9e3a3 | 2015-06-25 18:33:50 -0700 | [diff] [blame] | 31 | * associated with a type. These types are: |
| 32 | * |
| 33 | * - Hashed |
| 34 | * - Broadcast |
| 35 | * - Failover |
| 36 | * - Simple |
| 37 | * |
Saurav Das | 8a0732e | 2015-11-20 15:27:53 -0800 | [diff] [blame] | 38 | * These types will indicate to the driver what the intended behavior is. |
alshabib | 9d9e3a3 | 2015-06-25 18:33:50 -0700 | [diff] [blame] | 39 | * For example, a broadcast next objective with a collection of output |
| 40 | * treatments will indicate to a driver that all output actions are expected |
| 41 | * to be executed simultaneously. The driver is then free to implement this |
| 42 | * as a group or a simple action list. |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 43 | */ |
Thomas Vachuska | a9d491e | 2015-05-20 11:17:21 -0700 | [diff] [blame] | 44 | @Beta |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 45 | public interface NextObjective extends Objective { |
| 46 | |
| 47 | /** |
| 48 | * Represents the type of next phase to build. |
| 49 | */ |
| 50 | enum Type { |
| 51 | /** |
| 52 | * A hashed packet processing. |
| 53 | */ |
| 54 | HASHED, |
| 55 | |
| 56 | /** |
| 57 | * Broadcast packet process. |
| 58 | */ |
| 59 | BROADCAST, |
| 60 | |
| 61 | /** |
| 62 | * Failover handling. |
| 63 | */ |
| 64 | FAILOVER, |
| 65 | |
| 66 | /** |
| 67 | * Simple processing. Could be a group or a treatment. |
| 68 | */ |
| 69 | SIMPLE |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * The collection of treatments that need to be applied to a set of traffic. |
| 74 | * |
| 75 | * @return a collection of traffic treatments |
Charles Chan | f261d5c | 2018-10-31 21:00:06 -0700 | [diff] [blame] | 76 | * @deprecated in 1.14.2, replaced by {@link #nextTreatments} |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 77 | */ |
Charles Chan | f261d5c | 2018-10-31 21:00:06 -0700 | [diff] [blame] | 78 | @Deprecated |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 79 | Collection<TrafficTreatment> next(); |
| 80 | |
| 81 | /** |
Charles Chan | f261d5c | 2018-10-31 21:00:06 -0700 | [diff] [blame] | 82 | * The collection of next treatments that need to be applied to a set of traffic. |
| 83 | * |
| 84 | * @return a collection of next treatments |
| 85 | */ |
| 86 | Collection<NextTreatment> nextTreatments(); |
| 87 | |
| 88 | /** |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 89 | * The type of operation that will be applied to the traffic using the collection |
| 90 | * of treatments. |
| 91 | * |
| 92 | * @return a type |
| 93 | */ |
| 94 | Type type(); |
| 95 | |
| 96 | /** |
Charles Chan | 4ca2f7f | 2016-03-25 13:40:16 -0700 | [diff] [blame] | 97 | * Auxiliary optional information provided to the device driver. Typically |
Saurav Das | 8a0732e | 2015-11-20 15:27:53 -0800 | [diff] [blame] | 98 | * conveys information about selectors (matches) that are intended to |
| 99 | * use this Next Objective. |
| 100 | * |
| 101 | * @return a selector intended to pass meta information to the device driver. |
| 102 | * Value may be null if no meta information is provided. |
| 103 | */ |
| 104 | TrafficSelector meta(); |
| 105 | |
| 106 | /** |
Ray Milkey | 3004c7d | 2017-12-13 09:43:20 -0800 | [diff] [blame] | 107 | * Returns a new builder set to create a copy of this objective. |
| 108 | * |
| 109 | * @return new builder |
| 110 | */ |
| 111 | @Override |
| 112 | Builder copy(); |
| 113 | |
| 114 | /** |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 115 | * A next step builder. |
| 116 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 117 | interface Builder extends Objective.Builder { |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 118 | |
| 119 | /** |
| 120 | * Specifies the id for this next objective. |
| 121 | * |
| 122 | * @param nextId an integer |
| 123 | * @return a next objective builder |
| 124 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 125 | Builder withId(int nextId); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 126 | |
| 127 | /** |
| 128 | * Sets the type of next step. |
| 129 | * |
| 130 | * @param type a type |
| 131 | * @return a next step builder |
| 132 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 133 | Builder withType(Type type); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 134 | |
| 135 | /** |
| 136 | * Adds a treatment to this next step. |
| 137 | * |
| 138 | * @param treatment a traffic treatment |
| 139 | * @return a next step builder |
Charles Chan | f261d5c | 2018-10-31 21:00:06 -0700 | [diff] [blame] | 140 | * @deprecated in 1.14.2, replaced by {@link #addTreatment(NextTreatment)} |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 141 | */ |
Charles Chan | f261d5c | 2018-10-31 21:00:06 -0700 | [diff] [blame] | 142 | @Deprecated |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 143 | Builder addTreatment(TrafficTreatment treatment); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 144 | |
Ray Milkey | 810d6e7 | 2015-08-14 10:35:06 -0700 | [diff] [blame] | 145 | /** |
Charles Chan | f261d5c | 2018-10-31 21:00:06 -0700 | [diff] [blame] | 146 | * Adds a next treatment to this next step. |
| 147 | * |
| 148 | * @param nextTreatment a next treatment |
| 149 | * @return a next step builder |
| 150 | */ |
| 151 | Builder addTreatment(NextTreatment nextTreatment); |
| 152 | |
| 153 | /** |
Ray Milkey | 810d6e7 | 2015-08-14 10:35:06 -0700 | [diff] [blame] | 154 | * Specifies the application which applied the filter. |
| 155 | * |
| 156 | * @param appId an application id |
| 157 | * @return an objective builder |
| 158 | */ |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 159 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 160 | Builder fromApp(ApplicationId appId); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 161 | |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 162 | /** |
Ray Milkey | 810d6e7 | 2015-08-14 10:35:06 -0700 | [diff] [blame] | 163 | * Sets the priority for this objective. |
| 164 | * |
| 165 | * @param priority an integer |
| 166 | * @return an objective builder |
| 167 | */ |
| 168 | @Override |
| 169 | Builder withPriority(int priority); |
| 170 | |
| 171 | /** |
Saurav Das | 8a0732e | 2015-11-20 15:27:53 -0800 | [diff] [blame] | 172 | * Set meta information related to this next objective. |
| 173 | * |
| 174 | * @param selector match conditions |
| 175 | * @return an objective builder |
| 176 | */ |
Saurav Das | 4ce4596 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 177 | Builder withMeta(TrafficSelector selector); |
Saurav Das | 8a0732e | 2015-11-20 15:27:53 -0800 | [diff] [blame] | 178 | |
| 179 | /** |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 180 | * Builds the next objective that will be added. |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 181 | * |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 182 | * @return a next objective |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 183 | */ |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 184 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 185 | NextObjective add(); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 186 | |
| 187 | /** |
| 188 | * Builds the next objective that will be removed. |
| 189 | * |
| 190 | * @return a next objective. |
| 191 | */ |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 192 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 193 | NextObjective remove(); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 194 | |
| 195 | /** |
| 196 | * Builds the next objective that will be added. |
| 197 | * The context will be used to notify the calling application. |
| 198 | * |
| 199 | * @param context an objective context |
| 200 | * @return a next objective |
| 201 | */ |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 202 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 203 | NextObjective add(ObjectiveContext context); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 204 | |
| 205 | /** |
| 206 | * Builds the next objective that will be removed. |
| 207 | * The context will be used to notify the calling application. |
| 208 | * |
| 209 | * @param context an objective context |
| 210 | * @return a next objective |
| 211 | */ |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 212 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 213 | NextObjective remove(ObjectiveContext context); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 214 | |
Saurav Das | 8a0732e | 2015-11-20 15:27:53 -0800 | [diff] [blame] | 215 | /** |
| 216 | * Build the next objective that will be added, with {@link Operation} |
| 217 | * ADD_TO_EXISTING. |
| 218 | * |
| 219 | * @return a next objective |
| 220 | */ |
| 221 | NextObjective addToExisting(); |
| 222 | |
| 223 | /** |
| 224 | * Build the next objective that will be removed, with {@link Operation} |
| 225 | * REMOVE_FROM_EXISTING. |
| 226 | * |
| 227 | * @return a next objective |
| 228 | */ |
| 229 | NextObjective removeFromExisting(); |
| 230 | |
| 231 | /** |
| 232 | * Builds the next objective that will be added, with {@link Operation} |
| 233 | * ADD_TO_EXISTING. The context will be used to notify the calling application. |
| 234 | * |
| 235 | * @param context an objective context |
| 236 | * @return a next objective |
| 237 | */ |
| 238 | NextObjective addToExisting(ObjectiveContext context); |
| 239 | |
| 240 | /** |
| 241 | * Builds the next objective that will be removed, with {@link Operation} |
| 242 | * REMOVE_FROM_EXISTING. The context will be used to notify the calling application. |
| 243 | * |
| 244 | * @param context an objective context |
| 245 | * @return a next objective |
| 246 | */ |
| 247 | NextObjective removeFromExisting(ObjectiveContext context); |
| 248 | |
Saurav Das | ceccf24 | 2017-08-03 18:30:35 -0700 | [diff] [blame] | 249 | /** |
Jonghwan Hyun | f810a7a | 2018-02-12 16:43:45 +0900 | [diff] [blame] | 250 | * Build the next objective that will be modified with {@link Operation} |
| 251 | * MODIFY. |
| 252 | * |
| 253 | * @return a next objective |
| 254 | */ |
| 255 | |
| 256 | NextObjective modify(); |
| 257 | /** |
| 258 | * Build the next objective that will be modified, with {@link Operation} |
| 259 | * MODIFY. The context will be used to notify the calling application. |
| 260 | * |
| 261 | * @param context an objective context |
| 262 | * @return a next objective |
| 263 | */ |
| 264 | NextObjective modify(ObjectiveContext context); |
| 265 | |
| 266 | /** |
Saurav Das | ceccf24 | 2017-08-03 18:30:35 -0700 | [diff] [blame] | 267 | * Builds the next objective that needs to be verified. |
| 268 | * |
| 269 | * @return a next objective with {@link Operation} VERIFY |
| 270 | */ |
| 271 | NextObjective verify(); |
| 272 | |
| 273 | /** |
| 274 | * Builds the next objective that needs to be verified. The context will |
| 275 | * be used to notify the calling application. |
| 276 | * |
| 277 | * @param context an objective context |
| 278 | * @return a next objective with {@link Operation} VERIFY |
| 279 | */ |
| 280 | NextObjective verify(ObjectiveContext context); |
| 281 | |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | } |