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