blob: 6d4acaac3fbe3e5e4dcc9924c8c280130d809488 [file] [log] [blame]
alshabibfaa1e362015-04-02 15:01:54 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
alshabibfaa1e362015-04-02 15:01:54 -07003 *
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 */
16package org.onosproject.net.flowobjective;
17
Thomas Vachuskaa9d491e2015-05-20 11:17:21 -070018import com.google.common.annotations.Beta;
alshabib2a441c62015-04-13 18:39:38 -070019import org.onosproject.core.ApplicationId;
Andrea Campanellacbd16942021-06-01 16:33:14 +020020import org.onosproject.net.Annotations;
Saurav Das8a0732e2015-11-20 15:27:53 -080021import org.onosproject.net.flow.TrafficSelector;
alshabibfaa1e362015-04-02 15:01:54 -070022import org.onosproject.net.flow.TrafficTreatment;
23
24import 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
alshabib9d9e3a32015-06-25 18:33:50 -070029 * the egress function.
30 *
Sho SHIMIZUfee286d2015-07-01 10:19:10 -070031 * A next objective is made up of a collection of traffic treatments
alshabib9d9e3a32015-06-25 18:33:50 -070032 * associated with a type. These types are:
33 *
34 * - Hashed
35 * - Broadcast
36 * - Failover
37 * - Simple
38 *
Saurav Das8a0732e2015-11-20 15:27:53 -080039 * These types will indicate to the driver what the intended behavior is.
alshabib9d9e3a32015-06-25 18:33:50 -070040 * 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.
alshabibfaa1e362015-04-02 15:01:54 -070044 */
Thomas Vachuskaa9d491e2015-05-20 11:17:21 -070045@Beta
alshabibfaa1e362015-04-02 15:01:54 -070046public 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 Chanb87d9f12018-10-31 21:00:06 -070077 * @deprecated in 1.14.2, replaced by {@link #nextTreatments}
alshabibfaa1e362015-04-02 15:01:54 -070078 */
Charles Chanb87d9f12018-10-31 21:00:06 -070079 @Deprecated
alshabibfaa1e362015-04-02 15:01:54 -070080 Collection<TrafficTreatment> next();
81
82 /**
Charles Chanb87d9f12018-10-31 21:00:06 -070083 * 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 /**
alshabibfaa1e362015-04-02 15:01:54 -070090 * 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 Chan4ca2f7f2016-03-25 13:40:16 -070098 * Auxiliary optional information provided to the device driver. Typically
Saurav Das8a0732e2015-11-20 15:27:53 -080099 * 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 Milkey3004c7d2017-12-13 09:43:20 -0800108 * 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 /**
alshabibfaa1e362015-04-02 15:01:54 -0700116 * A next step builder.
117 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700118 interface Builder extends Objective.Builder {
alshabibfaa1e362015-04-02 15:01:54 -0700119
120 /**
121 * Specifies the id for this next objective.
122 *
123 * @param nextId an integer
124 * @return a next objective builder
125 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700126 Builder withId(int nextId);
alshabibfaa1e362015-04-02 15:01:54 -0700127
128 /**
129 * Sets the type of next step.
130 *
131 * @param type a type
132 * @return a next step builder
133 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700134 Builder withType(Type type);
alshabibfaa1e362015-04-02 15:01:54 -0700135
136 /**
137 * Adds a treatment to this next step.
138 *
139 * @param treatment a traffic treatment
140 * @return a next step builder
Charles Chanb87d9f12018-10-31 21:00:06 -0700141 * @deprecated in 1.14.2, replaced by {@link #addTreatment(NextTreatment)}
alshabibfaa1e362015-04-02 15:01:54 -0700142 */
Charles Chanb87d9f12018-10-31 21:00:06 -0700143 @Deprecated
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700144 Builder addTreatment(TrafficTreatment treatment);
alshabibfaa1e362015-04-02 15:01:54 -0700145
Ray Milkey810d6e72015-08-14 10:35:06 -0700146 /**
Charles Chanb87d9f12018-10-31 21:00:06 -0700147 * 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 Milkey810d6e72015-08-14 10:35:06 -0700155 * Specifies the application which applied the filter.
156 *
157 * @param appId an application id
158 * @return an objective builder
159 */
alshabib2a441c62015-04-13 18:39:38 -0700160 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700161 Builder fromApp(ApplicationId appId);
alshabib2a441c62015-04-13 18:39:38 -0700162
alshabibfaa1e362015-04-02 15:01:54 -0700163 /**
Ray Milkey810d6e72015-08-14 10:35:06 -0700164 * 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 Das8a0732e2015-11-20 15:27:53 -0800173 * Set meta information related to this next objective.
174 *
175 * @param selector match conditions
176 * @return an objective builder
177 */
Saurav Das4ce45962015-11-24 23:21:05 -0800178 Builder withMeta(TrafficSelector selector);
Saurav Das8a0732e2015-11-20 15:27:53 -0800179
180 /**
Andrea Campanellacbd16942021-06-01 16:33:14 +0200181 * 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 /**
alshabib2a441c62015-04-13 18:39:38 -0700190 * Builds the next objective that will be added.
alshabibfaa1e362015-04-02 15:01:54 -0700191 *
alshabib2a441c62015-04-13 18:39:38 -0700192 * @return a next objective
alshabibfaa1e362015-04-02 15:01:54 -0700193 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800194 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700195 NextObjective add();
alshabib2a441c62015-04-13 18:39:38 -0700196
197 /**
198 * Builds the next objective that will be removed.
199 *
200 * @return a next objective.
201 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800202 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700203 NextObjective remove();
alshabib2a441c62015-04-13 18:39:38 -0700204
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 Vachuska00f48162016-02-29 17:07:23 -0800212 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700213 NextObjective add(ObjectiveContext context);
alshabib2a441c62015-04-13 18:39:38 -0700214
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 Vachuska00f48162016-02-29 17:07:23 -0800222 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700223 NextObjective remove(ObjectiveContext context);
alshabibfaa1e362015-04-02 15:01:54 -0700224
Saurav Das8a0732e2015-11-20 15:27:53 -0800225 /**
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 Dasceccf242017-08-03 18:30:35 -0700259 /**
Jonghwan Hyunf810a7a2018-02-12 16:43:45 +0900260 * 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 Dasceccf242017-08-03 18:30:35 -0700277 * 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
alshabibfaa1e362015-04-02 15:01:54 -0700292 }
293
294}